public override INotificationResult Notify(IList <INotificationResult> sources) { var added = new List <TSource>(); var removed = new List <TSource>(); var moved = new List <TSource>(); foreach (ICollectionChangedNotificationResult change in sources) { if (change.IsReset) { OnCleared(); return(new CollectionChangedNotificationResult <TSource>(this)); } if (change.AddedItems != null) { added.AddRange(SL.Cast <TSource>(change.AddedItems)); } if (change.RemovedItems != null) { removed.AddRange(SL.Cast <TSource>(change.RemovedItems)); } if (change.MovedItems != null) { moved.AddRange(SL.Cast <TSource>(change.MovedItems)); } } RaiseEvents(added, removed, moved); return(new CollectionChangedNotificationResult <TSource>(this, added, removed, moved)); }
public override INotificationResult Notify(IList <INotificationResult> sources) { var notification = CollectionChangedNotificationResult <TSource> .Create(this); var added = notification.AddedItems; var removed = notification.RemovedItems; var moved = notification.MovedItems; foreach (ICollectionChangedNotificationResult change in sources) { if (change.IsReset) { OnCleared(); notification.TurnIntoReset(); return(notification); } var offset = change.Source == source ? 0 : SL.Count(source); if (change.AddedItems != null) { added.AddRange(SL.Cast <TSource>(change.AddedItems)); if (change.NewItemsStartIndex != -1) { notification.UpdateNewStartIndex(offset + change.NewItemsStartIndex); } } if (change.RemovedItems != null) { removed.AddRange(SL.Cast <TSource>(change.RemovedItems)); if (change.OldItemsStartIndex != -1) { notification.UpdateOldStartIndex(offset + change.OldItemsStartIndex); } } if (change.MovedItems != null) { moved.AddRange(SL.Cast <TSource>(change.MovedItems)); if (change.NewItemsStartIndex != -1) { notification.UpdateNewStartIndex(offset + change.NewItemsStartIndex); } if (change.OldItemsStartIndex != -1) { notification.UpdateOldStartIndex(offset + change.OldItemsStartIndex); } } } RaiseEvents(added, removed, moved, notification.OldItemsStartIndex, notification.NewItemsStartIndex); return(notification); }
/// <summary>Finds the named method in the specifid type.</summary> /// <param name="type">Type to look in.</param> /// <param name="methodName">Name of method to look for.</param> /// <param name="args">Arguments to method.</param> /// <param name="method">Best method found.</param> /// <returns>Number of matching methods.</returns> private int FindMethod(Type type, string methodName, Expression[] args, out MethodBase method) { const BindingFlags Flags = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Instance; foreach (Type t in SelfAndBaseTypes(type)) { MemberInfo[] members = t.FindMembers(MemberTypes.Method, Flags, Type.FilterName, methodName); int count = this.FindBestMethod(Enumerable.Cast <MethodBase>(members), args, out method); if (count != 0) { return(count); } } method = null; return(0); }
//Note: currently the selected features are one select behind. //e.g on drawing the first region all the layers features are returned // on drawing the second region all the features matching the first region are returned etc.. private void AttributeQueryHandler_End(object sender, MapActionHandlerEventArgs e) { IFeatureLayer l = Enumerable.FirstOrDefault( Caster.Cast <IFeatureLayer>( Processor.Where(Map.SelectedLayers, delegate(ILayer o) { return(o as IFeatureLayer != null); }))); if (l != null) { FeatureDataView dv = new FeatureDataView(l.SelectedFeatures.Table); if (l.SelectedFeatures.AttributeFilter != null) { dv.AttributeFilter = (AttributeBinaryExpression) l.SelectedFeatures.AttributeFilter.Clone(); } if (l.SelectedFeatures.SpatialFilter != null) { dv.SpatialFilter = (SpatialBinaryExpression) l.SelectedFeatures.SpatialFilter.Clone(); } if (l.SelectedFeatures.OidFilter != null) { dv.OidFilter = (OidCollectionExpression) l.SelectedFeatures.OidFilter.Clone(); } if (l.SelectedFeatures.ViewDefinition != null) { dv.ViewDefinition = (FeatureQueryExpression) l.SelectedFeatures.ViewDefinition.Clone(); } QueryResultsTab tab = new QueryResultsTab(l.LayerName, dv); resultsTabControl.TabPages.Insert(0, tab); resultsTabControl.SelectedTab = tab; } }
private Boolean inOidFilter(FeatureDataRow feature) { if (!feature.HasOid) { return(false); } if (_viewDefinition == null || _viewDefinition.OidPredicate == null) { return(true); } // NOTE: This will get to be a performance problem due to the // poor structuring of the OID values. Consider creating a local, // sorted index where a binary search can be performed. IEnumerable oids = _viewDefinition.OidPredicate.OidValues; Int32 count = 0; if (Enumerable.FirstOrDefault(Caster.Cast <object>(oids)) == null) //jd:added explicit type param to allow compiliation in net3.5 { return(true); } Object featureOid = feature.GetOid(); Debug.Assert(featureOid != null); foreach (Object oid in oids) { if (featureOid.Equals(oid)) { return(true); } } return(false); }
public static System.Reflection.MemberInfo[] GetCachedFields(this System.Type type, System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) { if (ReflectionHelper.fieldInfoCache.TryGetValue(type, out var fieldInfos) == false) { var fieldInfosArr = Enumerable.Cast <System.Reflection.MemberInfo>(Enumerable.Where(type.GetAllFields(flags), f => f.IsPublic == true || Enumerable.Any(f.CustomAttributes, a => a.AttributeType == typeof(ME.ECS.Serializer.SerializeFieldAttribute)) == true)); fieldInfosArr = Enumerable.Union(fieldInfosArr, Enumerable.Where(type.GetAllProperties(flags), f => f.CanRead == true && f.CanWrite == true && Enumerable.Any(f.CustomAttributes, a => a.AttributeType == typeof(ME.ECS.Serializer.SerializeFieldAttribute)) ) ); fieldInfos = Enumerable.ToArray(Enumerable.OrderBy(fieldInfosArr, x => x.Name)); ReflectionHelper.fieldInfoCache.Add(type, fieldInfos); } return(fieldInfos); }
private void SequenceChanged(object sender, NotifyCollectionChangedEventArgs e) { SortedDictionary <TKey, ObservableCollection <TItem> > searchTree; if (searchTrees.TryGetValue(sender as IEnumerable <TItem>, out searchTree)) { if (e.OldItems != null) { foreach (TItem item in e.OldItems) { DetachItem(searchTree, item); } OnRemoveItems(SL.Cast <TItem>(e.OldItems)); } if (e.NewItems != null) { foreach (TItem item in e.NewItems) { AttachItem(searchTree, item); } OnAddItems(SL.Cast <TItem>(e.NewItems)); } } }
public override bool Contains(TTarget item) { return(SL.Contains(SL.Cast <TTarget>(source), item)); }
public override IEnumerator <TTarget> GetEnumerator() { return(SL.Cast <TTarget>(source).GetEnumerator()); }