Пример #1
0
        public WhoReferencesAssembly(UsageQueryAggregator aggregator, string fileName) : base(aggregator)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("File name was null or empty.");
            }

            myAssembly = Path.GetFileNameWithoutExtension(fileName);
            aggregator.AddVisitScope(fileName);
        }
Пример #2
0
        public WhoInstantiatesType(UsageQueryAggregator aggregator, TypeDefinition type)
            : base(aggregator)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type was null");
            }

            myType = type;
            Aggregator.AddVisitScope(type.Module.Assembly.Name.Name);
        }
Пример #3
0
        public UsageVisitor(UsageQueryAggregator aggregator)
        {
            if (aggregator == null)
            {
                throw new ArgumentNullException("aggregator");
            }

            Aggregator = aggregator;

            // subscribe ourself to the aggregator when the query is constructed
            Aggregator.AddQuery(this);
        }
Пример #4
0
        public WhoUsesStringConstant(UsageQueryAggregator aggregator, string searchString, bool bExactMatch, StringComparison compMode) :
            base(aggregator)
        {
            if (String.IsNullOrEmpty(searchString))
            {
                throw new ArgumentException("The search string was null or empty");
            }

            mySearchString   = searchString;
            mybExatchMatch   = bExactMatch;
            myComparisonMode = compMode;
        }
Пример #5
0
        public WhoDerivesFromType(UsageQueryAggregator aggregator, List <TypeDefinition> typeDefs) : base(aggregator)
        {
            if (typeDefs == null)
            {
                throw new ArgumentException("The type list to query for was null.");
            }

            foreach (var type in typeDefs)
            {
                Aggregator.AddVisitScope(type.Module.Assembly.Name.Name);
            }

            mySearchBaseTypes = typeDefs;
        }
Пример #6
0
        public WhoUsesEvents(UsageQueryAggregator aggreagator, List <EventDefinition> events) : base(aggreagator)
        {
            if (events == null)
            {
                throw new ArgumentException("The events list was null.");
            }

            myEvents = events;

            foreach (var ev in myEvents)
            {
                Aggregator.AddVisitScope(ev.AddMethod.DeclaringType.Module.Assembly.Name.Name);
                myEventNames.Add(ev.AddMethod.Name);
                myEventNames.Add(ev.RemoveMethod.Name);
            }
        }
Пример #7
0
        public WhoHasFieldOfType(UsageQueryAggregator aggregator, List <TypeDefinition> fieldTypes)
            : base(aggregator)
        {
            if (fieldTypes == null)
            {
                throw new ArgumentNullException("fieldTypes");
            }

            mySearchTypes = fieldTypes;

            foreach (TypeDefinition fieldType in fieldTypes)
            {
                mySearchTypeNames.Add(fieldType.Name);
                Aggregator.AddVisitScope(fieldType.Module.Assembly.Name.Name);
            }
        }
Пример #8
0
        public WhoUsesMethod(UsageQueryAggregator aggregator, List <MethodDefinition> methods) : base(aggregator)
        {
            if (methods == null)
            {
                throw new ArgumentNullException("The method list to query for was null.");
            }

            foreach (var method in methods)
            {
                Aggregator.AddVisitScope(method.DeclaringType.Module.Assembly.Name.Name);
                List <MethodDefinition> typeMethods = null;
                if (!myMethodNames.TryGetValue(method.DeclaringType.Name, out typeMethods))
                {
                    typeMethods = new List <MethodDefinition>();
                    myMethodNames[method.DeclaringType.Name] = typeMethods;
                }
                myMethodNames[method.DeclaringType.Name].Add(method);
            }
        }
Пример #9
0
        public WhoAccessesField(UsageQueryAggregator aggregator, List <FieldDefinition> fields) : base(aggregator)
        {
            if (fields == null)
            {
                throw new ArgumentException("The field list was null.");
            }

            mySearchFields = fields;

            foreach (FieldDefinition field in fields)
            {
                if (field.HasConstant)
                {
                    throw new ArgumentException(
                              String.Format("The field {0} is constant. Its value is compiled directly into the users of this constant which makes is impossible to search for users of it.",
                                            field.Print(FieldPrintOptions.All)));
                }
                myDeclaringTypeNamesToSearch.Add(field.DeclaringType.Name);
                Aggregator.AddVisitScope(field.DeclaringType.Module.Assembly.Name.Name);
            }
        }
