Exemple #1
0
        private void EmitConditional(FleeILGenerator ilg, IServiceProvider services, BranchManager bm)
        {
            Label falseLabel = bm.FindLabel("falseLabel");
            Label endLabel   = bm.FindLabel("endLabel");

            // Emit the condition
            _myCondition.Emit(ilg, services);

            // On false go to the false operand
            if (ilg.IsTemp == true)
            {
                bm.AddBranch(ilg, falseLabel);
                ilg.Emit(OpCodes.Brfalse_S, falseLabel);
            }
            else if (bm.IsLongBranch(ilg, falseLabel) == false)
            {
                ilg.Emit(OpCodes.Brfalse_S, falseLabel);
            }
            else
            {
                ilg.Emit(OpCodes.Brfalse, falseLabel);
            }

            // Emit the true operand
            _myWhenTrue.Emit(ilg, services);
            ImplicitConverter.EmitImplicitConvert(_myWhenTrue.ResultType, _myResultType, ilg);

            // Jump to end
            if (ilg.IsTemp == true)
            {
                bm.AddBranch(ilg, endLabel);
                ilg.Emit(OpCodes.Br_S, endLabel);
            }
            else if (bm.IsLongBranch(ilg, endLabel) == false)
            {
                ilg.Emit(OpCodes.Br_S, endLabel);
            }
            else
            {
                ilg.Emit(OpCodes.Br, endLabel);
            }

            bm.MarkLabel(ilg, falseLabel);
            ilg.MarkLabel(falseLabel);

            // Emit the false operand
            _myWhenFalse.Emit(ilg, services);
            ImplicitConverter.EmitImplicitConvert(_myWhenFalse.ResultType, _myResultType, ilg);
            // Fall through to end
            bm.MarkLabel(ilg, endLabel);
            ilg.MarkLabel(endLabel);
        }
Exemple #2
0
        private void EmitConditional(YaleIlGenerator ilg, ExpressionContext context, BranchManager branchManager)
        {
            var falseLabel = branchManager.FindLabel("falseLabel");
            var endLabel   = branchManager.FindLabel("endLabel");

            // Emit the condition
            condition.Emit(ilg, context);

            // On false go to the false operand
            if (ilg.IsTemp)
            {
                branchManager.AddBranch(ilg, falseLabel);
                ilg.Emit(OpCodes.Brfalse_S, falseLabel);
            }
            else if (branchManager.IsLongBranch(ilg, falseLabel) == false)
            {
                ilg.Emit(OpCodes.Brfalse_S, falseLabel);
            }
            else
            {
                ilg.Emit(OpCodes.Brfalse, falseLabel);
            }

            // Emit the true operand
            whenTrue.Emit(ilg, context);
            ImplicitConverter.EmitImplicitConvert(whenTrue.ResultType, resultType, ilg);

            // Jump to end
            if (ilg.IsTemp)
            {
                branchManager.AddBranch(ilg, endLabel);
                ilg.Emit(OpCodes.Br_S, endLabel);
            }
            else if (branchManager.IsLongBranch(ilg, endLabel) == false)
            {
                ilg.Emit(OpCodes.Br_S, endLabel);
            }
            else
            {
                ilg.Emit(OpCodes.Br, endLabel);
            }

            branchManager.MarkLabel(ilg, falseLabel);
            ilg.MarkLabel(falseLabel);

            // Emit the false operand
            whenFalse.Emit(ilg, context);
            ImplicitConverter.EmitImplicitConvert(whenFalse.ResultType, resultType, ilg);
            // Fall through to end
            branchManager.MarkLabel(ilg, endLabel);
            ilg.MarkLabel(endLabel);
        }
Exemple #3
0
        public HttpResponseMessage AddBranch([FromBody] BranchModel branchModel)
        {
            using (logic = new BranchManager())
            {
                try
                {
                    //בדיקה האם הפרמטר שעבר לפונקציה בתור מודל עומד בדרישות הואלידציה
                    //BOהגדרות הואלידציה מוגדרות בתוך ה
                    //Data annotation בתור
                    if (!ModelState.IsValid)
                    {
                        string error = ModelState.Where(ms => ms.Value.Errors.Any()).Select(ms => ms.Value.Errors[0].ErrorMessage).FirstOrDefault();
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, error));
                    }

                    // הולידציה עברה בהצלחה
                    branchModel = logic.AddBranch(branchModel);

                    return(Request.CreateResponse(HttpStatusCode.Created, branchModel));
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ExceptionHelper.GetInnerMessage(ex)));
                }
            }
        }
 public ActionResult Create(BranchModel branch)
 {
     try
     {
         BranchManager.AddBranch(Utility.convertSrcToTarget <BranchModel, Branch>(branch), "nirshan");
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
    /// <summary>
    /// 添加按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            Branch branch = new Branch();
            branch.BranchName      = this.txtBranchName.Text;
            branch.BranchShortName = this.txtBranchShortName.Text;
            branch = BranchManager.AddBranch(branch);

            BindBranchInfo();
            txtBranchShortName.Text = "";
            txtBranchName.Text      = "";
        }
    }
