Inheritance: MonoBehaviour
Exemplo n.º 1
0
    bool DrawWithinTimeRangeInterior(ConditionNode currentCondition, bool typeChangedToThis)
    {
        bool result     = false;
        int  labelWidth = 90;

        WorldDate startDate;
        WorldDate finishDate;
        bool      hoursOnly;

        EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle);
        {
            result |= DrawGenericWorldDateField(currentCondition.WithinTimeRange.Start, labelWidth, "Start", out startDate, currentCondition.WithinTimeRange.HoursOnly);
            result |= DrawGenericWorldDateField(currentCondition.WithinTimeRange.Finish, labelWidth, "Finish", out finishDate, currentCondition.WithinTimeRange.HoursOnly);
            result |= DrawGenericBoolField(currentCondition.WithinTimeRange.HoursOnly, labelWidth, "Hours Only?", out hoursOnly);
        }
        EditorGUILayout.EndVertical();

        if (typeChangedToThis || result)
        {
            currentCondition.SetWithinTimeRangeCondition(startDate, finishDate, hoursOnly);
            Debug.Log("Zmiana na Within Time Range");
        }

        return(result);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Renders a dialog step
        /// </summary>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <returns>Dialog Step Render Result</returns>
        public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject)
        {
            ConditionNode conditionNode = data.Condition;

            if (conditionNode == null)
            {
                return(null);
            }

            ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleCondition);

            if (!_renderers.ContainsKey(template.RenderingEngine))
            {
                throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ConditionNode", template.RenderingEngine.ToString()));
            }

            string oldContext = _errorCollection.CurrentErrorContext;

            _errorCollection.CurrentErrorContext = _localizer["ErrorContextCondition"];
            try
            {
                return(await _renderers[template.RenderingEngine].RenderDialogStep(template, data, flexFieldObject, conditionNode));
            }
            catch (Exception ex)
            {
                _errorCollection.AddException(ex);
                return(new ExportDialogStepRenderResult {
                    StepCode = "<<ERROR_RENDERING_CONDITION>>"
                });
            }
            finally
            {
                _errorCollection.CurrentErrorContext = oldContext;
            }
        }
Exemplo n.º 3
0
    bool DrawStoryStateHappenedInterior(ConditionNode currentCondition, bool typeChangedToThis)
    {
        bool result     = false;
        int  labelWidth = 90;

        string stateMachineName;
        string stateName;
        bool   stateHappened;

        EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle);
        {
            //Item setting
            result |= DrawGenericStringField(currentCondition.StoryStateHappened.PlotName, labelWidth, "Plot Name", out stateMachineName);
            result |= DrawGenericStringField(currentCondition.StoryStateHappened.StateName, labelWidth, "State Name", out stateName);
            result |= DrawGenericBoolField(currentCondition.StoryStateHappened.HasHappened, labelWidth, "Happened?", out stateHappened);
        }
        EditorGUILayout.EndVertical();

        if (typeChangedToThis || result)
        {
            currentCondition.SetStoryStateHappenedCondition(stateMachineName, stateName, stateHappened);
            Debug.Log("Zmiana story state happened");
        }

        return(typeChangedToThis || result);
    }
Exemplo n.º 4
0
    //TO FINISH
    bool DrawPlayerHasItemInterior(ConditionNode currentCondition, bool typeChangedToThis)
    {
        bool result     = false;
        int  labelWidth = 90;

        ItemScript item;
        int        quantity;
        bool       weWantItem;

        EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle);
        {
            result |= DrawGenericAssetField <ItemScript>(currentCondition.PlayerHasItem.Item, labelWidth, "Item", out item);
            result |= DrawGenericIntField(currentCondition.PlayerHasItem.Quantity, labelWidth, "Quantity", out quantity, 0);
            result |= DrawGenericBoolField(currentCondition.PlayerHasItem.IsRequired, labelWidth, "Wanted?", out weWantItem);
        }
        EditorGUILayout.EndVertical();

        if (typeChangedToThis || result)
        {
            currentCondition.SetPlayerHasItemCondition(item, quantity, weWantItem);
            Debug.Log("Zmiana playerHasItem");
        }

        return(typeChangedToThis || result);
    }
