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


C# TypeReference.MakeGenericInstanceType方法代码示例

本文整理汇总了C#中Mono.Cecil.TypeReference.MakeGenericInstanceType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.MakeGenericInstanceType方法的具体用法?C# TypeReference.MakeGenericInstanceType怎么用?C# TypeReference.MakeGenericInstanceType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.TypeReference的用法示例。


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

示例1: ImportRuntimeModuleDictionary

 private void ImportRuntimeModuleDictionary(ModuleDefinition module, TypeReference tDict)
 {
     var tFuncOfModule = FuncOfT.MakeGenericInstanceType(RuntimeModule);
     var tModuleDict = tDict.MakeGenericInstanceType(Type, tFuncOfModule);
     DictionaryOfTypeToModuleFn = module.Import(tModuleDict);
     DictionaryOfTypeToModuleFn_New =
         module.Import(tModuleDict.Resolve()
                                  .GetDefaultConstructor())
               .MakeHostInstanceGeneric(Type, tFuncOfModule);
     DictionaryOfTypeToModuleFn_Add =
         module.Import(tModuleDict.Resolve().GetMethod("Add")).MakeHostInstanceGeneric(Type, tFuncOfModule);
     DictionaryOfTypeToModuleFn_TryGetValue =
         module.Import(tModuleDict.Resolve().GetMethod("TryGetValue"))
               .MakeHostInstanceGeneric(Type, tFuncOfModule);
 }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:15,代码来源:References.cs

示例2: ImportProviderBindingDictionary

 private void ImportProviderBindingDictionary(ModuleDefinition module, TypeReference tDict)
 {
     var tFuncOfProviderBinding = FuncOfT5.MakeGenericInstanceType(String, Object, Boolean, String, Binding);
     var tProviderDict = tDict.MakeGenericInstanceType(String, tFuncOfProviderBinding);
     DictionaryOfStringToProviderBindingFn = tProviderDict;
     DictionaryOfStringToProviderBindingFn_New =
         module.Import(tProviderDict.Resolve()
                                    .GetConstructors()
                                    .First(
                                        c =>
                                        c.Parameters.Count == 1 &&
                                        c.Parameters[0].ParameterType.Name.StartsWith("IEqualityComparer")))
               .MakeHostInstanceGeneric(String, tFuncOfProviderBinding);
     DictionaryOfStringToProviderBindingFn_Add =
         module.Import(tProviderDict.Resolve().GetMethod("Add"))
               .MakeHostInstanceGeneric(String, tFuncOfProviderBinding);
     DictionaryOfStringToProviderBindingFn_TryGetValue =
         module.Import(tProviderDict.Resolve().GetMethod("TryGetValue"))
               .MakeHostInstanceGeneric(String, tFuncOfProviderBinding);
 }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:20,代码来源:References.cs

示例3: ImportGeneric

 /// <summary>
 /// Imports a method of a generic type.
 /// </summary>
 /// <returns>
 /// Returns an imported method with the given generic arguments applied to the declaring type.
 /// </returns>
 /// <param name="t">The type declaring the desired method.</param>
 /// <param name="predicate">A predicate identifying the desired method.  Must match one and only one method.</param>
 /// <param name="genericArguments">The generic arguments to be applied.</param>
 protected MethodReference ImportGeneric(TypeReference t, Func<MethodDefinition, bool> predicate, params TypeReference[] genericArguments)
 {
     var gt = t.MakeGenericInstanceType(genericArguments);
     return ModuleDefinition
         .Import(gt.Resolve().Methods.FirstOrDefault(predicate))
         .MakeHostInstanceGeneric(genericArguments);
 }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:16,代码来源:Generator.cs

示例4: ImportInjectBindingDictionary

        private void ImportInjectBindingDictionary(ModuleDefinition module, TypeReference tDict)
        {
            var tFuncOfBinding = FuncOfT.MakeGenericInstanceType(Binding);
            var tDictOfStringToBindingFn = tDict.MakeGenericInstanceType(
                String, tFuncOfBinding);

            DictionaryOfStringToBindingFn = tDictOfStringToBindingFn;
            DictionaryOfStringToBindingFn_New =
                module.Import(
                    tDictOfStringToBindingFn.Resolve()
                                            .Methods
                                            .First(
                                                c =>
                                                c.Name == ".ctor" &&
                                                c.Parameters.Count == 1 &&
                                                c.Parameters[0].ParameterType.Name.StartsWith("IEqualityComparer")))
                      .MakeHostInstanceGeneric(String, tFuncOfBinding);
            DictionaryOfStringToBindingFn_Add =
                module.Import(tDictOfStringToBindingFn.Resolve().GetMethod("Add"))
                      .MakeHostInstanceGeneric(String, tFuncOfBinding);
            DictionaryOfStringToBindingFn_TryGetValue =
                module.Import(tDictOfStringToBindingFn.Resolve().GetMethod("TryGetValue"))
                      .MakeHostInstanceGeneric(String, tFuncOfBinding);
        }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:24,代码来源:References.cs

示例5: GetFnMethods

        private Tuple<TypeReference, MethodReference, MethodReference> GetFnMethods(
            TypeReference tFn,
            params TypeReference[] generics)
        {
            var t = Import(tFn.MakeGenericInstanceType(generics));

            var ctor = ImportGeneric(
                tFn,
                m => m.IsConstructor
                     && (m.Attributes & MethodAttributes.Public) == MethodAttributes.Public
                     && m.Parameters.Count == 2,
                generics);

            var invoke = ImportGeneric(
                tFn,
                m => m.Name == "Invoke",
                generics);

            return Tuple.Create(t, ctor, invoke);
        }
开发者ID:benjamin-bader,项目名称:stiletto,代码行数:20,代码来源:LoaderGenerator.cs


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