System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetProperties C# (CSharp) Method

GetProperties() private method

Retrieves the properties for this type.
private GetProperties ( ) : PropertyDescriptorCollection
return PropertyDescriptorCollection
            internal PropertyDescriptorCollection GetProperties()
            {
                // Worst case collision scenario:  we don't want the perf hit
                // of taking a lock, so if we collide we will query for
                // properties twice.  Not a big deal.
                //
                if (_properties == null)
                {
                    PropertyDescriptor[] propertyArray;
                    Dictionary<string, PropertyDescriptor> propertyList = new Dictionary<string, PropertyDescriptor>(10);
                    Type baseType = _type;
                    Type objType = typeof(object);

                    do
                    {
                        propertyArray = ReflectGetProperties(baseType);
                        foreach (PropertyDescriptor p in propertyArray)
                        {
                            if (!propertyList.ContainsKey(p.Name))
                            {
                                propertyList.Add(p.Name, p);
                            }
                        }
                        baseType = baseType.GetTypeInfo().BaseType;
                    }
                    while (baseType != null && baseType != objType);

                    propertyArray = new PropertyDescriptor[propertyList.Count];
                    propertyList.Values.CopyTo(propertyArray, 0);
                    _properties = new PropertyDescriptorCollection(propertyArray, true);
                }

                return _properties;
            }