Exemplo n.º 5
0
    bool DrawAttributeTestInterior(ConditionNode currentCondition, bool typeChangedToThis)
    {
        bool result     = false;
        int  labelWidth = 90;

        CharacterAttribute stat;
        int             modificator;
        CharacterSkills skill;

        EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle);
        {
            result |= DrawCharacterAttributeField(currentCondition.AttributeTest.Attribute, labelWidth, out stat);
            result |= DrawTestModificatorField(currentCondition.AttributeTest.AttributeMod, labelWidth, out modificator);
            result |= DrawPlayerSkillField(currentCondition.AttributeTest.Skill, labelWidth, out skill);
        }
        EditorGUILayout.EndVertical();


        if (typeChangedToThis || result)
        {
            currentCondition.SetAttributeTestCondition(stat, modificator, skill);
            Debug.Log("Zmiana attribute test");
        }

        return(typeChangedToThis || result);
    }
Exemplo n.º 6
0
            public void Execute(object parameter)
            {
                ConditionNode newNode = new ConditionNode();

                newNode.Loaded = Node.Loaded;
                Node.ChildNodes.Add(newNode);
            }
        public IConditionalExpressionNodeWrapper AddConditionalExpressionNode()
        {
            var node = new ConditionNode();

            CurrentNode.Nodes.Add(node);
            return(new SparkConditionNodeWrapper(node));
        }
Exemplo n.º 8
0
    public Node Create(NodeType type)
    {
        Node node = null;

        switch (type)
        {
        case NodeType.Root:
            node = new RootNode();
            break;

        case NodeType.Action:
            node = new ActionNode();
            break;

        case NodeType.Sequencer:
            node = new SequencerNode();
            break;

        case NodeType.Selector:
            node = new SelectorNode();
            break;

        case NodeType.Random:
            node = new RandomNode();
            break;

        case NodeType.RandomSelector:
            node = new RandomSelectorNode();
            break;

        case NodeType.RandomSequencer:
            node = new RandomSequencerNode();
            break;

        case NodeType.Decorator:
            node = new DecoratorNode();
            break;

        case NodeType.Condition:
            node = new ConditionNode();
            break;

        case NodeType.ConditionWhile:
            node = new ConditionWhileNode();
            break;

        default:
            Debug.Assert(false, "未定義のノードタイプ");
            break;
        }

        if (node != null)
        {
            node.Init(idSeed);
            Register(idSeed, node);
            idSeed += 1;
        }

        return(node);
    }
Exemplo n.º 9
0
        protected override void VisitCondition(ConditionNode conditionNode)
        {
            AddNode(conditionNode);

            AddLink(conditionNode, conditionNode.WhenFalse, Categories.NormalFlowEdge, "False");
            AddLink(conditionNode, conditionNode.WhenTrue, Categories.NormalFlowEdge, "True");
        }
Exemplo n.º 10
0
    public virtual void SetPrevious(ConditionNode previous, Vector2 clickPos, int idChoice)
    {
        SetPrevious(previous, clickPos);

        previous.nextNodeIdList[idChoice] = id;
        previous.nextNodeList[idChoice]   = this;
    }
