當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。