Example #1
0
 public void SendConfigurationTestNoIpGateway()
 {
     Assert.Throws <ArgumentException>(
         delegate
     {
         DefaultGateway gateway            = new DefaultGateway();
         ConfigurationNetSettings settings = new ConfigurationNetSettings(gateway);
     },
         "no exception if neither IPv4 nor IPv6 address set");
 }
Example #2
0
        public void SetUp()
        {
            PluginCache.ResetAll();
            builder  = PluginCache.FindBuilder(typeof(ClassWithMixOfSetters));
            instance = new SmartInstance <ClassWithMixOfSetters>().WithCtorArg("Age").EqualTo(34);
            _session = new BuildSession();

            TheDefaultGateway = new DefaultGateway();
            _session.RegisterDefault(typeof(IGateway), TheDefaultGateway);

            _target = null;
        }
Example #3
0
        public void look_at_expression()
        {
            var gateway = new DefaultGateway();
            Expression <Func <IContext, TopLevel> > expression = c => new TopLevel(new Leaf(gateway, new ColorService("red")))
            {
                Foo = new Foo(Guid.NewGuid())
            };

            //Expression<Func<IContext, TopLevel>> expression = c => new TopLevel(new Leaf(gateway, new ColorService("red")));

            Debug.WriteLine(expression);
        }
Example #4
0
        public void SendConfigurationTestIPv6Gateway()
        {
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice device  = new ConfigurationDevice("0009E5001231");
            DefaultGateway      gateway = new DefaultGateway();

            gateway.InternetProtocolV6Address = "2001:db8:85a3::8a2e:370:7334";
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(gateway);
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 1000);
            Assert.True(this.gotSuccessResponse && !this.gotErrorResponse && !this.gotTimeout, "got timeout or error for correct configuration response");
        }
Example #5
0
        public void use_predefined_setter_values_for_buildup()
        {
            var theGateway = new DefaultGateway();
            var container  = new Container(x => {
                x.ForConcreteType <BuildUpTarget1>().Configure
                .Setter(y => y.Gateway).Is(theGateway);
            });

            var target = new BuildUpTarget1();

            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
        public ConfigurationNetSettings(DefaultGateway gateway)
        {
            if (gateway == null)
            {
                throw new ArgumentNullException("gateway");
            }

            if (string.IsNullOrEmpty(gateway.InternetProtocolV4Address) && string.IsNullOrEmpty(gateway.InternetProtocolV6Address))
            {
                throw new ArgumentException("gateway");
            }

            this.DefaultGateway = gateway;
        }
Example #7
0
        public void SetUp()
        {
            TheDefaultGateway = new DefaultGateway();

            var args = new ExplicitArguments();

            args.Set <IGateway>(TheDefaultGateway);

            builder  = new Plugin(typeof(ClassWithMixOfSetters)).CreateBuilder();
            instance = new SmartInstance <ClassWithMixOfSetters>().Ctor <int>("Age").Is(34);
            _session = BuildSession.Empty(args);

            _target = null;
        }
Example #8
0
        public static IAddress[] StringToAddresses(string str)
        {
            var remoteAddresses = new List <IAddress>();

            foreach (var remoteAddress in str.Split(','))
            {
                DNSService     dns;
                DHCPService    dhcp;
                WINSService    wins;
                LocalSubnet    localSubnet;
                DefaultGateway defaultGateway;
                IPRange        range;
                SingleIP       ip;
                NetworkAddress network;
                if (DNSService.TryParse(remoteAddress, out dns))
                {
                    remoteAddresses.Add(dns);
                }
                else if (DHCPService.TryParse(remoteAddress, out dhcp))
                {
                    remoteAddresses.Add(dhcp);
                }
                else if (WINSService.TryParse(remoteAddress, out wins))
                {
                    remoteAddresses.Add(wins);
                }
                else if (LocalSubnet.TryParse(remoteAddress, out localSubnet))
                {
                    remoteAddresses.Add(localSubnet);
                }
                else if (DefaultGateway.TryParse(remoteAddress, out defaultGateway))
                {
                    remoteAddresses.Add(defaultGateway);
                }
                else if (IPRange.TryParse(remoteAddress, out range))
                {
                    remoteAddresses.Add(range);
                }
                else if (SingleIP.TryParse(remoteAddress, out ip))
                {
                    remoteAddresses.Add(ip);
                }
                else if (NetworkAddress.TryParse(remoteAddress, out network))
                {
                    remoteAddresses.Add(network);
                }
            }
            return(remoteAddresses.ToArray());
        }
Example #9
0
        internal byte[] ToArray()
        {
            var ret = new byte[27];

            IP.GetAddressBytes().CopyTo(ret, 0);
            SubnetMask.GetAddressBytes().CopyTo(ret, 4);
            MacAddress.GetAddressBytes().CopyTo(ret, 8);
            DefaultGateway.GetAddressBytes().CopyTo(ret, 14);
            Server.GetAddressBytes().CopyTo(ret, 18);
            ret[22] = FarLimit;
            Bytes.Write(2, ComPort).CopyTo(ret, 23);
            ret[25] = (byte)TcpMode;
            ret[26] = (byte)(DhcpEnabled ? 1 : 0);
            return(ret);
        }
        public BuildUpTester()
        {
            theDefaultGateway = new DefaultGateway();

            var args = new ExplicitArguments();

            args.Set <IGateway>(theDefaultGateway);
            session = BuildSession.Empty(args);

            theDependencies = new DependencyCollection {
                { "Age", 34 }
            };

            target = null;
        }
Example #11
0
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp()
        {
            var theGateway = new DefaultGateway();
            var container  = new Container(x => {
                x.For <IGateway>().Use(theGateway);
                x.Policies.SetAllProperties(y => { y.OfType <IGateway>(); });
            });

            var target = new BuildUpTarget1();

            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
            target.Service.ShouldBeNull();
        }
        public void ConfigurationNetSettingsInstantiation()
        {
            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings(null, null);
            },
                "no exception if both gateway and configuration interface are null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), null);
            },
                "no exception if gateway is null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings((ConfigurationInterface)null);
            },
                "no exception if configuration interface is null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings((DefaultGateway)null);
            },
                "no exception if gateway is null");

            Assert.DoesNotThrow(
                delegate
            {
                DefaultGateway gateway            = new DefaultGateway();
                gateway.InternetProtocolV4Address = "172.19.1.1";
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), gateway);
            },
                "exception thrown for correct instantiation");

            Assert.Throws <ArgumentException>(
                delegate
            {
                DefaultGateway gateway            = new DefaultGateway();
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), gateway);
            },
                "no exception if gateway IP is null or empty ");
        }
