Ejemplo n.º 1
0
        internal static PropertyXML Create(ProviderPropertyDefinition pdef, object value)
        {
            PropertyXML propertyXML = new PropertyXML();

            propertyXML.PropertyName = pdef.Name;
            propertyXML.ClassName    = pdef.Type.FullName;
            propertyXML.values       = new List <PropertyValueBaseXML>();
            propertyXML.isDefault    = object.Equals(value, pdef.DefaultValue);
            if (pdef.IsMultivalued && value is MultiValuedPropertyBase)
            {
                MultiValuedPropertyBase multiValuedPropertyBase = (MultiValuedPropertyBase)value;
                using (IEnumerator enumerator = ((IEnumerable)multiValuedPropertyBase).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object value2 = enumerator.Current;
                        PropertyValueBaseXML propertyValueBaseXML = PropertyValueBaseXML.Create(pdef, value2);
                        if (propertyValueBaseXML != null)
                        {
                            propertyXML.values.Add(propertyValueBaseXML);
                        }
                    }
                    return(propertyXML);
                }
            }
            if (value != null)
            {
                PropertyValueBaseXML propertyValueBaseXML2 = PropertyValueBaseXML.Create(pdef, value);
                if (propertyValueBaseXML2 != null)
                {
                    propertyXML.values.Add(propertyValueBaseXML2);
                }
            }
            return(propertyXML);
        }
Ejemplo n.º 2
0
 internal static void Add(List <PropertyUpdateXML> updates, ProviderPropertyDefinition pdef, object value, PropertyUpdateOperation op)
 {
     updates.Add(new PropertyUpdateXML
     {
         Operation = op,
         Property  = PropertyXML.Create(pdef, value)
     });
 }
        internal static ConfigurableObjectXML Create(ConfigurableObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            ConfigurableObjectXML configurableObjectXML = new ConfigurableObjectXML();

            configurableObjectXML.ClassName = obj.GetType().Name;
            foreach (PropertyDefinition propertyDefinition in obj.ObjectSchema.AllProperties)
            {
                ProviderPropertyDefinition providerPropertyDefinition = propertyDefinition as ProviderPropertyDefinition;
                if (providerPropertyDefinition != null && !ConfigurableObjectXML.PropertiesNotToSerialize.ContainsKey(propertyDefinition))
                {
                    object      value       = obj[providerPropertyDefinition];
                    PropertyXML propertyXML = PropertyXML.Create(providerPropertyDefinition, value);
                    if (propertyXML != null)
                    {
                        configurableObjectXML.properties[providerPropertyDefinition.Name] = propertyXML;
                    }
                }
            }
            return(configurableObjectXML);
        }