当前位置: 首页>>代码示例>>C#>>正文


C# Delegate.Equals方法代码示例

本文整理汇总了C#中System.Delegate.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Delegate.Equals方法的具体用法?C# Delegate.Equals怎么用?C# Delegate.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Delegate的用法示例。


在下文中一共展示了Delegate.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Remove

        /// <summary>
        /// Remove the given delegate from my invocation list.
        /// </summary>
        protected override sealed Delegate Remove(Delegate other)
        {
            if (this.Equals(other))
            {
                // Front of the list
                var result = next;
                next = null;
                return result;
            }

            MulticastDelegate parent = this;
            while ((parent != null) && (!other.Equals(parent.next)))
            {
                parent = parent.next;
            }

            if (parent != null)
            {
                MulticastDelegate otherx = parent.next;
                parent.next = otherx.next;
                otherx.next = null;
            }

            return this;
        }
开发者ID:rfcclub,项目名称:api,代码行数:28,代码来源:MulticastDelegate.cs

示例2: RemoveListener

 public void RemoveListener(Delegate listener)
 {
     this.listeners.RemoveAll(reference => {
         //Remove the listener, and prune collected listeners
         Delegate target = reference.Target;
         return listener.Equals(target) || target == null;
     });
 }
开发者ID:michaelnero,项目名称:SignalR-demos,代码行数:8,代码来源:WeakDelegatesManager.cs

示例3: RemoveListener

 public void RemoveListener(Delegate listener)
 {
     _listeners.RemoveAll(reference =>
     {
         var local0 = reference.Target;
         if (!listener.Equals(local0))
             return local0 == null;
         return true;
     });
 }
开发者ID:unicloud,项目名称:FRP,代码行数:10,代码来源:WeakDelegatesManager.cs

示例4: RemoveListener

        public void RemoveListener(Delegate listener)
        {
            if (listener == null) throw new ArgumentNullException("listener");
            Contract.EndContractBlock();

            this.listeners.RemoveAll(reference =>
            {
                //Remove the listener, and prune collected listeners
                Delegate target = reference.Target;
                return listener.Equals(target) || target == null;
            });
        }
开发者ID:xperiandri,项目名称:PortablePrism,代码行数:12,代码来源:WeakDelegatesManager.cs

