Something went wrong. Try again.
Modular scanner/radio client and multi-broadcast server. uniscan.dexrn.me
Something went wrong. Try again.
UniScan src Client UniScan.Client.App Views Remote Connection ConnectionMethod TCPConnectionMethodFactoryViewModel.cs
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748using System.ComponentModel.DataAnnotations;using System.Linq;using System.Net;using CommunityToolkit.Mvvm.ComponentModel;using UniScan.Client.App.Core;using UniScan.Client.App.UI.ConnectionMethod;using UniScan.Client.App.UI.Validation;using UniScan.Client.App.Views.ViewModel;using UniScan.Network.Client.Remote.Connection.Methods;
namespace UniScan.Client.App.Views.Remote.Connection.ConnectionMethod;
#if !browser[ConnectionMethodFactoryViewModel("TCP")]public partial class TCPConnectionMethodFactoryViewModel : ViewModelBase, IConnectionMethodFactoryViewModel<TCPConnectionMethodFactoryViewModel, TCPRemoteConnectionMethod>{ public TCPConnectionMethodFactoryViewModel() { ValidateAllProperties(); } [ObservableProperty] [NotifyDataErrorInfo] [Required(ErrorMessage = "IP Address is required")] [NotifyPropertyChangedFor(nameof(IsValid))] [ValidatorParser<EndpointValidatorParser>(ErrorMessage = "Must be a valid IP Address, such as 127.0.0.1")] public partial string Address { get; set; } [ObservableProperty] [NotifyDataErrorInfo] [Required(ErrorMessage = "Port is required")] [NotifyPropertyChangedFor(nameof(IsValid))] [ParsableValidator<ushort>(ErrorMessage = "Must be a valid port number, such as 9000")] public partial string Port { get; set; } public bool IsValid => !GetErrors(nameof(Address)).Any() && !GetErrors(nameof(Port)).Any(); public TCPRemoteConnectionMethod Create() { ushort port = ushort.Parse(Port); EndPoint e = IPAddress.TryParse(Address, out IPAddress? addr) ? new IPEndPoint(addr, port) : new DnsEndPoint(Address, port); return new TCPRemoteConnectionMethod(e); }}#endif