/// <summary>
 /// Вызов деструктора, если объекты не равны
 /// </summary>
 /// <param name="obj1">Оригинальный объект</param>
 /// <param name="obj2">Объект для сравнения</param>
 public static void DisposeIfNotEqualTo(this IDisposable obj1, IDisposable obj2)
 {
     if (!(obj1 == null || obj1.Equals(obj2)))
     {
         obj1.Dispose();
     }
 }
示例#2
0
        public void AddInstanceForDisposal(IDisposable instance)
        {
            if (instance == null || instance.Equals(_caller))
            {
                return;
            }

            lock (_synchRoot)
                _items.Add(instance);
        }
示例#3
0
文件: Counter.cs 项目: blqw/blqw-Core
 /// <summary> 减少引用
 /// </summary>
 /// <param name="token">通过Add方法获取的标记对象</param>
 public void Remove(IDisposable token)
 {
     if (token == null)
     {
         return;
     }
     if (token is CounterToken == false)
     {
         throw new ArgumentException("参数不是一个有效的引用标记", "token");
     }
     if (token.Equals(this) == false)
     {
         throw new ArgumentOutOfRangeException("token", "此标记不属于当前计数器");
     }
     token.Dispose();
 }
示例#4
0
 public override bool Equals(object obj)
 {
     return(Object.Equals(obj));
 }
示例#5
0
 private void ShowPanel(IDisposable panel)
 {
     pMultiAdd.Visible = panel.Equals(pMultiAdd);
     pMultiColor.Visible = panel.Equals(pMultiColor);
     pChannels.Visible = panel.Equals(pChannels);
 }
示例#6
0
 private void ShowPanel(IDisposable panel)
 {
     pMultiAdd.Visible   = panel.Equals(pMultiAdd);
     pMultiColor.Visible = panel.Equals(pMultiColor);
     pChannels.Visible   = panel.Equals(pChannels);
 }