示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }