Esempio n. 1
0
        public static void GetProperties(
            Type type,
            out Dictionary <string, PropertyInfo> elements,
            out Dictionary <string, PropertyInfo> attributes,
            out PropertyInfo contentProperty,
            out PropertyInfo reinitProperty
            )
        {
            XmlTypeInfo info;

            if (!typeInfos.TryGetValue(type, out info))
            {
                info = new XmlTypeInfo();
                foreach (var property in type.GetRuntimeProperties())
                {
                    if (property.GetCustomAttribute <UiIgnoreAttribute>() != null)
                    {
                        continue;
                    }
                    var ptype = property.PropertyType;

                    if (ptype.IsPrimitive || ptype.IsEnum ||
                        ptype == typeof(string) || ptype == typeof(InterfaceColor) ||
                        ptype == typeof(InterfaceModel) || ptype == typeof(InterfaceImage))
                    {
                        if (property.SetMethod == null)
                        {
                            continue;
                        }
                        info.Attributes.Add(property.Name, property);
                    }
                    else if (ptype == typeof(UiRecreateHandle))
                    {
                        info.Reinit = property;
                    }
                    else
                    {
                        if (property.GetCustomAttribute <UiContentAttribute>() != null)
                        {
                            info.Content = property;
                        }
                        info.Elements.Add(property.Name, property);
                    }
                }
                typeInfos.Add(type, info);
            }

            elements        = info.Elements;
            attributes      = info.Attributes;
            contentProperty = info.Content;
            reinitProperty  = info.Reinit;
        }
Esempio n. 2
0
        public virtual bool GetXmlTypeInfo(String xmlName, out ConstructorInfo constructInfo, out bool isUnique)
        {
            constructInfo = null;
            isUnique      = false;
            InitXmlTypeInfo();
            XmlTypeInfo typeInfo = new XmlTypeInfo();

            if (!String.IsNullOrEmpty(xmlName))
            {
                if (s_xmlTypeInfo.TryGetValue(xmlName.ToUpper(), out typeInfo))
                {
                    constructInfo = typeInfo._constructInfo;
                    isUnique      = typeInfo._isUnique;
                    return(true);
                }
            }
            return(false);
        }