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


C# TypeReference类代码示例

本文整理汇总了C#中TypeReference的典型用法代码示例。如果您正苦于以下问题:C# TypeReference类的具体用法?C# TypeReference怎么用?C# TypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeReference类属于命名空间,在下文中一共展示了TypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDefaultValueForType

		public static Expression CreateDefaultValueForType(TypeReference type)
		{
			if (type != null && !type.IsArrayType) {
				switch (type.Type) {
					case "System.SByte":
					case "System.Byte":
					case "System.Int16":
					case "System.UInt16":
					case "System.Int32":
					case "System.UInt32":
					case "System.Int64":
					case "System.UInt64":
					case "System.Single":
					case "System.Double":
						return new PrimitiveExpression(0, "0");
					case "System.Char":
						return new PrimitiveExpression('\0', "'\\0'");
					case "System.Object":
					case "System.String":
						return new PrimitiveExpression(null, "null");
					case "System.Boolean":
						return new PrimitiveExpression(false, "false");
					default:
						return new DefaultValueExpression(type);
				}
			} else {
				return new PrimitiveExpression(null, "null");
			}
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:29,代码来源:ExpressionBuilder.cs

示例2: CloneMethodWithDeclaringType

    private static MethodReference CloneMethodWithDeclaringType(MethodDefinition methodDef, TypeReference declaringTypeRef)
    {
        if (!declaringTypeRef.IsGenericInstance || methodDef == null)
        {
            return methodDef;
        }

        var methodRef = new MethodReference(methodDef.Name, methodDef.ReturnType, declaringTypeRef)
        {
            CallingConvention = methodDef.CallingConvention,
            HasThis = methodDef.HasThis,
            ExplicitThis = methodDef.ExplicitThis
        };

        foreach (var paramDef in methodDef.Parameters)
        {
            methodRef.Parameters.Add(new ParameterDefinition(paramDef.Name, paramDef.Attributes, paramDef.ParameterType));
        }

        foreach (var genParamDef in methodDef.GenericParameters)
        {
            methodRef.GenericParameters.Add(new GenericParameter(genParamDef.Name, methodRef));
        }

        return methodRef;
    }
开发者ID:mdabbagh88,项目名称:Ionad,代码行数:26,代码来源:CecilExtensions.cs

示例3: FieldDefinition

 public FieldDefinition(ClassDefinition owner, string name, TypeReference fieldType)
     : this()
 {
     Owner = owner;
     Name = name;
     Type = fieldType;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:7,代码来源:FieldDefinition.cs

示例4: FindCoreReferences

    public void FindCoreReferences()
    {
        var coreTypes = new List<TypeDefinition>();
        AppendTypes("mscorlib", coreTypes);
        AppendTypes("System.IO", coreTypes);
        AppendTypes("System.Runtime", coreTypes);
        AppendTypes("System.Reflection", coreTypes);

        var textReaderTypeDefinition = coreTypes.First(x => x.Name == "TextReader");
        ReadToEndMethod = ModuleDefinition.ImportReference(textReaderTypeDefinition.Find("ReadToEnd"));

        var exceptionTypeDefinition = coreTypes.First(x => x.Name == "Exception");
        ExceptionConstructorReference = ModuleDefinition.ImportReference(exceptionTypeDefinition.Find(".ctor", "String"));

        var stringTypeDefinition = coreTypes.First(x => x.Name == "String");
        ConcatReference = ModuleDefinition.ImportReference(stringTypeDefinition.Find("Concat", "String", "String", "String"));

        DisposeTextReaderMethod = ModuleDefinition.ImportReference(textReaderTypeDefinition.Find("Dispose"));
        var streamTypeDefinition = coreTypes.First(x => x.Name == "Stream");
        DisposeStreamMethod = ModuleDefinition.ImportReference(streamTypeDefinition.Find("Dispose"));
        StreamTypeReference = ModuleDefinition.ImportReference(streamTypeDefinition);
        var streamReaderTypeDefinition = coreTypes.First(x => x.Name == "StreamReader");
        StreamReaderTypeReference = ModuleDefinition.ImportReference(streamReaderTypeDefinition);
        StreamReaderConstructorReference = ModuleDefinition.ImportReference(streamReaderTypeDefinition.Find(".ctor", "Stream"));
        var assemblyTypeDefinition = coreTypes.First(x => x.Name == "Assembly");
        AssemblyTypeReference = ModuleDefinition.ImportReference(assemblyTypeDefinition);
        GetExecutingAssemblyMethod = ModuleDefinition.ImportReference(assemblyTypeDefinition.Find("GetExecutingAssembly"));
        GetManifestResourceStreamMethod = ModuleDefinition.ImportReference(assemblyTypeDefinition.Find("GetManifestResourceStream", "String"));
    }
开发者ID:Misiu,项目名称:Resourcer,代码行数:29,代码来源:ReferenceFinder.cs

示例5: FindWinRTMsCoreReferences

 public void FindWinRTMsCoreReferences()
 {
     var systemRuntime = assemblyResolver.Resolve("System.Runtime");
     var systemRuntimeTypes = systemRuntime.MainModule.Types;
     var voidDefinition = systemRuntimeTypes.First(x => x.Name == "Void");
     VoidTypeReference = Module.Import(voidDefinition);
 }
开发者ID:MartinDemberger,项目名称:Costura,代码行数:7,代码来源:MsCoreReferenceFinder.cs

示例6: FindMsCoreReferences

    void FindMsCoreReferences()
    {
        var msCoreLibDefinition = AssemblyResolver.Resolve("mscorlib");

        msCoreTypes = msCoreLibDefinition.MainModule.Types.ToList();

        var objectDefinition = msCoreTypes.FirstOrDefault(x => x.Name == "Object");
        if (objectDefinition == null)
        {
            throw new WeavingException("Only compat with desktop .net");
        }

        var voidDefinition = msCoreTypes.First(x => x.Name == "Void");
        voidTypeReference = ModuleDefinition.ImportReference(voidDefinition);

        var dictionary = msCoreTypes.First(x => x.Name == "Dictionary`2");
        var dictionaryOfStringOfString = ModuleDefinition.ImportReference(dictionary);
        dictionaryOfStringOfStringAdd = ModuleDefinition.ImportReference(dictionaryOfStringOfString.Resolve().Methods.First(m => m.Name == "Add"))
            .MakeHostInstanceGeneric(ModuleDefinition.TypeSystem.String, ModuleDefinition.TypeSystem.String);

        var list = msCoreTypes.First(x => x.Name == "List`1");
        var listOfString = ModuleDefinition.ImportReference(list);
        listOfStringAdd = ModuleDefinition.ImportReference(listOfString.Resolve().Methods.First(m => m.Name == "Add"))
            .MakeHostInstanceGeneric(ModuleDefinition.TypeSystem.String);

        var compilerGeneratedAttribute = msCoreTypes.First(x => x.Name == "CompilerGeneratedAttribute");
        compilerGeneratedAttributeCtor = ModuleDefinition.ImportReference(compilerGeneratedAttribute.Methods.First(x => x.IsConstructor));
    }
开发者ID:rodrigoferrobrti,项目名称:Costura,代码行数:28,代码来源:MsCoreReferenceFinder.cs

示例7: AddAppliesToType

        internal void AddAppliesToType(string typeName)
        {
            TypeReference tr = new TypeReference();

            tr.name = typeName;
            this.referenceList.Add(tr);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:displayDescriptionDataMethods.cs

示例8: IsType

		/// <summary>
		/// Determines whether a type given by its full name corresponds to a type reference.
		/// </summary>
		public static bool IsType(TypeReference type, string typeName)
		{
			if (type.SystemType == typeName) return true;

			int index = typeName.LastIndexOf('.');
			return (index > 0 && type.SystemType == typeName.Substring(index + 1));
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:10,代码来源:Utility.cs

示例9: Fill

        internal static void Fill(string tdString, TypeReference item)
        {
            if (!string.IsNullOrEmpty(tdString))
            {
                char prefix = tdString[0];
                var td = (TypeDescriptors) prefix;
                switch (td)
                {
                    case TypeDescriptors.Array:
                        var atype = (ArrayType) item;

                        TypeReference elementType = Allocate(tdString.Substring(1));
                        Fill(tdString.Substring(1), elementType);

                        /* All types are already allocated
                         * We want to reuse object reference if already in type repository
                         * BUT if not, we don't want to add a new reference to this type:
                         * it's a 'transient' type only used in the Dexer object model but
                         * not persisted in dex file.
                         */
                        atype.ElementType = elementType; //context.Import(elementType, false);

                        break;
                    case TypeDescriptors.FullyQualifiedName:
                        var cref = (ClassReference) item;
                        cref.Fullname = tdString.Substring(1, tdString.Length - 2);
                        break;
                }
            }
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:30,代码来源:TypeDescriptor.cs

示例10: GetName

    public static string GetName(TypeReference type)
    {
        if (type.IsNested)
            return GetName (type.DeclaringType) + "+" + type.Name;

        return type.Name;
    }
开发者ID:mono,项目名称:TreemapViewer,代码行数:7,代码来源:Main.cs

示例11: CheckTypeReferenceForProperWinRTHome

 public void CheckTypeReferenceForProperWinRTHome(TypeReference typeReference, string module)
 {
     ScopeReference scope = GetScopeReferenceOfType(typeReference);
     Assert.Equal(module, scope.Name.Value);
     int windowsRuntimeFlag = ((int)System.Reflection.AssemblyContentType.WindowsRuntime << 9);
     Assert.True((((int)scope.Flags) & windowsRuntimeFlag) == windowsRuntimeFlag);
 }
开发者ID:tijoytom,项目名称:corert,代码行数:7,代码来源:ExplicitScopeTests.cs

示例12: Execute

    public void Execute()
    {
        var msCoreLibDefinition = assemblyResolver.Resolve("mscorlib");
        var msCoreTypes = msCoreLibDefinition.MainModule.Types;

        var objectDefinition = msCoreTypes.FirstOrDefault(x => x.Name == "Object");
        if (objectDefinition == null)
        {
            ExecuteWinRT();
            return;
        }
        var module = moduleWeaver.ModuleDefinition;

        var methodBaseDefinition = msCoreTypes.First(x => x.Name == "MethodBase");
        GetMethodFromHandle = module.ImportReference(methodBaseDefinition.Methods.First(x => x.Name == "GetMethodFromHandle"));

        var methodInfo = msCoreTypes.FirstOrDefault(x => x.Name == "MethodInfo");
        MethodInfoTypeReference = module.ImportReference(methodInfo);

        var compilerGeneratedDefinition = msCoreTypes.First(x => x.Name == "CompilerGeneratedAttribute");
        CompilerGeneratedReference = module.ImportReference(compilerGeneratedDefinition.Methods.First(x => x.IsConstructor));

        var systemCoreDefinition = GetSystemCoreDefinition();

        var expressionTypeDefinition = systemCoreDefinition.MainModule.Types.First(x => x.Name == "Expression");
        var propertyMethodDefinition =
            expressionTypeDefinition.Methods.First(
                x => x.Name == "Property" && x.Parameters.Last().ParameterType.Name == "MethodInfo");
        PropertyReference = module.ImportReference(propertyMethodDefinition);
    }
开发者ID:qkub,项目名称:ExpandoIntelligizer,代码行数:30,代码来源:MsCoreReferenceFinder.cs

示例13: VariableStartEntry

 /// <summary>
 /// Default ctor
 /// </summary>
 public VariableStartEntry(int offset, Register register, IVariable variable, TypeReference type) : base(offset)
 {
     this.register = register;
     Variable = variable;
     name = variable.OriginalName;
     this.type = type;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:DebugInfoBuilder.VariableStartEntry.cs

示例14: PointerTypeReference

        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pointedToType">The pointed to type</param>
        public PointerTypeReference(TypeReference pointedToType)
        {
            if(pointedToType == null)
                throw new ArgumentNullException("pointedToType");

            this.PointedToType = pointedToType;
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:13,代码来源:PointerTypeReference.cs

示例15: ReadObject

        private TypeReference ReadObject(JsonReader reader)
        {
            reader.Read();
            if (reader.TokenType != JsonToken.PropertyName || ((string)reader.Value != "__ref__" && (string)reader.Value != "type"))
            {
                throw new ArgumentException("Unexpected token type " + reader.TokenType);
            }

            var isRef = (string) reader.Value == "__ref__";

            reader.Read();
            if (reader.TokenType != JsonToken.String)
            {
                throw new ArgumentException("Unexpected token type " + reader.TokenType);
            }

            var retval = new TypeReference
            {
                IsReference = isRef,
                Name = (string)reader.Value
            };
            reader.Read();

            return retval;
        }
开发者ID:lokeuei,项目名称:glTF,代码行数:25,代码来源:ArrayOfTypeReferencesConverter.cs


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