public virtual ChoPlugIn CreatePlugIn() { ChoPlugInAttribute plugInAttribute = ChoType.GetAttribute <ChoPlugInAttribute>(GetType()); if (plugInAttribute == null) { throw new ChoPlugInException("Missing ChoPlugInAttribute decorated for '{0}' plugin builder.".FormatString(GetType().Name)); } Type type = plugInAttribute.PlugInType; if (type == null) { throw new ChoPlugInException("Can't find plugin for '{0}' plugin builder.".FormatString(GetType().Name)); } ChoPlugIn p = ChoActivator.CreateInstance(type) as ChoPlugIn; if (p == null) { throw new ChoPlugInException("Can't find plugin for '{0}' plugin builder.".FormatString(GetType().Name)); } InitPlugIn(p); return(p); }
internal static string GetPlugInName(Type plugInBuilderType) { ChoPlugInAttribute plugInAttribute = ChoType.GetAttribute <ChoPlugInAttribute>(plugInBuilderType); if (plugInAttribute == null) { throw new ChoPlugInException("Missing ChoPlugInAttribute decorated for '{0}' plugin builder.".FormatString(plugInBuilderType.Name)); } return(plugInAttribute.Name); }
internal static Type GetPlugInType(Type plugInBuilderType) { ChoPlugInAttribute plugInAttribute = ChoType.GetAttribute <ChoPlugInAttribute>(plugInBuilderType); if (plugInAttribute == null) { return(null); } Type type = plugInAttribute.PlugInType; if (type == null) { throw new ChoPlugInException("Can't find plugin for '{0}' plugin builder.".FormatString(plugInBuilderType.Name)); } return(type); }
public ChoPlugInBuilder() { _plugInBuilderProperty = new Lazy <ChoPlugInBuilderProperty>(() => { ChoPlugInAttribute plugInAttribute = ChoType.GetAttribute <ChoPlugInAttribute>(GetType()); if (plugInAttribute == null) { throw new ChoPlugInException("Missing ChoPlugInAttribute decorated for '{0}' plugin builder.".FormatString(GetType().Name)); } Type type = plugInAttribute.PlugInBuilderPropertyType; if (type == null) { throw new ChoPlugInException("Can't find plugin property for '{0}' plugin builder.".FormatString(GetType().Name)); } ChoPlugInBuilderProperty p = ChoActivator.CreateInstance(type) as ChoPlugInBuilderProperty; if (p == null) { throw new ChoPlugInException("Can't find plugin property for '{0}' plugin builder.".FormatString(GetType().Name)); } try { InitPlugInBuilderProperty(p); } catch { } p.PropertyChanged += ((s, e) => { ApplyPropertyValues(p, e.PropertyName); }); return(p); }, true); }