示例#1
0
    Task BuildTask_GetTreasue()
    {
        List <Task> taskList = new List <Task>();

        Task isDoorNotLocked = new IsFalse(theDoor.isLocked);
        Task waitABeat       = new Wait(0.5f);
        Task openDoor        = new OpenDoor(theDoor);

        taskList.Add(isDoorNotLocked);
        taskList.Add(waitABeat);
        taskList.Add(openDoor);
        Sequence openUnlockedDoor = new Sequence(taskList);

        taskList = new List <Task>();
        Task isDoorClosed = new IsTrue(theDoor.isClosed);
        Task hulkOut      = new HulkOut(this.gameObject);
        Task bargeDoor    = new BargeDoor(theDoor.transform.GetChild(0).GetComponent <Rigidbody>());

        taskList.Add(isDoorClosed);
        taskList.Add(waitABeat);
        taskList.Add(hulkOut);
        taskList.Add(waitABeat);
        taskList.Add(bargeDoor);
        Sequence bargeClosedDoor = new Sequence(taskList);

        // open a closed door, one way or another
        taskList = new List <Task>();
        taskList.Add(openUnlockedDoor);
        taskList.Add(bargeClosedDoor);
        Selector openTheDoor = new Selector(taskList);

        // get the treasure when the door is closed
        taskList = new List <Task>();
        Task moveToDoor     = new MoveKinematicToObject(this.GetComponent <Kinematic>(), theDoor.gameObject);
        Task moveToTreasure = new MoveKinematicToObject(this.GetComponent <Kinematic>(), theTreasure.gameObject);

        taskList.Add(moveToDoor);
        taskList.Add(waitABeat);
        taskList.Add(openTheDoor); // one way or another
        taskList.Add(waitABeat);
        taskList.Add(moveToTreasure);
        Sequence getTreasureBehindClosedDoor = new Sequence(taskList);

        // get the treasure when the door is open
        taskList = new List <Task>();
        Task isDoorOpen = new IsFalse(theDoor.isClosed);

        taskList.Add(isDoorOpen);
        taskList.Add(moveToTreasure);
        Sequence getTreasureBehindOpenDoor = new Sequence(taskList);

        // get the treasure, one way or another
        taskList = new List <Task>();
        taskList.Add(getTreasureBehindOpenDoor);
        taskList.Add(getTreasureBehindClosedDoor);
        Selector getTreasure = new Selector(taskList);

        return(getTreasure);
    }
示例#2
0
        public bool IsFalse_IsValid(bool propertyValue)
        {
            //Create Validator
            var validator = new IsFalse<Contact>();
            RuleValidatorContext<Contact, bool> context = BuildContextForContactActive(propertyValue);

            //Validate the validator only, return true of no error returned
            return validator.Validate(context, null) == null;
        }
示例#3
0
        public void IsFalseRuleIsNotValid()
        {
            IsFalse rule   = new IsFalse("IsFalse", "IsFalseRule", true);
            Result  result = rule.Execute();

            Assert.IsFalse(result.IsValid);
            Assert.IsNotNullOrEmpty(result.Message);
            Assert.IsNotNull(result.RulePolicy);
            Assert.AreEqual(result.RulePolicy.Severity, Severity.Exception);
        }
