public void AutoTest() { var type = this.GetType(); var attributes = type.GetCustomAttributes(true); foreach (Object attribute in attributes) { if (attribute is IgnoreTestAttribute) { Console.WriteLine("{0}'s test is ignored.", type); return; } } Scope = new FunctionScope(ScopeType.Default); ContextScope = new FunctionScope(ScopeType.Context); GlobalScope = new FunctionScope(ScopeType.Global); Manager = new FlowSourceManager(new Engine(), true, GlobalScope, ContextScope, null); try { OnInitialize(); foreach (CustomMemberInfo <PropertyInfo> info in outProperty.Values) { try { GetPropertyValue(info.MemberInfo.Name); } catch (Exception e) { Console.WriteLine("Property Test:{2}\n{0} in {1}", e.InnerException != null ? e.InnerException.GetType().Name : e.GetType().Name, type, info.MemberInfo.PropertyType); Console.WriteLine(); } } foreach (CustomMemberInfo <MethodInfo> memberInfo in methodList.Values) { try { memberInfo.MemberInfo.Invoke(this, new object[] { new FlowEventArgs(this, false) }); } catch (Exception e) { Console.WriteLine("Method Test:{2}\n{0} in {1}", e.InnerException.GetType().Name, type, memberInfo.MemberInfo.Name); Console.WriteLine(); } } } catch (Exception e) { Console.WriteLine(e.Message + "\n" + e.StackTrace); } }
internal OperationType WaitOperation(FlowSourceManager flowSourceManager) { currentFlowSourceManager = flowSourceManager; operationType = OperationType.Wait; resetEvent = new ManualResetEvent(false); Waiting = true; OnOperationWaited(flowSourceManager); while (operationType == OperationType.Wait) { resetEvent.WaitOne(); } OnOperationAccepted(flowSourceManager); return(operationType); }
private void ReadScopes(XmlReader reader, FlowSourceManager manager) { while (reader.Read()) { switch (reader.Name) { case "Scope": var ID = int.Parse(reader.GetAttribute("ID"), CultureInfo.InvariantCulture); var scopeId = ParseId(reader.GetAttribute("ScopeID")); var scope = new FunctionScope(ScopeType.User) { Id = ID, ParentId = scopeId }; manager.AddScope(scope); break; } } reader.Close(); }
public FlowSourceManager Load(Stream stream, bool debugMode, Guid contextGuid, DebugController debugController) { if (!contexts.TryGetValue(contextGuid, out FunctionScope contextScope)) { contextScope = new FunctionScope(ScopeType.Context); contexts.Add(contextGuid, contextScope); globalScope.AddChild(contextScope); } var manager = new FlowSourceManager(this, debugMode, globalScope, contextScope, debugController); var defaultValues = LoadSync(stream, manager); manager.Connect(defaultValues); manager.Error += e => { Error?.Invoke(e); }; managers.Add(manager); return(manager); }
private void ReadFlows(XmlReader reader, FlowSourceManager manager) { while (reader.Read()) { switch (reader.Name) { case "Flow": int srcID = int.Parse(reader.GetAttribute("SrcID"), CultureInfo.InvariantCulture), destID = int.Parse(reader.GetAttribute("DestID"), CultureInfo.InvariantCulture); var flowInfo = new FlowInfo { SrcID = srcID, DestID = destID, SrcName = reader.GetAttribute("SrcName"), DestName = reader.GetAttribute("DestName") }; manager.AddFlowInfo(flowInfo); break; } } reader.Close(); }
internal void OnSourceChanged(string str, FlowSourceManager flowSourceManager) { SourceChanged?.Invoke(str, flowSourceManager); }
private void OnOperationAccepted(FlowSourceManager flowSourceManager) { OperationAccepted?.Invoke(flowSourceManager); }
private void OnErrorOccurred(FlowSourceManager flowSourceManager, FlowExecutionException e) { ErrorOccurred?.Invoke(flowSourceManager, e); }
internal void Error(FlowSourceManager flowSourceManager, FlowExecutionException e) { OnErrorOccurred(flowSourceManager, e); }
private KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]>[] ReadSources(XmlReader reader, FlowSourceManager manager) { var ret = new List <KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]> >(); while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Source": var fullName = reader.GetAttribute("FullName"); var ID = int.Parse(reader.GetAttribute("ID"), CultureInfo.InvariantCulture); var scopeId = ParseId(reader.GetAttribute("ScopeID")); var source = FlowSourceObjectManager.CreateSource(fullName); if (source == null) { throw new ArgumentException(String.Format("{0} not found", fullName)); } source.Id = ID; source.ScopeId = scopeId; var defaultValues = ReadValues(reader.ReadSubtree(), source); ret.Add(new KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]>(source, defaultValues)); manager.AddFlowSourceObject(source); break; } } } reader.Close(); return(ret.ToArray()); }
private KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]>[] LoadSync(Stream stream, FlowSourceManager manager) { var reader = XmlReader.Create(stream); KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]>[] defaultValues = null; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Sources": defaultValues = ReadSources(reader.ReadSubtree(), manager); break; case "Flows": ReadFlows(reader.ReadSubtree(), manager); break; case "Scope": ReadScopes(reader.ReadSubtree(), manager); break; } } } reader.Close(); return(defaultValues); }