Exemplo n.º 11
0
        public IConditionalExpressionNodeWrapper AddConditionalExpressionNode()
        {
            ConditionNode expressionNode = new ConditionNode();

            _body.Add(expressionNode);
            return(new SparkConditionNodeWrapper(expressionNode));
        }
    void DrawExitField(ConditionNode condition, bool isSuccess)
    {
        EditorGUILayout.BeginHorizontal();
        {
            if (isSuccess)
            {
                /*
                 * condition.NextDialogueIDIfPassed =
                 * EditorGUILayout.TextField(
                 *    (condition.NextDialogueIDIfPassed == null) ?
                 *        "" : condition.NextDialogueIDIfPassed
                 *    );*/

                condition.NextDialogueIfPassed =
                    (Dialogue)EditorGUILayout.ObjectField("", condition.NextDialogueIfPassed, typeof(Dialogue), false, GUILayout.Width(100));
            }
            else
            {/*
              * condition.NextDialogueIDIfFailed =
              *   EditorGUILayout.TextField(
              *       (condition.NextDialogueIDIfFailed == null) ?
              *           "" : condition.NextDialogueIDIfFailed
              *       );*/
                condition.NextDialogueIfFailed =
                    (Dialogue)EditorGUILayout.ObjectField("", condition.NextDialogueIfFailed, typeof(Dialogue), false, GUILayout.Width(100));
            }
        }
        EditorGUILayout.EndHorizontal();
    }
Exemplo n.º 13
0
        private void btnRemoveCondition_Click(object sender, EventArgs e)
        {
            if (m_CurrentExpression == m_ConditionalRoot)
            {
                m_ConditionalRoot = null;
            }
            else
            {
                LogicalNode selectedLogicalNode = (LogicalNode)tlvCondition.GetParent(m_CurrentExpression);
                if (selectedLogicalNode != null)
                {
                    selectedLogicalNode.Nodes.Remove(m_CurrentExpression);
                    if (selectedLogicalNode.Nodes.Count < 2)
                    {
                        //Remove logical node
                        LogicalNode parentLogicalNode = (LogicalNode)tlvCondition.GetParent(selectedLogicalNode);

                        if (parentLogicalNode != null && selectedLogicalNode.Nodes.Count == 0)
                        {
                            parentLogicalNode.Nodes.Remove(selectedLogicalNode);
                        }
                        else if (parentLogicalNode == null && selectedLogicalNode.Nodes.Count == 1)
                        {
                            //TODO when not drinking beer: resolve lowest level in loop in case nested logical node
                            m_ConditionalRoot = selectedLogicalNode.Nodes.First();
                            selectedLogicalNode.Nodes.Clear();
                        }
                    }
                }
            }
            m_CurrentExpression = null;
            zRefreshCondition();
        }
Exemplo n.º 14
0
        public override DynValue Visit(ConditionNode conditionNode)
        {
            foreach (var branch in conditionNode.IfElifBranches)
            {
                var exprResult = Visit(branch.Key);

                if (exprResult.IsTruth)
                {
                    Environment.EnterScope();
                    {
                        ExecuteStatementList(branch.Value);
                    }
                    Environment.ExitScope();

                    return(DynValue.Zero);
                }
            }

            if (conditionNode.ElseBranch != null)
            {
                Environment.EnterScope();
                {
                    ExecuteStatementList(conditionNode.ElseBranch);
                }
                Environment.ExitScope();
            }

            return(DynValue.Zero);
        }
Exemplo n.º 15
0
            public override string GetExpressionString()
            {
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < _childNodes.Count; i++)
                {
                    if (i > 0)
                    {
                        sb.AppendFormat(" {0} ", OperatorName);
                    }
                    ConditionNode child = (ConditionNode)_childNodes[i];

                    string formatString;
                    if (child is LogicalNode)
                    {
                        formatString = "({0})";
                    }
                    else
                    {
                        formatString = "{0}";
                    }

                    sb.AppendFormat(formatString, child.GetExpressionString());
                }
                return(sb.ToString());
            }
