BuildProxyType() public method

Creates a proxy that inherits the proxied object's class.

Only (non-final) methods can be proxied, unless they are members of one of the interfaces that target class implements. In that case, methods will be proxied using explicit interface implementation, which means that client code will have to cast the proxy to a specific interface in order to invoke the methods.

public BuildProxyType ( ) : Type
return System.Type
コード例 #1
0
        public void WithSealedClass()
        {
            InheritanceProxyTypeBuilder builder = (InheritanceProxyTypeBuilder)GetProxyBuilder();

            builder.TargetType = typeof(SealedClass);
            builder.BuildProxyType();
        }
コード例 #2
0
        public void WithSealedClass()
        {
            InheritanceProxyTypeBuilder builder = (InheritanceProxyTypeBuilder)GetProxyBuilder();

            builder.TargetType = typeof(SealedClass);
            Assert.Throws <ArgumentException>(() => builder.BuildProxyType());
        }