Esempio n. 1
0
        /// <summary>
        /// Instantiates a TreeWalkerParameters object with the properies that are required to instantiate a TreeWalkerSession object.
        /// </summary>
        /// <param name="sessionId">The unique identifier for this session.</param>
        /// <param name="jsonSchema">The JSON schema.</param>
        /// <param name="forgeState">The Forge state.</param>
        /// <param name="callbacks">The callbacks object.</param>
        /// <param name="token">The cancellation token.</param>
        public TreeWalkerParameters(
            Guid sessionId,
            string jsonSchema,
            IForgeDictionary forgeState,
            ITreeWalkerCallbacks callbacks,
            CancellationToken token)
        {
            if (sessionId == Guid.Empty)
            {
                throw new ArgumentNullException("sessionId");
            }
            if (string.IsNullOrWhiteSpace(jsonSchema))
            {
                throw new ArgumentNullException("jsonSchema");
            }
            if (forgeState == null)
            {
                throw new ArgumentNullException("forgeState");
            }
            if (callbacks == null)
            {
                throw new ArgumentNullException("callbacks");
            }
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }

            this.SessionId  = sessionId;
            this.JsonSchema = jsonSchema;
            this.ForgeState = forgeState;
            this.Callbacks  = callbacks;
            this.Token      = token;
        }
Esempio n. 2
0
        public void TestInitialize(string jsonSchema)
        {
            // Initialize contexts, callbacks, and actions.
            this.sessionId  = Guid.NewGuid();
            this.forgeState = new ForgeDictionary(new Dictionary <string, object>(), this.sessionId);
            this.callbacks  = new TreeWalkerCallbacks();
            this.token      = new CancellationTokenSource().Token;

            this.UserContext.Name         = "MyName";
            this.UserContext.ResourceType = "Container";

            this.UserContext.GetCount = (Func <Int32>)(() =>
            {
                return(1);
            });

            this.UserContext.GetCountAsync = (Func <Task <Int32> >)(() =>
            {
                return(Task.FromResult(2));
            });

            this.parameters = new TreeWalkerParameters(
                this.sessionId,
                jsonSchema,
                this.forgeState,
                this.callbacks,
                this.token)
            {
                UserContext          = this.UserContext,
                ForgeActionsAssembly = typeof(CollectDiagnosticsAction).Assembly
            };

            this.session = new TreeWalkerSession(this.parameters);
        }
Esempio n. 3
0
        /// <summary>
        /// Instantiates a TreeWalkerParameters object with the properties that are required to instantiate a TreeWalkerSession object.
        /// </summary>
        /// <param name="sessionId">The unique identifier for this session.</param>
        /// <param name="forgeTree">The ForgeTree for this session.</param>
        /// <param name="forgeState">The Forge state.</param>
        /// <param name="callbacks">The callbacks object.</param>
        /// <param name="token">The cancellation token.</param>
        public TreeWalkerParameters(
            Guid sessionId,
            ForgeTree forgeTree,
            IForgeDictionary forgeState,
            ITreeWalkerCallbacks callbacks,
            CancellationToken token)
        {
            if (sessionId == Guid.Empty)
            {
                throw new ArgumentNullException("sessionId");
            }
            if (forgeTree == null)
            {
                throw new ArgumentNullException("forgeTree");
            }
            if (forgeState == null)
            {
                throw new ArgumentNullException("forgeState");
            }
            if (callbacks == null)
            {
                throw new ArgumentNullException("callbacks");
            }
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }

            this.SessionId  = sessionId;
            this.ForgeTree  = forgeTree;
            this.ForgeState = forgeState;
            this.Callbacks  = callbacks;
            this.Token      = token;
        }
Esempio n. 4
0
        /// <summary>
        /// Instantiates an ActionContext object.
        /// </summary>
        /// <param name="sessionId">The unique identifier for this tree walking session.</param>
        /// <param name="treeNodeKey">The TreeNode's key where the Action is taking place.</param>
        /// <param name="treeActionKey">The TreeAction's key of the Action taking place.</param>
        /// <param name="actionName">The name of the Action.</param>
        /// <param name="actionInput">The input for this Action.</param>
        /// <param name="properties">The properties of this Action.</param>
        /// <param name="userContext">The user context for this Action.</param>
        /// <param name="token">The cancellation token.</param>
        /// <param name="forgeState">The forge state dictionary.</param>
        /// <param name="treeName">The name of the ForgeTree in the JsonSchema.</param>
        /// <param name="rootSessionId">The unique identifier for the root/parent tree walking session.</param>
        public ActionContext(
            Guid sessionId,
            string treeNodeKey,
            string treeActionKey,
            string actionName,
            object actionInput,
            object properties,
            object userContext,
            CancellationToken token,
            IForgeDictionary forgeState,
            string treeName,
            Guid rootSessionId)
        {
            if (sessionId == null)
            {
                throw new ArgumentNullException("sessionId");
            }
            if (string.IsNullOrWhiteSpace(treeNodeKey))
            {
                throw new ArgumentNullException("treeNodeKey");
            }
            if (string.IsNullOrWhiteSpace(actionName))
            {
                throw new ArgumentNullException("actionName");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            if (forgeState == null)
            {
                throw new ArgumentNullException("forgeState");
            }
            if (string.IsNullOrWhiteSpace(treeName))
            {
                throw new ArgumentNullException("treeName");
            }
            if (rootSessionId == null)
            {
                throw new ArgumentNullException("rootSessionId");
            }

            this.SessionId     = sessionId;
            this.TreeNodeKey   = treeNodeKey;
            this.TreeActionKey = treeActionKey;
            this.ActionName    = actionName;
            this.ActionInput   = actionInput;
            this.Properties    = properties;
            this.UserContext   = userContext;
            this.Token         = token;
            this.forgeState    = forgeState;
            this.TreeName      = treeName;
            this.RootSessionId = rootSessionId;
        }