示例#4
0
        public bool IsFalse_IsValid(bool propertyValue)
        {
            //Create Validator
            var validator = new IsFalse <Contact>();
            RuleValidatorContext <Contact, bool> context = BuildContextForContactActive(propertyValue);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
示例#5
0
 /// <summary>
 ///   Creates the rule.
 /// </summary>
 /// <param name="target"> </param>
 /// <returns> </returns>
 public override RulePolicy CreateRule(object target)
 {
     Rule = new IsFalse(RuleName, FailMessage, (bool)target);
     return(Rule);
 }
示例#6
0
 public static ICondition BuildMockCondition()
 {
     return(IsFalse.New());
 }
示例#7
0
        public static ITag LoadTag(XmlNode xmlNode, IList <Include> includes)
        {
            ITag tag          = null;
            bool isIn         = xmlNode.Attributes?["In"] != null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim();
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId       = xmlNode.Attributes?["RefId"]?.Value;
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property = property,
                    //Prepend = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, includes);
                if (childTag != null && tag != null)
                {
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }
示例#8
0
    Task ConfigureBehavior()
    {
        List <Task> taskList = new List <Task>();

        Task Human         = new IsTrue(creature.isHuman);
        Task Dog           = new IsTrue(creature.isDogPresent);
        Task NotHuman      = new IsFalse(creature.isHuman);
        Task NoDog         = new IsFalse(creature.isDogPresent);
        Task saveHuman     = new saveHuman(creature);
        Task walkAround    = new walkAround(creature);
        Task ShootAir      = new shootAir(creature);
        Task ShootHuman    = new shootHuman(creature);
        Task ShootCreature = new shootCreature(creature);
        Task petDog        = new petDog(creature);
        Task takeDog       = new takeDog(creature);


        taskList.Add(Human);
        taskList.Add(NoDog);
        taskList.Add(walkAround);
        taskList.Add(ShootAir);

        Sequence SpareTheHuman = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(NotHuman);
        taskList.Add(NoDog);
        taskList.Add(saveHuman);
        taskList.Add(ShootCreature);

        Sequence SaveTheHuman = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(Dog);
        taskList.Add(Human);
        taskList.Add(ShootHuman);
        taskList.Add(petDog);
        taskList.Add(takeDog);

        Sequence SaveTheDog = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(Dog);
        taskList.Add(NotHuman);
        taskList.Add(ShootCreature);
        taskList.Add(petDog);
        taskList.Add(takeDog);

        Sequence SaveTheDogFromMonster = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(SaveTheDog);
        taskList.Add(SpareTheHuman);
        taskList.Add(SaveTheHuman);
        taskList.Add(SaveTheDogFromMonster);


        Selector selector = new Selector(taskList);

        return(selector);
    }
示例#9
0
        private ITag LoadTag(XmlNode xmlNode, Statement statement)
        {
            ITag tag          = null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var innerText = xmlNode.InnerText;
                var bodyText  = innerText;
                //bodyText += innerText.Trim().Replace("\r", " ").Replace("\n", " ");
                //bodyText += " ";
                return(new SqlText
                    {
                        Statement = statement,
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId = xmlNode.Attributes?["RefId"]?.Value;
                if (refId.IndexOf('.') < 0)
                {
                    refId = $"{statement.SmartSqlMap.Scope}.{refId}";
                }
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = xmlNode.Attributes?["Prepend"]?.Value
                };
                statement.IncludeDependencies.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = xmlNode.Attributes?["Prepend"]?.Value,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { return(null); }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            tag.Statement = statement;
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, statement);
                if (childTag != null && tag != null)
                {
                    childTag.Parent = tag;
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }
示例#10
0
        public static ITag LoadTag(XmlNode xmlNode)
        {
            ITag tag          = null;
            bool isIn         = xmlNode.Attributes?["In"] != null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value;
            var  property     = xmlNode.Attributes?["Property"]?.Value;
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value;

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = xmlNode.InnerText.Replace("\n", "");
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property = property,
                    //Prepend = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value;
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value;
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default: { break; };
            }
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode);
                (tag as Tag).ChildTags.Add(childTag);
            }
            return(tag);
        }
示例#11
0
    Task BuildTask_GetPill()
    {
        List <Task> taskList = new List <Task>();


        ///Open unlocked door
        Task isDoorNotLocked = new IsFalse(targetDoor.bIsLocked);
        Task catchBreath     = new Pause(2f);
        Task openDoor        = new OpenDoor(targetDoor);

        taskList.Add(isDoorNotLocked);
        taskList.Add(catchBreath);
        taskList.Add(openDoor);
        Sequence sqOpenUnlockedDoor = new Sequence(taskList);



        ///Barge door
        taskList = new List <Task>();
        Task isDoorClosed = new IsTrue(targetDoor.bIsClosed);
        Task stackUp      = new StackUp(this.gameObject);
        Task bargeDoor    = new BargeDoor(targetDoor.transform.GetChild(0).GetComponent <Rigidbody>());

        taskList.Add(isDoorClosed);
        taskList.Add(catchBreath);
        taskList.Add(stackUp);
        taskList.Add(catchBreath);
        taskList.Add(bargeDoor);
        Sequence sqBargeClosedDoor = new Sequence(taskList);


        ///Guarantee open closed door
        taskList = new List <Task>();

        taskList.Add(sqOpenUnlockedDoor);
        taskList.Add(sqBargeClosedDoor);
        Selector sqOpenTheDoor = new Selector(taskList);


        ///Get pill behind closed door
        taskList = new List <Task>();
        Task moveToDoor = new MoveKinematicToObject(this.gameObject.GetComponent <Kinematic>(), targetDoor.gameObject);
        Task moveToPill = new MoveKinematicToObject(this.gameObject.GetComponent <Kinematic>(), drugs.gameObject);

        taskList.Add(moveToDoor);
        taskList.Add(catchBreath);
        taskList.Add(sqOpenTheDoor);
        taskList.Add(catchBreath);
        taskList.Add(moveToPill);
        Sequence sqGetTreasureBehindClosedDoor = new Sequence(taskList);


        //Get pill if door is open
        taskList = new List <Task>();
        Task isDoorOpen = new IsFalse(targetDoor.bIsClosed);

        taskList.Add(isDoorOpen);
        taskList.Add(moveToPill);
        Sequence sqGetTreasureBehindOpenDoor = new Sequence(taskList);


        //Guarantee get pill
        taskList = new List <Task>();

        taskList.Add(sqGetTreasureBehindOpenDoor);
        taskList.Add(sqGetTreasureBehindClosedDoor);
        Selector sqGetTreasure = new Selector(taskList);



        return(sqGetTreasure);
    }
