Пример #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);
        }
Пример #2
0
        public override string ToString()
        {
            if (this.values.Count == 0)
            {
                return(string.Format("{0}: ", this.PropertyName));
            }
            if (this.values.Count != 1)
            {
                return(string.Format("{0}: {1}", this.PropertyName, CommonUtils.ConcatEntries <PropertyValueBaseXML>(this.values, null)));
            }
            PropertyValueBaseXML propertyValueBaseXML = this.values[0];

            if (propertyValueBaseXML is PropertyBinaryValueXML && this.PropertyName.ToUpper().EndsWith("GUID"))
            {
                return(string.Format("{0}: {1}", this.PropertyName, ((PropertyBinaryValueXML)propertyValueBaseXML).AsGuid));
            }
            return(string.Format("{0}: {1}", this.PropertyName, propertyValueBaseXML));
        }