// GET: CONTENTTABLEs public ActionResult Index() { //cek session user yang login if (Session["userId"] == null) { return(RedirectToAction("Login", "USERTABLEs", new { area = "" })); } //cek role if (Session["userRole"].ToString() == "admin") { // role admin bisa melihat semua content tanpa batasan var cONTENTTABLEs = db.CONTENTTABLEs.Include(c => c.CONTENTTYPETABLE).Include(c => c.STATUSTABLE); return(View(cONTENTTABLEs.ToList())); } else { // role non-admin hanya bisa melihat content sesuai role yang dimilikinya var uss = Convert.ToInt32(Session["userId"]); var vv = from c in db.CONTENTTABLEs join cr in db.CONTENTROLEs on c.CONTENTID equals cr.CONTENTID join ur in db.USERROLEs on cr.ROLEID equals ur.ROLEID join u in db.USERTABLEs on ur.USERID equals u.USERID where ur.USERID == uss select c; var disc = Enumerable.Distinct(vv); var cONTENTTABLEs = from all in disc select all; return(View(cONTENTTABLEs.ToList())); } }
public async Task DistinctWithInt64SourceWithComparerIsEquivalentToDistinctTest() { // Arrange // Arrange 'queryAdapter' parameter var queryAdapter = await GetQueryAdapterAsync(DisallowAll); // Arrange 'source' parameter var source = GetQueryable <long>(); // Arrange 'asyncSource' parameter var asyncSource = queryAdapter.GetAsyncQueryable <long>(); // Arrange 'comparer' parameter var comparer = EqualityComparer <long> .Default; // Arrange 'expectedResult' parameter var expectedResult = Enumerable.Distinct <long>(source, comparer); // Act var result = await AsyncQueryable.Distinct <long>(asyncSource, comparer).ToListAsync().ConfigureAwait(false); // Assert Assert.Equal(expectedResult, result); }
private void Window_Activated(object sender, EventArgs e) { FileWatcher_ToUpdate = Enumerable.ToList(Enumerable.Distinct(FileWatcher_ToUpdate)); if (FileWatcher_ToUpdate.Count == 0 || FileWatcher_Updating) { return; } string str1 = "Following files has changed:\n"; foreach (RDAFile rdaFile in FileWatcher_ToUpdate) { str1 = str1 + rdaFile.FileName + "\n"; } string Message = str1 + "\nDo you want to update the RDA File Items?"; FileWatcher_Updating = true; if (MessageWindow.Show(Message, MessageWindow.MessageWindowType.YesNo) == MessageBoxResult.Yes) { foreach (RDAFile rdaFile in FileWatcher_ToUpdate) { string str2 = DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdaFile.FileName; string str3 = StringExtension.MakeUnique(Path.ChangeExtension(str2, null) + "$", Path.GetExtension(str2), (d => File.Exists(d))); File.Copy(str2, str3); rdaFile.SetFile(str3); } } FileWatcher_Updating = false; FileWatcher_ToUpdate.Clear(); }
public RationModel(List <ShipModel_BattleAll> ships_f, Dictionary <int, List <Mst_slotitem> > data) { this._ships = new List <ShipModel_Eater>(); this._shared = new List <ShipModel_Eater>(); for (int i = 0; i < ships_f.get_Count(); i++) { ShipModel_BattleAll shipModel_BattleAll = ships_f.get_Item(i); if (shipModel_BattleAll != null && data.ContainsKey(shipModel_BattleAll.TmpId)) { ShipModel_Eater shipModel_Eater = shipModel_BattleAll.__CreateEater__(); if (i > 0) { ShipModel_Eater shipModel_Eater2 = this._GetSharedShip(data, ships_f.get_Item(i - 1)); if (shipModel_Eater2 != null) { this._shared.Add(shipModel_Eater2); } } if (i < ships_f.get_Count() - 1) { ShipModel_Eater shipModel_Eater3 = this._GetSharedShip(data, ships_f.get_Item(i + 1)); if (shipModel_Eater3 != null) { this._shared.Add(shipModel_Eater3); } } this._ships.Add(shipModel_Eater); } } Enumerable.Distinct <ShipModel_Eater>(this._ships); }
private void UpdateData() { this.InternalReset(); if (this.PerfTable == null || this.VoltageTable == null) { return; } int num = 0; this._EntryControlList = new List <CE033>(); List <byte> list = Enumerable.ToList <byte>(Enumerable.Distinct <byte>(Enumerable.Select <Voltage, byte>(Enumerable.OrderBy <Voltage, byte>(Enumerable.Where <Voltage>(this.PerfTable.Voltages, e => !e.PE004), e => e.Caption), e => e.Index))); if (list == null) { return; } foreach (byte vid in list) { if (vid < this.VoltageTable.ListaVoltagens.Count) { VoltageEntry obj1 = this.VoltageTable.ListaVoltagens[vid]; CE033 obj2 = new CE033(); obj2.VoltageEntry = obj1; obj2.Left = 0; obj2.Top = num; obj2.Caption = this.GetCaption(vid); this.Controls.Add(obj2); this._EntryControlList.Add(obj2); num += obj2.Height; } } this.Enabled = true; }
internal override void UpdateValuesIfUndefined(IEnumerable <object> values) { if (this._dataSourceType != CategoryScale.DataSourceType.Series && (this.Categories.Count != 0 || this._dataSourceType == CategoryScale.DataSourceType.TreeSource)) { return; } this.BeginInit(); try { this.Categories.Clear(); foreach (object obj in Enumerable.Distinct <object>(values)) { if (obj != null) { this.Categories.Add(new Category() { Key = obj, Content = obj }); } } this._dataSourceType = CategoryScale.DataSourceType.Series; } finally { this.EndInit(); } }
protected void PanelInstitucii_Load(object sender, EventArgs e) { List <HelpClassWebServices> servicesPermissions = new WebservicesDAL().GetUsersWebServicesPermissions(true, (USER)this.Session["user"]); List <INSTITUTION> list = new List <INSTITUTION>(); foreach (long id in Enumerable.Distinct <long>(Enumerable.Select <HelpClassWebServices, long>((IEnumerable <HelpClassWebServices>)servicesPermissions, (Func <HelpClassWebServices, long>)(p => p.IDInstitution)))) { INSTITUTION byId = new InstitutionsDAL().GetByID(id); if (byId != null) { list.Add(byId); } } this.PanelInstitucii.Controls.Clear(); foreach (INSTITUTION institution in list) { Label label = new Label(); this.PanelInstitucii.Controls.Add((Control) new LiteralControl("<p>")); label.ID = "LabelInst" + (object)institution.ID; label.Text = institution.Tittle; label.CssClass = "lblpanelsinfo"; this.PanelInstitucii.Controls.Add((Control)label); LinkButton linkButton = new LinkButton(); linkButton.ID = "LinkInst" + (object)institution.ID; linkButton.Text = "Повеќе..."; linkButton.CssClass = "linkpanelsinfo"; linkButton.Click += new EventHandler(this.LinkInst_Click); this.PanelInstitucii.Controls.Add((Control)linkButton); this.PanelInstitucii.Controls.Add((Control) new LiteralControl("</p>")); } }
public Dictionary <int, List <Mst_item_shop> > GetMstCabinet() { IEnumerable <XElement> enumerable = Utils.Xml_Result(Mst_item_shop.tableName, Mst_item_shop.tableName, null); if (enumerable == null) { return(null); } var enumerable2 = Enumerable.Distinct(Enumerable.Select(Extensions.Elements <XElement>(enumerable, "Cabinet_no"), (XElement key) => new { no = int.Parse(key.get_Value()) })); Dictionary <int, List <Mst_item_shop> > dictionary = Enumerable.ToDictionary(enumerable2, key => key.no, val => new List <Mst_item_shop>()); using (IEnumerator <XElement> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { XElement current = enumerator.get_Current(); Mst_item_shop mst_item_shop = null; Model_Base.SetMaster <Mst_item_shop>(out mst_item_shop, current); dictionary.get_Item((int)mst_item_shop.Cabinet_no).Add(mst_item_shop); } } if (!Enumerable.Any <Mem_ship>(Comm_UserDatas.Instance.User_ship.get_Values(), (Mem_ship x) => x.Stype == 22)) { Mst_item_shop mst_item_shop2 = Enumerable.FirstOrDefault <Mst_item_shop>(dictionary.get_Item(1), (Mst_item_shop x) => x.Item1_id == 23); dictionary.get_Item(1).Remove(mst_item_shop2); } return(dictionary); }
public static IEnumerable <T> Distinct <T>(this IEnumerable <T> t, params Expression <Func <T, object> >[] e) { if (e.IsNullOrEmpty()) { return(Enumerable.Distinct(t)); } return(t.Distinct(new GeneralComparer <T>(e))); }
private void bindGridView() { //bizParamsList = Service.GetBizParamsList(); var groupNames = Enumerable.Distinct(from o in BizParamsList select o.GroupName); this.GridView1.DataSource = groupNames; this.GridView1.DataBind(); }
public GiftSendViewModel(long giftId, string categoryName, bool isProduct, string description, string imageUrl, int price, int giftsLeft, NavigationService navigationService, List <long> userIds) : this(giftId, categoryName, isProduct, description, imageUrl, price, giftsLeft, navigationService) { if (userIds == null) { return; } this._userIds.AddRange((IEnumerable <long>)Enumerable.Distinct <long>(userIds)); }
private static void RefreshAssembly() { if (BindingContext._assemblies == null) { BindingContext._assemblies = Enumerable.ToArray <Assembly>(Enumerable.OrderBy <Assembly, string>(Enumerable.Where <Assembly>(AppDomain.get_CurrentDomain().GetAssemblies(), (Assembly o) => !o.get_Location().Contains("Editor")), (Assembly o) => o.get_FullName())); BindingContext._modelTypes = Enumerable.ToArray <Type>(Enumerable.OrderBy <Type, string>(Enumerable.Where <Type>(Enumerable.SelectMany <Assembly, Type>(BindingContext._assemblies, (Assembly o) => o.GetTypes()), (Type o) => o.get_IsPublic()), (Type o) => o.get_Name())); BindingContext._namespaces = Enumerable.ToArray <string>(Enumerable.Distinct <string>(Enumerable.OrderBy <string, string>(Enumerable.Select <Type, string>(BindingContext._modelTypes, (Type o) => o.get_Namespace()), (string o) => o))); } }
private List <AnnotationSceneNode> ComputeReferencedAnnotations(IEnumerable <string> references) { ExceptionChecks.CheckNullArgument <IEnumerable <string> >(references, "referencesString"); return(Enumerable.ToList <AnnotationSceneNode>(Enumerable.Distinct <AnnotationSceneNode>(Enumerable.Select(Enumerable.Where(Enumerable.Join(this.Annotations, references, (Func <AnnotationSceneNode, string>)(annotation => annotation.Id), (Func <string, string>)(annoId => annoId), (annotation, annoId) => new { annotation = annotation, annoId = annoId }), param0 => param0.annotation.IsAttached), param0 => param0.annotation)))); }
// GET: CONTENTTABLEs/Delete/5 public ActionResult Delete(int?id) { //cek session login if (Session["userId"] == null) { return(RedirectToAction("Login", "USERTABLEs", new { area = "" })); } //cek parameter id if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //menyamakan role dari user dengan role dari content var uss = Convert.ToInt32(Session["userId"]); var konten = from c in db.CONTENTTABLEs join cr in db.CONTENTROLEs on c.CONTENTID equals cr.CONTENTID join ur in db.USERROLEs on cr.ROLEID equals ur.ROLEID where (ur.USERID == uss) & (cr.CONTENTID == id) select c; var disc = Enumerable.Distinct(konten); var hasil = from all in disc select all; if (hasil.Count() == 0) { //role dari konten dengan role dari user berbeda //kalau bukan admin tidak diperbolehkan, dilempar if (Session["userRole"].ToString() != "admin") { return(RedirectToAction("Index")); } } //cek kepemilikan content if (db.CONTENTTABLEs.Where(m => m.CONTENTID == id).Select(c => c.USERID).FirstOrDefault() != uss) { //kalau bukan admin ataupun konten tersebut miliknya, dilempar if (Session["userRole"].ToString() != "admin") { return(RedirectToAction("Index")); } } //cek id di database CONTENTTABLE cONTENTTABLE = db.CONTENTTABLEs.Find(id); if (cONTENTTABLE == null) { //id tidak ada di database return(HttpNotFound()); } return(View(cONTENTTABLE)); }
public FileResult Attachment(int?id) { //cek parameter id if (id == null) { return(null); } else { //ada id di parameternya var uss = Convert.ToInt32(Session["userId"]); var konten = from c in db.CONTENTTABLEs join cr in db.CONTENTROLEs on c.CONTENTID equals cr.CONTENTID join ur in db.USERROLEs on cr.ROLEID equals ur.ROLEID where (ur.USERID == uss) & (cr.CONTENTID == id) select c; var disc = Enumerable.Distinct(konten); var hasil = from all in disc select all; if (hasil.Count() != 0 || Session["userRole"].ToString() == "admin") //role user sesuai dengan role konten || user adalah admin { CONTENTTABLE att = db.CONTENTTABLEs.Where(m => m.CONTENTID == id).FirstOrDefault(); //cek id ke database if (att != null) { string filename = att.CONTENTFILEPATH.ToString(); filename = filename.Remove(0, 18); System.Diagnostics.Debug.WriteLine(filename); var reg = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(Path.GetExtension(filename).ToLower()); string contentType = "application/unknown"; //cek file if (reg != null) { //file ada string registryContentType = reg.GetValue("Content Type") as string; if (!String.IsNullOrWhiteSpace(registryContentType)) { //tampilkan file contentType = registryContentType; return(new FilePathResult("~/UserContentFiles/" + filename, contentType)); } } return(null); } return(null); } else { //System.Diagnostics.Debug.WriteLine("wes gak admin, role e dee gak cocok sisan karo konten e"); return(null); } } }
public int Linq_Collection_Reference() { var sum = 0; foreach (var item in Enumerable.Distinct(collectionReference)) { sum += item; } return(sum); }
public int Linq_Enumerable_Reference() { var sum = 0; foreach (var item in Enumerable.Distinct(enumerableReference)) { sum += item; } return(sum); }
public int Linq_List_Value() { var sum = 0; foreach (var item in Enumerable.Distinct(listValue)) { sum += item; } return(sum); }
public int Linq_Array() { var sum = 0; foreach (var item in Enumerable.Distinct(array)) { sum += item; } return(sum); }
protected virtual Range <IComparable> GetActualYDataRange() { IEnumerable <object> yvalues = XYSeries.GetYValues((IEnumerable <DataPoint>) this.ActualDataPoints); if (this.ActualYValueType == DataValueType.Category) { this.YValues = Enumerable.Distinct <object>(yvalues); } return(this.YAggregator.GetRange(yvalues)); }
/// <summary> /// Sort and concat two string /// </summary> /// <param name="strOne">First unsorted string</param> /// <param name="strTwo">Second unsorted string</param> /// <returns>New string</returns> internal static string ConcatStr(string strOne, string strTwo) { var result = Enumerable.Distinct((string.Concat(strOne, strTwo)).OrderBy(x => x)).ToArray(); string strRes = string.Empty; foreach (char item in result) { strRes += item; } return(strRes); }
private void RecomputeCachedAnnotationReferences(params string[] ids) { foreach (AnnotationEditor.ReferenceInfo referenceInfo in Enumerable.Distinct <AnnotationEditor.ReferenceInfo>(Enumerable.Join(Enumerable.SelectMany(this.referenceSub.PathNodes, (Func <SceneNodeSubscription <object, AnnotationEditor.ReferenceInfo> .PathNodeInfo, IEnumerable <string> >)(pathNode => (IEnumerable <string>)pathNode.Info.ReferencedAnnotationIds), (pathNode, referencedId) => new { pathNode = pathNode, referencedId = referencedId }), (IEnumerable <string>)ids, param0 => param0.referencedId, (Func <string, string>)(id => id), (param0, id) => param0.pathNode.Info))) { referenceInfo.ReferencedAnnotations = this.ComputeReferencedAnnotations((IEnumerable <string>)referenceInfo.ReferencedAnnotationIds); } }
public void GetSupportedMethods() { Assert.That( DistinctExpressionNode.GetSupportedMethods(), Is.EquivalentTo( new[] { GetGenericMethodDefinition(() => Queryable.Distinct <object> (null)), GetGenericMethodDefinition(() => Enumerable.Distinct <object> (null)) })); }
/// <summary> /// Returns distinct elements from a sequence using the values produced by the <paramref name="selector"/> to compare them. /// </summary> /// <typeparam name="T">The type of the objects to compare.</typeparam> /// <typeparam name="TValue">The type of the result of the selector to be applied to the objects to compare.</typeparam> /// <param name="source">The sequence to remove elements from.</param> /// <param name="selector">A delegate used to select which values to be used to compare objects of type <typeparamref name="T"/>.</param> /// <param name="equalityComparer">An <see cref="IEqualityComparer{T}"/> to compare values produced by <paramref name="selector"/>.</param> /// <returns>An <see cref="IEnumerable{T}" /> that contains distinct elements from the source sequence.</returns> /// <remarks> /// Best used to extract the distinct instances of a reference type using a property as discriminator. /// </remarks> public static IEnumerable <T> DistinctBy <T, TValue>(this IEnumerable <T>?source, Func <T, TValue> selector, IEqualityComparer <TValue>?equalityComparer = null) { _ = selector ?? throw new ArgumentNullException(nameof(selector)); if (source is null) { return(Array.Empty <T>()); } return(Enumerable.Distinct(source, new SelectorEqualityComparer <T, TValue>(selector, equalityComparer ?? EqualityComparer <TValue> .Default))); }
public void Distinct() { //Arrange var testList = User.GenerateSampleModels(100); IQueryable testListQry = testList.AsQueryable(); //Act var result = BasicQueryable.Distinct(testListQry); //Assert CollectionAssert.AreEqual(Enumerable.Distinct(testList).ToArray(), result.Cast <User>().ToArray()); }
/// <summary> /// Returns the changed root node. /// </summary> public SyntaxNode GetChangedRoot() { var nodes = Enumerable.Distinct(_changes.Select(c => c.Node)); var newRoot = _root.TrackNodes(nodes); foreach (var change in _changes) { newRoot = change.Apply(newRoot, _generator); } return(newRoot); }
private void PauseGroupOverlaps(bool force) { if (!force && this.GameState.Loading || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.LevelManager.PickupGroups.Count == 0)) { return; } Vector3 b1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 b2 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); foreach (TrileGroup trileGroup in Enumerable.Distinct <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values)) { float num = float.MaxValue; float?nullable = new float?(); foreach (TrileInstance trileInstance in trileGroup.Triles) { num = Math.Min(num, FezMath.Dot(trileInstance.Center, b1)); if (!trileInstance.PhysicsState.Puppet) { nullable = new float?(FezMath.Dot(trileInstance.Center, b2)); } } foreach (PickupState pickupState1 in this.PickupStates) { if (pickupState1.Group == trileGroup) { TrileInstance trileInstance = pickupState1.Instance; bool flag = !FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b1), num); trileInstance.PhysicsState.Paused = flag; if (flag) { trileInstance.PhysicsState.Puppet = true; pickupState1.LastMovement = Vector3.Zero; } else { pickupState1.VisibleOverlapper = (PickupState)null; foreach (PickupState pickupState2 in this.PickupStates) { if (FezMath.AlmostEqual(pickupState2.Instance.Center * vector3, pickupState1.Instance.Center * vector3)) { pickupState2.VisibleOverlapper = pickupState1; } } if (nullable.HasValue && FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b2), nullable.Value)) { trileInstance.PhysicsState.Puppet = false; } } } } } }
public void DistinctTest() { int[] enumerable = new int[] { 0, 1, 2 }; EnumerableAssert.AreSequentialEqual( Enumerable.Distinct(enumerable), EnumerableExtensions.Distinct(enumerable, EqualityComparer <int> .Default)); enumerable = new int[] { 0, 1, 1, 1, 2, 2 }; EnumerableAssert.AreSequentialEqual( Enumerable.Distinct(enumerable), EnumerableExtensions.Distinct(enumerable, EqualityComparer <int> .Default)); }
public void Distinct_With_ValidData_Must_Succeed(int[] source) { // Arrange var expected = Enumerable .Distinct(source); // Act var result = ArrayExtensions .Distinct(source.AsSpan()); // Assert _ = result.SequenceEqual(expected).Must().BeTrue(); }
public Population(List <NetworkGenome> genomeList, int generation) { this.Genomes = new List <NetworkGenome>(); if (genomeList != null) { foreach (NetworkGenome NetworkGenomes in genomeList) { this.Genomes.Add(NetworkGenomes.Clone() as NetworkGenome); } } this.SpeciesIds = Enumerable.Distinct <int>(Enumerable.Select <NetworkGenome, int>((IEnumerable <NetworkGenome>) this.Genomes, (Func <NetworkGenome, int>)(genomes => genomes.Species))); this.Generation = generation; }