示例#12
0
        private ITag LoadTag(XNode xmlNode, IList <Include> includes)
        {
            ITag tag          = null;
            var  prepend      = xmlNode?.GetAttribute("Prepend")?.Trim();
            var  property     = xmlNode?.GetAttribute("Property")?.Trim();
            var  compareValue = xmlNode?.GetAttribute("CompareValue")?.Trim();

            #region Init Tag
            switch (xmlNode.GetName())
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.GetValue().Replace("\n", "").Trim();
                return(new SqlText
                    {
                        LineInfo = XmlLineInfo.Create(xmlNode),
                        BodyText = bodyText
                    });
            }

            case "If":
            {
                tag = new IfTag
                {
                    Test = xmlNode.GetAttribute("Test")
                };
                break;
            }

            case "Include":
            {
                var refId       = xmlNode?.GetAttribute("RefId");
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Bind":
            {
                tag = new BindTag
                {
                    Name  = xmlNode.GetAttribute("Name"),
                    Value = xmlNode.GetAttribute("Value"),
                };
                break;
            }

            case "Trim":
            {
                tag = new TrimTag
                {
                    Prefix          = xmlNode.GetAttribute("Prefix"),
                    PrefixOverrides = xmlNode.GetAttribute("PrefixOverrides"),
                    Suffix          = xmlNode.GetAttribute("Suffix"),
                    ChildTags       = new List <ITag>(),
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.Parent;
                var switchProperty = xmlNode?.GetAttribute("Property")?.Trim();
                var switchPrepend  = xmlNode?.GetAttribute("Prepend")?.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    Test         = xmlNode?.GetAttribute("Test")?.Trim(),
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.Parent;
                var switchProperty = xmlNode?.GetAttribute("Property")?.Trim();
                var switchPrepend  = xmlNode?.GetAttribute("Prepend")?.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode?.GetAttribute("Open")?.Trim();
                var separator = xmlNode?.GetAttribute("Separator")?.Trim();
                var close     = xmlNode?.GetAttribute("Close")?.Trim();
                var key       = xmlNode?.GetAttribute("Key")?.Trim();
                var index     = xmlNode?.GetAttribute("Index")?.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Index     = index,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode?.GetAttribute("DbProvider")?.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.GetName()}.");
            };
            }
            #endregion
            if (tag != null)
            {
                tag.LineInfo = XmlLineInfo.Create(xmlNode);
            }
            if (xmlNode is XElement ell)
            {
                foreach (XNode childNode in ell.Nodes())
                {
                    ITag childTag = LoadTag(childNode, includes);
                    if (childTag != null && tag != null)
                    {
                        childTag.Parent = tag;
                        (tag as Tag).ChildTags.Add(childTag);
                    }
                }
            }
            return(tag);
        }
