Exemple #1
0
 /// <summary>
 /// Gets or create a new proxy type for ducktyping
 /// </summary>
 /// <param name="proxyType">ProxyType interface</param>
 /// <param name="targetType">Target type</param>
 /// <returns>CreateTypeResult instance</returns>
 public static CreateTypeResult GetOrCreateProxyType(Type proxyType, Type targetType)
 {
     return(DuckTypeCache.GetOrAdd(
                new TypesTuple(proxyType, targetType),
                key => new Lazy <CreateTypeResult>(() => CreateProxyType(key.ProxyDefinitionType, key.TargetType)))
            .Value);
 }
Exemple #2
0
 /// <summary>
 /// Get or creates a proxy type implementing the interface type to access the given instance type
 /// </summary>
 /// <param name="duckType">Duck type</param>
 /// <param name="instanceType">Instance type</param>
 /// <returns>Proxy type</returns>
 private static Type GetOrCreateProxyType(Type duckType, Type instanceType)
 => DuckTypeCache.GetOrAdd(new VTuple <Type, Type>(duckType, instanceType),
                           types => CreateProxyType(types.Item1, types.Item2));