/// <summary>
/// Gets the DelegateDuckProxyType object for a given duck type.
/// </summary>
/// <param name="toType">Type to be casted to.</param>
/// <param name="fromType">Type of delegate to be casted.</param>
/// <returns>The duck proxy type to use to cast or prepare for casting.</returns>
private static DelegateDuckProxyType GetProxyType(Type toType, Type fromType)
{
DelegateDuckProxyType proxyType = null;
FromTypeTree <DelegateDuckProxyType> fromTypeTree = null;
if (s_ProxyTypeTree.ContainsKey(toType))
{
fromTypeTree = s_ProxyTypeTree[toType];
if (fromTypeTree.ContainsKey(fromType))
{
proxyType = fromTypeTree[fromType];
}
}
if (proxyType == null)
{
proxyType = new DelegateDuckProxyType(toType, fromType);
if (proxyType.CanProxy())
{
if (fromTypeTree == null)
{
fromTypeTree = new FromTypeTree <DelegateDuckProxyType>();
s_ProxyTypeTree.Add(toType, fromTypeTree);
}
fromTypeTree.Add(fromType, proxyType);
}
}
return(proxyType);
}