Exemplo n.º 16
0
        private void Transform(ElementNode node, IList <Node> body)
        {
            AttributeNode forAttribute = node.GetAttribute("for");
            AttributeNode forType      = node.GetAttribute("fortype");
            AttributeNode forProperty  = node.GetAttribute("forproperty");

            if (forAttribute != null)
            {
                // put in as content property
                node.Attributes.Remove(forAttribute);
                node.RemoveAttributesByName("name");
                node.RemoveAttributesByName("value");
                var nameNode = new ExpressionNode(forAttribute.Value.GetPropertyNameSnippet());

                var valueNode = new ConditionNode("resource!=null")
                {
                    Nodes = new List <Node>()
                    {
                        new ExpressionNode(forAttribute.Value)
                    }
                };
                SetNodeNameAndValue(node, valueNode, nameNode, body, forAttribute);
            }
            else if (forType != null)
            {
                if (forProperty == null)
                {
                    throw new Exception("Must have both a forProperty attribute if using the forType attribute.");
                }
                node.Attributes.Remove(forType);
                node.Attributes.Remove(forProperty);
                node.RemoveAttributesByName("name");
                SetNodeNameAndValue(node, null, new TextNode(string.Concat(forType.Value, ".", forProperty.Value)), body, forAttribute);
            }
        }
    static ConditionNode ComputeNot(ConditionNode root, ref int i)
    {
        int j = i;

        while (j < root.Children.Count)
        {
            if (root.Children[j].Operator == ConditionOperator.NOT)
            {
                j++;
            }
            else
            {
                break;
            }
        }
        var right = root.Children[j];
        int p     = j;

        Compute(right);
        right = new ConditionNode()
        {
            Symbol   = right.Symbol,
            Operator = right.Operator,
            Value    = right.Value
        };
        while (j > i)
        {
            right.Not();
            j--;
        }
        ;
        i = p;
        return(right);
    }
Exemplo n.º 18
0
        private FunctionNode CreateFunctionNode(ASTNode himeDeclNode)
        {
            ASTNode          himeFuncNode = GetHimeFuncNode(himeDeclNode);
            FunctionTypeNode type         = _expressionHelper.CreateFunctionTypeNode(himeFuncNode.Children[_conf.FUNCTIONTYPE_POS]);

            List <string> parameterIdentifiers = GetParameterIdentifiers(himeFuncNode);
            string        typeID     = GetTypeID(himeFuncNode);
            string        functionID = GetFunctionID(himeFuncNode);

            if (typeID != functionID)
            {
                throw new FunctionIdentifierMatchException(functionID, typeID);
            }

            TextPosition position = himeFuncNode.Children[0].Position;

            if (IsConditional(himeDeclNode))
            {
                List <ConditionNode> conditions = new List <ConditionNode>();
                VisitConditions(GetFunctionContent(himeDeclNode),
                                conditions,
                                false);
                return(new FunctionNode(conditions, typeID, parameterIdentifiers, type,
                                        position.Line, position.Column));
            }
            else
            {
                ConditionNode condition = GetInsertedConditionNode(himeDeclNode);
                return(new FunctionNode(typeID, condition, parameterIdentifiers, type,
                                        position.Line, position.Column));
            }
        }
 private void CheckCondition(ConditionNode node, List <string> identifiers)
 {
     if (node.Condition != null)
     {
         _dispatch(node.Condition, identifiers);
     }
 }
Exemplo n.º 20
0
    bool DrawStatisticCheckInterior(ConditionNode currentCondition, bool typeChangedToThis)
    {
        bool result     = false;
        int  labelWidth = 90;

        CharacterStatistic stat;
        float           value;
        InequalityTypes inequality;

        EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle);
        {
            result |= DrawCharacterStatisticField(currentCondition.StatisticCheck.Statistic, labelWidth, out stat);
            result |= DrawInequalityField(currentCondition.StatisticCheck.InequalityType, labelWidth, out inequality);
            result |= DrawGenericFloatField(currentCondition.StatisticCheck.ValueChecked, labelWidth, "Statistic Value", out value);
            //DrawValueCheckedField(currentCondition.AttributeCheck.ValueChecked, labelWidth, out value);
        }
        EditorGUILayout.EndVertical();

        if (typeChangedToThis || result)
        {
            currentCondition.SetStatisticCheckCondition(stat, inequality, value);
            Debug.Log("Zmiana attribute check");
        }

        return(typeChangedToThis || result);
    }
