當前位置: 首頁>>代碼示例>>C#>>正文


C# MulticastDelegate.EqualsWithoutInvocationList方法代碼示例

本文整理匯總了C#中System.MulticastDelegate.EqualsWithoutInvocationList方法的典型用法代碼示例。如果您正苦於以下問題:C# MulticastDelegate.EqualsWithoutInvocationList方法的具體用法?C# MulticastDelegate.EqualsWithoutInvocationList怎麽用?C# MulticastDelegate.EqualsWithoutInvocationList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.MulticastDelegate的用法示例。


在下文中一共展示了MulticastDelegate.EqualsWithoutInvocationList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LastIndexOf

        /// <summary>
        /// Will return an index into [head] + tail, or -1 if not found 
        /// </summary>
        private int LastIndexOf(MulticastDelegate o)
        {
            int oInvLen = o.InvocationListLength;
            var oInvList = o.InvocationList;
            var invList = InvocationList;

            // We need to start comparing from the end.

            // Mono's implementation uses the KMP algorithm, but at a first
            // glance this seems to be overkill for an invocation list. In the
            // typical usage scenario, 'o' will have no invocation list at all.
            // We stick to the naive implementation for now.
            int i = InvocationListLength - oInvLen;

            if (oInvLen == 0)
            {
                for(; i > 0; --i)
                {
                    if (o.EqualsWithoutInvocationList(invList[i - 1]))
                        return i;
                }
            }
            else
            {
                for (; i > 0; --i)
                {
                    if (!o.EqualsWithoutInvocationList(invList[i - 1]))
                        continue;

                    for (int j = 0; j < oInvLen; ++j)
                    {
                        if (!invList[i + j].EqualsWithoutInvocationList(oInvList[j]))
                            goto next_iteration;
                    }

                    // found it!
                    return i;

                    next_iteration:;
                }
            }

            // 0 = this
            return i < 0 || !o.EqualsWithoutInvocationList(this) ? -1 : 0;
        }
開發者ID:sebastianhaba,項目名稱:api,代碼行數:48,代碼來源:MulticastDelegate.cs


注:本文中的System.MulticastDelegate.EqualsWithoutInvocationList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。