public void TestConfigurationProperty()
        {
            ConfigurationPropertyImpl v1 = new ConfigurationPropertyImpl();

            v1.Order             = (1);
            v1.IsConfidential    = (true);
            v1.IsRequired        = true;
            v1.Name              = ("foo");
            v1.HelpMessageKey    = ("help key");
            v1.DisplayMessageKey = ("display key");
            v1.GroupMessageKey   = ("group key");
            v1.Value             = ("bar");
            v1.ValueType         = (typeof(string));
            v1.Operations        = FrameworkUtil.AllAPIOperations();

            ConfigurationPropertyImpl v2 = (ConfigurationPropertyImpl)
                                           CloneObject(v1);

            Assert.AreEqual(1, v2.Order);
            Assert.IsTrue(v2.IsConfidential);
            Assert.IsTrue(v2.IsRequired);
            Assert.AreEqual("foo", v2.Name);
            Assert.AreEqual("help key", v2.HelpMessageKey);
            Assert.AreEqual("display key", v2.DisplayMessageKey);
            Assert.AreEqual("group key", v2.GroupMessageKey);
            Assert.AreEqual("bar", v2.Value);
            Assert.AreEqual(typeof(string), v2.ValueType);
            Assert.IsTrue(CollectionUtil.Equals(
                              FrameworkUtil.AllAPIOperations(), v2.Operations));
        }
        public void TestAPIConfiguration()
        {
            ConfigurationPropertyImpl prop1 = new ConfigurationPropertyImpl();

            prop1.Order             = (1);
            prop1.IsConfidential    = (true);
            prop1.Name              = ("foo");
            prop1.HelpMessageKey    = ("help key");
            prop1.DisplayMessageKey = ("display key");
            prop1.GroupMessageKey   = ("group key");
            prop1.Value             = ("bar");
            prop1.ValueType         = (typeof(string));
            prop1.Operations        = null;

            ConfigurationPropertiesImpl props1 = new ConfigurationPropertiesImpl();

            props1.Properties = (CollectionUtil.NewReadOnlyList <ConfigurationPropertyImpl>(prop1));

            APIConfigurationImpl v1 = new APIConfigurationImpl();

            v1.ConnectorPoolConfiguration  = (new ObjectPoolConfiguration());
            v1.ConfigurationProperties     = (props1);
            v1.IsConnectorPoolingSupported = (true);
            v1.ProducerBufferSize          = (200);
            v1.SupportedOperations         = (FrameworkUtil.AllAPIOperations());
            IDictionary <SafeType <APIOperation>, int> map =
                CollectionUtil.NewDictionary <SafeType <APIOperation>, int>(SafeType <APIOperation> .Get <CreateApiOp>(), 6);

            v1.TimeoutMap = (map);

            APIConfigurationImpl v2 = (APIConfigurationImpl)
                                      CloneObject(v1);

            Assert.IsTrue(!Object.ReferenceEquals(v1, v2));
            Assert.IsNotNull(v2.ConnectorPoolConfiguration);
            Assert.IsNotNull(v2.ConfigurationProperties);
            Assert.AreEqual(v1.ConnectorPoolConfiguration, v2.ConnectorPoolConfiguration);
            Assert.AreEqual(v1.ConfigurationProperties, v2.ConfigurationProperties);
            Assert.IsTrue(v2.IsConnectorPoolingSupported);
            Assert.AreEqual(200, v2.ProducerBufferSize);
            Assert.IsTrue(CollectionUtil.SetsEqual(
                              FrameworkUtil.AllAPIOperations(),
                              v2.SupportedOperations));
            Assert.AreEqual(map, v2.TimeoutMap);
        }
Ejemplo n.º 3
0
        public void TestConfigurationProperties()
        {
            ConfigurationPropertyImpl prop1 = new ConfigurationPropertyImpl();

            prop1.Order             = (1);
            prop1.IsConfidential    = (true);
            prop1.Name              = ("foo");
            prop1.HelpMessageKey    = ("help key");
            prop1.DisplayMessageKey = ("display key");
            prop1.Value             = ("bar");
            prop1.ValueType         = (typeof(string));
            prop1.Operations        = null;

            ConfigurationPropertiesImpl v1 = new ConfigurationPropertiesImpl();

            v1.Properties = (CollectionUtil.NewReadOnlyList <ConfigurationPropertyImpl>(prop1));
            v1.SetPropertyValue("foo", "bar");

            ConfigurationPropertiesImpl v2 = (ConfigurationPropertiesImpl)
                                             CloneObject(v1);

            Assert.AreEqual("bar", v2.GetProperty("foo").Value);
        }
Ejemplo n.º 4
0
        CreateConfigurationProperties(Configuration defaultObject)
        {
            SafeType <Configuration> config = SafeType <Configuration> .Get(defaultObject);

            ConfigurationPropertiesImpl properties =
                new ConfigurationPropertiesImpl();
            IList <ConfigurationPropertyImpl> temp =
                new List <ConfigurationPropertyImpl>();
            IDictionary <string, PropertyInfo> descs = GetFilteredProperties(config);

            foreach (PropertyInfo desc in descs.Values)
            {
                String name = desc.Name;

                // get the configuration options..
                ConfigurationPropertyAttribute options =
                    GetPropertyOptions(desc);
                // use the options to set internal properties..
                int    order        = 0;
                String helpKey      = name + ".help";
                String displKey     = name + ".display";
                bool   confidential = false;
                bool   required     = false;
                if (options != null)
                {
                    // determine the display and help keys..
                    if (!StringUtil.IsBlank(options.HelpMessageKey))
                    {
                        helpKey = options.HelpMessageKey;
                    }
                    if (!StringUtil.IsBlank(options.DisplayMessageKey))
                    {
                        displKey = options.DisplayMessageKey;
                    }
                    // determine the order..
                    order        = options.Order;
                    required     = options.Required;
                    confidential = options.Confidential;
                }
                Type type = desc.PropertyType;
                if (!FrameworkUtil.IsSupportedConfigurationType(type))
                {
                    const String MSG = "Property type ''{0}'' is not supported.";
                    throw new ArgumentException(String.Format(MSG, type));
                }

                Object value = desc.GetValue(defaultObject, null);

                ConfigurationPropertyImpl prop = new ConfigurationPropertyImpl();
                prop.IsConfidential    = confidential;
                prop.IsRequired        = required;
                prop.DisplayMessageKey = displKey;
                prop.HelpMessageKey    = helpKey;
                prop.Name       = name;
                prop.Order      = order;
                prop.Value      = value;
                prop.ValueType  = type;
                prop.Operations = options == null ? null : TranslateOperations(options.Operations);

                temp.Add(prop);
            }
            properties.Properties = (temp);
            return(properties);
        }