Exemplo n.º 1
0
        //private static void EmitDebuggerDisplay (TypeBuilder typeBuilder, Type proxyType, Type implType)
        //{
        //    var constructor = typeof(DebuggerDisplayAttribute).GetConstructor(new Type[] { typeof(string) });
        //    var arguments = new object[] { String.Format("DynamicProxy :: {0} => {1}", implType.FullName, proxyType.FullName) };
        //    var debuggerDisplay = new CustomAttributeBuilder(constructor, arguments);
        //    typeBuilder.SetCustomAttribute(debuggerDisplay);
        //}
        private static void EmitAdapterMethods(Type adapterType, AdapterEmitter emitter)
        {
            var methods = adapterType.IsClass
                          ? adapterType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic)
                                       .Where(m => CanOverrideMethod(m))
                          : adapterType.GetMethods()
                                       .Where(m => !m.IsSpecialName);

            foreach (var method in methods)
            {
                emitter.EmitMethod(method);
            }
        }
Exemplo n.º 2
0
        private static void EmitAdapterProperties(Type adapterType, AdapterEmitter emitter)
        {
            var properties = adapterType.IsClass
                             ? adapterType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic)
                                          .Where(p => p.CanRead
                                                      ? CanOverrideMethod(p.GetGetMethod())
                                                      : p.CanWrite && CanOverrideMethod(p.GetSetMethod()))
                                          .ToArray()
                             : adapterType.GetProperties();

            if (properties.Length != 0)
            {
                foreach (var property in properties)
                {
                    if (property.GetIndexParameters().Any())
                    {
                        emitter.EmitIndexer(property);
                    }
                    else
                    {
                        emitter.EmitProperty(property);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void EmitAdapterEvents(Type adapterType, AdapterEmitter emitter)
        {
            var events = adapterType.GetEvents();

            if (events.Length != 0)
            {
                foreach (var evt in events)
                {
                    emitter.EmitEvent(evt);
                }
            }
        }