public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition)
 {
     this.condition = condition;
     this.embeddedStatement = embeddedStatement;
     this.conditionType = conditionType;
     this.conditionPosition = conditionPosition;
 }
Exemplo n.º 2
0
        public Filters Or(string name, ConditionType conditionType, object value)
        {
            this.filters.Add(
                new Filter { Name = name, Value = value, FilterType = FilterType.Or, ConditionType = conditionType });

            return this;
        }
        public GroupedCondition(IBooleanCondition conditionA, ConditionType conditionType, IBooleanCondition conditionB)
        {
            condition = conditionType;

            this.conditionA = conditionA;
            this.conditionB = conditionB;
        }
 public IntBooleanCondition(string field, int condition, ConditionType conditionType = ConditionType.OR, bool negate = false)
 {
     Field = field;
     Condition = condition.ToString();
     ConditionType = conditionType;
     Negate = negate;
 }
Exemplo n.º 5
0
        public ConditionModel Build(string expression, Type dataContextType, ConditionType conditionType)
        {
            if (String.IsNullOrWhiteSpace(expression))
            {
                return new ConditionModel();
            }

            _stack = new Stack<object>();
            _parameters = RuleParameterProviders.Providers.SelectMany(x => x.GetParameters(dataContextType).ToList())
                                                      .DistinctBy(x => x.Name)
                                                      .ToList();

            var exp = Expression.Parse(expression);
            Visit(exp);

            var top = _stack.Peek();
            if (top is ComparisonModel)
            {
                BuildComparisonGroup();
            }

            BuildConditionModel(conditionType);

            var model = (ConditionModel)_stack.Pop();
            model.Expression = expression;

            return model;
        }
Exemplo n.º 6
0
 public Result(ConditionType Type, string Variable, string Op, int Value)
 {
     this.Type = Type;
     this.Variable = Variable;
     this.Op = Op;
     this.Value = Value;
 }
Exemplo n.º 7
0
 public ConditionTreeLeaf(ConditionType type, string name, ConditionComparison comparison, PropertyUnion compareTo)
 {
     Type = type;
     VariableName = name;
     Comparison = comparison;
     CompareTo = compareTo;
 }
