private DynamicProxy(Type type, IContainer container, DelegateAttribute delegateAttribute,
                      DecorateAttribute decorateAttribute)
 {
     _typeToBeWrapped   = type;
     _container         = container;
     _delegateAttribute = delegateAttribute;
     _decorateAttribute = decorateAttribute;
 }
        // Creation method will be called using reflection as not in all cases T is known during compile time
        public static T Create <T>(IContainer container, DelegateAttribute delegateAttribute,
                                   DecorateAttribute decorateAttribute) where T : class
        {
            if (!typeof(T).IsInterface)
            {
                throw new ArgumentException("T must be an Interface");
            }

            if (delegateAttribute != null && !delegateAttribute.On.IsInterface)
            {
                throw new ArgumentException("Interface expected");
            }

            return(new DynamicProxy(typeof(T), container, delegateAttribute, decorateAttribute).ActLike <T>(delegateAttribute.On));
        }
Beispiel #3
0
 [RefreshProperties(RefreshProperties.All)] public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
 {
     if (context == null || provider == null || context.Instance == null)
     {
         return(base.EditValue(provider, value));
     }
     if (m_MethodDelegate == null)
     {
         DelegateAttribute attr = (DelegateAttribute)context.PropertyDescriptor.Attributes[typeof(DelegateAttribute)];
         m_MethodDelegate = attr.GetMethod;
     }
     if (m_sender == null)
     {
         m_sender = context.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor;
     }
     return(m_MethodDelegate.Invoke(m_sender, null));
 }