private static void RegisterElement(Type type) { KmlElementAttribute element = TypeBrowser.GetElement(type.GetTypeInfo()); if (element != null) { var xml = new XmlComponent(null, element.ElementName, element.Namespace); RegisterType(xml, type); } }
private static void RegisterAssembly(Assembly assembly) { foreach (var type in assembly.GetExportedTypes()) { if (type.IsSubclassOf(typeof(Element))) { KmlElementAttribute element = TypeBrowser.GetElement(type); if (element != null) { var xml = new XmlComponent(null, element.ElementName, element.Namespace); RegisterType(xml, type); } } } }
private static Dictionary <string, object> GetEnumValues(TypeInfo enumType) { var lookup = new Dictionary <string, object>(StringComparer.Ordinal); foreach (FieldInfo field in enumType.DeclaredFields.Where(f => f.IsStatic)) { KmlElementAttribute element = TypeBrowser.GetElement(field); if (element != null) { lookup.Add(element.ElementName, field.GetValue(null)); } } return(lookup); }
private static object GetEnum(Type type, string value) { if (value != null) { value = value.Trim(); foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static)) { KmlElementAttribute element = TypeBrowser.GetElement(field); if (element != null && string.Equals(element.ElementName, value, StringComparison.Ordinal)) { return(field.GetValue(null)); } } } return(null); }
private static object GetEnum(TypeInfo typeInfo, string value) { if (value != null) { value = value.Trim(); foreach (FieldInfo field in typeInfo.DeclaredFields.Where(f => f.IsStatic)) { KmlElementAttribute element = TypeBrowser.GetElement(field); if (element != null && string.Equals(element.ElementName, value, StringComparison.Ordinal)) { return(field.GetValue(null)); } } } return(null); }