Exemplo n.º 8
0
 // <summary>
 /// 添加一个筛选条件
 /// </summary>
 public void AddCondition(Conditionner condition, ConditionType AndOr) {
     if (gszConditionner != "") {
         gszConditionner += " " + (AndOr == ConditionType.And ? "and" : "or");
         gszConditionner += " (" + condition.ToString() + ")";
     } else {
         gszConditionner = "(" + condition.ToString() + ")";
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Condition"/> class.
 /// </summary>
 /// <param name="label">The label.</param>
 public Condition(string label)
 {
     _label = label;
     _subconditions = new List<LeftHandSideCondition>();
     _conditionType = ConditionType.Positive;
     _fields = new Term[3];
     _evaluator = new Equals();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new Jump or Call instruction
 /// </summary>
 /// <param name="isCall">true if this is a call instruction</param>
 /// <param name="dest">destination address</param>
 /// <param name="condition">the condition to execute this instruction on</param>
 public JumpCall(bool isCall,
                 short dest,
                 ConditionType condition = ConditionType.Unconditional)
     : base(condition)
 {
     this.IsCall = isCall;
     this.Destination = dest;
 }
Exemplo n.º 11
0
        public CastCondition(int conditionGroup, ConditionType type, double[] values, ConditionValueName[] valuenames)
        {
            this.ConditionGroup = conditionGroup;
            this.Type = type;
            this.Values = values;
            this.ValueNames = valuenames;

        }
Exemplo n.º 12
0
 // <summary>
 /// 添加一个筛选条件
 /// </summary>
 public void AddCondition(string szCondition, ConditionType AndOr) {
     if (gszConditionner != "") {
         gszConditionner += " " + (AndOr == ConditionType.And ? "and" : "or");
         gszConditionner += " " + szCondition;
     } else {
         gszConditionner = szCondition;
     }
 }
Exemplo n.º 13
0
 public IcmpConstInstruction(ConditionType cond, VirtualRegister rd, VirtualRegister r1, int immed)
     : base("icmp")
 {
     this.cond = cond;
     this.r1 = r1;
     this.immed = immed;
     this.rd = rd;
 }
Exemplo n.º 14
0
 public IcmpInstruction(ConditionType cond, VirtualRegister rd, VirtualRegister r1, VirtualRegister r2, string type)
     : base("icmp")
 {
     this.cond = cond;
     this.r1 = r1;
     this.r2 = r2;
     this.rd = rd;
     this.type = type;
 }
Exemplo n.º 15
0
 public NetObject(string ip, string dns, string name, BaseType type, int position, ConditionType state, int threadId)
 {
     _ip = ip;
         _dns = dns;
         _name = name;
         _type = type;
         _position = position;
         _state = state;
         _threadId = threadId;
 }
		public ArgumentExcludeCondition(List<Token> toks)
		{
			Token tok = toks[0];
			if (tok.Type != TokenType.Identifier)
				throw new Exception("Unknown token for argument to exclude condition!");
			ArgToExclude = Utils.SingleDigitParse(tok.Value[3]) - 1;
			if (ArgToExclude != 0)
				throw new Exception("Cannot exclude anything but the first argument!");
			tok = toks[1];
			int nextTokIdx = 2;
			switch (tok.Type)
			{
				case TokenType.LThan:
					if (toks[2].Type == TokenType.Equal)
					{
						nextTokIdx++;
						Condition = ConditionType.LessOrEqual;
					}
					else
					{
						Condition = ConditionType.Less;
					}
					break;
				case TokenType.GThan:
					if (toks[2].Type == TokenType.Equal)
					{
						nextTokIdx++;
						Condition = ConditionType.GreaterOrEqual;
					}
					else
					{
						Condition = ConditionType.Greater;
					}
					break;
				case TokenType.Equal:
					if (toks[2].Type != TokenType.Equal)
						throw new Exception("Unknown condition for an argument exclude!");
					nextTokIdx++;
					Condition = ConditionType.Equal;
					break;
				case TokenType.Exclaim:
					if (toks[2].Type != TokenType.Equal)
						throw new Exception("Unknown condition for an argument exclude!");
					nextTokIdx++;
					Condition = ConditionType.NotEqual;
					break;

				default:
					throw new Exception("Unknown condition for an argument exclude!");
			}
			tok = toks[nextTokIdx];
			if (tok.Type != TokenType.Number)
				throw new Exception("The value being compared to in an argument exclude condition must be a decimal number!");
			ConditionArg = tok.NumberValue.Value;
		}
Exemplo n.º 17
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Type"></param>
        public ConditionListForm(ConditionType Type)
        {
            InitializeComponent();

            // Set internal vars
            this.List = new ConditionList(Type);
            this.OrigList = new ConditionList(Type);
            this.Node = new TreeNode();

            Initialize();
        }
Exemplo n.º 18
0
        public void OnArea(ConditionType eventType, Collider other)
        {
            if (Once == true && Result != ConditionResult.NEVER)
            {
                return;
            }

            if (Type == eventType)
            {
                Result = ConditionResult.CONDITION_ON;
            }
        }
Exemplo n.º 19
0
        public Filters AndSql(string name, ConditionType conditionType, string value)
        {
            this.filters.Add(
                new Filter
                    {
                        Name = name,
                        Value = value,
                        FilterType = FilterType.And,
                        ValueType = ValueType.Sql,
                        ConditionType = conditionType
                    });

            return this;
        }
Exemplo n.º 20
0
 /*********
 ** Private methods
 *********/
 /// <summary>Get whether a token type accepted a <see cref="PlayerType"/> input argument before Content Patcher 1.24.</summary>
 /// <param name="type">The condition type.</param>
 private bool IsOldPlayerToken(ConditionType type)
 {
     return(type
            is ConditionType.DailyLuck
            or ConditionType.FarmhouseUpgrade
            or ConditionType.HasCaughtFish
            or ConditionType.HasConversationTopic
            or ConditionType.HasDialogueAnswer
            or ConditionType.HasFlag
            or ConditionType.HasProfession
            or ConditionType.HasReadLetter
            or ConditionType.HasSeenEvent
            or ConditionType.HasActiveQuest
            or ConditionType.ChildNames
            or ConditionType.ChildGenders);
 }
Exemplo n.º 21
0
        public void GetPossibleStrings_WithOneToken(ConditionType conditionType)
        {
            // arrange
            ConditionKey     conditionKey = new ConditionKey(conditionType);
            ConditionFactory factory      = new ConditionFactory();
            TokenString      tokenStr     = new TokenString("{{" + conditionType + "}}", new HashSet <ConditionKey> {
                conditionKey
            }, TokenStringBuilder.TokenPattern);
            ConditionDictionary conditions = factory.BuildEmpty();

            // act
            IEnumerable <string> actual = factory.GetPossibleStrings(tokenStr, conditions);

            // assert
            this.SortAndCommaDelimit(actual).Should().Be(this.CommaDelimitedValues[conditionKey]);
        }
Exemplo n.º 22
0
        private void BuildConditionModel(ConditionType conditionType)
        {
            var model = new ConditionModel
            {
                Type = conditionType
            };

            while (_stack.Count > 0)
            {
                model.Groups.Add((ComparisonGroup)_stack.Pop());
            }

            model.Groups.Reverse();

            _stack.Push(model);
        }
        public void Type_HavingSettedType_ReturnsSettedValue()
        {
            // Arrange
            ConditionType expected = ConditionType.IsoCountryCode;

            Condition <ConditionType> sut = new Condition <ConditionType>
            {
                Type = expected
            };

            // Act
            ConditionType actual = sut.Type;

            // Assert
            actual.Should().Be(expected);
        }
Exemplo n.º 24
0
 // Needs to change this
 public ConditionTriggered( GameWorld world, Texture2D texture,
     Vector2 pos, float rotation, SharedResourceList triglist, String name = "ConditionTrigger",
     String texture_name = TNames.ground_switch_inactive, float cooldown = -1,
     SharedResourceList<TriggerableObject> t_objects = null,
     ConditionType c_type = ConditionType.DEATH )
     : base(world, texture, texture, pos, null, TriggerType.NO_COLLISION, cooldown,
          rotation, texture_name: texture_name, t_obj_list: t_objects)
 {
     m_condition_type = c_type;
     if ( trigger_list != null ) {
         trigger_list = triglist;
     }
     else {
         trigger_list = new SharedResourceList( m_world );
     }
 }
Exemplo n.º 25
0
 private Condition(ConditionType kind, LogicalType?type, ImmutableArray <IPart> parts, bool isPartial = false)
 {
     this.Kind = kind;
     if (parts.Length > 1)
     {
         // This only matters when there are multiple parts
         this.type = type ?? throw new InvalidOperationException($"If there are multiple parts to a condition, then it must have a {nameof(LogicalType)}");
     }
     // Only partial commands should retain the type even if there is only one part
     // (since the full condition has multiple parts)
     if (isPartial)
     {
         this.type = type;
     }
     this.parts = parts;
 }
        public void SimpleCompound(bool a, bool b, ConditionType conditionType, bool expected)
        {
            Guid inputIdA = new Guid("A916E57F-A5C7-4426-AC9F-44396E4427E6");
            Guid inputIdB = new Guid("9DFD98B0-FE1F-4A3E-B021-43617877A486");

            StateMachineInput[] inputs =
            {
                new StateMachineInput
                {
                    Id = inputIdA
                },
                new StateMachineInput
                {
                    Id = inputIdB
                },
            };

            //Condition (A & B)
            var rootCondition = new StateMachineCondition()
            {
                ConditionType = conditionType,
                Conditions    = new List <StateMachineCondition>(2)
                {
                    new StateMachineCondition()
                    {
                        ConditionType = ConditionType.Input,
                        SourceInputId = inputIdA,
                    },
                    new StateMachineCondition()
                    {
                        ConditionType = ConditionType.Input,
                        SourceInputId = inputIdB,
                    }
                }
            };

            //Generate the instructions
            var instructions = _instructionFactory.GetInstructions(rootCondition, inputs);

            bool[] inputValues = new bool[]
            {
                a,
                b
            };

            Assert.Equal(expected, instructions.Evalutate(inputValues));
        }
Exemplo n.º 27
0
        public void Add(string fieldName, DateTime value, ConditionType conditionType)
        {
            string str          = value.ToString();
            string dateTimeType = "DAY";

            if (value != DateTime.MinValue)
            {
                string str2 = string.Empty;
                switch (conditionType)
                {
                case ConditionType.More:
                    //str2 = ">'" + str + "'";
                    str2 = "DATEDIFF(" + dateTimeType + ",'" + str + "'," + fieldName + ")>0";
                    break;

                case ConditionType.Less:
                    //str2 = "<'" + str + "'";
                    str2 = "DATEDIFF(" + dateTimeType + ",'" + str + "'," + fieldName + ")<0";
                    break;

                case ConditionType.MoreOrEqual:
                    //str2 = ">='" + str + "'";
                    str2 = "DATEDIFF(" + dateTimeType + ",'" + str + "'," + fieldName + ")>=0";
                    break;

                case ConditionType.LessOrEqual:
                    //str2 = "<='" + str + "'";
                    str2 = "DATEDIFF(" + dateTimeType + ",'" + str + "'," + fieldName + ")<=0";
                    break;

                case ConditionType.Equal:
                    //str2 = "<='" + str + "'";
                    str2 = "DATEDIFF(" + dateTimeType + ",'" + str + "'," + fieldName + ")=0";
                    break;
                }
                if (this.conditionString == string.Empty)
                {
                    //this.conditionString = fieldName + str2;
                    this.conditionString = str2;
                }
                else
                {
                    //this.conditionString = this.conditionString + " AND " + fieldName + str2;
                    this.conditionString = this.conditionString + " AND " + str2;
                }
            }
        }
Exemplo n.º 28
0
        public Condition Parse(ConditionType kind, ExpressionSyntax expression)
        {
            using (new OperationTimer(i => Timings.Update(TimingOperation.ExpressionToCondition, i)))
            {
                var list = new LinkedList <BooleanExpression>();
                list.AddFirst(new BooleanExpression(expression));
                Queue <LinkedListNode <BooleanExpression> > queue = new Queue <LinkedListNode <BooleanExpression> >();
                ExplodeExpression(list, list.First, queue);

                while (queue.Count > 0)
                {
                    ExplodeExpression(list, queue.Dequeue(), queue);
                }

                var condition = new Condition(kind);
                var lastOp    = Operator.None;
                foreach (var item in list)
                {
                    LogicalType conditionType;
                    switch (lastOp)
                    {
                    case Operator.Or:
                        conditionType = LogicalType.Or;
                        break;

                    case Operator.And:
                        conditionType = LogicalType.And;
                        break;

                    default:
                        conditionType = LogicalType.Mixed;
                        break;
                    }
                    if (item.IsIsExpression)
                    {
                        condition = condition.WithIs(conditionType, new ExpressionKey(item.Expression, item.IsType), item.Expression, item.HasNotPrefix);
                    }
                    else
                    {
                        condition = condition.With(conditionType, new ExpressionKey(item.Expression, model), item.Expression, item.Value);
                    }
                    lastOp = item.Operator;
                }

                return(condition);
            }
        }
Exemplo n.º 29
0
        public static Condition FromXml(UXMLElement element)
        {
            ConditionType type = element.GetEnum <ConditionType>("type");

            switch (type)
            {
            case ConditionType.has_collectable: {
                return(new HasCollectableCondition(element.GetString("id")));
            }

            case ConditionType.has_collection: {
                return(new HasCollectionCondition(element.GetString("id")));
            }

            case ConditionType.has_story_collection: {
                return(new HasStoryCollectionCondition(element.GetString("id")));
            }

            case ConditionType.last_search_room: {
                return(new LastSearchRoomCondition(element.GetString("id")));
            }

            case ConditionType.level_ge: {
                return(new LevelGeCondition(element.GetInt("value")));
            }

            case ConditionType.quest_completed: {
                return(new QuestCompletedCondition(element.GetString("id")));
            }

            case ConditionType.random: {
                return(new RandomCondition(element.GetFloat("value")));
            }

            case ConditionType.room_mode: {
                return(new RoomModeCondition(element.GetEnum <RoomMode>("value")));
            }

            case ConditionType.search_counter_ge: {
                return(new SearchCounterGeCondition(element.GetInt("value")));
            }

            default: {
                return(new NoneCondition());
            }
            }
        }
Exemplo n.º 30
0
        private PrimitiveType SizeFromCondition(ConditionType ct)
        {
            switch (ct)
            {
            case ConditionType.Eq:
            case ConditionType.Lt:
            case ConditionType.Le:
            case ConditionType.Nuv:
            case ConditionType.Znv:
            case ConditionType.Sv:
            case ConditionType.Odd:
            case ConditionType.Tr:
            case ConditionType.Ne:
            case ConditionType.Ge:
            case ConditionType.Gt:
            case ConditionType.Uv:
            case ConditionType.Vnz:
            case ConditionType.Nsv:
            case ConditionType.Even:
            case ConditionType.Ult:
            case ConditionType.Ule:
            case ConditionType.Uge:
            case ConditionType.Ugt:
                return(PrimitiveType.Word32);

            case ConditionType.Eq64:
            case ConditionType.Lt64:
            case ConditionType.Le64:
            case ConditionType.Nuv64:
            case ConditionType.Znv64:
            case ConditionType.Sv64:
            case ConditionType.Odd64:
            case ConditionType.Ne64:
            case ConditionType.Ge64:
            case ConditionType.Gt64:
            case ConditionType.Uv64:
            case ConditionType.Vnz64:
            case ConditionType.Nsv64:
            case ConditionType.Even64:
            case ConditionType.Ult64:
            case ConditionType.Ule64:
            case ConditionType.Uge64:
            case ConditionType.Ugt64:
                return(PrimitiveType.Word64);
            }
            throw new NotImplementedException($"Condition type {ct} not implemented.");
        }
Exemplo n.º 31
0
        public static string Format(this ConditionType condition)
        {
            switch (condition)
            {
            case ConditionType.Cancer:
            case ConditionType.Diabetes:
            case ConditionType.Obesity:
            case ConditionType.Smoking:
                return(condition.ToString());

            case ConditionType.WeakendImmuneSystem:
                return("Weakened Immune System");

            default:
                throw new Exception($"Unexpected Condition {condition}");
            }
        }
Exemplo n.º 32
0
        public static bool IsConditionAllowed(this AutoQueryableProfile profile, ConditionType conditionType)
        {
            bool isConditionAllowed = true;
            bool?isAllowed          = profile?.AllowedConditions?.HasFlag(conditionType);
            bool?isDisallowed       = profile?.DisAllowedConditions?.HasFlag(conditionType);

            if (isAllowed.HasValue && !isAllowed.Value)
            {
                isConditionAllowed = false;
            }

            if (isDisallowed.HasValue && isDisallowed.Value)
            {
                isConditionAllowed = false;
            }
            return(isConditionAllowed);
        }
Exemplo n.º 33
0
        /// <summary>
        /// Returns an array of operators that can apply to a given type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="extraCondition">An optional extra condition that can be forced into the result.</param>
        /// <returns></returns>
        public static ConditionType[] GetApplicableOperators(DatabaseType type, ConditionType extraCondition)
        {
            if (extraCondition == ConditionType.FullTextSearch)
            {
                return new[] { ConditionType.Unspecified, ConditionType.FullTextSearch }
            }
            ;

            var list = GetApplicableConditionTypes(type).ToList();

            if (extraCondition != ConditionType.Unspecified && !list.Contains(extraCondition))
            {
                list.Add(extraCondition);
            }

            return(list.ToArray());
        }
Exemplo n.º 34
0
 public ProgramBlock()
 {
     // init stuff
     Type            = "";
     ScriptCondition = "";
     ScriptSource    = "";
     ScriptErrors    = "";
     //
     AppAssembly = null;
     //
     Commands      = new List <ProgramCommand>();
     Conditions    = new List <ProgramCondition>();
     ConditionType = ConditionType.None;
     //
     isProgramEnabled = true;
     IsRunning        = false;
 }
Exemplo n.º 35
0
 /// <summary>
 /// 根据条件列表自动添加查询条件 如果条件列表为空 添加Where 否则添加 指定类型
 /// </summary>
 /// <param name="fieldName">字段名称</param>
 /// <param name="isAnd">条件类型是否是And</param>
 public Query AutoAddCondition(string fieldName, bool isAnd = true)
 {
     if (HasCondition())
     {
         ConditionType conType = ConditionType.And;
         if (!isAnd)
         {
             conType = ConditionType.Or;
         }
         NewCondition(conType, fieldName);
     }
     else
     {
         NewCondition(ConditionType.None, fieldName);
     }
     return(this);
 }
Exemplo n.º 36
0
    public static bool Compair(float value1, ConditionType type, float value2)
    {
        switch (type)
        {
        case ConditionType.Equal: return(value1 == value2);

        case ConditionType.Greater: return(value1 > value2);

        case ConditionType.Less: return(value1 < value2);

        case ConditionType.LessOrEqual: return(value1 <= value2);

        case ConditionType.GreaterOrEqual: return(value1 >= value2);

        default: return(false);
        }
    }
Exemplo n.º 37
0
    public void Load(LevelRewardsPassable source)
    {
        rewardOneCondition  = source.rewardOneCondition;
        rewardOneComparison = source.rewardOneComparison;
        rewardOneValue      = source.rewardOneValue;
        rewardOnePrefab     = source.rewardOnePrefab;

        rewardTwoCondition  = source.rewardTwoCondition;
        rewardTwoComparison = source.rewardTwoComparison;
        rewardTwoValue      = source.rewardTwoValue;
        rewardTwoPrefab     = source.rewardTwoPrefab;

        rewardThreeCondition  = source.rewardThreeCondition;
        rewardThreeComparison = source.rewardThreeComparison;
        rewardThreeValue      = source.rewardThreeValue;
        rewardThreePrefab     = source.rewardThreePrefab;
    }
        public override void DrawInspectorGUI()
        {
            targetTransform = (Transform)UnityEditor.EditorGUILayout.ObjectField(new GUIContent("Target Transform",
                                                                                                "The transform to apply the condition to."), targetTransform, typeof(Transform), true);

            transformComponent = (TransformComponent)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Transform Component",
                                                                                                          "The transform component that will be used for the condition. Either position or rotation."), transformComponent);

            axis = (Axis)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Target Axis",
                                                                              "The axis that the condition will be based on."), axis);

            conditionType = (ConditionType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Condition Type",
                                                                                                "The type of condition the user wants. Options are greater than, greater than or equal to, equal to, less than or equal to or less than."), conditionType);

            value = UnityEditor.EditorGUILayout.FloatField(new GUIContent("Value",
                                                                          "The value that will be compared against the value in the axis selected above."), value);
        }
