Beispiel #1
0
        internal FlowSourceManager(Engine engine, bool debugMode, FunctionScope globalScope, FunctionScope contextScope, DebugController debugController)
        {
            this.engine          = engine;
            this.debugMode       = debugMode;
            this.contextScope    = contextScope;
            this.globalScope     = globalScope;
            this.debugController = debugController;

            callBackDictionary = new Dictionary <string, List <FlowCallEventHandler> >();
            sources            = new Dictionary <int, FlowSourceObjectBase>();
            flowInfos          = new List <FlowInfo>();
            eventQueue         = new EventQueue();
            currentQueue       = eventQueue;

            scope = new FunctionScope(ScopeType.Default);
            contextScope.AddChild(scope);
            scopes      = new List <FunctionScope>();
            breakPoints = new HashSet <int>();

            Items = new Dictionary <string, object>();
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            foreach (FunctionScope scope in scopes)
            {
                FunctionScope parent = null;
                if (scope.ParentId < 0)
                {
                    parent = this.scope;
                }
                else
                {
                    parent = scopes.FirstOrDefault(s => s.Id == scope.ParentId);
                }
                parent.AddChild(scope);
            }

            foreach (FlowSourceObjectBase source in sources.Values)
            {
                source.Manager      = this;
                source.Scope        = GetScopeById(source.ScopeId);
                source.ContextScope = contextScope;
                source.GlobalScope  = globalScope;
                source.Initialize();
            }

            foreach (KeyValuePair <FlowSourceObjectBase, KeyValuePair <string, string>[]> kvp in defaultValues)
            {
                foreach (KeyValuePair <string, string> defaultValue in kvp.Value)
                {
                    kvp.Key.SetValue(defaultValue.Key, defaultValue.Value);
                }
            }

            initialized = true;
        }