public ClassProxyDefinition(Type type, InterfaceDefinition[] interfaces) : base(type, interfaces) { if (type.IsInterface) { throw new ArgumentException("Specified type cannot be an interface type.", "type"); } }
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"); } }
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) { }