Exemplo n.º 39
0
        /// <summary>
        /// this not thread safe
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public static List <FilterViewModel> ConvertJsonAsList(string jsonString, ConditionType conditionType = ConditionType.ENUM_INT)
        {
            List <object> listObject = JsonConvert.DeserializeObject <List <object> >(jsonString, new JsonSerializerSettings {
                Formatting = Formatting.None
            });
            List <FilterViewModel> listFilter = new List <FilterViewModel>();

            listObject.ForEach(obj =>
            {
                object parseObject = JsonConvert.DeserializeObject <object>(obj.ToString());
                var model          = new FilterViewModel();
                model.SetFilterViewModel(parseObject.ToString(), conditionType);
                //listFilter.Add(new FilterViewModel().SetFilterViewModel(obj.ToString(), conditionType));
                listFilter.Add(model);
            });
            return(listFilter);
        }
 public ConditionHandlerWidget(ConditionType ConditionType, IContainer Parent) : base(Parent)
 {
     this.ConditionType = ConditionType;
     RadioBox           = new RadioBox(this);
     RadioBox.SetText(ConditionType.Name);
     RadioBox.OnCheckChanged += delegate(BaseEventArgs e)
     {
         if (RadioBox.Checked)
         {
             BasicCondition condition = GetConditionsWindow().SelectedCondition;
             this.SetCondition(condition);
             GetConditionsWindow().SetActiveType(this);
         }
     };
     UIParser = new ConditionUIParser(ConditionType.UI, this);
     UIParser.Load(null);
 }
