本文整理汇总了C#中System.Delegate.IsDynamicDelegate方法的典型用法代码示例。如果您正苦于以下问题:C# Delegate.IsDynamicDelegate方法的具体用法?C# Delegate.IsDynamicDelegate怎么用?C# Delegate.IsDynamicDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Delegate
的用法示例。
在下文中一共展示了Delegate.IsDynamicDelegate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CombineImpl
// This method will combine this delegate with the passed delegate
// to form a new delegate.
internal Delegate CombineImpl(Delegate follow)
{
if ((Object)follow == null) // cast to object for a more efficient test
return this;
// Verify that the types are the same...
if (!InternalEqualTypes(this, follow))
throw new ArgumentException();
if (IsDynamicDelegate() && follow.IsDynamicDelegate())
{
throw new InvalidOperationException();
}
MulticastDelegate dFollow = (MulticastDelegate)follow;
Delegate[] resultList;
int followCount = 1;
Delegate[] followList = dFollow.m_helperObject as Delegate[];
if (followList != null)
followCount = (int)dFollow.m_extraFunctionPointerOrData;
int resultCount;
Delegate[] invocationList = m_helperObject as Delegate[];
if (invocationList == null)
{
resultCount = 1 + followCount;
resultList = new Delegate[resultCount];
resultList[0] = this;
if (followList == null)
{
resultList[1] = dFollow;
}
else
{
for (int i = 0; i < followCount; i++)
resultList[1 + i] = followList[i];
}
return NewMulticastDelegate(resultList, resultCount);
}
else
{
int invocationCount = (int)m_extraFunctionPointerOrData;
resultCount = invocationCount + followCount;
resultList = null;
if (resultCount <= invocationList.Length)
{
resultList = invocationList;
if (followList == null)
{
if (!TrySetSlot(resultList, invocationCount, dFollow))
resultList = null;
}
else
{
for (int i = 0; i < followCount; i++)
{
if (!TrySetSlot(resultList, invocationCount + i, followList[i]))
{
resultList = null;
break;
}
}
}
}
if (resultList == null)
{
int allocCount = invocationList.Length;
while (allocCount < resultCount)
allocCount *= 2;
resultList = new Delegate[allocCount];
for (int i = 0; i < invocationCount; i++)
resultList[i] = invocationList[i];
if (followList == null)
{
resultList[invocationCount] = dFollow;
}
else
{
for (int i = 0; i < followCount; i++)
resultList[invocationCount + i] = followList[i];
}
}
return NewMulticastDelegate(resultList, resultCount, true);
}
}