Пример #1
0
        public void Execute()
        {
            var context = new VisitorContext(this);

            VisitProperties(context);
            VisitMethods(context);
        }
Пример #2
0
 public void Visit(MethodDefinition method, VisitorContext context)
 {
     if (IsLazy(method))
     {
         var instrumentor = new DoubleCheckedLockingWeaver(method, context);
         instrumentor.Instrument();
     }
 }
Пример #3
0
        public override void Execute()
        {
            var context = new VisitorContext(this);

            VisitProperties(context);
            VisitMethods(context);
            VisitAssemblyReferences(context);
        }
Пример #4
0
 public void Visit(MethodDefinition method, VisitorContext context)
 {
     if (IsLazy(method))
     {
         var instrumentor = new DoubleCheckedLockingWeaver(method, context);
         instrumentor.Instrument();
     }
 }
Пример #5
0
 public void Visit(PropertyDefinition property, VisitorContext context)
 {
     if (IsLazy(property) && property.GetMethod != null && !IsLazy(property.GetMethod))
     {
         var instrumentor = new DoubleCheckedLockingWeaver(property.GetMethod, context);
         instrumentor.Instrument();
     }
 }
Пример #6
0
 public void Visit(PropertyDefinition property, VisitorContext context)
 {
     if (IsLazy(property) && property.GetMethod != null && !IsLazy(property.GetMethod))
     {
         var instrumentor = new DoubleCheckedLockingWeaver(property.GetMethod, context);
         instrumentor.Instrument();
     }
 }
Пример #7
0
 protected LazyWeaver(MethodDefinition method, VisitorContext context)
 {
     Method     = method;
     Context    = context;
     ObjRef     = method.Module.ImportReference(typeof(object));
     ObjCtorRef = method.Module.ImportReference(new MethodReference(".ctor", method.Module.TypeSystem.Void, ObjRef)
     {
         HasThis = true,
     });
 }
Пример #8
0
 public DoubleCheckedLockingWeaver(MethodDefinition method, VisitorContext context)
 {
     _method     = method;
     _context    = context;
     _objRef     = method.Module.Import(typeof(object));
     _objCtorRef = method.Module.Import(new MethodReference(".ctor", method.Module.TypeSystem.Void, _objRef)
     {
         HasThis = true,
     });
 }
Пример #9
0
 protected LazyWeaver(MethodDefinition method, VisitorContext context)
 {
     Method = method;
     Context = context;
     ObjRef = method.Module.Import(typeof(object));
     ObjCtorRef = method.Module.Import(new MethodReference(".ctor", method.Module.TypeSystem.Void, ObjRef)
     {
         HasThis = true,
     });
 }
 public DoubleCheckedLockingWeaver(MethodDefinition method, VisitorContext context)
 {
     _method = method;
     _context = context;
     _objRef = method.Module.Import(typeof(object));
     _objCtorRef = method.Module.Import(new MethodReference(".ctor", method.Module.TypeSystem.Void, _objRef)
     {
         HasThis = true,
     });
 }
Пример #11
0
 public void Visit(PropertyDefinition property, VisitorContext context)
 {
     var lazyAttribute = GetLazyAttribute(property);
     if (lazyAttribute != null && property.GetMethod != null && !IsLazy(property.GetMethod))
     {
         var instrumentor = GetWeaver(property.GetMethod, context);
         instrumentor.Instrument();
         property.CustomAttributes.Remove(lazyAttribute);
     }
 }
Пример #12
0
 public void Visit(MethodDefinition method, VisitorContext context)
 {
     var lazyAttribute = GetLazyAttribute(method);
     if (lazyAttribute != null)
     {
         var instrumentor = GetWeaver(method, context);
         instrumentor.Instrument();
         method.CustomAttributes.Remove(lazyAttribute);
     }
 }
Пример #13
0
        public void Visit(MethodDefinition method, VisitorContext context)
        {
            var lazyAttribute = GetLazyAttribute(method);

            if (lazyAttribute != null)
            {
                var instrumentor = GetWeaver(method, context);
                instrumentor.Instrument();
                method.CustomAttributes.Remove(lazyAttribute);
            }
        }
Пример #14
0
        public void Visit(PropertyDefinition property, VisitorContext context)
        {
            var lazyAttribute = GetLazyAttribute(property);

            if (lazyAttribute != null && property.GetMethod != null && !IsLazy(property.GetMethod))
            {
                var instrumentor = GetWeaver(property.GetMethod, context);
                instrumentor.Instrument();
                property.CustomAttributes.Remove(lazyAttribute);
            }
        }
Пример #15
0
        private void VisitProperties(VisitorContext context)
        {
            var propertyVisitors = GetImplementations <IPropertyVisitor>();
            var q = from type in ModuleDefinition.Types
                    from property in type.Properties
                    select property;

            foreach (var property in q.ToList())
            {
                foreach (var visitor in propertyVisitors)
                {
                    visitor.Visit(property, context);
                }
            }
        }
Пример #16
0
        private void VisitMethods(VisitorContext context)
        {
            var methodVisitors = GetImplementations <IMethodVisitor>();
            var q = from type in GetTypes(ModuleDefinition.Types)
                    from method in type.GetMethods()
                    select method;

            foreach (var method in q.ToList())
            {
                foreach (var visitor in methodVisitors)
                {
                    visitor.Visit(method, context);
                }
            }
        }
Пример #17
0
        private void VisitAssemblyReferences(VisitorContext context)
        {
            // Attempt to locate the "AutoLazy" assembly reference.
            var assemblyName = ModuleDefinition.AssemblyReferences.FirstOrDefault(
                reference => reference.FullName.StartsWith("AutoLazy")
                );

            // Verify our result.
            if (assemblyName == null)
            {
                // Will happen if AutoLazy is added, but not used.
                return;
            }

            // Remove unnecessary references remaining in our subject assembly.
            ModuleDefinition.AssemblyReferences.Remove(assemblyName);
        }
Пример #18
0
 private LazyWeaver GetWeaver(MethodDefinition method, VisitorContext context)
 {
     return(method.Parameters.Count == 0
         ? (LazyWeaver) new DoubleCheckedLockingWeaver(method, context)
         : new KeyedLazyWeaver(method, context));
 }
Пример #19
0
 private LazyWeaver GetWeaver(MethodDefinition method, VisitorContext context)
 {
     return method.Parameters.Count == 0
         ? (LazyWeaver)new DoubleCheckedLockingWeaver(method, context)
         : new KeyedLazyWeaver(method, context);
 }
Пример #20
0
 public DoubleCheckedLockingWeaver(MethodDefinition method, VisitorContext context)
     : base(method, context)
 {
 }
Пример #21
0
 public KeyedLazyWeaver(MethodDefinition method, VisitorContext context)
     : base(method, context)
 {
 }
 public DoubleCheckedLockingWeaver(MethodDefinition method, VisitorContext context)
     : base(method, context)
 {
 }
Пример #23
0
 protected LazyWeaver(MethodDefinition method, VisitorContext context)
 {
     Method  = method;
     Context = context;
 }
Пример #24
0
 public KeyedLazyWeaver(MethodDefinition method, VisitorContext context)
     : base(method, context)
 {
 }