Exemplo n.º 41
0
        public static IConditionTreeItem ReadConditionCollection(this System.IO.BinaryReader reader)
        {
            Stack <ConditionTreeLeaf> andList = new Stack <ConditionTreeLeaf>();
            int numConditions = reader.ReadInt32();

            for (int l = 0; l < numConditions; l++)
            {
                ConditionType       conditionType = (ConditionType)reader.ReadInt32();
                ConditionComparison comparison    = (ConditionComparison)reader.ReadInt32();
                string     variableName           = reader.ReadString();
                BinaryType binType;
                object     compareTo = reader.ReadType(out binType);
                andList.Push(new ConditionTreeLeaf(conditionType, variableName, comparison, binType.ToPropertyUnion(compareTo)));
            }

            return(LegacyConditionParser.AndListToTree(andList));
        }
        public bool IsConditionAllowed(ConditionType conditionType)
        {
            var isConditionAllowed = true;
            var isAllowed          = AllowedConditions?.HasFlag(conditionType);
            var isDisallowed       = DisAllowedConditions?.HasFlag(conditionType);

            if (isAllowed.HasValue && !isAllowed.Value)
            {
                isConditionAllowed = false;
            }

            if (isDisallowed.HasValue && isDisallowed.Value)
            {
                isConditionAllowed = false;
            }
            return(isConditionAllowed);
        }
