Example #1
0
        IBaseNode IDecisionTree.LoadVariables(IPersistence persistence)
        {
            if (persistence.NextRecord())
            {
                string    type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);
                IBaseNode node = IDecisionTreeInterface.CreateNewNode(type);

                node.Reference = persistence.GetFieldValue(Constants.BaseNode_Reference, new Guid().ToString());
                int count = persistence.GetFieldValue(Constants.BaseNode_NodeCount, 0);
                node.NodeType = (eNodeType)Enum.Parse(typeof(eNodeType), persistence.GetFieldValue(Constants.BaseNode_Type, eNodeType.unknown.ToString()), true);
                node.Name     = persistence.GetFieldValue(Constants.BaseNode_Name, "");

                node.Parent = this;
                node.Tree   = this;

                if (persistence.NextRecord())
                {
                    type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);
                    IBaseNode variables = IDecisionTreeInterface.CreateNewNode(type);

                    variables.Parent = node;
                    variables.Tree   = this;
                    variables.Retrieve(persistence);

                    return(variables);
                }
            }

            return(null);
        }
Example #2
0
        protected virtual bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            switch (phase)
            {
            case ePersistence.Initial:
                Reference = persistence.GetFieldValue(Constants.BaseNode_Reference, new Guid().ToString());
                count     = persistence.GetFieldValue(Constants.BaseNode_NodeCount, 0);
                if (NodeType == eNodeType.unknown)
                {
                    NodeType = (eNodeType)Enum.Parse(typeof(eNodeType), persistence.GetFieldValue(Constants.BaseNode_Type, eNodeType.unknown.ToString()), true);
                }
                _Name        = persistence.GetFieldValue(Constants.BaseNode_Name, "");
                _Description = persistence.GetFieldValue(Constants.BaseNode_Description, "");
                break;

            case ePersistence.Final:
                if (!IsReadOnly())
                {
                    for (int i = 0; i < count; i++)
                    {
                        if (persistence.NextRecord())
                        {
                            string type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);

                            IBaseNode node = Tree.CreateNewNode(type);
                            node.NodeLoaded += NodeLoaded;
                            node.Parent      = this;

                            Nodes.Add(node);

                            node.Retrieve(persistence);
                        }
                    }

                    OnNodeLoaded();
                }
                break;
            }

            return(true);
        }