📄 propertieschangedeventargs.cs
字号:
namespace Imps.Client.Core
{
using System;
using System.Collections.Generic;
using System.Reflection;
public class PropertiesChangedEventArgs : EventArgs
{
private IDictionary<string, object> _changedContext;
private IList<string> _changedProperties;
private object _syncRoot;
public PropertiesChangedEventArgs()
{
this._changedProperties = new List<string>();
this._syncRoot = this._changedProperties;
}
public PropertiesChangedEventArgs(IEnumerable<string> changedProperties)
{
this._changedProperties = new List<string>(changedProperties);
this._syncRoot = this._changedProperties;
}
public void AddChangedProperty<T>(string name, ChangedValuePair<T> context)
{
lock (this._syncRoot)
{
if (!this._changedProperties.Contains(name))
{
this._changedProperties.Add(name);
}
if (context != null)
{
if (this._changedContext == null)
{
this._changedContext = new Dictionary<string, object>();
}
if (this._changedContext.ContainsKey(name))
{
ChangedValuePair<T> pair = this._changedContext.get_Item(name) as ChangedValuePair<T>;
this._changedContext.Remove(name);
if (pair != null)
{
if (object.Equals(pair.OldValue, context.NewValue))
{
this._changedProperties.Remove(name);
goto Label_00C7;
}
context = new ChangedValuePair<T>(pair.OldValue, context.NewValue);
}
}
this._changedContext.Add(name, context);
Label_00C7:;
}
}
}
public bool ContainsAllOfProperties(params string[] names)
{
lock (this._syncRoot)
{
for (int i = 0; i < names.Length; i++)
{
if (!this._changedProperties.Contains(names[i]))
{
return false;
}
}
return true;
}
}
public bool ContainsAnyOfProperties(params string[] names)
{
lock (this._syncRoot)
{
for (int i = 0; i < names.Length; i++)
{
if (this._changedProperties.Contains(names[i]))
{
return true;
}
}
return false;
}
}
public bool ContainsProperty(string name)
{
lock (this._syncRoot)
{
return this._changedProperties.Contains(name);
}
}
public IEnumerator<string> GetEnumerator()
{
lock (this._syncRoot)
{
return this._changedProperties.GetEnumerator();
}
}
public void RemoveChangedProperty(string name)
{
lock (this._syncRoot)
{
this._changedProperties.Remove(name);
if (this._changedContext != null)
{
this._changedContext.Remove(name);
}
}
}
public int Count
{
get
{
lock (this._syncRoot)
{
return this._changedProperties.get_Count();
}
}
}
public object this[string name]
{
get
{
lock (this._syncRoot)
{
if (this._changedContext == null)
{
return null;
}
return this._changedContext.get_Item(name);
}
}
}
public string this[int index]
{
get
{
lock (this._syncRoot)
{
return this._changedProperties.get_Item(index);
}
}
}
public object SyncRoot
{
get
{
return this._syncRoot;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -