Example #1
0
        /// <summary>
        /// Sets the property and save.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="prop">The prop.</param>
        /// <param name="save">if set to <c>true</c> [save].</param>
        private void SetPropertyAndSave(PropertyInfoCollection collection, PropertyInfo property, bool save, bool overwrite)
        {
            if (collection != null)
            {
                PropertyInfo setProperty = collection[property.Name];

                if (setProperty == null)
                {
                    collection.Add(property);
                }
                else if (overwrite == true)
                {
                    setProperty.Namespace = property.Namespace;
                    //Calculated property not set
                    if (property.Calculated == false)
                    {
                        setProperty.Value = property.Value;
                    }
                }

                if (save == true)
                {
                    SavePropertyCollection(collection);
                }
            }
        }
Example #2
0
        internal static InformationApi.Collections.PropertyInfoCollection BuildPropInfoCol(Type t)
        {
            var props = t.GetProperties();
            var ret   = new PropertyInfoCollection();

            foreach (var p in props)
            {
                ret.Add(BuildPropInfo(p));
            }

            return(ret);
        }
Example #3
0
        private static PropertyInfoCollection GetCloneableProperties(Type destinationType, Type baseType)
        {
            PropertyInfoCollection descriptor;

            if (!PropertiesDescriptorCache.TryGetValue(destinationType, out descriptor))
            {
                descriptor = new PropertyInfoCollection();
                foreach (var propertyInfo in destinationType.GetProperties())
                {
                    var item = GetCloneableProperty(propertyInfo, baseType);
                    if (item != null)
                    {
                        descriptor.Add(item.Name, item);
                    }
                }
                PropertiesDescriptorCache.Add(destinationType, descriptor);
            }
            return(descriptor);
        }
Example #4
0
        private void SetProperty(PropertyInfoCollection collection, PropertyInfo property, bool overwrite)
        {
            if (collection != null)
            {
                PropertyInfo setProperty = collection[property.Name];

                if (setProperty == null)
                {
                    collection.Add(property);
                }
                else if (overwrite == true)
                {
                    setProperty.Namespace = property.Namespace;
                    //Calculated property not set
                    if (property.Calculated == false)
                        setProperty.Value = property.Value;
                }
            }
        }