示例#13
0
        public ITag Build(XmlNode xmlNode)
        {
            ITag tag          = null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim();
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId       = xmlNode.Attributes?["RefId"]?.Value;
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                //includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    Test         = xmlNode.Attributes?["Test"]?.Value.Trim(),
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Bind":
            {
                tag = new BindTag
                {
                    Name  = xmlNode.Attributes["Name"]?.Value,
                    Value = xmlNode.Attributes["Value"]?.Value,
                };
                break;
            }

            case "Trim":
            {
                tag = new TrimTag
                {
                    Prefix          = xmlNode.Attributes["Prefix"]?.Value,
                    PrefixOverrides = xmlNode.Attributes["PrefixOverrides"]?.Value,
                    Suffix          = xmlNode.Attributes["Suffix"]?.Value,
                    ChildTags       = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "If":
            {
                var test = xmlNode.Attributes["Test"]?.Value;
                tag = new IfTag
                {
                    Test = test
                };
            }
            break;

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            #endregion
            return(tag);
        }
    tasks BuildTask_GetTreasue()
    {
        // create our behavior tree based on Millington pg. 344
        // building from the bottom up

        //I like the use of a list, much more than what Millington
        List <tasks> taskList = new List <tasks>();

        // if door isn't locked, open it
        tasks isDoorNotLocked = new IsFalse(theDoor.isLocked);
        tasks waitABeat       = new Wait(0.5f);
        tasks openDoor        = new OpenDoor(theDoor);

        taskList.Add(isDoorNotLocked);
        taskList.Add(waitABeat);
        taskList.Add(openDoor);
        Sequence openUnlockedDoor = new Sequence(taskList);

        // barge a closed door
        taskList = new List <tasks>();
        tasks isDoorClosed = new IsTrue(theDoor.isClosed);
        // made a small change to get the rigid body of the door instead of the children
        tasks bargeDoor = new BargeDoor(theDoor.transform.GetComponent <Rigidbody>());

        taskList.Add(isDoorClosed);
        taskList.Add(waitABeat);
        taskList.Add(bargeDoor);
        Sequence bargeClosedDoor = new Sequence(taskList);

        // open a closed door, one way or another
        taskList = new List <tasks>();
        taskList.Add(openUnlockedDoor);
        taskList.Add(bargeClosedDoor);
        Selector openTheDoor = new Selector(taskList);

        // get the treasure when the door is closed
        taskList = new List <tasks>();
        tasks moveToDoor     = new MoveKinematicToObject(this.GetComponent <Kinematic>(), theDoor.gameObject);
        tasks moveToTreasure = new MoveKinematicToObject(this.GetComponent <Kinematic>(), theTreasure.gameObject);

        taskList.Add(moveToDoor);
        taskList.Add(waitABeat);
        taskList.Add(openTheDoor); // one way or another
        taskList.Add(waitABeat);
        taskList.Add(moveToTreasure);
        Sequence getTreasureBehindClosedDoor = new Sequence(taskList);

        // get the treasure when the door is open
        taskList = new List <tasks>();
        tasks isDoorOpen = new IsFalse(theDoor.isClosed);

        taskList.Add(isDoorOpen);
        taskList.Add(moveToTreasure);
        Sequence getTreasureBehindOpenDoor = new Sequence(taskList);

        // get the treasure, one way or another
        taskList = new List <tasks>();
        taskList.Add(getTreasureBehindOpenDoor);
        taskList.Add(getTreasureBehindClosedDoor);
        Selector getTreasure = new Selector(taskList);

        return(getTreasure);
    }
示例#15
0
        public static ITag LoadTag(XmlNode xmlNode, IList <Include> includes)
        {
            ITag tag          = null;
            bool isIn         = !string.IsNullOrEmpty(xmlNode.GetValueInXmlAttributes("In"));
            var  prepend      = xmlNode.GetValueInXmlAttributes("Prepend");
            var  property     = xmlNode.GetValueInXmlAttributes("Property");
            var  compareValue = xmlNode.GetValueInXmlAttributes("CompareValue");

            #region Init Tag
            string lowerXmlNodeName = xmlNode.Name.ToLower();
            switch (lowerXmlNodeName)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.GetInnerTextInXmlAttributes();
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            //case "OrderBy":
            case "orderby":
            {
                var bodyText = " " + xmlNode.GetInnerTextInXmlAttributes();
                tag = new OrderBy
                {
                    ChildTags = new List <ITag>(),

                    BodyText = bodyText
                };
                break;
            }

            //case "Include":
            case "include":
            {
                var refId       = xmlNode.GetValueInXmlAttributes("RefId");
                var include_tag = new Include
                {
                    RefId = refId
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            //case "If":
            case "if":
            {
                var Test = xmlNode.GetValueInXmlAttributes("Test");
                tag = new IfTag
                {
                    Test      = Test,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsEmpty":
            case "isempty":
            {
                tag = new IsEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsEqual":
            case "isequal":
            {
                tag = new IsEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsGreaterEqual":
            case "isgreaterequal":
            {
                tag = new IsGreaterEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsGreaterThan":
            case "isgreaterthan":
            {
                tag = new IsGreaterThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsLessEqual":
            case "islessequal":
            {
                tag = new IsLessEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsLessThan":
            case "islessthan":
            {
                tag = new IsLessThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsNotEmpty":
            case "isnotempty":
            {
                tag = new IsNotEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsNotEqual":
            case "isnotequal":
            {
                tag = new IsNotEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "IsNotNull":
            case "isnotnull":
            {
                tag = new IsNotNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsNull":
            case "isnull":
            {
                tag = new IsNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsTrue":
            case "istrue":
            {
                tag = new IsTrue
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsFalse":
            case "isfalse":
            {
                tag = new IsFalse
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "IsProperty":
            case "isproperty":
            {
                tag = new IsProperty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Switch":
            case "switch":
            {
                tag = new Switch
                {
                    Property = property,
                    //Prepend = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Case":
            case "case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.GetValueInXmlAttributes("Property");
                var switchPrepend  = switchNode.GetValueInXmlAttributes("Prepend");
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            //case "Default":
            case "default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.GetValueInXmlAttributes("Property");
                var switchPrepend  = switchNode.GetValueInXmlAttributes("Prepend");
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Choose":
            case "choose":
            {
                tag = new ChooseTag
                {
                    //Property = property,
                    //Prepend = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "when":
            {
                var Test = xmlNode.GetValueInXmlAttributes("Test");
                //var switchNode = xmlNode.ParentNode;
                //var switchProperty = switchNode.GetValueInXmlAttributes("Property");
                //var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend");
                tag = new ChooseTag.ChooseWhenTag
                {
                    Test = Test,
                    //Property = switchProperty,
                    //Prepend = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "otherwise":
            {
                //var switchNode = xmlNode.ParentNode;
                //var switchProperty = switchNode.GetValueInXmlAttributes("Property");
                //var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend");
                tag = new ChooseTag.ChooseOtherwiseTag
                {
                    //Property = switchProperty,
                    //Prepend = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "trim":
            {
                var Prefix          = xmlNode.GetValueInXmlAttributes("Prefix", "", false);
                var Suffix          = xmlNode.GetValueInXmlAttributes("Suffix", "", false);
                var PrefixOverrides = xmlNode.GetValueInXmlAttributes("PrefixOverrides");
                var SuffixOverrides = xmlNode.GetValueInXmlAttributes("SuffixOverrides");
                tag = new TrimTag
                {
                    Prefix          = Prefix,
                    Suffix          = Suffix,
                    PrefixOverrides = PrefixOverrides,
                    SuffixOverrides = SuffixOverrides,
                    ChildTags       = new List <ITag>()
                };
                break;
            }

            case "set":
            {
                tag = new SetTag()
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "where":
            {
                tag = new WhereTag
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Where":
            //case "where":
            //    {
            //        tag = new Where
            //        {
            //            ChildTags = new List<ITag>()
            //        };
            //        break;
            //    }
            //case "Dynamic":
            case "dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Variable":
            case "variable":
            {
                var bodyText = xmlNode.GetInnerTextInXmlAttributes();
                tag = new Variable
                {
                    BodyText  = bodyText,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Bind":
            case "bind":
            {
                var Name  = xmlNode.GetValueInXmlAttributes("Name");
                var Value = xmlNode.GetValueInXmlAttributes("Value");
                //var bodyText = xmlNode.GetInnerTextInXmlAttributes();
                tag = new BindTag
                {
                    Name      = Name,
                    Value     = Value,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Foreach":
            case "foreach":
            {
                var open      = xmlNode.GetValueInXmlAttributes("Open");
                var separator = xmlNode.GetValueInXmlAttributes("Separator");
                var close     = xmlNode.GetValueInXmlAttributes("Close");
                var item      = xmlNode.GetValueInXmlAttributes("Item");
                var index     = xmlNode.GetValueInXmlAttributes("Index");
                tag = new Foreach
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Item      = item,
                    Index     = index,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            //case "Env":
            case "env":
            {
                var dbProvider = xmlNode.GetValueInXmlAttributes("DbProvider");
                var DbType     = xmlNode.GetValueInXmlAttributes("DbType");
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    DbType     = DbType,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new Exception(string.Format("Statement.LoadTag unkonw tagName:{0}.", xmlNode.Name));
            };
            }
            #endregion
            //加载组合查询条件查询
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, includes);
                if (childTag != null && tag != null)
                {
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }