コード例 #1
0
 public bool CanAddInvariants()
 {
     return(MetaDataDecoder.IsClass(ClassType));
 }
コード例 #2
0
        public IClassDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions, MethodResult> ClassDriver(Type type, bool inferInvariantsJustForReadonlyFields = true)
        {
            WeakReference reference;
            CDriver       result;

            if (mCDrivers.TryGetValue(type, out reference) && reference != null && reference.IsAlive)
            {
                result = reference.Target as CDriver;
                return(result);
            }
            else
            {
                if (!inferInvariantsJustForReadonlyFields || this.MetaDataDecoder.Fields(type).Where(this.MetaDataDecoder.IsReadonly).Any())
                {
                    var cd = new CDriver(this, MetaDataDecoder, type);
                    mCDrivers[type]            = new WeakReference(cd);
                    this.mMaxClassDriversCount = Math.Max(mCDriversCount, this.mMaxClassDriversCount);

#if DEBUG && false
                    var old = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("-- ADD CLASS DRIVER -- Max Class Drivers Count is: {0} ; class drivers count is: {1}", this.mMaxClassDriversCount, mCDriversCount); // DEBUG
                    Console.ForegroundColor = old;
#endif

                    return(cd);
                }
                else
                {
#if DEBUG && false
                    this.Output.WriteLine("The type {0} does not contain any readonly field. As a consequence we do not need a class driver", MetaDataDecoder.Name(type));
#endif
                    return(null);
                }
            }
        }