private static IEnumerable <string> DocumentsFor(TypeDefinition typeDefinition)
        {
            CollectSourceDocumentsVisitor visitor = new CollectSourceDocumentsVisitor();

            typeDefinition.Accept(visitor);
            return(visitor.Documents);
        }
Esempio n. 2
0
        public void AddAdditionalMembers(TypeDefinition host)
        {
            // Make sure the type implements IActivatorHost
            var interfaceWeaver = new ImplementActivatorHostWeaver();

            host.Accept(interfaceWeaver);
        }
        public static InflatedCollectionCollector Collect(TypeDefinition type)
        {
            InflatedCollectionCollector generics = new InflatedCollectionCollector();
            GenericContextFreeVisitor   visitor  = new GenericContextFreeVisitor(generics);

            type.Accept(visitor);
            return(generics);
        }
        /// <summary>
        ///     Modifies the current <paramref name="target" /> to support third-party method call interception for all method
        ///     calls made inside the target.
        /// </summary>
        /// <param name="target">The target object.</param>
        /// <param name="methodCallFilter">
        ///     The <see cref="IMethodCallFilter" /> instance that determines the method calls that will
        ///     be intercepted.
        /// </param>
        /// <param name="hostMethodFilter">
        ///     The <see cref="IMethodFilter" /> instance that determines the host method calls that
        ///     will be modified
        /// </param>
        public static void InterceptMethodCalls(this TypeDefinition target, IMethodCallFilter methodCallFilter,
                                                IMethodFilter hostMethodFilter)
        {
            var rewriter = new InterceptMethodCalls(methodCallFilter);

            target.Accept(new ImplementModifiableType(GetDefaultTypeFilter()));
            target.WeaveWith(rewriter);
        }
        /// <summary>
        ///     Modifies the current <paramref name="target" /> to support third-party method call interception.
        /// </summary>
        /// <param name="target">The target object.</param>
        /// <param name="typeFilter">The filter that will determine the target types that will be modified.</param>
        /// <param name="hostMethodFilter">The filter that will determine the methods that will be modified on the target type.</param>
        /// <param name="methodCallFilter">
        ///     The filter that will determine which third-party methods will be intercepted on the
        ///     target type.
        /// </param>
        public static void InterceptMethodCalls(this TypeDefinition target, Func <TypeReference, bool> typeFilter,
                                                Func <MethodReference, bool> hostMethodFilter,
                                                Func <MethodReference, bool> methodCallFilter)
        {
            var rewriter = new InterceptMethodCalls(hostMethodFilter, methodCallFilter);

            target.Accept(new ImplementModifiableType(typeFilter));
            target.WeaveWith(rewriter);
        }
Esempio n. 6
0
        /// <summary>
        /// Write a type signature to the text buffer
        /// </summary>
        /// <param name="tdef">Type definition</param>
        protected override void WriteTypeSignature(TypeDefinition tdef)
        {
            tdef.Accept(this);


            if (tdef.GenericParameters.Count > 0)
            {
                Replace(GENERIC_TYPE_TAG + tdef.GenericParameters.Count, String.Empty);
            }
        }
        /// <summary>
        ///     Intercepts all method bodies on the target item.
        /// </summary>
        /// <param name="target">The target to be modified.</param>
        /// <param name="methodFilter">The method filter that will determine the methods that will be modified.</param>
        public static void InterceptMethodBody(this TypeDefinition target,
                                               Func <MethodReference, bool> methodFilter)
        {
            var typeFilter = GetTypeFilter();

            target.Accept(new ImplementModifiableType(typeFilter));

            IMethodWeaver interceptMethodBody = new InterceptMethodBody(methodFilter);

            target.WeaveWith(interceptMethodBody);
        }
Esempio n. 8
0
        /// <summary>
        /// Write a type signature to the text buffer
        /// </summary>
        /// <param name="tdef">Type definition</param>
        protected override void WriteTypeSignature(TypeDefinition tdef)
        {
            tdef.Accept(this);

            if (tdef.GenericParameters.Count <= 0)
            {
                return;
            }

            foreach (var genparam in tdef.GenericParameters.Where(genparam => genparam.Constraints.Count > 0))
            {
                Write(ECSharpKeyword.@where, ESpaceSurrounder.Both);
                genparam.Accept(this);
                VisitVisitableCollection(GenericConstraintListStart, String.Empty, BasicSeparator, false, genparam.Constraints);
            }

            Replace(GenericTypeTag + tdef.GenericParameters.Count, String.Empty);
        }
Esempio n. 9
0
        /// <summary>
        /// Write a type signature to the text buffer
        /// </summary>
        /// <param name="tdef">Type definition</param>
        protected override void WriteTypeSignature(TypeDefinition tdef)
        {
            tdef.Accept(this);

            if (tdef.GenericParameters.Count > 0)
            {
                foreach (GenericParameter genparam in tdef.GenericParameters)
                {
                    if (genparam.Constraints.Count > 0)
                    {
                        Write(ECSharpKeyword.@where, ESpaceSurrounder.Both);
                        genparam.Accept(this);
                        VisitVisitableCollection(GENERIC_CONSTRAINT_LIST_START, String.Empty, BASIC_SEPARATOR, false, genparam.Constraints);
                    }
                }
                Replace(GENERIC_TYPE_TAG + tdef.GenericParameters.Count, String.Empty);
            }
        }