• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IMetadataHost类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TypeInferencer

 internal TypeInferencer(INamedTypeReference containingType, IMetadataHost host) {
   Contract.Requires(containingType != null);
   Contract.Requires(host != null);
   this.containingType = containingType;
   this.host = host;
   this.platformType = containingType.PlatformType;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:7,代码来源:TypeInferencer.cs


示例2: FieldAssignmentReplacementBuilder

 public FieldAssignmentReplacementBuilder(FieldReference field, IMetadataHost host, ExpressionStatement assignment, ReplacementRegistry registry)
 {
     this.field = field;
     this.host = host;
     this.assignment = assignment;
     this.registry = registry;
 }
开发者ID:jamarchist,项目名称:SharpMock,代码行数:7,代码来源:FieldAssignmentReplacementBuilder.cs


示例3: FindClosureMoveNext

 /// <summary>
 /// For an iterator method, find the closure class' MoveNext method and return its body.
 /// </summary>
 /// <param name="host"></param>
 /// <param name="possibleIterator">The (potential) iterator method.</param>
 /// <returns>Dummy.MethodBody if <paramref name="possibleIterator"/> does not fit into the code pattern of an iterator method, 
 /// or the body of the MoveNext method of the corresponding closure class if it does.
 /// </returns>
 public static IMethodBody/*?*/ FindClosureMoveNext(IMetadataHost host, ISourceMethodBody/*!*/ possibleIterator) {
   if (possibleIterator is Dummy) return null;
   var nameTable = host.NameTable;
   var possibleIteratorBody = possibleIterator.Block;
   foreach (var statement in possibleIteratorBody.Statements) {
     var expressionStatement = statement as IExpressionStatement;
     if (expressionStatement != null)
       return FirstStatementIsIteratorCreation(host, possibleIterator, nameTable, statement);
     break;
   }
   foreach (var statement in possibleIteratorBody.Statements){
     //var lds = statement as ILocalDeclarationStatement;
     //if (lds != null) {
     //  if (lds.InitialValue != null)
     //    return null;
     //  else
     //    continue;
     //}
     var returnStatement = statement as IReturnStatement;
     if (returnStatement == null) return null;
     var blockExpression = returnStatement.Expression as IBlockExpression;
     if (blockExpression == null) return null;
     foreach (var s in blockExpression.BlockStatement.Statements) {
       return FirstStatementIsIteratorCreation(host, possibleIterator, nameTable, s);
     }
   }
   return null;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:36,代码来源:MoveNext.cs


示例4: AnonymousDelegateCachingRemover

 internal AnonymousDelegateCachingRemover(IMetadataHost host, Hashtable<IAnonymousDelegate>/*?*/ delegatesCachedInFields,
   Hashtable<LocalDefinition, AnonymousDelegate>/*?*/ delegatesCachedInLocals)
   : base(host) {
   Contract.Requires(host != null);
   this.delegatesCachedInFields = delegatesCachedInFields;
   this.delegatesCachedInLocals = delegatesCachedInLocals;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:7,代码来源:AnonymousDelegateCachingRemover.cs


示例5: FirstStatementIsIteratorCreation

 private static IMethodBody/*?*/ FirstStatementIsIteratorCreation(IMetadataHost host, ISourceMethodBody possibleIterator, INameTable nameTable, IStatement statement) {
   ICreateObjectInstance createObjectInstance = GetICreateObjectInstance(statement);
   if (createObjectInstance == null) {
     // If the first statement in the method body is not the creation of iterator closure, return a dummy.
     // Possible corner case not handled: a local is used to hold the constant value for the initial state of the closure.
     return null;
   }
   ITypeReference closureType/*?*/ = createObjectInstance.MethodToCall.ContainingType;
   ITypeReference unspecializedClosureType = ContractHelper.Unspecialized(closureType);
   if (!AttributeHelper.Contains(unspecializedClosureType.Attributes, host.PlatformType.SystemRuntimeCompilerServicesCompilerGeneratedAttribute))
     return null;
   INestedTypeReference closureTypeAsNestedTypeReference = unspecializedClosureType as INestedTypeReference;
   if (closureTypeAsNestedTypeReference == null) return null;
   ITypeReference unspecializedClosureContainingType = ContractHelper.Unspecialized(closureTypeAsNestedTypeReference.ContainingType);
   if (closureType != null && TypeHelper.TypesAreEquivalent(possibleIterator.MethodDefinition.ContainingTypeDefinition, unspecializedClosureContainingType)) {
     IName MoveNextName = nameTable.GetNameFor("MoveNext");
     foreach (ITypeDefinitionMember member in closureType.ResolvedType.GetMembersNamed(MoveNextName, false)) {
       IMethodDefinition moveNext = member as IMethodDefinition;
       if (moveNext != null) {
         ISpecializedMethodDefinition moveNextGeneric = moveNext as ISpecializedMethodDefinition;
         if (moveNextGeneric != null)
           moveNext = moveNextGeneric.UnspecializedVersion.ResolvedMethod;
         return moveNext.Body;
       }
     }
   }
   return null;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:28,代码来源:MoveNext.cs


示例6: CalculateCyclomaticComplexity

 private static int CalculateCyclomaticComplexity(this IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     var methodBody = method.Decompile(pdb, host);
     var cyclomaticComplexityCalculator = new CyclomaticComplexityCalculator();
     cyclomaticComplexityCalculator.Traverse(methodBody.Statements());
     return cyclomaticComplexityCalculator.Result;
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CyclomaticComplexityOfAst.cs


示例7: AnalyzeFileInHost

 private static void AnalyzeFileInHost(string toAnalyse, IMetadataHost host)
 {
     AnalyzeFileWithPdb(toAnalyse, host, (pdb) =>
     {
         AnalyzeAssembly(host.LoadUnitFrom(toAnalyse) as IAssembly, pdb);
     });
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:Program.cs


示例8: AnalyzeAssemblyInHost

 private void AnalyzeAssemblyInHost(IMetadataHost host, IAssembly assembly, string pdbPath)
 {
     if (pdbPath != null)
         AnalyzeAssemblyInHostWithProgramDatabase(assembly, host, pdbPath);
     else
         AnalyzeTypes(assembly, null, host, Report);
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:AssemblyVisitor.cs


示例9: SpecifiedMethodCallRegistrar

 public SpecifiedMethodCallRegistrar(IMetadataHost host, ILogger log, ReplacementRegistry registry)
 {
     this.host = host;
     this.log = log;
     this.registry = registry;
     reflector = new UnitReflector(host);
 }
开发者ID:jamarchist,项目名称:SharpMock,代码行数:7,代码来源:SpecifiedMethodCallRegistrar.cs


示例10: TypeAndMethods

 private TypeMetricsWithMethodMetrics TypeAndMethods(PdbReader pdb, IMetadataHost host, INamedTypeDefinition type)
 {
     var typeAndMethods = new TypeMetricsWithMethodMetrics();
     typeAndMethods.AddMethodReports(AnalyzeMethods(type, pdb, host));
     typeAndMethods.Type = AnalyzeType(type, pdb, typeAndMethods.Methods);
     return typeAndMethods;
 }
开发者ID:usus,项目名称:Usus.NET,代码行数:7,代码来源:TypeVisitor.cs


示例11: Decompile

 public static SourceMethodBody Decompile(this IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     return new SourceMethodBody(method.Body, host, pdb, pdb,
                DecompilerOptions.Loops |
                DecompilerOptions.AnonymousDelegates |
                DecompilerOptions.Iterators);
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:MethodExtensions.cs


示例12: Reachable

    internal static void Reachable(
      IMetadataHost host,
      ISlice<MethodReferenceAdaptor, FieldReferenceAdaptor, TypeReferenceAdaptor, IAssemblyReference> slice,
      HashSet<object> thingsToKeep,
      HashSet<uint> methodsWhoseBodiesShouldBeKept,
      out Dictionary<IMethodDefinition, uint> contractOffsets
      ) {

      Contract.Requires(host != null);
      Contract.Requires(slice != null);
      Contract.Requires(thingsToKeep != null);
      Contract.Requires(methodsWhoseBodiesShouldBeKept != null);

      var traverser = new MetadataTraverser();
      var me = new FindReachable(host, traverser, slice, thingsToKeep, methodsWhoseBodiesShouldBeKept);
      traverser.TraverseIntoMethodBodies = true;
      traverser.PreorderVisitor = me;

      var methodsToTraverse = slice.Methods;
      foreach (var m in methodsToTraverse) {
        var methodDefinition = m.reference.ResolvedMethod;
        traverser.Traverse(methodDefinition);
      }

      foreach (var c in slice.Chains) {
        VisitChain(c, traverser);
      }
      contractOffsets = me.contractOffsets;
      return;
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:30,代码来源:FindReachable.cs


示例13: RewriteModule

        public static IModule RewriteModule(IMetadataHost host, ILocalScopeProvider localScopeProvider, ISourceLocationProvider sourceLocationProvider, IModule module)
        {
            var m = new PropertyChangedWeaver(host);
            m._rewriter = new ReferenceReplacementRewriter(host, localScopeProvider, sourceLocationProvider);

            return m.Rewrite(module);
        }
开发者ID:robocoder,项目名称:aphid,代码行数:7,代码来源:PropertyChangedWeaver.cs


示例14: Of

 public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     if (method.HasOperations())
         return method.CalculateStatements(pdb, host);
     else
         return 0;
 }
开发者ID:cessor,项目名称:MTSS12,代码行数:7,代码来源:NumberOfStatements.cs


示例15: SharpMockTypes

        public SharpMockTypes(IMetadataHost host)
        {
            var funcs = new Dictionary<int, INamedTypeReference>();
            var acts = new Dictionary<int, INamedTypeReference>();

            var sharpMockTypes =
                host.LoadUnitFrom(
                    System.Reflection.Assembly.GetExecutingAssembly().Location);
            var sharpMockDelegateTypes = sharpMockTypes as IAssembly;
            Unit = sharpMockTypes;

            foreach (var type in sharpMockDelegateTypes.GetAllTypes())
            {
                if (type.Name.Value == "VoidAction")
                {
                    acts.Add(type.GenericParameterCount, type);
                }

                if (type.Name.Value == "Function")
                {
                    funcs.Add(type.GenericParameterCount - 1, type);
                }
            }

            functions = new GenericMethodTypeDictionary(funcs, "Unable to find type Function<> with {0} input parameter arguments.");
            actions = new GenericMethodTypeDictionary(acts, "Unable to find type VoidAction<> with {0} parameter arguments.");
        }
开发者ID:jamarchist,项目名称:SharpMock,代码行数:27,代码来源:SharpMockTypes.cs


示例16: AssemblyReference

 /// <summary>
 /// Allocates a reference to a .NET assembly.
 /// </summary>
 /// <param name="host">Provides a standard abstraction over the applications that host components that provide or consume objects from the metadata model.</param>
 /// <param name="assemblyIdentity">The identity of the referenced assembly.</param>
 /// <param name="isRetargetable">True if the implementation of the referenced assembly used at runtime is not expected to match the version seen at compile time.</param>
 /// <param name="containsForeignTypes">
 /// True if the referenced assembly contains types that describe objects that are neither COM objects nor objects that are managed by the CLR.
 /// Instances of such types are created and managed by another runtime and are accessed by CLR objects via some form of interoperation mechanism.
 /// </param>
 public AssemblyReference(IMetadataHost host, AssemblyIdentity assemblyIdentity, bool isRetargetable = false, bool containsForeignTypes = false)
 {
     this.host = host;
       this.assemblyIdentity = assemblyIdentity;
       this.isRetargetable = isRetargetable;
       this.containsForeignTypes = containsForeignTypes;
 }
开发者ID:rasiths,项目名称:visual-profiler,代码行数:17,代码来源:PlatformTypes.cs


示例17: Of

 public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     if (method.HasOperations())
         return method.CalculateCyclomaticComplexity(pdb, host);
     else
         return 0;
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CyclomaticComplexityOfAst.cs


示例18: DotNetDesktopStubMethodBodyEmitter

    public DotNetDesktopStubMethodBodyEmitter(IMetadataHost host)
      : base(host) {

      this.consoleWriteLine = new Microsoft.Cci.MethodReference(host,
        GarbageCollectHelper.CreateTypeReference(host, coreAssemblyReference, "System.Console"),
        CallingConvention.Default,
        host.PlatformType.SystemVoid,
        host.NameTable.GetNameFor("WriteLine"),
        0,
        host.PlatformType.SystemString);

      this.environmentGetStackTrace = new Microsoft.Cci.MethodReference(host,
        GarbageCollectHelper.CreateTypeReference(host, coreAssemblyReference, "System.Environment"),
        CallingConvention.Default,
        host.PlatformType.SystemString,
        host.NameTable.GetNameFor("get_StackTrace"),
        0);

      this.environmentExit = new Microsoft.Cci.MethodReference(host,
        GarbageCollectHelper.CreateTypeReference(host, coreAssemblyReference, "System.Environment"),
        CallingConvention.Default,
        host.PlatformType.SystemVoid,
        host.NameTable.GetNameFor("Exit"),
        0,
        host.PlatformType.SystemInt32);
    }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:26,代码来源:Sweep.cs


示例19: ForEachRemover

        /// <summary>
        /// A rewriter for CodeModel method bodies, which changes any foreach loops found in the body into lower level structures.
        /// </summary>
        /// <param name="host">An object representing the application that is hosting the converter. It is used to obtain access to some global
        /// objects and services such as the shared name table and the table for interning references.</param>
        /// <param name="sourceLocationProvider">An object that can map the ILocation objects found in a block of statements to IPrimarySourceLocation objects. May be null.</param>
        public ForEachRemover(IMetadataHost host, ISourceLocationProvider/*?*/ sourceLocationProvider)
            : base(host)
        {
            this.sourceLocationProvider = sourceLocationProvider;


            this.moveNext = new MethodReference()
            {
                CallingConvention = CallingConvention.HasThis,
                ContainingType = host.PlatformType.SystemCollectionsIEnumerator,
                InternFactory = host.InternFactory,
                Name = host.NameTable.GetNameFor("MoveNext"),
                Parameters = new List<IParameterTypeInformation>(),
                Type = host.PlatformType.SystemBoolean,
            };

            var assemblyReference = new Immutable.AssemblyReference(this.host, this.host.CoreAssemblySymbolicIdentity);
            IUnitNamespaceReference ns = new Immutable.RootUnitNamespaceReference(assemblyReference);
            ns = new Immutable.NestedUnitNamespaceReference(ns, this.host.NameTable.GetNameFor("System"));
            var iDisposable = new Immutable.NamespaceTypeReference(this.host, ns, this.host.NameTable.GetNameFor("IDisposable"), 0, false, false, true, PrimitiveTypeCode.Reference);
            this.disposeMethod = new MethodReference()
            {
                CallingConvention = CallingConvention.HasThis,
                ContainingType = iDisposable,
                InternFactory = host.InternFactory,
                Name = this.host.NameTable.GetNameFor("Dispose"),
                Parameters = new List<IParameterTypeInformation>(),
                Type = this.host.PlatformType.SystemVoid,
            };
        }
开发者ID:xornand,项目名称:cci,代码行数:36,代码来源:ForEachRemover.cs


示例20: CalculateStatements

 private static int CalculateStatements(this IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     var methodBody = method.Decompile(pdb, host);
     var statementCollector = new StatementCollector(pdb);
     statementCollector.Traverse(methodBody.Statements());
     return statementCollector.ResultCount;
 }
开发者ID:cessor,项目名称:MTSS12,代码行数:7,代码来源:NumberOfStatements.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMetadataProvider类代码示例发布时间:2022-05-24
下一篇:
C# IMetaDataImport类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap