public EndPointViewPage()
        {
            InitializeComponent();
            var endpointViewModel = new EndpointViewModel(this);

            DataContext = endpointViewModel;
        }
Esempio n. 2
0
        public static Endpoint ToEndpoint(this EndpointViewModel vm)
        {
            var endpoint = new Endpoint
            {
                Id          = vm.Id,
                Enabled     = vm.Enabled,
                Name        = vm.Name,
                Kind        = vm.Kind,
                LastUpdated = DateTimeOffset.UtcNow
            };

            if (vm.Kind == Endpoint.EndpointKind.Http)
            {
                var httpVm = (HttpEndpointViewModel)vm;

                endpoint.SetHttpLocation(httpVm.Location);
                endpoint.SetHttpResponseMatch(httpVm.ResponseMatch);

                if (!string.IsNullOrWhiteSpace(httpVm.StatusCodes))
                {
                    endpoint.SetHttpStatusCodes(httpVm.StatusCodes.Split(',').Select(code => int.Parse(code.Trim())).ToList());
                }

                endpoint.SetHttpIgnoreTlsCerts(httpVm.IgnoreCerts);
                endpoint.SetHttpCustomTlsCert(httpVm.CustomCert);
            }
            else if (vm.Kind == Endpoint.EndpointKind.Icmp)
            {
                var icmpVm = (IcmpEndpointViewModel)vm;

                endpoint.SetIcmpAddress(icmpVm.Address);
            }
            else
            {
                throw new NotImplementedException();
            }

            return(endpoint);
        }
 public EndpointControl(EndpointViewModel model)
 {
     InitializeComponent();
     DataContext = model;
 }