public async Task <ActionResult> Edit([Bind(Include = "ID,Title,ImageFile,ImageSize,Description,LastEdit")] OfType ofType, HttpPostedFileBase imgFile) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = Path.GetFileName(imgFile.FileName); double imgSize = imgFile.ContentLength; string imgToPath = Path.Combine(Server.MapPath("~/Content/Uploads/Types"), imgName); if (!System.IO.File.Exists(imgToPath)) { // Delete previously uploaded file System.IO.File.Delete(ofType.ImageFile); // Image file is uploaded imgFile.SaveAs(imgToPath); ofType.ImageFile = imgToPath; // New file size ofType.ImageSize = imgSize; } } db.Entry(ofType).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.LastEdit = DateTime.Now; return(View(ofType)); }
public async Task <IHttpActionResult> PutOfType(int id, OfType ofType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ofType.ID) { return(BadRequest()); } db.Entry(ofType).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Enable(bool enable, OfType type) { GetComponent <CanvasGroup>().DOFade(enable ? 1f : .3f, .3f); selectable = enable; normalText.SetActive(false); ctrlText.SetActive(false); shiftText.SetActive(false); switch (type) { case OfType.Normal: normalText.SetActive(enable); break; case OfType.Ctrl: ctrlText.SetActive(enable); break; case OfType.Shift: shiftText.SetActive(enable); break; default: break; } if (!enable) { FadeTextBox(false); } }
private static OfType GetOfType(Type type) { if (!Cache.TryGetValue(type, out OfType ofType)) { ofType = new OfType(type); Cache.TryAdd(type, ofType); } return(ofType); }
public async Task <IHttpActionResult> GetOfType(int id) { OfType ofType = await db.OfTypes.FindAsync(id); if (ofType == null) { return(NotFound()); } return(Ok(ofType)); }
public async Task <IHttpActionResult> PostOfType(OfType ofType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OfTypes.Add(ofType); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = ofType.ID }, ofType)); }
public async Task <ActionResult> DeleteConfirmed(int id) { OfType ofType = await db.OfTypes.FindAsync(id); db.OfTypes.Remove(ofType); await db.SaveChangesAsync(); // Check for associated image file if exists then delete it if (System.IO.File.Exists(ofType.ImageFile)) { System.IO.File.Delete(ofType.ImageFile); } return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> DeleteOfType(int id) { OfType ofType = await db.OfTypes.FindAsync(id); if (ofType == null) { return(NotFound()); } db.OfTypes.Remove(ofType); await db.SaveChangesAsync(); return(Ok(ofType)); }
// GET: OfTypes/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OfType ofType = await db.OfTypes.FindAsync(id); if (ofType == null) { return(HttpNotFound()); } return(View(ofType)); }
// GET: OfTypes/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OfType ofType = await db.OfTypes.FindAsync(id); if (ofType == null) { return(HttpNotFound()); } ViewBag.LastEdit = DateTime.Now; return(View(ofType)); }
private void EnableKeys(bool enable, OfType type) { DisableAllKeys(); switch (type) { case OfType.Ctrl: for (int i = 0; i < keys.Length; i++) { if (keys[i].selectableCtrl) { keys[i].Enable(enable, type); } } break; case OfType.Shift: for (int i = 0; i < keys.Length; i++) { if (keys[i].selectableShift) { keys[i].Enable(enable, type); } } break; default: break; } if (!showShift && !showCtrl) { for (int i = 0; i < keys.Length; i++) { if (keys[i].selectableNormal) { keys[i].Enable(true, OfType.Normal); } } } }
public async Task <ActionResult> Create([Bind(Include = "ID,Title,ImageFile,ImageSize,Description,LastEdit")] OfType ofType, HttpPostedFileBase imgFile) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = Path.GetFileName(imgFile.FileName); double imgSize = imgFile.ContentLength; string imgToPath = Path.Combine(Server.MapPath("~/Content/Uploads/SubTypes"), imgName); // Image file is uploaded imgFile.SaveAs(imgToPath); ofType.ImageFile = imgToPath; // New file size ofType.ImageSize = imgSize; } db.OfTypes.Add(ofType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ofType)); }
/// <summary> /// Gets a function capable of performing this <see cref="BinaryComparison"/> /// </summary> public Func <T, T, bool> GetEvaluator <T>() => OfType <T> .GetFunc(Type);
/// <summary> /// Evaluates the specified <paramref name="left"/> and <paramref name="right"/> according to this <see cref="BinaryComparison"/> /// </summary> public bool Evaluate <T>(T left, T right) => OfType <T> .GetFunc(Type)(left, right);
public void ShowExample_Click(object sender, EventArgs e) { Form form = null; switch (((Button)sender).Name) { // LINQ Dynamic | Restriction Operators case "uiROWhere": form = new Where(); break; // LINQ Dynamic | Projection Operators case "uiPOSelect": form = new Select(); break; case "uiPOSelectMany": form = new SelectMany(); break; // LINQ Dynamic | Aggregate Operators case "uiAOMin": form = new Min(); break; case "uiAOMax": form = new Max(); break; case "uiAOSum": form = new Sum(); break; case "uiAOCount": form = new Count(); break; case "uiAOAverage": form = new Average(); break; case "uiAOAggregate": form = new Aggregate(); break; // LINQ Dynamic | Query Execution case "uiQEDeferredExecution": form = new DeferredExecution(); break; case "uiQEQueryReuse": form = new QueryReuse(); break; case "uiQEImmediateExecution": form = new ImmediateExecution(); break; // LINQ Dynamic | Join Operators case "uiJOCrossJoin": form = new CrossJoin(); break; case "uiJOGroupJoin": form = new GroupJoin(); break; case "uiJOCrossWithGroupJoin": form = new CrossJoinwithGroupJoin(); break; case "uiJOLeftOuterJoin": form = new LeftOuterJoin(); break; // LINQ Dynamic | Set Operators case "uiSODistinct": form = new Distinct(); break; case "uiSOExcept": form = new Except(); break; case "uiSOIntersect": form = new Intersect(); break; case "uiSOUnion": form = new Union(); break; // LINQ Dynamic | Element Operators case "uiEOElementAt": form = new ElementAt(); break; case "uiEOFirst": form = new First(); break; case "uiEOFirstDefault": form = new FirstOrDefault(); break; // LINQ Dynamic | Custom Sequence Operators case "uiCSOCombine": form = new Combine(); break; // LINQ Dynamic | Quantifiers case "uiQuantifiersAll": form = new All(); break; case "uiQuantifiersAny": form = new Any(); break; // LINQ Dynamic | Grouping Operators case "uiGOGroupBy": form = new GroupBy(); break; // LINQ Dynamic | Miscellaneous Operators case "uiMOConcat": form = new Concat(); break; case "uiMOEqualAll": form = new EqualAll(); break; // LINQ Dynamic | Generation Operators case "uiGORepeat": form = new Repeat(); break; case "uiGORange": form = new Range(); break; // LINQ Dynamic | Ordering Operators case "uiOOOrderBy": form = new OrderBy(); break; case "uiOOThenBy": form = new ThenBy(); break; case "uiOOThenByDescending": form = new ThenByDescending(); break; case "uiOOOrderByDescending": form = new OrderByDescending(); break; case "uiOOReverse": form = new Reverse(); break; // LINQ Dynamic | Conversion Operators case "uiCOOfType": form = new OfType(); break; case "uiCOToArray": form = new ToArray(); break; case "uiCOToDictionary": form = new ToDictionary(); break; case "uiCOToList": form = new ToList(); break; // LINQ Dynamic | Partitioning Operators case "uiPOTake": form = new Take(); break; case "uiPOTakeWhile": form = new TakeWhile(); break; case "uiPOSkip": form = new Skip(); break; case "uiPOSkipWhile": form = new SkipWhile(); break; } form.StartPosition = FormStartPosition.CenterParent; form.ShowDialog(); }
public void CreateDataAndIterateSession(int numObj) { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); UInt32 dbNum = session.DatabaseNumberOf(typeof(NotSharingPage)); Database db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA)); db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); UInt32 dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); Placement place = new Placement(dbNum, 100); for (int i = 0; i < numObj; i++) { NotSharingPage ns = new NotSharingPage(); session.Persist(ns); SharingPageTypeA sA = new SharingPageTypeA(); session.Persist(sA); SharingPageTypeB sB = new SharingPageTypeB(); if (i % 5 == 0) { sB.Persist(session, place); } else if (i % 1001 == 0) { sB.Persist(session, sA); } else if (i % 3001 == 0) { sB.Persist(session, ns); } else { session.Persist(sB); } } session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); UInt32 dbNum = session.DatabaseNumberOf(typeof(NotSharingPage)); Database db = session.OpenDatabase(dbNum); AllObjects <NotSharingPage> all = session.AllObjects <NotSharingPage>(true, false); OfType all2 = session.OfType(typeof(NotSharingPage), true, false); dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA)); Database dbA = session.OpenDatabase(dbNum); dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); Database dbB = session.OpenDatabase(dbNum); AllObjects <SharingPageTypeA> allA = session.AllObjects <SharingPageTypeA>(true, false); AllObjects <SharingPageTypeB> allB = session.AllObjects <SharingPageTypeB>(true, false); int start = numObj / 2; NotSharingPage ns = all.ElementAt(numObj); NotSharingPage ns2 = (NotSharingPage)all2.ElementAt(numObj); Assert.AreEqual(ns, ns2); SharingPageTypeA sA = allA.ElementAt(15); SharingPageTypeB sB = allB.ElementAt(10); for (int i = start; i < numObj; i++) { ns = all.ElementAt(i); } //for (int i = start; i < numObj; i++) // ns = all.Skip(i).T //for (int i = start; i < numObj; i++) // sA = allA.ElementAt(i); all.Skip(100); all2.Skip(100); for (int i = start; i < numObj; i += 5) { ns = all.ElementAt(i); ns2 = (NotSharingPage)all2.ElementAt(i); Assert.AreEqual(ns, ns2); } for (int i = 5; i < 100; i += 5) { sB = allB.ElementAt(i); } for (int i = 0; i < numObj; i += 45000) { ns = all.ElementAt(i); } session.Commit(); session.BeginUpdate(); session.DeleteDatabase(db); session.DeleteDatabase(dbA); session.DeleteDatabase(dbB); session.Commit(); } }
public void CreateDataAndIterateDb(int numObj) { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.Verify(); session.Commit(); session.BeginUpdate(); UInt32 dbNum = session.DatabaseNumberOf(typeof(NotSharingPage)); Database db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA)); db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); db = session.OpenDatabase(dbNum, true, false); if (db != null) { session.DeleteDatabase(db); } session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.Verify(); session.Commit(); session.BeginUpdate(); UInt32 dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); Placement place = new Placement(dbNum, 100); for (int i = 0; i < numObj; i++) { NotSharingPage ns = new NotSharingPage(); session.Persist(ns); SharingPageTypeA sA = new SharingPageTypeA(); session.Persist(sA); SharingPageTypeB sB = new SharingPageTypeB(); if (i % 5 == 0) { sB.Persist(session, place); } else if (i % 1001 == 0) { sB.Persist(session, sA); } else if (i % 3001 == 0) { sB.Persist(session, ns); } else { session.Persist(sB); } } session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.Verify(); UInt32 dbNum = session.DatabaseNumberOf(typeof(NotSharingPage)); Database db = session.OpenDatabase(dbNum); AllObjects <NotSharingPage> all = db.AllObjects <NotSharingPage>(); int ct = all.Count(); dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA)); OfType ofType = db.OfType(typeof(NotSharingPage)); int ct2 = (int)ofType.Count; Assert.AreEqual(ct, ct2); Database dbA = session.OpenDatabase(dbNum); dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB)); Database dbB = session.OpenDatabase(dbNum); AllObjects <SharingPageTypeA> allA = dbA.AllObjects <SharingPageTypeA>(); AllObjects <SharingPageTypeB> allB = dbB.AllObjects <SharingPageTypeB>(); OfType allA2 = dbA.OfType(typeof(SharingPageTypeA)); int start = numObj / 2; NotSharingPage ns = all.ElementAt(numObj); SharingPageTypeA sA = allA.ElementAt(numObj); SharingPageTypeA sA2 = (SharingPageTypeA)allA2.ElementAt(numObj); Assert.AreEqual(sA, sA2); sA = allA.ElementAt(10); sA2 = (SharingPageTypeA)allA2.ElementAt(10); Assert.AreEqual(sA, sA2); //MethodInfo method = typeof(Database).GetMethod("AllObjects"); //MethodInfo generic = method.MakeGenericMethod(sA.GetType()); //dynamic itr = generic.Invoke(dbA, new object[]{ true }); //SharingPageTypeA sAb = itr.ElementAt(numObj); //Assert.AreEqual(sA, sAb); //SharingPageTypeA sAc = itr.ElementAt(numObj); SharingPageTypeB sB = allB.ElementAt(numObj); List <NotSharingPage> notSharingPageList = all.Skip(100).ToList(); List <SharingPageTypeA> sharingPageTypeA = allA.Take(5).Skip(100).ToList(); for (int i = start; i < numObj; i++) { sA = allA.ElementAt(i); } for (int i = start; i < numObj; i += 5) { ns = all.ElementAt(i); } for (int i = start; i < numObj; i += 5) { sB = allB.ElementAt(i); } for (int i = 0; i < numObj; i += 45000) { ns = all.ElementAt(i); } int allB_count = allB.Count(); for (int i = 0; i < allB_count - 1; i++) { Assert.NotNull(allB.ElementAt(i)); } session.Commit(); session.BeginUpdate(); session.DeleteDatabase(db); session.DeleteDatabase(dbA); session.DeleteDatabase(dbB); session.Commit(); } }
/// <summary> /// Gets an expression representing this <see cref="BinaryComparison"/> /// </summary> public Expression <Func <T, T, bool> > GetExpression <T>() => OfType <T> .GetExpression(Type);
public virtual void SetChild(SourceStruct srcStruct) { throw new InvalidOperationException($"Can't set child for a 'SourceStruct Object -must be a SourceContainer!\nThis object: {this}, of type: {OfType.ToString()}"); }
public static void CreateFilter(object sender, object selectedItem) { if (selectedItem is FilterCollectionViewModel filterCollectionViewModel) { CreateFilter(sender, filterCollectionViewModel.Parent); return; } var button = (Button)sender; var type = (string)button.CommandParameter; FilterBase entity; switch (type) { case nameof(ActiveOn): entity = ActiveOn.New("0001-01-01"); break; case nameof(ActiveWithin): entity = ActiveWithin.New("0001-01-01,0001-01-01"); break; case nameof(OfType): entity = OfType.New("TypeName"); break; case nameof(NotOfType): entity = NotOfType.New("TypeName"); break; case nameof(Contain): entity = Contain.New("Property", "Value"); break; case nameof(NotContain): entity = NotContain.New("Property", "Value"); break; case nameof(EqualTo): entity = EqualTo.New("Property", "Value"); break; case nameof(NotEqualTo): entity = NotEqualTo.New("Property", "Value"); break; case nameof(GreaterThan): entity = GreaterThan.New("Property", "Value"); break; case nameof(LessThan): entity = LessThan.New("Property", "Value"); break; case nameof(GreaterThanEqualTo): entity = GreaterThanEqualTo.New("Property", "Value"); break; case nameof(LessThanEqualTo): entity = LessThanEqualTo.New("Property", "Value"); break; case nameof(Between): entity = Between.New("Property", "0001-01-01", "0001-01-01"); break; case nameof(WithinArray): entity = WithinArray.New("Property", "ValueA,ValueB,ValueC"); break; case nameof(NotWithinArray): entity = NotWithinArray.New("Property", "ValueA,ValueB,ValueC"); break; case nameof(IsNull): entity = IsNull.New("Property"); break; case nameof(IsNotNull): entity = IsNotNull.New("Property"); break; case nameof(IsNullOrGreaterThan): entity = IsNullOrGreaterThan.New("Property", "Value"); break; case nameof(IsNullOrGreaterThanEqualTo): entity = IsNullOrGreaterThanEqualTo.New("Property", "Value"); break; case nameof(IsNullOrLessThan): entity = IsNullOrLessThan.New("Property", "Value"); break; case nameof(IsNullOrLessThanEqualTo): entity = IsNullOrLessThanEqualTo.New("Property", "Value"); break; case nameof(StartsWith): entity = StartsWith.New("Property", "Value"); break; case nameof(EndsWith): entity = EndsWith.New("Property", "Value"); break; case nameof(TakeFirst): entity = TakeFirst.New(1); break; case nameof(OfDerivedType): entity = OfDerivedType.New("TypeName"); break; case nameof(NotOfDerivedType): entity = NotOfDerivedType.New("TypeName"); break; default: throw new ArgumentOutOfRangeException(); } FilterViewModel viewModel; FilterCollectionViewModel viewModelCollection; if (selectedItem is GroupViewModel entityGroupViewModel) { entityGroupViewModel.IsExpanded = true; entityGroupViewModel.Element.Filters.Add(entity); viewModelCollection = entityGroupViewModel.Children.OfType <FilterCollectionViewModel>().First(); viewModel = new FilterViewModel(entity, viewModelCollection); viewModelCollection.Children.Add(viewModel); } else if (selectedItem is OutputViewModel outputViewModel) { if (!(outputViewModel.Element is AggregateOutputBase elementAsAggregate)) { return; } outputViewModel.IsExpanded = true; elementAsAggregate.Filters.Add(entity); viewModelCollection = outputViewModel.Children.OfType <FilterCollectionViewModel>().First(); viewModel = new FilterViewModel(entity, viewModelCollection); viewModelCollection.Children.Add(viewModel); } else { return; } viewModelCollection.IsExpanded = true; viewModel.IsSelected = true; viewModel.IsExpanded = true; }
public override string ToString() { return($"SourceObject: Type-{OfType.ToString()}, Text-{Text}"); }
public static ILotData GetLotData(string lotId, IList<ICassette> cassettes, int nGWaferCount, WaferSize wafesize, OfType ofType, PolishDivision isRepolishing, int assembly1CarrierPlateCount, int assembly1WaferCount, int assembly2CarrierPlateCount, int assembly2WaferCount, IList<IWafer> wafers) { var lotData = new Mock<ILotData>(); lotData.Setup(x => x.LotId).Returns(lotId); lotData.Setup(x => x.Cassettes).Returns(cassettes); lotData.Setup(x => x.NGWaferCount).Returns(nGWaferCount); lotData.Setup(x => x.WaferSize).Returns(wafesize); lotData.Setup(x => x.OfType).Returns(ofType); lotData.Setup(x => x.PolishDivision).Returns(isRepolishing); lotData.Setup(x => x.Assembly1.CarrierPlateCount).Returns(assembly1CarrierPlateCount); lotData.Setup(x => x.Assembly1.WaferCount).Returns(assembly1WaferCount); lotData.Setup(x => x.Assembly2.CarrierPlateCount).Returns(assembly2CarrierPlateCount); lotData.Setup(x => x.Assembly2.WaferCount).Returns(assembly2WaferCount); lotData.Setup(x => x.Wafers).Returns(wafers); return lotData.Object; }