Exemplo n.º 21
0
        protected override void Visit(ConditionNode conditionNode)
        {
            var conditionChunk = new ConditionalChunk
            {
                Condition = conditionNode.Code,
                Type      = ConditionalType.If,
                Position  = Locate(conditionNode)
            };

            Chunks.Add(conditionChunk);

            if (_sendAttributeOnce != null)
            {
                conditionChunk.Body.Add(_sendAttributeOnce);
            }
            if (_sendAttributeIncrement != null)
            {
                conditionChunk.Body.Add(_sendAttributeIncrement);
            }

            using (new Frame(this, conditionChunk.Body))
            {
                Accept(conditionNode.Nodes);
            }
        }
        /// <summary>
        /// Renders a dialog step
        /// </summary>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <returns>Dialog Step Render Result</returns>
        public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc)
        {
            ConditionNode conditionNode = data.Condition;

            if (conditionNode == null)
            {
                return(null);
            }

            ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleCondition);

            ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult();

            renderResult.StepCode = ReplaceNodeId(template.Code, data);
            renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ConditionsStart, Placeholder_ConditionsEnd).Replace(renderResult.StepCode, m => {
                return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildConditions(m.Groups[1].Value, data, conditionNode, npc, false), m.Groups[2].Value)));
            });
            renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_AllConditionsStart, Placeholder_AllConditionsEnd).Replace(renderResult.StepCode, m => {
                return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildConditions(m.Groups[1].Value, data, conditionNode, npc, true), m.Groups[2].Value)));
            });
            renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ElseStart, Placeholder_ElseEnd).Replace(renderResult.StepCode, m => {
                return(ExportUtil.IndentListTemplate(BuildElsePart(m.Groups[1].Value, data), m.Groups[2].Value));
            });

            return(renderResult);
        }
        /// <summary>
        /// Builds a parent text preview for the a dialog step
        /// </summary>
        /// <param name="child">Child node</param>
        /// <param name="parent">Parent</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <returns>Parent text preview for the dialog step</returns>
        public async Task <string> BuildParentTextPreview(ExportDialogData child, ExportDialogData parent, KortistoNpc npc, ExportPlaceholderErrorCollection errorCollection)
        {
            ConditionNode conditionNode = parent.Condition;

            if (conditionNode == null)
            {
                return(null);
            }

            List <string> previewForConditions = new List <string>();

            foreach (Condition curCondition in conditionNode.Conditions)
            {
                ExportDialogDataChild childObj = parent.Children.FirstOrDefault(c => c.NodeChildId == curCondition.Id);
                if (childObj == null || childObj.Child != child)
                {
                    continue;
                }

                string conditionText = await _conditionRenderer.RenderCondition(_project, curCondition, _errorCollection, npc, _exportSettings);

                previewForConditions.Add(ExportUtil.BuildTextPreview(conditionText));
            }

            if (parent.Children.Any(c => c.Child == child && c.NodeChildId == ExportConstants.ConditionElseNodeChildId))
            {
                previewForConditions.Add("else");
            }

            return(string.Join(", ", previewForConditions));
        }
Exemplo n.º 24
0
        public void RemoveLinkedParameterFromVariableNode()
        {
            int paramIndex = this.Connection.OrderOfArgumentID;

            if (this.Connection.ParentNode.NodeType == NodeType.ConditionNode)
            {
                ConditionNode n = this.Connection.ParentNode as ConditionNode;
                n.ConnectedToVariableName            = "";
                n.ConnectedToVariableCallerClassName = "";
            }

            if (this.Connection.ParentNode.NodeType == NodeType.MethodNode)
            {
                DynamicNode n = this.Connection.ParentNode as DynamicNode;
                n.ArgumentCache[paramIndex].ArgIsExistingVariable   = false;
                n.ArgumentCache[paramIndex].ArgExistingVariableName = "";

                if (!this.IsNoLinkedInputField)
                {
                    n.EnableInputOnParameter(paramIndex);
                }
            }

            //MainViewModel.Instance.LogStatus("Removing linked parameter connection on " + n.NodeName + ", parameter " + paramIndex);
        }
