当前位置: 首页>>代码示例>>C#>>正文


C# ITypeResolver.ResolveType方法代码示例

本文整理汇总了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);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:11,代码来源:TypeResolver.cs

示例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;
        }
开发者ID:6bee,项目名称:aqua-core,代码行数:15,代码来源:FieldInfo.cs

示例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());
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:28,代码来源:StringGen.cs

示例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;
        }
开发者ID:6bee,项目名称:aqua-core,代码行数:64,代码来源:MethodInfo.cs


注:本文中的ITypeResolver.ResolveType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。