コード例 #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
        private void AddPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }
            Verify();

            //lock (_padLock)
            //{
            if (_topPlugIn == null)
            {
                _topPlugIn = _nextPlugIn = plugIn;
            }
            else
            {
                _nextPlugIn = _nextPlugIn.ContinueWith(plugIn);
            }

            //Point next plugin to the last item

            while (_nextPlugIn.Next != null)
            {
                _nextPlugIn = _nextPlugIn.Next;
            }
            //}
        }
コード例 #3
0
 public void Reset()
 {
     Verify();
     _topPlugIn = _nextPlugIn = null;
     _result    = null;
     _isRunning = false;
 }
コード例 #4
0
        protected virtual void InitPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }

            plugIn.Name              = Name;
            plugIn.Description       = Description;
            plugIn.DoPropertyResolve = DoPropertyResolve;
            plugIn.Enabled           = Enabled;
        }
コード例 #5
0
        public IEnumerable <ChoPlugIn> AsEnumerable()
        {
            ChoPlugIn next = this;

            yield return(next);

            while (next.Next != null)
            {
                next = next.Next;
                yield return(next);
            }

            yield break;
        }
コード例 #6
0
        protected override void InitPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }

            base.InitPlugIn(plugIn);

            ChoJavaScriptFilePlugIn o = plugIn as ChoJavaScriptFilePlugIn;

            if (o == null)
            {
                return;
            }

            o.ScriptFilePath = ScriptFilePath;
            o.Arguments      = Arguments.GetValue();
        }
コード例 #7
0
        protected override void InitPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }

            base.InitPlugIn(plugIn);

            ChoVBNETCodeSnippetPlugIn o = plugIn as ChoVBNETCodeSnippetPlugIn;

            if (o == null)
            {
                return;
            }

            o.CodeSnippet = CodeSnippet.GetValue();
            o.Arguments   = Arguments.GetValue();
            o.Namespaces  = Namespaces;
        }
コード例 #8
0
        protected override void InitPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }

            base.InitPlugIn(plugIn);

            ChoJavaScriptPlugIn o = plugIn as ChoJavaScriptPlugIn;

            if (o == null)
            {
                return;
            }

            o.Script           = Script.GetValue();
            o.Arguments        = Arguments.GetValue();
            o.WorkingDirectory = WorkingDirectory;
        }
コード例 #9
0
ファイル: ChoPlugInEditor.cs プロジェクト: lanicon/Cinchoo
        private string FormatException(ChoPlugIn plugIn, Exception ex, string errMsg = null)
        {
            StringBuilder msg = new StringBuilder();

            if (plugIn != null)
            {
                msg.AppendLine("Error found running '{0}' plugin.".FormatString(plugIn.Name));
            }
            else
            {
                msg.AppendLine(errMsg.IsNullOrWhiteSpace() ? "Error found running all plugins." : errMsg);
            }

            msg.AppendLine("Error Msg: {0}.".FormatString(ex.Message));
            msg.AppendLine();
            msg.AppendLine("StackTrace:");
            msg.AppendLine(ChoApplicationException.ToString(ex));

            return(msg.ToString());
        }
コード例 #10
0
        protected override void InitPlugIn(ChoPlugIn plugIn)
        {
            if (plugIn == null)
            {
                return;
            }

            base.InitPlugIn(plugIn);

            ChoDotNetAssemblyPlugIn o = plugIn as ChoDotNetAssemblyPlugIn;

            if (o == null)
            {
                return;
            }

            o.TypeName       = TypeName;
            o.MethodName     = MethodName;
            o.IsStaticMethod = IsStaticMethod;
            o.Arguments      = Arguments.GetValue();
        }
コード例 #11
0
        private void RunAsync(object value, object contextInfo = null, ChoAbortableAsyncCallback callback = null)
        {
            Verify();

            if (_topPlugIn == null)
            {
                return;
            }

            ActivePlugIn = null;
            _result      = ChoAbortableQueuedExecutionService.Global.Enqueue(() =>
            {
                if (_topPlugIn == null)
                {
                    return(null);
                }

                _isRunning = true;

                //lock (_padLock)
                //{
                try
                {
                    _topPlugIn.ContextInfo = contextInfo;
                    _topPlugIn.BeforeRun  += OnBeforePlugInRun;
                    _topPlugIn.AfterRun   += OnAfterPlugInRun;

                    return(_topPlugIn.Run(value));
                }
                finally
                {
                    //_topPlugIn.BeforeRun -= BeforePlugInRun;
                }
                //}
            },
                                                                             callback, null, -1);
        }
コード例 #12
0
 public ChoPlugIn ContinueWith(ChoPlugIn plugIn)
 {
     _nextPlugIn = plugIn;
     return(_nextPlugIn);
 }
コード例 #13
0
 private void OnBeforePlugInRun(object sender, ChoPlugInRunEventArgs e)
 {
     ActivePlugIn = sender as ChoPlugIn;
     BeforePlugInRun.Raise(sender, e);
 }
コード例 #14
0
 public void Add(ChoPlugIn plugIn)
 {
     AddPlugIn(plugIn);
 }