本文整理汇总了C#中TypeBase.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# TypeBase.DeepClone方法的具体用法?C# TypeBase.DeepClone怎么用?C# TypeBase.DeepClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeBase
的用法示例。
在下文中一共展示了TypeBase.DeepClone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeGenericInstance
public static TypeBase MakeGenericInstance(this GenericBaseType genericType, TypeBase genericTemplateType)
{
// TODO cache generic instance that are using predefined hlsl types
var newType = genericTemplateType.DeepClone();
var genericParameters = ((IGenerics)genericTemplateType).GenericParameters;
var genericArguments = ((IGenerics)newType).GenericArguments;
var genericInstanceParameters = genericType.Parameters;
var genericParameterTypes = new TypeBase[genericParameters.Count];
var genericBaseParameterTypes = new TypeBase[genericParameters.Count];
// Look for parameter instance types
for (int i = 0; i < genericInstanceParameters.Count; i++)
{
var genericInstanceParameter = genericInstanceParameters[i];
if (genericInstanceParameter is TypeBase)
{
var genericInstanceParameterType = (TypeBase)genericInstanceParameter;
genericParameterTypes[i] = genericInstanceParameterType;
genericBaseParameterTypes[i] = TypeBase.GetBaseType(genericInstanceParameterType);
genericParameters[i] = genericParameterTypes[i];
genericArguments.Add(genericInstanceParameterType);
}
}
// Replace all references to template arguments to their respective generic instance types
SearchVisitor.Run(
newType,
node =>
{
var typeInferencer = node as ITypeInferencer;
if (typeInferencer != null && typeInferencer.TypeInference.Declaration is GenericDeclaration)
{
var genericDeclaration = (GenericDeclaration)typeInferencer.TypeInference.Declaration;
var i = genericDeclaration.Index;
var targeType = genericDeclaration.IsUsingBase ? genericBaseParameterTypes[i] : genericParameterTypes[i];
if (node is TypeBase)
return targeType.ResolveType();
}
return node;
});
return newType;
}