public LogQuery WithLevel(LogLevel?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, EnumOperator @operator = EnumOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case EnumOperator.Equal: Entities = Entities.Where(l => l.Level == value); return(this); case EnumOperator.NotEqual: Entities = Entities.Where(l => l.Level != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
private void btnClear_Click(object sender, EventArgs e) { currentOperator = EnumOperator.None; lblResult.Text = ""; lblEquation.Text = ""; numSum = 0; }
public static String GetString(this EnumOperator type, string columnNmae, string value, string valueType) { switch (type) { case EnumOperator.Equal: return(string.Format("{2}.ToLower().Equal({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.GreaterThan: return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}>0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.LessThan: return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}<0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.GreaterThanOrEqual: return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}>=0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.LessThanOrEqual: return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}<=0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.NotEqual: return(string.Format("!{2}.ToLower().Equal({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); case EnumOperator.Like: return(string.Format("{2}.ToLower().Contains({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae)); default: return("="); } }
public TransactionRequestQuery WithStatus(TransactionRequestStatus?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, EnumOperator @operator = EnumOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case EnumOperator.Equal: Entities = Entities.Where(tr => tr.Status == value); return(this); case EnumOperator.NotEqual: Entities = Entities.Where(tr => tr.Status != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public OrderLineQuery WithType(ItemType?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, EnumOperator @operator = EnumOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case EnumOperator.Equal: Entities = Entities.Where(ol => ol.Type == value); return(this); case EnumOperator.NotEqual: Entities = Entities.Where(ol => ol.Type != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public static String GetString(this EnumOperator type) { switch (type) { case EnumOperator.Equal: return("="); case EnumOperator.GreaterThan: return(">"); case EnumOperator.LessThan: return("<"); case EnumOperator.GreaterThanOrEqual: return(">="); case EnumOperator.LessThanOrEqual: return("<="); case EnumOperator.NotEqual: return("<>"); case EnumOperator.Like: return("like"); default: return("="); } }
/// <summary> /// 只需输入运算符,工厂就能实例化出合适的对象,通过多态,返回父类的方式实现了计算器的结果 /// </summary> /// <param name="operate">运算符</param> /// <returns></returns> public static Operation createOpeate(EnumOperator op) { Operation oper = null; switch (op) { case EnumOperator.Add: oper = new OperationAdd(); break; case EnumOperator.Minus: oper = new OperationSub(); break; case EnumOperator.Multiply: oper = new OperationMul(); break; case EnumOperator.Divide: oper = new OperationDiv(); break; default: break; } return(oper); }
/// <summary> /// 归零方法 /// </summary> private void gui0() { currentOperator = EnumOperator.None; lblMain.Text = ""; lblFu.Text = ""; numSum = 0; }
public QueuedEmailQuery WithSendPriority(Priority?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, EnumOperator @operator = EnumOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case EnumOperator.Equal: Entities = Entities.Where(qe => qe.SendPriority == value); return(this); case EnumOperator.NotEqual: Entities = Entities.Where(qe => qe.SendPriority != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public static string ToCommand(this EnumOperator pOperator) { switch (pOperator) { case EnumOperator.Equal: return("="); case EnumOperator.Different: return("<>"); case EnumOperator.LessThan: return("<"); case EnumOperator.GreaterThan: return(">"); case EnumOperator.LessEqualThan: return("<="); case EnumOperator.GreaterEqualThan: return(">="); case EnumOperator.In: return("IN"); case EnumOperator.NotIn: return("NOT IN"); case EnumOperator.Like: return("LIKE"); default: return(string.Empty); } }
public EnumParam(TEnum value, EnumOperator valueOperator) { if (valueOperator == EnumOperator.EqualsNull) { throw new NotNullableException("EnumParam cannot be null"); } FOperator = valueOperator; FValue = value; }
public static bool IsListOperator(this EnumOperator pOperator) { switch (pOperator) { case EnumOperator.In: case EnumOperator.NotIn: return(true); default: return(false); } }
/// <summary> /// 根据运算符和两个数字计算结果 /// 调用简单工厂模式生成的类 /// </summary> private void Evaluate() { Operation oper; //根据不同的对象生成不同的类,多态! switch (currentOperator) { case EnumOperator.None: break; //加 case EnumOperator.Add: oper = OperationFactory.createOpeate(EnumOperator.Add); oper.NumberA = numSum; oper.NumnberB = currentValue; numSum = oper.GetResult(); break; //减 case EnumOperator.Minus: oper = OperationFactory.createOpeate(EnumOperator.Minus); oper.NumberA = numSum; oper.NumnberB = currentValue; numSum = oper.GetResult(); break; //乘 case EnumOperator.Multiply: oper = OperationFactory.createOpeate(EnumOperator.Multiply); oper.NumberA = numSum; oper.NumnberB = currentValue; numSum = oper.GetResult(); break; //除 case EnumOperator.Divide: //判断结果 if (currentValue != 0) { oper = OperationFactory.createOpeate(EnumOperator.Divide); oper.NumberA = numSum; oper.NumnberB = currentValue; numSum = oper.GetResult(); } else { MessageBox.Show("除数不能为0哦,亲~", "出错了~"); } break; } currentValue = 0; currentOperator = EnumOperator.None; }
public NullableEnumParam(TEnum value, EnumOperator enumOperator) { if (typeof(TEnum).IsClass && value == null) { FOperator = EnumOperator.EqualsNull; IsNull = false; return; } FOperator = enumOperator; FValue = value; if (enumOperator == EnumOperator.EqualsNull) { IsNull = false; } }
public int ApplyOperation(int number1, int number2, EnumOperator enumOperator) { switch (enumOperator) { case EnumOperator.Plus: return(number1 + number2); case EnumOperator.Minus: return(number1 - number2); case EnumOperator.Times: return(number1 * number2); default: throw new FaultException("Unknown operator"); } }
/// <summary> /// 定义一个枚举运算符参数的函数 /// 里面调用DisplayOperator方法 /// </summary> /// <param name="op"></param> private void OperatorClick(EnumOperator op) { if (currentOperator != EnumOperator.None) { //计算 Evaluate(); } else { //numSum = double.Parse(lblResult.Text); double.TryParse(lblMain.Text, out numSum); } DisplayOperator(op); lblMain.Text = ""; currentOperator = op; }
/// <summary> /// 根据运算符号来执行四则运算显示的内容 /// </summary> /// <param name="op"></param> private void DisplayOperator(EnumOperator op) { //选择判断 switch (op) { case EnumOperator.None: lblFu.Text = lblMain.Text; lblFu.Text += ""; break; case EnumOperator.Add: if (lblMain.Text != "") { lblFu.Text = lblMain.Text; } lblFu.Text += "+"; break; case EnumOperator.Minus: if (lblMain.Text != "") { lblFu.Text = lblMain.Text; } lblFu.Text += "-"; break; case EnumOperator.Multiply: lblFu.Text = lblMain.Text; lblFu.Text += "x"; break; case EnumOperator.Divide: lblFu.Text = lblMain.Text; lblFu.Text += "➗"; break; default: break; } }
private void DisplayOperator(EnumOperator op) { switch (op) { case EnumOperator.None: label2.Text = label1.Text; label2.Text += ""; break; case EnumOperator.Add: if (label1.Text != "") { label2.Text = label1.Text; } label2.Text += "+"; break; case EnumOperator.Minus: if (label1.Text != "") { label2.Text = label1.Text; } label2.Text += "-"; break; case EnumOperator.Multiply: label2.Text = label1.Text; label2.Text += "x"; break; case EnumOperator.Divide: label2.Text = label1.Text; label2.Text += "➗"; break; default: break; } }
private void DisplayOperator(EnumOperator op) { switch (op) { case EnumOperator.None: lblEquation.Text = lblResult.Text; lblEquation.Text += ""; break; case EnumOperator.Add: if (lblResult.Text != "") { lblEquation.Text = lblResult.Text; } lblEquation.Text += "+"; break; case EnumOperator.Minus: if (lblResult.Text != "") { lblEquation.Text = lblResult.Text; } lblEquation.Text += "-"; break; case EnumOperator.Multiply: lblEquation.Text = lblResult.Text; lblEquation.Text += "x"; break; case EnumOperator.Divide: lblEquation.Text = lblResult.Text; lblEquation.Text += "÷"; break; default: break; } }
void OnEnable() { blending = GetComponent <Blending>(); targetCamera = GetComponent <Camera>(); blending.enabled = true; mouseTracker.Clear(); mouseCurr = new MousePosition(targetCamera, blending.BlendingData); fsmTrackerTargetMode = new FSM <TargetModeEnum>(this); fsmGUIMode = new FSM <GUIModeEnum>(this); cornerControl = new CornerControl(this, blending, mouseTracker, mouseCurr); edgeControl = new EdgeControl(this, blending, mouseTracker, mouseCurr); blendControl = new BlendControl(this, blending, mouseTracker, mouseCurr); #region FSM Setup fsmTrackerTargetMode.State(TargetModeEnum.None); fsmTrackerTargetMode.State(TargetModeEnum.Corner) .Enter(fsm => cornerControl.Activity = true) .Update(fsm => cornerControl.Update()) .Exit(fsm => cornerControl.Activity = false); fsmTrackerTargetMode.State(TargetModeEnum.Edge) .Enter(fsm => edgeControl.Activity = true) .Update(fsm => edgeControl.Update()) .Exit(fsm => edgeControl.Activity = false); fsmTrackerTargetMode.State(TargetModeEnum.Blend) .Enter(fsm => blendControl.Activity = true) .Update(fsm => blendControl.Update()) .Exit(fsm => blendControl.Activity = false); fsmTrackerTargetMode.Init(); fsmGUIMode.State(GUIModeEnum.Hidden).Update(fsm => { if (Input.GetKeyDown(config.guiModeToggleKey)) { fsm.Goto(GUIModeEnum.Show); } }); fsmGUIMode.State(GUIModeEnum.Show).Update(fsm => { if (Input.GetKeyDown(config.guiModeToggleKey)) { fsm.Goto(GUIModeEnum.Hidden); } }); fsmGUIMode.Init(); #endregion #region Reactive setup trackerMode.Changed += (r => { fsmTrackerTargetMode.Goto(r.Value); trackerIndex.Value = EnumOperator <TargetModeEnum> .FindIndex(r.Value); }); trackerIndex.Changed += (r => { trackerMode.Value = EnumOperator <TargetModeEnum> .ValueAt(r.Value); }); screenColumnCount.Changed += (r => { UpdateScreenSetup(r.Value, screenRowCount.Value); screenColumnCountText.Value = r.Value.ToString(); }); screenRowCount.Changed += (r => { UpdateScreenSetup(screenColumnCount.Value, r.Value); screenRowCountText.Value = r.Value.ToString(); }); screenColumnCountText.Changed += (r => { int nextValue; if (int.TryParse(r.Value, out nextValue)) { screenColumnCount.Value = Mathf.Max(1, nextValue); } }); screenRowCountText.Changed += (r => { int nextValue; if (int.TryParse(r.Value, out nextValue)) { screenRowCount.Value = Mathf.Max(1, nextValue); } }); outputMode.Changed += (r => { blending.BlendingData.OutputKeyword = r.Value; outputIndex.Value = EnumOperator <KwOutput> .FindIndex(r.Value); }); outputIndex.Changed += (r => { outputMode.Value = EnumOperator <KwOutput> .ValueAt(r.Value); }); wireframeMode.Changed += (r => { blending.BlendingData.WireframeKeyword = r.Value; wireframeIndex.Value = EnumOperator <KwWireframe> .FindIndex(r.Value); }); wireframeIndex.Changed += (r => { wireframeMode.Value = EnumOperator <KwWireframe> .ValueAt(r.Value); }); textureBlendMode.Changed += (r => { blending.BlendingData.TextureBlendkeyword = r.Value; textureBlendIndex.Value = EnumOperator <KwTextureBlend> .FindIndex(r.Value); }); textureBlendIndex.Changed += (r => textureBlendMode.Value = EnumOperator <KwTextureBlend> .ValueAt(r.Value)); maskTextureIndex.Changed += (r => { blending.BlendingData.MaskTextureIndex = r.Value; maskTextureIndexText.Value = r.Value.ToString(); }); maskTextureIndexText.Changed += (r => { int nextValue; if (int.TryParse(r.Value, out nextValue)) { maskTextureIndex.Value = nextValue; } }); #endregion Load(); UpdateScreenSetup(screenColumnCount.Value, screenRowCount.Value); }
public static bool Evaluate(EnumOperator operatorType, object first, object second) {
private void CreateNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { List<string> ops = new List<string>(0); DefineVariable(Type, name, null); switch (operation) { case EnumOperator.UNARY_PLUS: { for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } Instruction ins = new Instruction((int)EnumOpcodes.ADD, ops.ToArray<string>()); break; } case EnumOperator.UNARY_MINUS: { for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } Instruction ins = new Instruction((int)EnumOpcodes.SUB, ops.ToArray<string>()); break; } case EnumOperator.UNARY_MULTIPLY: { bool issigned = false; for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { if ((int)branches.ElementAt(i).Value < 0) { issigned = true; } ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } if (issigned) { Instruction ins = new Instruction((int)EnumOpcodes.IMUL, ops.ToArray<string>()); } else { Instruction ins = new Instruction((int)EnumOpcodes.MUL,ops.ToArray<string>()); } break; } case EnumOperator.UNARY_DIVIDE: { bool issigned = false; for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { if ((int)branches.ElementAt(i).Value < 0) { issigned = true; } ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } if (issigned) { Instruction ins = new Instruction((int)EnumOpcodes.IDIV, ops.ToArray<string>()); } else { Instruction ins = new Instruction((int)EnumOpcodes.DIV, ops.ToArray<string>()); } break; } } return; }
private int GetOperation(EnumOperator Operator) { return (int)Operator; }
public void GetEnumDescriptionByInt_Null_Test() { var description = EnumOperator.GetEnumDescriptionByInt(null); Assert.IsTrue(description == PackageStoredTypeEnum.UnKnown.GetDescription()); }
public void GetEnumDescriptionByInt_InEnum_Test() { var description = EnumOperator.GetEnumDescriptionByInt(1); Assert.IsTrue(description == PackageStoredTypeEnum.Normal.GetDescription()); }
public Filter(string property, object value, EnumOperator operatorType) { Property = property; Value = value; OperatorType = operatorType; }
private void CreateAlphaNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { DefineVariable(Type, name, null); }
private void CreateBinaryInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { List<string> ops = new List<string>(0); DefineVariable(Type, name, null); switch(operation) { case EnumOperator.ASSIGNMEMT: { for (int i = 0; i < branches.Count; i++) { ops.Add(this.thetree.ASTbranches.ElementAt(i).name); ops.Add((string)this.thetree.ASTbranches.ElementAt(i).Value); } } break; } }