Exemplo n.º 43
0
        public (DataType, Func <FormattableString>) GetConditionGenerator(ConditionType conditionType)
        {
            switch (conditionType)
            {
            case ConditionType.DaysAgo:
                return(DataType.Integer, () => $"{TableColumn} >= {DateTime.Now.AddDays(GetValue<int>() * -1).ToOADate()}");

            case ConditionType.DoesContain:
                return(DataType.String, () => $"{TableColumn} like '%{GetValue<string>()}%'");

            case ConditionType.DoesNotContain:
                return(DataType.String, () => $"NOT ({TableColumn} like '%{GetValue<string>()}%')");

            default:
                throw new NotImplementedException($"Condition type {conditionType} is not implemented yet.");
            }
        }
Exemplo n.º 44
0
        public MultipleCondition(ConditionType type, IEnumerable values)
        {
            Values = values;
            switch (type)
            {
            case ConditionType.AllOf:
                Type = "all_of";
                break;

            case ConditionType.OneOf:
                Type = "one_of";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Exemplo n.º 45
0
    public List <SingleContract> ParseContract(int level)
    {
        List <SingleContract> ret = new List <SingleContract>();

        List <List <string> > data = Parser.ContractParse(contractAsset[level]);

        for (int i = 0; i < data.Count; i++)
        {
            int                   article          = int.Parse(data[i][0]);
            int                   clause           = int.Parse(data[i][1]);
            ConditionClass        conditionClass   = (ConditionClass)System.Enum.Parse(typeof(ConditionClass), data[i][2]);
            ConditionType         conditionType    = (ConditionType)System.Enum.Parse(typeof(ConditionType), data[i][3]);
            int                   conditionValue   = int.Parse(data[i][4]);
            ResultClass           resultClass      = (ResultClass)System.Enum.Parse(typeof(ResultClass), data[i][5]);
            float                 resultValue      = float.Parse(data[i][6]);
            string                contractText     = data[i][7];
            List <SimpleContract> relatedContracts = new List <SimpleContract>();

            if (data[i].Count > 8)
            {
                for (int j = 8; j < data[i].Count; j++)
                {
                    if (data[i][j] == "")
                    {
                        continue;
                    }
                    int relatedContract = int.Parse(data[i][j]);
                    int relatedArticle  = relatedContract / 10;
                    int relatedClause   = relatedContract % 10;

                    SimpleContract cont = new SimpleContract(relatedArticle, relatedClause);
                    relatedContracts.Add(cont);
                }
            }

            SingleContract contract = new SingleContract(article, clause, conditionClass, conditionType, conditionValue, resultClass, resultValue, contractText, relatedContracts);
            if (contract.Article == 0)
            {
                contract.isAgree = true;
            }
            ret.Add(contract);
        }

        return(ret);
    }
Exemplo n.º 46
0
 public WizardScript(ProgramBlock pb)
 {
     if (pb == null || String.IsNullOrEmpty(pb.ScriptSource))
     {
         return;
     }
     try
     {
         var s = JsonConvert.DeserializeObject <WizardScript>(pb.ScriptSource);
         Commands      = s.Commands;
         Conditions    = s.Conditions;
         ConditionType = s.ConditionType;
     }
     catch (Exception e)
     {
         // TODO: report initialization exception
     }
 }
Exemplo n.º 47
0
        public static string getTooltip(string ItemText)
        {
            ConditionType type = (ConditionType)Enum.Parse(typeof(ConditionType), ItemText);

            string tooltip;

            if (!D3Helper.A_Collection.Presets.Manual.Tooltips.ConditionTypes.TryGetValue(type, out tooltip))
            {
                tooltip = $"!ERROR! NO TOOLTIP DEFINED FOR CONDITION TYPE '{ItemText}'";
            }

            if (tooltip.Length >= 80)
            {
                tooltip = tooltip.Insert(80, "\n");
            }

            return(tooltip);
        }
Exemplo n.º 48
0
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        Conditions condition = new Conditions();

        condition.ParamConditions = new List <ParameterCondition>();
        JToken jtoken = JToken.ReadFrom(reader);

        foreach (JProperty prop in jtoken)
        {
            ConditionType type = (ConditionType)Enum.Parse(typeof(ConditionType), prop.Value.ToString(), true);
            condition.ParamConditions.Add(new ParameterCondition()
            {
                Condition     = type,
                ParameterName = prop.Name
            });
        }
        return(condition);
    }
Exemplo n.º 49
0
    private bool ConditionMet(LevelStats stats, ConditionType type, ComparisonType comparison, float value)
    {
        float statValue = stats.stats[type];

        switch (comparison)
        {
        case ComparisonType.AtLeast:
            return(statValue >= value);

        case ComparisonType.AtMost:
            return(statValue <= value);

        case ComparisonType.EqualTo:
            return(statValue == value);

        default:
            return(false);
        }
    }
Exemplo n.º 50
0
 public OtherBedroom(ConditionType wallAndTrimeB, ConditionType wallAndTrimeE, string wallAndTrimsCommentB,
                     string wallAndTrimsCommentE, ConditionType ceilingsB, ConditionType ceilingsE, string ceilingsCommentB,
                     string ceilingsCommentE, ConditionType closetsB, ConditionType closetsE, string closetsCommentB,
                     string closetsCommentE, ConditionType doorB, ConditionType doorE, string doorCommentB, string doorCommentE,
                     ConditionType lightingB, ConditionType lightingE, string lightingCommentB, string lightingCommentE,
                     ConditionType windowsCoveringB, ConditionType windowsCoveringE, ConditionType windowsCoveringCommentB,
                     ConditionType windowsCoveringCommentE, ConditionType electricalOutletsB, ConditionType electricalOutletsE,
                     string electricalOutletsCommentB, string electricalOutletsCommentE, ConditionType floorCarpetB, ConditionType floorCarpetE,
                     string floorCarpetCommentB, string floorCarpetCommentE)
 {
     WallAndTrimeB        = wallAndTrimeB;
     WallAndTrimeE        = wallAndTrimeE;
     WallAndTrimsCommentB = wallAndTrimsCommentB;
     WallAndTrimsCommentE = wallAndTrimsCommentE;
     CeilingsB            = ceilingsB;
     CeilingsE            = ceilingsE;
     CeilingsCommentB     = ceilingsCommentB;
     CeilingsCommentE     = ceilingsCommentE;
     ClosetsB             = closetsB;
     ClosetsE             = closetsE;
     ClosetsCommentB      = closetsCommentB;
     ClosetsCommentE      = closetsCommentE;
     DoorB                     = doorB;
     DoorE                     = doorE;
     DoorCommentB              = doorCommentB;
     DoorCommentE              = doorCommentE;
     LightingB                 = lightingB;
     LightingE                 = lightingE;
     LightingCommentB          = lightingCommentB;
     LightingCommentE          = lightingCommentE;
     WindowsCoveringB          = windowsCoveringB;
     WindowsCoveringE          = windowsCoveringE;
     WindowsCoveringCommentB   = windowsCoveringCommentB;
     WindowsCoveringCommentE   = windowsCoveringCommentE;
     ElectricalOutletsB        = electricalOutletsB;
     ElectricalOutletsE        = electricalOutletsE;
     ElectricalOutletsCommentB = electricalOutletsCommentB;
     ElectricalOutletsCommentE = electricalOutletsCommentE;
     FloorCarpetB              = floorCarpetB;
     FloorCarpetE              = floorCarpetE;
     FloorCarpetCommentB       = floorCarpetCommentB;
     FloorCarpetCommentE       = floorCarpetCommentE;
 }
Exemplo n.º 51
0
 /// <summary>
 /// 获取条件
 /// </summary>
 /// <param name="ConditionType">条件类型</param>
 /// <returns></returns>
 public static string GetConditionType(ConditionType conditionType)
 {
     switch (conditionType)
     {
         case ConditionType.等于:
             return "==";
         case ConditionType.不等于:
             return "!=";
         case ConditionType.大于:
             return ">";
         case ConditionType.大于等于:
             return ">=";
         case ConditionType.小于:
             return "<";
         case ConditionType.小于等于:
             return "<=";
         default:
             return string.Empty;
     }
 }
Exemplo n.º 52
0
        /// <summary>
        /// Creates a new <see cref="PropertyRule"/> for the specified property and condition type.
        /// </summary>
        /// <param name="rootType"></param>
        /// <param name="property"></param>
        /// <param name="conditionType"></param>
        /// <param name="invocationTypes"></param>
        /// <param name="predicates"></param>
        public PropertyRule(string rootType, string property, Func<ModelType, ConditionType> conditionType, RuleInvocationType invocationTypes, params string[] predicates)
            : base(rootType, rootType + "." + property, invocationTypes, predicates)
        {
            this.property = property;
            this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;

            if (conditionType != null)
            Initialize += (s, e) =>
            {
                // Make sure the condition type and rule have a unique name
                var type = RootType;
                var error = conditionType(type);
                var originalCode = error.Code;
                var uniqueCode = originalCode;
                int count = 1;
                while (ConditionType.GetConditionTypes(type).Any(ct => ct.Code == uniqueCode))
                    uniqueCode = originalCode + count++;
                error.Code = uniqueCode;
                Name = uniqueCode;

                // Assign the condition type to the rule
                ConditionTypes = new ConditionType[] { error };
            };
        }
Exemplo n.º 53
0
	void WhileOrUntil(
//#line  3562 "VBNET.ATG" 
out ConditionType conditionType) {

//#line  3563 "VBNET.ATG" 
		conditionType = ConditionType.None; 
		if (la.kind == 231) {
			lexer.NextToken();

//#line  3564 "VBNET.ATG" 
			conditionType = ConditionType.While; 
		} else if (la.kind == 224) {
			lexer.NextToken();

//#line  3565 "VBNET.ATG" 
			conditionType = ConditionType.Until; 
		} else SynErr(316);
	}
Exemplo n.º 54
0
 /// <summary>
 /// Creates a new Jump or Call instruction with an empty destination
 /// </summary>
 /// <param name="isCall">true if this is a call instruction</param>
 /// <param name="condition">the condition to execute this instruction on</param>
 /// <remarks>
 /// This is designed for instructions which will be fixed up later
 /// </remarks>
 public JumpCall(bool isCall, ConditionType condition = ConditionType.Unconditional)
     : this(isCall, 0, condition)
 {
 }
Exemplo n.º 55
0
 private void AddInfoToLast(AutomationProperty property, object value, ConditionType conditionType)
 {
     this.FindInfoList.Last().Add(new Info(property, value, conditionType));
 }
Exemplo n.º 56
0
 internal Info(AutomationProperty property, object value, ConditionType conditionType)
 {
     this.Property = property;
     this.Value = value;
     this.ConditionType = conditionType;
 }
Exemplo n.º 57
0
	void WhileOrUntil(
#line  3218 "VBNET.ATG" 
out ConditionType conditionType) {

#line  3219 "VBNET.ATG" 
		conditionType = ConditionType.None; 
		if (la.kind == 216) {
			lexer.NextToken();

#line  3220 "VBNET.ATG" 
			conditionType = ConditionType.While; 
		} else if (la.kind == 209) {
			lexer.NextToken();

#line  3221 "VBNET.ATG" 
			conditionType = ConditionType.Until; 
		} else SynErr(280);
	}
Exemplo n.º 58
0
 public void AddCondition(IUpdateCondition cnd, ConditionType type)
 {
     if (ChildConditions == null) ChildConditions = new LinkedList<ConditionItem>();
     ChildConditions.AddLast(new ConditionItem(cnd, type));
 }
		public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) {}
Exemplo n.º 60
0
	void WhileOrUntil(
#line  2733 "VBNET.ATG" 
out ConditionType conditionType) {

#line  2734 "VBNET.ATG" 
		conditionType = ConditionType.None; 
		if (la.kind == 181) {
			lexer.NextToken();

#line  2735 "VBNET.ATG" 
			conditionType = ConditionType.While; 
		} else if (la.kind == 177) {
			lexer.NextToken();

#line  2736 "VBNET.ATG" 
			conditionType = ConditionType.Until; 
		} else SynErr(262);
	}