public TreeWalkerSession()

in Forge.TreeWalker/src/TreeWalkerSession.cs [149:177]


        public TreeWalkerSession(TreeWalkerParameters parameters)
        {
            this.Parameters = parameters ?? throw new ArgumentNullException("parameters");

            if (string.IsNullOrWhiteSpace(parameters.TreeName))
            {
                this.Parameters.TreeName = DefaultTreeName;
            }

            // Initialize properties from required TreeWalkerParameters properties.
            this.Schema = parameters.ForgeTree ?? JsonConvert.DeserializeObject<ForgeTree>(parameters.JsonSchema);
            this.walkTreeCts = CancellationTokenSource.CreateLinkedTokenSource(parameters.Token);

            // Initialize properties from optional TreeWalkerParameters properties.
            GetActionsMapFromAssembly(parameters.ForgeActionsAssembly, out this.actionsMap);
            this.Parameters.ExternalExecutors = parameters.ExternalExecutors ?? new Dictionary<string, Func<string, CancellationToken, Task<object>>>();
            
            // TODO: Consider using a factory pattern to construct asynchronously.
            this.Parameters.TreeInput = this.GetOrCommitTreeInput(parameters.TreeInput).GetAwaiter().GetResult();

            this.expressionExecutor = new ExpressionExecutor(this as ITreeSession, parameters.UserContext, parameters.Dependencies, parameters.ScriptCache, this.Parameters.TreeInput);

            if (parameters.RootSessionId == Guid.Empty)
            {
                this.Parameters.RootSessionId = parameters.SessionId;
            }

            this.Status = "Initialized";
        }