예제 #1
0
        private static async Task <NetworkServicePresenter <V1Service>[]> GetUserNetworkServicesAsync()
        {
            var temp = await NetworkServiceConfigurator.LoadUserNetworkServicesAsync();

            var result = temp
                         .Select(x => new NetworkServicePresenter <V1Service>(x.Name, x.Protocol, x.Port, x.IsEnabled, x.Service))
                         .ToArray();

            return(result);
        }
예제 #2
0
        private static async Task <INetworkServiceCore[]> GetNetworkServicesAsync()
        {
            var predefinedNetworkServices = await NetworkServiceConfigurator.LoadPredefinedNetworkServicesAsync();

            var userNetworkServices = await NetworkServiceConfigurator.LoadUserNetworkServicesAsync();

            var allNetworkServices = predefinedNetworkServices.Cast <INetworkService>().Concat(userNetworkServices.Cast <INetworkService>());
            var tcpNetworkServices = allNetworkServices
                                     .Where(x => x.IsEnabled && x.Protocol == Protocol.Tcp)
                                     .Distinct(NetworkServiceCoreComparer.Instance)
                                     .OrderBy(x => x.Port);
            var udpNetworkServices = allNetworkServices
                                     .Where(x => x.IsEnabled && x.Protocol == Protocol.Udp)
                                     .Distinct(NetworkServiceCoreComparer.Instance)
                                     .OrderBy(x => x.Port);

            return(tcpNetworkServices.Concat(udpNetworkServices).ToArray());
        }