本文整理汇总了C#中ITypeResolver.ResolveType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeResolver.ResolveType方法的具体用法?C# ITypeResolver.ResolveType怎么用?C# ITypeResolver.ResolveType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeResolver
的用法示例。
在下文中一共展示了ITypeResolver.ResolveType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public static SqlType Resolve(SqlTypeCode typeCode, string typeName, DataTypeMeta[] metadata, ITypeResolver resolver)
{
if (PrimitiveTypes.IsPrimitive(typeCode))
return PrimitiveTypes.Resolve(typeCode, typeName, metadata);
if (resolver == null)
throw new NotSupportedException(String.Format("Cannot resolve type '{0}' without context.", typeName));
var resolveCcontext = new TypeResolveContext(typeCode, typeName, metadata);
return resolver.ResolveType(resolveCcontext);
}
示例2: ResolveField
public System.Reflection.FieldInfo ResolveField(ITypeResolver typeResolver)
{
Type declaringType;
try
{
declaringType = typeResolver.ResolveType(DeclaringType);
}
catch (Exception ex)
{
throw new Exception($"Declaring type '{DeclaringType}' could not be reconstructed", ex);
}
var fieldInfo = declaringType.GetField(Name);
return fieldInfo;
}
示例3: GetCtorSBytePtr
public static void GetCtorSBytePtr(ITypeResolver typeResolver, out byte[] code, out IList<object> tokenResolutions, out IList<IType> locals, out IList<IParameter> parameters)
{
IType systemString = typeResolver.System.System_String;
var codeBuilder = new IlCodeBuilder();
codeBuilder.LoadArgument(0);
// calculate length
codeBuilder.LoadArgument(0);
codeBuilder.Add(Code.Call, 2);
codeBuilder.Add(Code.Call, 3);
codeBuilder.Add(Code.Call, 1);
codeBuilder.Add(Code.Ret);
code = codeBuilder.GetCode();
locals = new List<IType>();
tokenResolutions = new List<object>();
tokenResolutions.Add(systemString.GetMethodByName("CreateStringFromEncoding", typeResolver));
tokenResolutions.Add(systemString.GetMethodByName("strlen", typeResolver));
tokenResolutions.Add(typeResolver.ResolveType("System.Text.Encoding").GetMethodByName("get_ASCII", typeResolver));
parameters = new List<IParameter>();
parameters.Add(typeResolver.System.System_SByte.ToPointerType().ToParameter());
}
示例4: ResolveMethod
public System.Reflection.MethodInfo ResolveMethod(ITypeResolver typeResolver)
{
Type declaringType;
try
{
declaringType = typeResolver.ResolveType(DeclaringType);
}
catch (Exception ex)
{
throw new Exception($"Declaring type '{DeclaringType}' could not be reconstructed", ex);
}
var genericArguments = ReferenceEquals(null, GenericArgumentTypes) ? new Type[0] : GenericArgumentTypes
.Select(typeInfo =>
{
try
{
var genericArgumentType = typeResolver.ResolveType(typeInfo);
return genericArgumentType;
}
catch (Exception ex)
{
throw new Exception($"Generic argument type '{typeInfo}' could not be reconstructed", ex);
}
})
.ToArray();
var parameterTypes = ReferenceEquals(null, ParameterTypes) ? new Type[0] : ParameterTypes
.Select(typeInfo =>
{
try
{
var parameterType = typeResolver.ResolveType(typeInfo);
return parameterType;
}
catch (Exception ex)
{
throw new Exception($"Parameter type '{typeInfo}' could not be reconstructed", ex);
}
})
.ToArray();
var methodInfo = declaringType.GetMethods(BindingFlags)
.Where(m => m.Name == Name)
.Where(m => !m.IsGenericMethod || m.GetGenericArguments().Length == genericArguments.Length)
.Where(m => m.GetParameters().Length == parameterTypes.Length)
.Select(m => m.IsGenericMethod ? m.MakeGenericMethod(genericArguments) : m)
.Where(m =>
{
var paramTypes = m.GetParameters();
for (int i = 0; i < parameterTypes.Length; i++)
{
if (paramTypes[i].ParameterType != parameterTypes[i])
{
return false;
}
}
return true;
})
.Single();
return methodInfo;
}