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); }
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; } //} }
public void Reset() { Verify(); _topPlugIn = _nextPlugIn = null; _result = null; _isRunning = false; }
protected virtual void InitPlugIn(ChoPlugIn plugIn) { if (plugIn == null) { return; } plugIn.Name = Name; plugIn.Description = Description; plugIn.DoPropertyResolve = DoPropertyResolve; plugIn.Enabled = Enabled; }
public IEnumerable <ChoPlugIn> AsEnumerable() { ChoPlugIn next = this; yield return(next); while (next.Next != null) { next = next.Next; yield return(next); } yield break; }
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(); }
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; }
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; }
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()); }
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(); }
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); }
public ChoPlugIn ContinueWith(ChoPlugIn plugIn) { _nextPlugIn = plugIn; return(_nextPlugIn); }
private void OnBeforePlugInRun(object sender, ChoPlugInRunEventArgs e) { ActivePlugIn = sender as ChoPlugIn; BeforePlugInRun.Raise(sender, e); }
public void Add(ChoPlugIn plugIn) { AddPlugIn(plugIn); }