Example #13
0
            public void Save(WidgetConfig config)
            {
                config["HostName"]       = HostName.ToString();
                config["LogonDomain"]    = LogonDomain.ToString();
                config["IpAddress"]      = IpAddress.ToString();
                config["MachineDomain"]  = MachineDomain.ToString();
                config["MacAddress"]     = MacAddress.ToString();
                config["BootTime"]       = BootTime.ToString();
                config["Cpu"]            = Cpu.ToString();
                config["DefaultGateway"] = DefaultGateway.ToString();
                config["DhcpServer"]     = DhcpServer.ToString();
                config["DnsServer"]      = DnsServer.ToString();
                config["FreeSpace"]      = FreeSpace.ToString();

                config["LabelColor"] = ColorTranslator.ToHtml(LabelColor);
                config["ValueColor"] = ColorTranslator.ToHtml(ValueColor);
            }
        public void SetUp()
        {
            TheDefaultGateway = new DefaultGateway();


            var args = new ExplicitArguments();

            args.Set <IGateway>(TheDefaultGateway);
            _session = BuildSession.Empty(args);

            theDependencies = new DependencyCollection {
                { "Age", 34 }
            };


            _target = null;
        }
        // ReSharper disable once ExcessiveIndentation
        public static IAddress[] StringToAddresses(string str)
        {
            var remoteAddresses = new List <IAddress>();

            foreach (var remoteAddress in str.Split(','))
            {
                if (DNSService.TryParse(remoteAddress, out var dns))
                {
                    remoteAddresses.Add(dns);
                }
                else if (DHCPService.TryParse(remoteAddress, out var dhcp))
                {
                    remoteAddresses.Add(dhcp);
                }
                else if (WINSService.TryParse(remoteAddress, out var wins))
                {
                    remoteAddresses.Add(wins);
                }
                else if (LocalSubnet.TryParse(remoteAddress, out var localSubnet))
                {
                    remoteAddresses.Add(localSubnet);
                }
                else if (DefaultGateway.TryParse(remoteAddress, out var defaultGateway))
                {
                    remoteAddresses.Add(defaultGateway);
                }
                else if (IPRange.TryParse(remoteAddress, out var range))
                {
                    remoteAddresses.Add(range);
                }
                else if (SingleIP.TryParse(remoteAddress, out SingleIP ip))
                {
                    remoteAddresses.Add(ip);
                }
                else if (NetworkAddress.TryParse(remoteAddress, out var network))
                {
                    remoteAddresses.Add(network);
                }
            }

            return(remoteAddresses.ToArray());
        }
