protected virtual void SetStaticAssociations(MethodBase consumedStatics, IMethodBodyReader reader)
        {
            if (consumedStatics == null)
            {
                throw new ArgumentNullResourceException("consumedStatics", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            if (reader == null)
            {
                throw new ArgumentNullResourceException("reader", Resources.General_Given_Parameter_Cannot_Be_Null);
            }
        }
 protected override void SetStaticAssociations(MethodBase consumedStatics, IMethodBodyReader reader)
 {
     base.SetStaticAssociations(consumedStatics, reader);
     IQueryable<Tuple<string, Type>> statics = from staticMethod in reader.Instructions.Select(instruction => instruction.Operand).OfType<MethodInfo>()
                                               where (staticMethod.Attributes & MethodAttributes.Static) == MethodAttributes.Static
                                               select new Tuple<string, Type>(consumedStatics.Name, staticMethod.DeclaringType);
     this.allStaticUsage.AddRange(statics);
 }
        /// <summary>
        /// Sets the consumes collection. Intended to be used by <see cref="VisualisableTypeWithAssociations"/>. Must be on this base class to be polymorphic.
        /// </summary>
        /// <param name="method">
        /// The method.
        /// </param>
        /// <param name="reader">
        /// The il reader.
        /// </param>
        protected virtual void SetConsumes(MethodBase method, IMethodBodyReader reader)
        {
            if (method == null)
            {
                throw new ArgumentNullResourceException("method", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            if (reader == null)
            {
                throw new ArgumentNullResourceException("reader", Resources.General_Given_Parameter_Cannot_Be_Null);
            }
        }
        protected override void SetConsumes(MethodBase method, IMethodBodyReader reader)
        {
            base.SetConsumes(method, reader);
            foreach (ILInstruction instruction in reader.Instructions.Where(i => i.Operand != null))
            {
                var externalMethodCall = instruction.Operand as MethodBase;
                if (externalMethodCall != null)
                {
                    Type declaringType = externalMethodCall.DeclaringType;
                    if ((externalMethodCall.Attributes & MethodAttributes.Static) == MethodAttributes.Static)
                    {
                        // Statics discovered elsewhere
                        continue;
                    }

                    if (method.DeclaringType != null)
                    {
                        if (method.IsConstructor && (declaringType == method.DeclaringType || declaringType == method.DeclaringType.BaseType))
                        {
                            // Calling another constructor in same class.
                            continue;
                        }
                    }

                    if (declaringType == null || TypeDescriptorHelper.AreEqual(declaringType, this.Id))
                    {
                        // Don't bother counting "self-consumption" calls.
                        continue;
                    }

                    this.allConsumptionUsage.Add(new Tuple<string, Type>(method.Name, declaringType));
                }
            }
        }