Exemple #6
0
        public HttpResponseMessage PostBranch([FromBody] Branch br)
        {
            BranchModel bm = new BranchModel
            {
                BranchID   = br.BranchID,
                Name       = br.Name,
                Address    = br.Address,
                Latitude   = br.Latitude,
                Longtitude = br.Longtitude
            };

            var x = branchMg.AddBranch(bm);

            return(Request.CreateResponse(HttpStatusCode.OK, x));
        }
Exemple #7
0
 private static void EmitBranchToTrueTerminal(FleeILGenerator ilg, Label trueTerminal, BranchManager bm)
 {
     if (ilg.IsTemp == true)
     {
         bm.AddBranch(ilg, trueTerminal);
         ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
     }
     else if (bm.IsLongBranch(ilg, trueTerminal) == false)
     {
         ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
     }
     else
     {
         ilg.Emit(OpCodes.Brtrue, trueTerminal);
     }
 }
Exemple #8
0
 private static void EmitBranchToTrueTerminal(YaleIlGenerator ilg, Label trueTerminal, BranchManager branchManager)
 {
     if (ilg.IsTemp)
     {
         branchManager.AddBranch(ilg, trueTerminal);
         ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
     }
     else if (branchManager.IsLongBranch(ilg, trueTerminal) == false)
     {
         ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
     }
     else
     {
         ilg.Emit(OpCodes.Brtrue, trueTerminal);
     }
 }
Exemple #9
0
		private static void EmitBranchToTrueTerminal(FleeILGenerator ilg, Label trueTerminal, BranchManager bm)
		{
			if (ilg.IsTemp == true) {
				bm.AddBranch(ilg, trueTerminal);
				ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
			} else if (bm.IsLongBranch(ilg, trueTerminal) == false) {
				ilg.Emit(OpCodes.Brtrue_S, trueTerminal);
			} else {
				ilg.Emit(OpCodes.Brtrue, trueTerminal);
			}
		}
Exemple #10
0
		private void EmitConditional(FleeILGenerator ilg, IServiceProvider services, BranchManager bm)
		{
			var falseLabel = bm.FindLabel("falseLabel");
			var endLabel = bm.FindLabel("endLabel");

			// Emit the condition
			MyCondition.Emit(ilg, services);

			// On false go to the false operand
			if (ilg.IsTemp == true) {
				bm.AddBranch(ilg, falseLabel);
				ilg.Emit(OpCodes.Brfalse_S, falseLabel);
			} else if (bm.IsLongBranch(ilg, falseLabel) == false) {
				ilg.Emit(OpCodes.Brfalse_S, falseLabel);
			} else {
				ilg.Emit(OpCodes.Brfalse, falseLabel);
			}

			// Emit the true operand
			MyWhenTrue.Emit(ilg, services);
			ImplicitConverter.EmitImplicitConvert(MyWhenTrue.ResultType, MyResultType, ilg);

			// Jump to end
			if (ilg.IsTemp == true) {
				bm.AddBranch(ilg, endLabel);
				ilg.Emit(OpCodes.Br_S, endLabel);
			} else if (bm.IsLongBranch(ilg, endLabel) == false) {
				ilg.Emit(OpCodes.Br_S, endLabel);
			} else {
				ilg.Emit(OpCodes.Br, endLabel);
			}

			bm.MarkLabel(ilg, falseLabel);
			ilg.MarkLabel(falseLabel);

			// Emit the false operand
			MyWhenFalse.Emit(ilg, services);
			ImplicitConverter.EmitImplicitConvert(MyWhenFalse.ResultType, MyResultType, ilg);
			// Fall through to end
			bm.MarkLabel(ilg, endLabel);
			ilg.MarkLabel(endLabel);
		}