Example #16
0
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp_through_ObjectFactory()
        {
            var theGateway = new DefaultGateway();
            var container  = new Container(x => {
                x.For <IGateway>().Use(theGateway);

                // First we create a new Setter Injection Policy that
                // forces StructureMap to inject all public properties
                // where the PropertyType is IGateway
                x.Policies.SetAllProperties(y => y.OfType <IGateway>());
            });

            // Create an instance of BuildUpTarget1
            var target = new BuildUpTarget1();

            // Now, call BuildUp() on target, and
            // we should see the Gateway property assigned
            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
Example #17
0
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp_through_ObjectFactory()
        {
            var theGateway = new DefaultGateway();

            ObjectFactory.Initialize(x =>
            {
                x.IgnoreStructureMapConfig = true;
                x.ForRequestedType <IGateway>().TheDefault.IsThis(theGateway);

                // First we create a new Setter Injection Policy that
                // forces StructureMap to inject all public properties
                // where the PropertyType is IGateway
                x.SetAllProperties(y => { y.OfType <IGateway>(); });
            });

            // Create an instance of BuildUpTarget1
            var target = new BuildUpTarget1();

            // Now, call BuildUp() on target, and
            // we should see the Gateway property assigned
            ObjectFactory.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
        void ReleaseDesignerOutlets()
        {
            if (NetworkUpdateButton != null)
            {
                NetworkUpdateButton.Dispose();
                NetworkUpdateButton = null;
            }

            if (Authentication != null)
            {
                Authentication.Dispose();
                Authentication = null;
            }

            if (BootFileLabel != null)
            {
                BootFileLabel.Dispose();
                BootFileLabel = null;
            }

            if (ConfigFileLabel != null)
            {
                ConfigFileLabel.Dispose();
                ConfigFileLabel = null;
            }

            if (DefaultGateway != null)
            {
                DefaultGateway.Dispose();
                DefaultGateway = null;
            }

            if (DeployButton != null)
            {
                DeployButton.Dispose();
                DeployButton = null;
            }

            if (DeviceType != null)
            {
                DeviceType.Dispose();
                DeviceType = null;
            }

            if (EnableDHCP != null)
            {
                EnableDHCP.Dispose();
                EnableDHCP = null;
            }

            if (EncryptConfig != null)
            {
                EncryptConfig.Dispose();
                EncryptConfig = null;
            }

            if (Encryption != null)
            {
                Encryption.Dispose();
                Encryption = null;
            }

            if (FirmwareStatus != null)
            {
                FirmwareStatus.Dispose();
                FirmwareStatus = null;
            }

            if (FlashFileLabel != null)
            {
                FlashFileLabel.Dispose();
                FlashFileLabel = null;
            }

            if (FreeSlots != null)
            {
                FreeSlots.Dispose();
                FreeSlots = null;
            }

            if (MacAddress != null)
            {
                MacAddress.Dispose();
                MacAddress = null;
            }

            if (NetworkKey != null)
            {
                NetworkKey.Dispose();
                NetworkKey = null;
            }

            if (NetworkMacAddress != null)
            {
                NetworkMacAddress.Dispose();
                NetworkMacAddress = null;
            }

            if (NetworkValue != null)
            {
                NetworkValue.Dispose();
                NetworkValue = null;
            }

            if (Output != null)
            {
                Output.Dispose();
                Output = null;
            }

            if (Passphrase != null)
            {
                Passphrase.Dispose();
                Passphrase = null;
            }

            if (PrimaryDNS != null)
            {
                PrimaryDNS.Dispose();
                PrimaryDNS = null;
            }

            if (RadioA != null)
            {
                RadioA.Dispose();
                RadioA = null;
            }

            if (RadioB != null)
            {
                RadioB.Dispose();
                RadioB = null;
            }

            if (RadioG != null)
            {
                RadioG.Dispose();
                RadioG = null;
            }

            if (RadioN != null)
            {
                RadioN.Dispose();
                RadioN = null;
            }

            if (ReKeyInternal != null)
            {
                ReKeyInternal.Dispose();
                ReKeyInternal = null;
            }

            if (SaveConfigurationButton != null)
            {
                SaveConfigurationButton.Dispose();
                SaveConfigurationButton = null;
            }

            if (SecondaryDNS != null)
            {
                SecondaryDNS.Dispose();
                SecondaryDNS = null;
            }

            if (SSID != null)
            {
                SSID.Dispose();
                SSID = null;
            }

            if (StaticIPAddress != null)
            {
                StaticIPAddress.Dispose();
                StaticIPAddress = null;
            }

            if (SubnetMask != null)
            {
                SubnetMask.Dispose();
                SubnetMask = null;
            }

            if (UpdateFirmwareButton != null)
            {
                UpdateFirmwareButton.Dispose();
                UpdateFirmwareButton = null;
            }
        }
Example #19
0
 /// <summary>
 /// 文字列配列型のデフォルトゲートウェイを取得します。
 /// </summary>
 public string[] GetDefaultGatewayStringArray() => DefaultGateway == null || DefaultGateway.ToString() == "0.0.0.0" || DefaultGateway == IPAddress ? null : new string[]
 {
     DefaultGateway.ToString()
 };
 /// <summary>
 ///     Determines whether a string is a valid default gateway address
 /// </summary>
 /// <returns>
 ///     <see langword="true" /> if <paramref name="str" /> is a valid default gateway address; otherwise,
 ///     <see langword="false" />.
 /// </returns>
 /// <param name="str">The string to validate.</param>
 /// <param name="address">The <see cref="DefaultGateway" /> instance that represents the passed string.</param>
 public static bool TryParse(string str, out DefaultGateway address)
 {
     return(TryParse <DefaultGateway>(str, out address));
 }