public void Parse_Five_5() { var str = new Constant("5"); var parsed = new Apply(Funcs.Parse, str).Specialize(Typs.Double); var o = parsed.Evaluate(null); Assert.Equal(5d, o); }
public void Given_expression_is_updated_with_simple_equality_check_Then_it_should_return_changed_expression() { Expression <Func <ExampleModel, bool> > expected = x => x.Name == x.Surname.Substring(x.Surname.Length - 2); var result = Generate <ExampleModel> .Expression(x => x.Name == Apply.This(x.Surname, ExampleExpressions.TwoLastChars)); result.ShouldBeEquivalentToExpression(expected); }
public void For_with_action() { Expression <Func <TestController, object> > expression = x => x.ReturnPost(); TransientRegistration[] registrations = Apply.For(expression).ConstraintRegistrations; registrations.Length.ShouldEqual(1); registrations[0].ActionDescriptor.ActionName.ShouldEqual(expression.CreateActionDescriptor().ActionName); }
public void AddNewApply(Apply apply) { apply.Recover(Users, Vacancies); apply.Vacancy.Applies.Add(apply); Applies.Add(apply); SaveConfig(); OnVacanciesChanged?.Invoke(); }
public static void Delete(Apply entity) { ISession session = SessionFactory.OpenSession(); { session.Delete(entity); session.Flush(); } }
public void ApplyDefaultFunctionWithId_ApplicationIsSuccessfull() { var e = new Apply(new Apply(Funcs.Default, new Constant("a")), Funcs.Id); Assert.Single(e.Types); Assert.Equal("string -> string", e.Types.First().ToString()); }
public ActionResult Apply(Apply apply) { apply.UserID = User.Identity.Name; apply.DateCreated = DateTime.Now; //apply. var result = siteService.InsertApply(apply); return(Json(result)); }
public void SpecializeToSmallest_IsSmallestType() { var app = new Apply(Funcs.Id, Funcs.Parse); Assert.Equal(2, app.Types.Count()); var smaller = app.SpecializeToSmallestType(); Assert.Single(smaller.Types); }
public ApplySv(int applyId) { try { ap = db.Apply.Single(a => a.id == applyId); } catch { throw new Exception("申请ID号不存在"); } }
public ApplySv(string sysNo) { try { ap = db.Apply.Single(a => a.sys_no == sysNo); } catch { throw new Exception("申请流水号不存在"); } }
public void ErrorWhenFetchingInstallations2() { var testError = new TestError("Error when fetching installations"); HomeModel.FetchVmItems .Apply(i => throw new Exception("Should not call this function")) .Apply(l => testError) (new Location(50.062006, 19.940984)).Match( error => Assert.Fail("Should match Right"), tuple => { var(errors, measurementVmItems) = tuple; Assert.AreEqual(testError, errors.First()); Assert.AreEqual(1, errors.Count); Assert.IsEmpty(measurementVmItems); } ); }
public void Securing_a_specific_action_for_a_role() { FluentMvcConfiguration.Create() .WithConvention(new MvcConvention()) .WithFilter(new AuthorizeAttribute { Roles = "Role" }, Apply.For <TestController>(tc => tc.ReturnPost())) .BuildFilterProvider(); }
public ComponentSyncRibbonDropDown() { AssignId = "CompSyncRibbonToolbar"; Group = "ComponentSyncGroup.ascx"; Name = "Component Synchronizer"; PageId = Constants.PageIds.HomePage; Dependencies.Add <ComponentSyncResourceGroup>(); Apply.ToView(Constants.Views.DashboardView, "DashboardToolbar"); }
public static ExtractedApplication GenerateExtractedApplication(Apply application, DateTime extractedDate) { return(new ExtractedApplication { ApplicationId = application.ApplicationId, ExtractedDate = extractedDate, Apply = application }); }
public async Task <ActionResult> DeleteConfirmed(int id) { Apply apply = await db.Applies.FindAsync(id); db.Applies.Remove(apply); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task GetOverviewViewModel_returns_model() { var applyData = new ApplyData { ApplyDetails = new ApplyDetails { UKPRN = Ukprn, OrganisationName = OrganisationName } }; var application = new Apply { ApplicationId = _applicationId, ApplyData = applyData, GatewayReviewStatus = GatewayReviewStatus.InProgress }; var contactDetails = new ContactDetails { Email = Email }; _applyApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(application); _applyApiClient.Setup(x => x.GetOversightDetails(_applicationId)).ReturnsAsync(() => new ApplicationOversightDetails { OversightStatus = OversightReviewStatus.None }); _applyApiClient.Setup(x => x.GetContactDetails(_applicationId)).ReturnsAsync(contactDetails); const string sectionReviewStatus = SectionReviewStatus.Pass; const string comment = "comments go here"; var returnedGatewayPageAnswers = new List <GatewayPageAnswerSummary> { new GatewayPageAnswerSummary { ApplicationId = _applicationId, PageId = GatewayPageIds.OrganisationRisk, Status = sectionReviewStatus, Comments = comment } }; _applyApiClient.Setup(x => x.GetGatewayPageAnswers(_applicationId)).ReturnsAsync(returnedGatewayPageAnswers); var gatewayReviewStatus = GatewayReviewStatus.InProgress; var request = new GetApplicationOverviewRequest(_applicationId, UserName); var viewModel = await _orchestrator.GetOverviewViewModel(request); Assert.AreEqual(_applicationId, viewModel.ApplicationId); Assert.AreEqual(viewModel.ApplicationEmailAddress, Email); Assert.AreEqual(Ukprn, viewModel.Ukprn); Assert.AreEqual(OrganisationName, viewModel.OrganisationName); Assert.AreEqual(gatewayReviewStatus, viewModel.GatewayReviewStatus); Assert.AreEqual(sectionReviewStatus, viewModel.Sequences.FirstOrDefault(seq => seq.SequenceNumber == 1).Sections.FirstOrDefault(sec => sec.PageId == GatewayPageIds.OrganisationRisk).Status); Assert.AreEqual(false, viewModel.IsClarificationsSelectedAndAllFieldsSet); }
public override void OnApply(Apply apply) { var dt = apply.Block.TryFindTypeParent(); if (dt != null) { // TODO: Give some warnings } }
public async Task GetClarificationViewModel_returns_model() { var applyData = new ApplyData { ApplyDetails = new ApplyDetails { UKPRN = Ukprn, OrganisationName = OrganisationName } }; var returnedRoatpApplicationResponse = new Apply { ApplicationId = _applicationId, ApplyData = applyData, GatewayReviewStatus = GatewayReviewStatus.InProgress }; var contactDetails = new ContactDetails { Email = Email }; _applyApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(returnedRoatpApplicationResponse); _applyApiClient.Setup(x => x.GetContactDetails(_applicationId)).ReturnsAsync(contactDetails); const string status = SectionReviewStatus.Clarification; const string comment = "comments go here"; var returnedGatewayPageAnswers = new List <GatewayPageAnswerSummary> { new GatewayPageAnswerSummary { ApplicationId = _applicationId, PageId = GatewayPageIds.OrganisationRisk, Status = status, Comments = comment } }; _applyApiClient.Setup(x => x.GetGatewayPageAnswers(_applicationId)).ReturnsAsync(returnedGatewayPageAnswers); var request = new GetApplicationClarificationsRequest(_applicationId, UserName); var viewModel = await _orchestrator.GetClarificationViewModel(request); Assert.AreEqual(_applicationId, viewModel.ApplicationId); Assert.AreEqual(Email, viewModel.ApplicationEmailAddress); Assert.AreEqual(Ukprn, viewModel.Ukprn); Assert.AreEqual(OrganisationName, viewModel.OrganisationName); Assert.AreEqual(1, viewModel.Sequences.Count); Assert.AreEqual("Organisation checks", viewModel.Sequences[0].SequenceTitle); Assert.AreEqual(1, viewModel.Sequences[0].Sections.Count); Assert.AreEqual("Organisation high risk", viewModel.Sequences[0].Sections[0].PageTitle); Assert.AreEqual(comment, viewModel.Sequences[0].Sections[0].Comment); }
public async Task <IActionResult> PutApply(int id, Apply apply) { if (id != apply.Id) { return(BadRequest()); } Apply result = await _appliesRepository.PutApplyAsync(id, apply); return(result != null?Ok(result) : (IActionResult)BadRequest()); }
public ContextMenu() { AssignId = ""; Name = ""; InsertBefore = "cm_whereused"; AddItem("alch_countitems", Resources.ContextMenuEntry, "CountItems"); Dependencies.Add <ButtonGroup>(); Apply.ToView(Constants.Views.DashboardView); }
public override void Given() { Expression <Func <ControllerWithOverloadedActions, object> > registeredAction = c => c.OverloadedAction(default(Model)); actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>()); FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()) .WithFilter <TestActionFilter>(Apply.For(registeredAction)) .BuildFilterProvider(); }
public static object Add(Apply entity) { entity.Serial = GetLatestSerial(); ISession session = SessionFactory.OpenSession(); { var id = session.Save(entity); session.Flush(); return(id); } }
public void loginAndApply() { Login login = new Login(form1, this); if (login.loginT() == 1) { Apply apply = new Apply(form1, this); apply.startProbe(); } }
public override void Given() { Expression <Func <TestController, object> > func = c => c.ReturnPost(); actionDescriptor = func.CreateActionDescriptor(); actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>()); Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()) .WithFilter <TestActionFilter>() .WithFilter <AuthorizeAttribute>(Apply.For <SecondTestController>()); }
public IActionResult Update(Apply apply) { var result = _applyService.Update(apply); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public ActionResult Edit([Bind(Include = "Id,ApplyStatus")] Apply apply) { if (ModelState.IsValid) { db.Entry(apply).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(apply)); }
protected void Page_Load(object sender, EventArgs e) { int recordID = Convert.ToInt32(Request["RecordID"]); int applyID = Convert.ToInt32(Request["ApplyID"]); bool rejected = Convert.ToBoolean(Request["rejected"]); Apply ap = Apply.GetApplyByID(applyID); SalaryApply si = SalaryApply.GetSalaryApplyByID(recordID); if (!IsPostBack) { salaryList.Text = transResult(si.StaffSalaryList, ref allCash); } //用户权限相关显示功能 Users usr = (Users)Session["Identify"]; BasicInfo info = BasicInfo.GetBasicInfoByID(usr.UserID); if (!rejected && ap.NextApprover == si.StaffName) { agreeButton.Visible = false; disagreeButton.Visible = false; cashierButton.Visible = false; rejectButton.Visible = false; whyDisagree.Visible = false; //可打印状态 proManager.Text = "已签字"; depManager.Text = "已签字"; financial.Text = "已签字"; company.Text = "已签字"; } else if (info.StaffName.Trim() == si.StaffName.Trim() || info.Position.Trim() == "出纳") { agreeButton.Visible = false; disagreeButton.Visible = false; if (info.Position.Trim() != "出纳") { cashierButton.Visible = false; rejectButton.Visible = false; whyDisagree.Visible = false; } } else if (info.Position.Trim() == "会计") { cashierButton.Visible = false; rejectButton.Visible = false; } else { cashierButton.Visible = false; rejectButton.Visible = false; } //测试阶段保持处理流程可见,运行阶段记得去掉 processShow.Visible = true; }
private void ChangeSelection() { if (Exit.IsFocused) { Apply.Focus(); } else { Exit.Focus(); } }
public void OnCompleted(ExecutingContext executeContext) { //以下代码仅用于演示 //流程结束(在完成事件中可以做业务操作) ApplyService applyService = new ApplyService(); Apply model = applyService.GetInstanceByInstanceID(executeContext.Instance.InstanceID); model.STATUS = 8; applyService.Persistent(model); new PendingService().Delete(executeContext.Instance.InstanceID); }
public PluginContextMenuExtension() { AssignId = ""; InsertBefore = Constants.ContextMenuIds.MainContextMenu.Refresh; AddItem("pub_summary_cm", "Published Summary", "PublishedSummary"); Dependencies.Add <PluginResourceGroup>(); Apply.ToView(Constants.Views.DashboardView); }
/// <summary> /// Constructor that takes a spell argument to create an affect and set its paramters. /// </summary> /// <param name="type"></param> /// <param name="name"></param> /// <param name="duration"></param> /// <param name="location"></param> /// <param name="modifier"></param> /// <param name="bitvector"></param> public Affect(AffectType type, string name, int duration, Apply location, int modifier, Bitvector bitvector) { _modifiers = new List<AffectApplyType>(); _value = name; _type = type; _duration = duration; AffectApplyType apply = new AffectApplyType(); apply.Amount = modifier; apply.Location = location; _modifiers.Add(apply); SetBitvector(bitvector); }
protected internal virtual void TraverseApply(Apply apply) { apply.Unsupported(); }
protected internal virtual Node TransformApply(Apply apply) { return apply.AcceptTransformer(this, true); }
protected internal override void TraverseApply(Apply apply) { Dispatch(apply); }
private void Process(Call call) { var m = call.Method; // the line below is necessary because // sometimes csc emits callvirt when calling non-virtual methods var virt = call.IsVirtual && m.IsVirtual(); var style = virt ? InvocationStyle.Virtual : InvocationStyle.NonVirtual; var p = m.EnclosingProperty(); if (p == null) { var getTypeFromHandle = typeof(Type).GetMethod("GetTypeFromHandle", new []{typeof(RuntimeTypeHandle)}); if (m == getTypeFromHandle && _args.First() is Const) { var typeHandle = _args.First().AssertCast<Const>().Value.AssertCast<RuntimeTypeHandle>(); Push(new Const(m.Invoke(null, new Object[]{typeHandle}))); } var getMethodFromHandle1 = typeof(MethodBase).GetMethod("GetMethodFromHandle", new []{typeof(RuntimeMethodHandle)}); if (m == getMethodFromHandle1 && _args.First() is Const) { var methodHandle = _args.First().AssertCast<Const>().Value.AssertCast<RuntimeMethodHandle>(); Push(new Const(m.Invoke(null, new Object[]{methodHandle}))); } var getMethodFromHandle2 = typeof(MethodBase).GetMethod("GetMethodFromHandle", new []{typeof(RuntimeMethodHandle), typeof(RuntimeTypeHandle)}); if (m == getMethodFromHandle2 && _args.First() is Const && _args.Second() is Const) { var methodHandle = _args.First().AssertCast<Const>().Value.AssertCast<RuntimeMethodHandle>(); var typeHandle = _args.Second().AssertCast<Const>().Value.AssertCast<RuntimeTypeHandle>(); Push(new Const(m.Invoke(null, new Object[]{methodHandle, typeHandle}))); } var getFieldFromHandle1 = typeof(FieldInfo).GetMethod("GetFieldFromHandle", new []{typeof(RuntimeFieldHandle)}); if (m == getFieldFromHandle1 && _args.First() is Const) { var fieldHandle = _args.First().AssertCast<Const>().Value.AssertCast<RuntimeFieldHandle>(); Push(new Const(m.Invoke(null, new Object[]{fieldHandle}))); } var getFieldFromHandle2 = typeof(FieldInfo).GetMethod("GetFieldFromHandle", new []{typeof(RuntimeFieldHandle), typeof(RuntimeTypeHandle)}); if (m == getFieldFromHandle2 && _args.First() is Const && _args.Second() is Const) { var fieldHandle = _args.First().AssertCast<Const>().Value.AssertCast<RuntimeFieldHandle>(); var typeHandle = _args.Second().AssertCast<Const>().Value.AssertCast<RuntimeTypeHandle>(); Push(new Const(m.Invoke(null, new Object[]{fieldHandle, typeHandle}))); } if (m.DeclaringType.IsArray && m.Name == "Address") { var getter = m.DeclaringType.ArrayGetter(); Push(new Addr(new Eval(new Apply(new Lambda(getter, style), _args)))); } else if (m.DeclaringType.IsDelegate() && m.Name == "Invoke") { var app = new Apply(_firstArg, _args.Skip(1)); if (m.Ret() != typeof(void)) { Push(new Eval(app)); } else { Qualify(new Eval(app)); } } else { if (m.IsConstructor) { // note. ctor can be called via "call", but not via "newobj" in two cases: // 1) base/this constructor invocation within a constructor if (m.DeclaringType.IsClass) { Qualify(new Eval(new Apply(new Lambda(m, style), _args))); } // 2) constructor invocation for structs else { var @this = _firstArg.AssertCast<Addr>().Target; var ctor_call = new Eval(new Apply(new Lambda(m, InvocationStyle.Ctor), _args.Skip(1))); Qualify(new Assign(@this, ctor_call)); } } else { var app = new Apply(new Lambda(m, style), _args); if (m.Ret() != typeof(void)) { Push(new Eval(app)); } else { Qualify(new Eval(app)); } } } } else { var prop = new Prop(p, p.IsStatic() ? null : _args.First(), virt); if (m == p.GetGetMethod(true)) { var index = p.IsStatic() ? _args : _args.Skip(1); if (p.GetIndexParameters().IsEmpty()) { index.AssertEmpty(); Push(prop); } else { Push(new Apply(prop, index)); } } else { (m == p.GetSetMethod(true)).AssertTrue(); var value = _args.Last(); var index = p.IsStatic() ? _args.SkipLast(1) : _args.Skip(1).SkipLast(1); if (p.GetIndexParameters().IsEmpty()) { index.AssertEmpty(); Qualify(new Assign(prop, value)); } else { Qualify(new Assign(new Apply(prop, index), value)); } } } }
protected override void TraverseApply(Apply apply) { var ass = apply.Parent as Assign; (ass != null && ass.Lhs == apply).AssertFalse(); var prop = apply.InvokedProp().AssertNotNull(); var getter = prop.Property.GetGetMethod(true); var @this = prop.Property.IsInstance() ? prop.This.MkArray() : Seq.Empty<Expression>(); var args = prop.InvocationIndexers() ?? Seq.Empty<Expression>(); var style = prop.InvokedAsVirtual ? InvocationStyle.Virtual : InvocationStyle.NonVirtual; var equiv = new Eval(new Apply(new Lambda(getter, style), @this.Concat(args))); Traverse(equiv); }
protected internal override Node TransformApply(Apply apply) { return Dispatch(apply); }
protected internal override void TraverseApply(Apply apply) { if (apply.Callee is Prop) { var p = ((Prop)apply.Callee).Property; if (p != null) { var m = (apply.Parent is Assign) ? p.GetSetMethod(true) : p.GetGetMethod(true); // classify var hasThis = p.IsInstance() || p.IsExtension(); var isIndexer = p.IsIndexer(); var isDefaultIndexer = p.IsDefaultIndexer(); var displayName = isDefaultIndexer ? null : isIndexer ? ((Func<String>)(() => { if (p.HasAttr<IndexerNameAttribute>()) { var inaCtor = typeof(IndexerNameAttribute).GetConstructor(typeof(String).MkArray()); (inaCtor.GetParameters().AssertSingle().Name == "indexerName").AssertTrue(); var inaCad = CustomAttributeData.GetCustomAttributes(p).Single(cad => cad.Constructor == inaCtor); var inaCarg = inaCad.ConstructorArguments.Single(); (inaCarg.ArgumentType == typeof(String)).AssertTrue(); return inaCarg.Value.AssertCast<String>(); } else { return p.Name; } }))() : p.Name; // qualifier // todo. support explicit interface implementation var target = apply.Callee.AssertCast<Prop>().This; if (hasThis) { Traverse(target); } else { target.AssertNull(); _writer.Write(p.DeclaringType.GetCSharpRef(ToCSharpOptions.Informative)); } // invocation if (!isDefaultIndexer) { var @this = ((Prop)apply.Callee).This; var t_this = @this.Type(); var is_ptr = t_this != null && t_this.IsPointer; _writer.Write(is_ptr ? "->" : "."); } _writer.Write(displayName); _writer.Write(m.GetCSharpTypeArgsClause(ToCSharpOptions.Informative)); _writer.Write("["); TraverseArgs(apply.ArgsInfo); _writer.Write("]"); } } else { // todo. return to this when lambdas decompilation is implemented _writer.Write(Syms.Lambda); } }
protected internal override void TraverseApply(Apply app) { Traverse(app.Callee); app.Args.ForEach(Traverse); var callee = app.Callee; if (callee is Lambda || callee is Apply) { var t_lam = Types[callee]; if (t_lam == null) Types.Add(app, null); else { var rest = t_lam.DasmFType().Skip(app.Args.Count()).ToReadOnly(); Types.Add(app, rest.AsmFType()); } } else if (callee is Prop) { var t_prop = Types[callee]; Types.Add(app, t_prop); } else { (app.Callee == null).AssertTrue(); Types.Add(app, null); } }