void ITypeEditor.Initialize(string editorParameter) { if (string.IsNullOrWhiteSpace(editorParameter)) { return; } // Find out the type - if the type could not be found, go out. Type type = Type.GetType(editorParameter); this.ObjectPropertiesHelp = ObjectExpressionTools.GetPropertyNames(type, null, false); }
private SeedEntry ParseElement(XElement elem) { string typeName = elem.Attribute("Type").Value; Type type = Type.GetType(typeName); if (type == null) { return(null); } if (type.GetConstructor(Type.EmptyTypes) == null) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SeedEntryTypeHasNoDefaultConstructor, type.FullName); return(null); } object instance = Activator.CreateInstance(type); foreach (XElement prop in elem.Elements("Set")) { string expression = prop.Attribute("Expression").Value; string valueRaw = prop.Value; PropertyInfo property = null; object target = null; if (!ObjectExpressionTools.GetPropertyFromExpression(instance, expression, false, out property, out target)) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.SeedEntryPropertyNotFound, expression, type.Name); break; } object value = Convert.ChangeType(valueRaw, property.PropertyType); if (!ObjectExpressionTools.TrySetValueFromExpression(instance, expression, value)) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.SeedEntrySetPropertyFailed, expression, type.Name); break; } } SeedEntry entry = new SeedEntry(); entry.Name = elem.Attribute("Name").Value; entry.UseIFormattable = bool.Parse(elem.Attribute("UseIFormattable").Value); entry.EntryType = type; entry.Instance = instance; return(entry); }