示例5: RemoveImpl

 protected virtual Delegate RemoveImpl(Delegate d)
 {
     return (d.Equals(this)) ? null : this;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:Delegate.cs

示例6: RemoveImpl

        // This method currently looks backward on the invocation list
        //  for an element that has Delegate based equality with value.  (Doesn't
        //  look at the invocation list.)  If this is found we remove it from
        //  this list and return a new delegate.  If its not found a copy of the
        //  current list is returned.
        internal Delegate RemoveImpl(Delegate value)
        {
            // There is a special case were we are removing using a delegate as
            //    the value we need to check for this case
            //
            MulticastDelegate v = value as MulticastDelegate;

            if (v == null)
                return this;
            if (v.m_helperObject as Delegate[] == null)
            {
                Delegate[] invocationList = m_helperObject as Delegate[];
                if (invocationList == null)
                {
                    // they are both not real Multicast
                    if (this.Equals(value))
                        return null;
                }
                else
                {
                    int invocationCount = (int)m_extraFunctionPointerOrData;
                    for (int i = invocationCount; --i >= 0;)
                    {
                        if (value.Equals(invocationList[i]))
                        {
                            if (invocationCount == 2)
                            {
                                // Special case - only one value left, either at the beginning or the end
                                return invocationList[1 - i];
                            }
                            else
                            {
                                Delegate[] list = DeleteFromInvocationList(invocationList, invocationCount, i, 1);
                                return NewMulticastDelegate(list, invocationCount - 1, true);
                            }
                        }
                    }
                }
            }
            else
            {
                Delegate[] invocationList = m_helperObject as Delegate[];
                if (invocationList != null)
                {
                    int invocationCount = (int)m_extraFunctionPointerOrData;
                    int vInvocationCount = (int)v.m_extraFunctionPointerOrData;
                    for (int i = invocationCount - vInvocationCount; i >= 0; i--)
                    {
                        if (EqualInvocationLists(invocationList, v.m_helperObject as Delegate[], i, vInvocationCount))
                        {
                            if (invocationCount - vInvocationCount == 0)
                            {
                                // Special case - no values left
                                return null;
                            }
                            else if (invocationCount - vInvocationCount == 1)
                            {
                                // Special case - only one value left, either at the beginning or the end
                                return invocationList[i != 0 ? 0 : invocationCount - 1];
                            }
                            else
                            {
                                Delegate[] list = DeleteFromInvocationList(invocationList, invocationCount, i, vInvocationCount);
                                return NewMulticastDelegate(list, invocationCount - vInvocationCount, true);
                            }
                        }
                    }
                }
            }

            return this;
        }
开发者ID:pgavlin,项目名称:corert,代码行数:77,代码来源:Delegate.cs

示例7: RemoveImpl

		protected virtual Delegate RemoveImpl(Delegate d)
		{
			if (!d.Equals(this))
			{
				return this;
			}
			return null;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:8,代码来源:Delegate.cs

示例8: RemoveImpl

 protected sealed override Delegate RemoveImpl(Delegate value)
 {
     MulticastDelegate delegate2 = value as MulticastDelegate;
     if (delegate2 != null)
     {
         if (delegate2._invocationList is object[])
         {
             object[] a = this._invocationList as object[];
             if (a != null)
             {
                 int invocationCount = (int) this._invocationCount;
                 int count = (int) delegate2._invocationCount;
                 for (int i = invocationCount - count; i >= 0; i--)
                 {
                     if (this.EqualInvocationLists(a, delegate2._invocationList as object[], i, count))
                     {
                         if ((invocationCount - count) == 0)
                         {
                             return null;
                         }
                         if ((invocationCount - count) == 1)
                         {
                             return (Delegate) a[(i != 0) ? 0 : (invocationCount - 1)];
                         }
                         object[] invocationList = this.DeleteFromInvocationList(a, invocationCount, i, count);
                         return this.NewMulticastDelegate(invocationList, invocationCount - count, true);
                     }
                 }
             }
         }
         else
         {
             object[] objArray = this._invocationList as object[];
             if (objArray == null)
             {
                 if (this.Equals(value))
                 {
                     return null;
                 }
             }
             else
             {
                 int num = (int) this._invocationCount;
                 int index = num;
                 while (--index >= 0)
                 {
                     if (value.Equals(objArray[index]))
                     {
                         if (num == 2)
                         {
                             return (Delegate) objArray[1 - index];
                         }
                         object[] objArray2 = this.DeleteFromInvocationList(objArray, num, index, 1);
                         return this.NewMulticastDelegate(objArray2, num - 1, true);
                     }
                 }
             }
         }
     }
     return this;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:61,代码来源:MulticastDelegate.cs

示例9: RemoveImpl

		protected sealed override Delegate RemoveImpl (Delegate removed)
		{
			if (removed == null)
				return this;

		    var removedMulticast = removed as MulticastDelegate;
		    if (removedMulticast == null || removedMulticast.invocationList == null)
		    {
		        if (invocationList == null)
		        {
                    // Both non multicast Delegate, so nothing left
		            if (base.Equals(removed))
		                return null;
		        }
		        else
		        {
                    // Remove from list
		            int invocationCount = invocationList.Length;
		            for (int i = invocationCount; --i >= 0;)
		            {
		                if (removed.Equals(invocationList[i]))
		                {
                            // Only two delegates?
                            // Returns the other one
		                    if (invocationCount == 2)
		                        return invocationList[1 - i];

		                    var newInvocationList = new Delegate[invocationCount - 1];
		                    
                            int j;
                            for (j = 0; j < i; j++)
                                newInvocationList[j] = invocationList[j];
                            for (j++; j < invocationCount; j++)
                                newInvocationList[j - 1] = invocationList[j];

                            return NewMulticast(newInvocationList);
		                }
		            }
		        }
		    }
		    else
		    {
		        var removedInvocationList = removedMulticast.invocationList;
                var removedInvocationCount = removedInvocationList.Length;

                // Removing a multicast delegate from a delegate wouldn't make sense, only consider the case
                // where we remove a multicast from a multicast
		        if (invocationList != null)
		        {
                    int invocationCount = invocationList.Length;

                    // Iterate over every possible range
                    // TODO: KPM?
		            for (int startIndex = invocationCount - removedInvocationCount; startIndex >= 0; --startIndex)
		            {
                        // Compare ranges
		                var equal = true;
		                for (int i = 0; i < removedInvocationCount; i++)
		                {
		                    if (!(invocationList[startIndex + i].Equals(removedInvocationList[i])))
		                    {
		                        equal = false;
		                        break;
		                    }
		                }

		                if (!equal)
                            continue; // Try startIndex - 1

                        // We have a match
		                var leftInvocationCount = invocationCount - removedInvocationCount;

                        // Nothing left?
                        if (leftInvocationCount == 0)
                            return null;

                        // Only one value left? (last or first)
                        if (leftInvocationCount == 1)
                            return invocationList[startIndex == 0 ? invocationCount - 1 : 0];

                        // General case
                        var newInvocationList = new Delegate[leftInvocationCount];

                        int j;
                        for (j = 0; j < startIndex; j++)
                            newInvocationList[j] = invocationList[j];
                        for (j += removedInvocationCount; j < invocationCount; j++)
                            newInvocationList[j - removedInvocationCount] = invocationList[j];

                        return NewMulticast(newInvocationList);
		            }
		        }
		    }

            // No changes
		    return this;
		}
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:97,代码来源:MulticastDelegate.cs

示例10: RemoveImpl

		protected sealed override Delegate RemoveImpl(Delegate value)
		{
			MulticastDelegate multicastDelegate = value as MulticastDelegate;
			if (multicastDelegate == null)
			{
				return this;
			}
			if (!(multicastDelegate._invocationList is object[]))
			{
				object[] array = this._invocationList as object[];
				if (array == null)
				{
					if (this.Equals(value))
					{
						return null;
					}
				}
				else
				{
					int num = (int)this._invocationCount;
					int num2 = num;
					while (--num2 >= 0)
					{
						if (value.Equals(array[num2]))
						{
							if (num == 2)
							{
								return (Delegate)array[1 - num2];
							}
							object[] invocationList = this.DeleteFromInvocationList(array, num, num2, 1);
							return this.NewMulticastDelegate(invocationList, num - 1, true);
						}
					}
				}
			}
			else
			{
				object[] array2 = this._invocationList as object[];
				if (array2 != null)
				{
					int num3 = (int)this._invocationCount;
					int num4 = (int)multicastDelegate._invocationCount;
					int i = num3 - num4;
					while (i >= 0)
					{
						if (this.EqualInvocationLists(array2, multicastDelegate._invocationList as object[], i, num4))
						{
							if (num3 - num4 == 0)
							{
								return null;
							}
							if (num3 - num4 == 1)
							{
								return (Delegate)array2[(i != 0) ? 0 : (num3 - 1)];
							}
							object[] invocationList2 = this.DeleteFromInvocationList(array2, num3, i, num4);
							return this.NewMulticastDelegate(invocationList2, num3 - num4, true);
						}
						else
						{
							i--;
						}
					}
				}
			}
			return this;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:67,代码来源:MulticastDelegate.cs


注:本文中的System.Delegate.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。