Пример #10
0
        public WhoUsesType(UsageQueryAggregator aggregator, List <TypeDefinition> funcArgTypes) :
            base(aggregator)
        {
            using (Tracer t = new Tracer(Level.L5, myType, "WhoUsesType"))
            {
                if (funcArgTypes == null)
                {
                    throw new ArgumentNullException("funcArgTypes");
                }

                mySearchArgTypes = funcArgTypes;


                foreach (TypeDefinition funcArgType in funcArgTypes)
                {
                    t.Info("Adding search type {0}", new LazyFormat(() => funcArgType.Print()));
                    myArgSearchTypeNames.Add(funcArgType.Name);
                    Aggregator.AddVisitScope(funcArgType.Module.Assembly.Name.Name);
                    new WhoAccessesField(aggregator, notConst.GetMatchingFields(funcArgType));
                }
            }
        }
Пример #11
0
        public WhoImplementsInterface(UsageQueryAggregator aggreator, List <TypeDefinition> interfaces) : base(aggreator)
        {
            if (interfaces == null || interfaces.Count == 0)
            {
                throw new ArgumentException("The interfaces collection was null.");
            }

            foreach (var type in interfaces)
            {
                if (!type.IsInterface)
                {
                    throw new ArgumentException(
                              String.Format("The type {0} is not an interface", type.Print()));
                }

                Aggregator.AddVisitScope(type.Module.Assembly.Name.Name);
                if (!myInterfaceNames.ContainsKey(type.Name))
                {
                    myInterfaceNames.Add(type.Name, type);
                }
            }
        }
Пример #12
0
 public WhoDerivesFromType(UsageQueryAggregator aggregator, TypeDefinition typeDef)
     : this(aggregator, new List <TypeDefinition> {
     ThrowIfNull <TypeDefinition>("typeDef", typeDef)
 })
 {
 }
Пример #13
0
 public WhoHasFieldOfType(UsageQueryAggregator aggregator, TypeDefinition fieldType)
     : this(aggregator, new List <TypeDefinition> {
     ThrowIfNull <TypeDefinition>("fieldType", fieldType)
 })
 {
 }
Пример #14
0
 public WhoUsesStringConstant(UsageQueryAggregator aggregator, string searchString)
     : this(aggregator, searchString, false, StringComparison.OrdinalIgnoreCase)
 {
 }
Пример #15
0
 public WhoAccessesField(UsageQueryAggregator aggreagator, FieldDefinition field) :
     this(aggreagator, new List <FieldDefinition> {
     ThrowIfNull <FieldDefinition>("field", field)
 })
 {
 }
Пример #16
0
 public WhoImplementsInterface(UsageQueryAggregator aggregator, TypeDefinition itf)
     : this(aggregator, new List <TypeDefinition>() { ThrowIfNull <TypeDefinition>("itf", itf) })
 {
 }
Пример #17
0
 public WhoUsesStringConstant(UsageQueryAggregator aggregator, string searchString, bool bExactMatch)
     : this(aggregator, searchString, bExactMatch, StringComparison.OrdinalIgnoreCase)
 {
 }
Пример #18
0
 public WhoUsesType(UsageQueryAggregator aggregator, TypeDefinition funcArgType) :
     this(aggregator, new List <TypeDefinition> {
     ThrowIfNull <TypeDefinition>("funcArgType", funcArgType)
 })
 {
 }
Пример #19
0
 public WhoUsesEvents(UsageQueryAggregator aggregator, EventDefinition ev) :
     this(aggregator, new List <EventDefinition> {
     ThrowIfNull <EventDefinition>("ev", ev)
 })
 {
 }