Exemplo n.º 25
0
        public void SetStep(StepEditContext stepEditContext)
        {
            this.m_StepEditContext = stepEditContext;
            cbVariable.DataSource  = m_StepEditContext.StateVariables.Primitives();

            //Step
            tpStep.Text       = m_StepEditContext.Step.DisplayName;
            m_StepEditor      = StepEditorFactory.GetStepEditor(m_StepEditContext);
            m_StepEditor.Dock = DockStyle.Fill;
            tpStep.Controls.Add(m_StepEditor);

            //Condition
            if (m_StepEditContext.Step.Condition != null)
            {
                m_ConditionalRoot = m_StepEditContext.Step.Condition;
                //m_CurrentExpression =

                zUpdateExpressionBuilder();
                btnRemoveCondition.Enabled     = true;
                panelExpressionBuilder.Enabled = true;
            }

            //Behavior
            cbStepFailureScope.SelectedItem = m_StepEditContext.Step.FailureScope;

            zRefreshCondition();
        }
 public static Node GetPropertyValueNode(this string propertyAccessor)
 {
     string objectName = propertyAccessor.GetObjectName();
     var conditionNode = new ConditionNode(string.Format("{0}!=null", objectName));
     conditionNode.Nodes.Add(new ExpressionNode(propertyAccessor));
     
     return conditionNode;
 }
        public static Node GetPropertyValueNode(this string propertyAccessor)
        {
            string objectName    = propertyAccessor.GetObjectName();
            var    conditionNode = new ConditionNode(string.Format("{0}!=null", objectName));

            conditionNode.Nodes.Add(new ExpressionNode(propertyAccessor));
            return(conditionNode);
        }
