static void Main(string[] args) { Console.WriteLine("Giving a second for the host to open..."); Thread.Sleep(1000); string endpointAddress = "net.pipe://localhost/Service"; var site = new InstanceContext(new Callback()); var factory = new DuplexChannelFactory <Server.IDynamicContract>(site, new NetNamedPipeBinding { OpenTimeout = TimeSpan.FromSeconds(10), MaxBufferSize = 2147483647, MaxReceivedMessageSize = 2147483647 }, new EndpointAddress(endpointAddress)); foreach (var operation in factory.Endpoint.Contract.Operations) { operation.Behaviors.Find <DataContractSerializerOperationBehavior>().DataContractResolver = new ReflectionDataContractResolver(); } var proxy = factory.CreateChannel(); Console.WriteLine("Created the proxy"); object product = CreateProduct(); Console.WriteLine("Product: {0}", product); Console.WriteLine("Calling the service passing the product..."); MyHolder input = new MyHolder { MyObject = product }; MyHolder output = proxy.EchoHolder(input); Console.WriteLine("Result: {0}", output); Console.WriteLine(); Console.WriteLine("Now passing a product not known by the server"); object address = CreateAddress(); string addressString = proxy.PutHolder(new MyHolder { MyObject = address }); Console.WriteLine("Result: {0}", addressString); Console.WriteLine(); Type[] dynamicTypes = address.GetType().Assembly.GetTypes(); Console.WriteLine("Do we know about Person yet?"); Console.WriteLine("All dynamic types so far"); foreach (var dynamicType in dynamicTypes) { Console.WriteLine(" {0}", dynamicType.Name); } Console.WriteLine("Retrieving a new type from the server"); output = proxy.GetHolder("Person", new string[] { "Name", "Age" }, new object[] { "John Doe", 33 }); Console.WriteLine("Output: {0}", output); Console.WriteLine("Type of output value: {0}", output.MyObject.GetType()); Console.WriteLine("Is it on the same assembly as the other types? {0}", output.MyObject.GetType().Assembly.Equals(address.GetType().Assembly)); }
static void Main(string[] args) { Console.WriteLine("Giving a second for the host to open..."); Thread.Sleep(1000); string endpointAddress = "http://" + Environment.MachineName + ":8000/Service"; var factory = new ChannelFactory <Server.IDynamicContract>(new BasicHttpBinding(), new EndpointAddress(endpointAddress)); foreach (var operation in factory.Endpoint.Contract.Operations) { operation.Behaviors.Find <DataContractSerializerOperationBehavior>().DataContractResolver = new DynamicTypeResolver(); } var proxy = factory.CreateChannel(); Console.WriteLine("Created the proxy"); object product = CreateProduct(); Console.WriteLine("Product: {0}", product); Console.WriteLine("Calling the service passing the product..."); MyHolder input = new MyHolder { MyObject = product }; MyHolder output = proxy.EchoHolder(input); Console.WriteLine("Result: {0}", output); Console.WriteLine(); Console.WriteLine("Now passing a product not known by the server"); object address = CreateAddress(); string addressString = proxy.PutHolder(new MyHolder { MyObject = address }); Console.WriteLine("Result: {0}", addressString); Console.WriteLine(); Type[] dynamicTypes = address.GetType().Assembly.GetTypes(); Console.WriteLine("Do we know about Person yet?"); Console.WriteLine("All dynamic types so far"); foreach (var dynamicType in dynamicTypes) { Console.WriteLine(" {0}", dynamicType.Name); } Console.WriteLine("Retrieving a new type from the server"); output = proxy.GetHolder("Person", new string[] { "Name", "Age" }, new object[] { "John Doe", 33 }); Console.WriteLine("Output: {0}", output); Console.WriteLine("Type of output value: {0}", output.MyObject.GetType()); Console.WriteLine("Is it on the same assembly as the other types? {0}", output.MyObject.GetType().Assembly.Equals(address.GetType().Assembly)); }
public override View GetView(int position, View convertView, ViewGroup parent) { if (inflater == null) { inflater = (LayoutInflater)c.GetSystemService(Context.LayoutInflaterService); } if (convertView == null) { convertView = inflater.Inflate(Resource.Layout.Model, parent, false); } //BIND DATA MyHolder holder = new MyHolder(convertView); holder.NameText.Text = projetos[position].Name; holder.Img.SetImageResource(projetos[position].Image); return(convertView); }
public Form1() { InitializeComponent(); MyHolder holder = new MyHolder(); for (int i = 0; i < 3; i++) { holder.Objects.Add(new MyObjType1 { Id = i, Name = i + "Name" }); } for (int i = 0; i < 3; i++) { holder.Objects.Add(new MyObjType2 { Reference = "Ref" + i }); } propertyGrid1.SelectedObject = holder; }
public MyHolder EchoHolder(MyHolder holder) { Console.WriteLine("In service, holder = {0}", holder); return(holder); }
public string PutHolder(MyHolder holder) { Console.WriteLine("In service, holder = {0}", holder); return(holder.ToString()); }