Ejemplo n.º 1
0
 public ClassProxyDefinition(Type type, InterfaceDefinition[] interfaces)
     : base(type, interfaces)
 {
     if (type.IsInterface)
     {
         throw new ArgumentException("Specified type cannot be an interface type.", "type");
     }
 }
Ejemplo n.º 2
0
        public void CanBuildSubClassProxyWithDuckType()
        {
            var duckTypeDefinition = new DuckTypeInterfaceDefinition(typeof(IShape));
            var interfaces = new InterfaceDefinition[] { duckTypeDefinition };
            var proxyDefinition = new ClassProxyDefinition(typeof(Square), interfaces);

            var type = _builder.Build(proxyDefinition);

            Assert.IsNotNull(type);
            Assert.That(typeof(Square).IsAssignableFrom(type));
            Assert.That(typeof(IShape).IsAssignableFrom(type));
        }
        public TargetedInterfaceProxyDefinition(
            Type type, 
            Type targetType, 
            InterfaceDefinition[] interfaces)
            : base(type, targetType, interfaces)
        {
            if (!type.IsInterface)
            {
                throw new ArgumentException("Specified type must be an interface type.", "type");
            }

            if (targetType.IsAssignableFrom(type))
            {
                throw new ArgumentException("Specified targetType must implement type interface.", "targetType");
            }
        }
Ejemplo n.º 4
0
        public void CanBuildSubClassProxyWithTargetedMixin()
        {
            var mixinDefinition = new MixinInterfaceDefinition(
                typeof(INotifyPropertyChanged),
                typeof(NotifyPropertyChangedMixin),
                false);

            var interfaces = new InterfaceDefinition[] { mixinDefinition };
            var proxyDefinition = new ClassProxyDefinition(typeof(Square), interfaces);

            var type = _builder.Build(proxyDefinition);

            Assert.IsNotNull(type);
            Assert.That(typeof(Square).IsAssignableFrom(type));
            Assert.That(typeof(INotifyPropertyChanged).IsAssignableFrom(type));
        }
 public InterfaceProxyDefinition(Type primaryInterfaceType, InterfaceDefinition[] interfaces)
     : base(primaryInterfaceType, interfaces)
 {
 }