realproxy

How to get the RealProxy when I know only the transparent proxy

╄→尐↘猪︶ㄣ 提交于 2019-12-10 16:18:56
问题 I have a transparent proxy, for instance one generated by WCF: ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>( new NetNamedPipeBinding(), "net.pipe://localhost/WcfTransparentProxy/Calculator" ); ICalculator calculator = channelFactory.CreateChannel(); How do I get the RealProxy from the transparent proxy? 回答1: There's a function in RemotingServices specifically for this: System.Runtime.Remoting.RemotingServices.GetRealProxy( transparentProxy ); 来源: https:/

How to wrap existing object instance into DispatchProxy?

荒凉一梦 提交于 2019-12-04 10:27:06
I'm looking for RealProxy replacement in .NET Core, and this issue forwards me to DispatchProxy . It has simple API, but it's unclear, how to wrap existing object into proxy. E.g., having this interface: interface IFoo { string Bar(int boo); } and this implementation: class FooImpl : IFoo { public string Bar(int boo) { return $"Value {boo} was passed"; } } how to get what I want? class Program { static void Main(string[] args) { var fooInstance = new FooImpl(); var proxy = DispatchProxy.Create<IFoo, FooProxy>(); var s = proxy.Bar(123); Console.WriteLine(s); } } class FooProxy : DispatchProxy {