Exemplo n.º 28
0
 public override void PopulateBranches(List <Node> list)
 {
     list.Add(this);
     VariableIdentifierNode.PopulateBranches(list);
     InitialValueNode?.PopulateBranches(list);
     ConditionNode?.PopulateBranches(list);
     WithExpressionNode?.PopulateBranches(list);
 }
        public void CheckConditionNode(TypeNode expectedType, ConditionNode condition, List <TypeNode> parameterTypes)
        {
            CheckElements(condition.Elements, parameterTypes);
            var newParams = GetNewParameters(parameterTypes, condition);

            CheckCondition(condition, newParams);
            CheckReturnExpr(condition, newParams, expectedType);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a new default ConditionNode at the given location.
        /// </summary>
        /// <param name="position"></param>
        /// <returns>A condition node with default values.</returns>
        private ConditionNode CreateConditionNode(Vector2 position)
        {
            ConditionNode node = new ConditionNode {
                title = "Condition"
            };

            node.SetPosition(new Rect(position, BaseNode.DefaultNodeSize));
            return(node);
        }
Exemplo n.º 31
0
    public static ConditionNode GeneratePlan(Condition condition, IWorldState worldState, int depth, int width)
    {
        LinkedList <Condition> stack = new LinkedList <Condition>();

        stack.AddFirst(condition);
        ConditionNode topNode = FillTree(stack, worldState, depth, width);

        return(topNode);
    }
        public static Node GetCreateUriSnippet(this string entity, bool isType)
        {
            if (isType)
            {
                entity = "typeof(" + entity + ")";
                return new ExpressionNode(entity + ".CreateUri()");
            }

            var nullCheck = new ConditionNode(entity.GetIsNotNullExpression());
            nullCheck.Nodes.Add(new ExpressionNode(entity + ".CreateUri()"));

            return nullCheck;
        }
        public static Node GetSelectedSnippet(this string propertyAccessor, string currentSelectedState, string optionValue)
        {
            string propertyNullTest = propertyAccessor.GetObjectName().GetIsNotNullExpression();
            string currentSelectedValueTest = string.Format(@"(""{0}""!="""")", currentSelectedState);
            string propertyValueTest = string.Format("({0}==\"{1}\")", propertyAccessor, optionValue);
            
            // argh
            // if ((propertyNullTest)&&(propertyValueTest))||(currentSelectedValueTest))
            string conidtion = string.Format("({0}&&{1})||{2}", propertyNullTest, propertyValueTest, currentSelectedValueTest);
            var node = new ConditionNode(conidtion);
            node.Nodes.Add(new TextNode("true"));

            return node;
        }
Exemplo n.º 34
0
        public void Only_those_that_are_matched_should_be_called()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode<Customer>();
            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode<Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode<Customer>();
            alphaNodeB.AddSuccessor(joinJunction);

            var actionNode = new ActionNode<Customer>(x => _secondaryCalled.Complete(x.Element.Object));

            var joinJunction2 = new JoinNode<Customer>(alphaNodeA);
            joinJunction2.AddSuccessor(actionNode);

            var alphaNodeC = new AlphaNode<Customer>();
            alphaNodeC.AddSuccessor(joinJunction2);

            var tree = new TypeNode<Customer>();

            var isPreferred = new ConditionNode<Customer>(x => x.Preferred);
            isPreferred.AddSuccessor(alphaNodeA);

            tree.AddSuccessor(isPreferred);

            tree.AddSuccessor(alphaNodeB);

            var isActive = new ConditionNode<Customer>(x => x.Active);
            isActive.AddSuccessor(alphaNodeC);
            tree.AddSuccessor(isActive);

            var visitor = new StringNodeVisitor();
            tree.Visit(visitor);

            Trace.WriteLine(visitor.Result);

            tree.Activate(_context);
            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
            _secondaryCalled.IsCompleted.ShouldBeFalse();
        }
Exemplo n.º 35
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="node"></param>
 public IfNode(ConditionNode condition, IBehaviourNode node,string name)
     : base(name)
 {
     this.AddNode(condition);
     this.AddNode(node);
 }
Exemplo n.º 36
0
 /// <summary>
 /// Constructs a new, empty, query.
 /// </summary>
 public Filter()
 {
     _topNode = null;
 }
Exemplo n.º 37
0
 /// <summary>
 /// clone
 /// </summary>
 /// <returns></returns>
 public IBehaviourNode Clone()
 {
     var behaviourNode = new ConditionNode(this._condition);
     base.CopyTo(behaviourNode);
     behaviourNode._fn = this._fn;
     behaviourNode._condition = this._condition;
     return behaviourNode;
 }
Exemplo n.º 38
0
 Filter Or(ConditionNode newCondition)
 {
     if (_topNode == null)
     {
         _topNode = newCondition;
     }
     else
     {
         MergeConditionIntoTree(LogicalOperator.OR, newCondition);
     }
     return this;
 }
Exemplo n.º 39
0
        Filter And(ConditionNode newCondition)
        {
            if (newCondition == null)
                throw new ArgumentNullException("newCondition", "condition may not be null");

            if (_topNode == null)
            {
                _topNode = newCondition;
            }
            else
            {
                MergeConditionIntoTree(LogicalOperator.AND, newCondition);
            }
            return this;
        }
Exemplo n.º 40
0
        void MergeConditionIntoTree(LogicalOperator desiredLogicalOperator, ConditionNode newCondition)
        {
            if (newCondition == null)
                throw new ArgumentNullException("newCondition", "condition may not be null");

            if (_topNode is LogicalNode && ((LogicalNode)_topNode).Operator == desiredLogicalOperator)
            {
                // top node is already of the desired type, so just add into it
                LogicalNode logicalNode = _topNode as LogicalNode;
                logicalNode.AddCondition(newCondition);
            }
            else
            {
                // push existing top node down to be beneath this node...
                LogicalNode newTopNode = new LogicalNode(desiredLogicalOperator);
                newTopNode.AddCondition(_topNode);
                newTopNode.AddCondition(newCondition);
                _topNode = newTopNode;
            }
        }
Exemplo n.º 41
0
            public void AddCondition(ConditionNode condition)
            {
                if (condition == null)
                    throw new ArgumentNullException("condition", "Cannot add a null condition.");

                _childNodes.Add(condition);
            }