本文整理汇总了C#中INotifyCollectionChanged.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# INotifyCollectionChanged.GetType方法的具体用法?C# INotifyCollectionChanged.GetType怎么用?C# INotifyCollectionChanged.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INotifyCollectionChanged
的用法示例。
在下文中一共展示了INotifyCollectionChanged.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnregisterCollection
/// <summary>
/// Unregisters the collection and stops automatically watching the collection. All undo/redo history will be removed.
/// </summary>
/// <param name="collection">The collection.</param>
/// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
public void UnregisterCollection(INotifyCollectionChanged collection)
{
Argument.IsNotNull("collection", collection);
Log.Debug("Unregistering collection of type '{0}'", collection.GetType().Name);
ClearActionsForObject(collection);
if (_observers.ContainsKey(collection))
{
_observers[collection].CancelSubscription();
_observers.Remove(collection);
Log.Debug("Unregistered collection");
}
else
{
Log.Debug("Collection was not registered, not unregistered");
}
}
示例2: ResetCollection
private void ResetCollection(INotifyCollectionChanged collection, IList newCollection)
{
if (collection != null)
{
var collectionChangedMethod = collection.GetType().GetMethod("OnCollectionChanged", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance);
if (collectionChangedMethod != null)
{
collectionChangedMethod.Invoke(collection, new object[] { new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null) });
collectionChangedMethod.Invoke(collection, new object[] { new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newCollection) });
SetDataContextBinder(DataContextBinder);
}
}
}
示例3: RegisterCollection
/// <summary>
/// Registers the collection and automatically. As soon as the <see cref="INotifyCollectionChanged.CollectionChanged"/> event
/// occurs, it will automatically create a backup of the collection to support undo.
/// </summary>
/// <param name="collection">The collection.</param>
/// <param name="tag">The tag.</param>
/// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
public void RegisterCollection(INotifyCollectionChanged collection, object tag = null)
{
Argument.IsNotNull("collection", collection);
Log.Debug("Registering collection of type '{0}' with tag '{1}'", collection.GetType().Name, TagHelper.ToString(tag));
if (!_observers.ContainsKey(collection))
{
_observers[collection] = new CollectionObserver(collection, tag, this);
Log.Debug("Registered collection");
}
else
{
Log.Debug("Collection already registered, not registered");
}
}