// ===++===
//
// OrtizOL
//
// ===--===
/*============================================================
//
// Clase: UsoMarshalByRefObject.cs
//
// Propósito: Demostrar el uso de la clase abstracta
// MarshalByRefObject.
//
============================================================*/
using System;
using System.Reflection;
namespace Receta.Cap03
{
public class Objeto : MarshalByRefObject
{
public void VerDominio()
{
Console.WriteLine("El objeto se está ejecutando en en el AppDomain: `{0}`", AppDomain.CurrentDomain.FriendlyName);
}
}
public class UsoMarshalByRefObject
{
public static void Main()
{
// Creación de una instancia de `Objeto`:
Objeto objetoLocal = new Objeto();
objetoLocal.VerDominio();
// Creación de un nuevo dominio de applicación:
AppDomain ad = AppDomain.CreateDomain("Nuevo Dominio");
// Creación de una nueva instancia en el nuevo dominio:
Objeto objetoRemoto = (Objeto) ad.CreateInstanceAndUnwrap(typeof(Objeto).Assembly.FullName.ToString(), "Receta.Cap03.Objeto");
objetoRemoto.VerDominio();
}
}
}
Ly8gPT09Kys9PT0KLy8KLy8gICAgT3J0aXpPTAovLwovLyA9PT0tLT09PQovKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQovLwovLyBDbGFzZTogVXNvTWFyc2hhbEJ5UmVmT2JqZWN0LmNzCi8vCi8vIFByb3DDs3NpdG86IERlbW9zdHJhciBlbCB1c28gZGUgbGEgY2xhc2UgYWJzdHJhY3RhIAovLyBNYXJzaGFsQnlSZWZPYmplY3QuCi8vCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCgp1c2luZyBTeXN0ZW07CnVzaW5nIFN5c3RlbS5SZWZsZWN0aW9uOwoKbmFtZXNwYWNlIFJlY2V0YS5DYXAwMwp7CiAgICBwdWJsaWMgY2xhc3MgT2JqZXRvIDogTWFyc2hhbEJ5UmVmT2JqZWN0CiAgICB7CiAgICAgICAgcHVibGljIHZvaWQgVmVyRG9taW5pbygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiRWwgb2JqZXRvIHNlIGVzdMOhIGVqZWN1dGFuZG8gZW4gZW4gZWwgQXBwRG9tYWluOiBgezB9YCIsIEFwcERvbWFpbi5DdXJyZW50RG9tYWluLkZyaWVuZGx5TmFtZSk7CiAgICAgICAgfQogICAgfQogICAgCiAgICBwdWJsaWMgY2xhc3MgVXNvTWFyc2hhbEJ5UmVmT2JqZWN0CiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQogICAgICAgIHsKICAgICAgICAgICAgLy8gQ3JlYWNpw7NuIGRlIHVuYSBpbnN0YW5jaWEgZGUgYE9iamV0b2A6CiAgICAgICAgICAgIE9iamV0byBvYmpldG9Mb2NhbCA9IG5ldyBPYmpldG8oKTsKICAgICAgICAgICAgb2JqZXRvTG9jYWwuVmVyRG9taW5pbygpOwogICAgICAgICAgICAKICAgICAgICAgICAgLy8gQ3JlYWNpw7NuIGRlIHVuIG51ZXZvIGRvbWluaW8gZGUgYXBwbGljYWNpw7NuOgogICAgICAgICAgICBBcHBEb21haW4gYWQgPSBBcHBEb21haW4uQ3JlYXRlRG9tYWluKCJOdWV2byBEb21pbmlvIik7CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBDcmVhY2nDs24gZGUgdW5hIG51ZXZhIGluc3RhbmNpYSBlbiBlbCBudWV2byBkb21pbmlvOiAgICAgICAgICAgIAogICAgICAgICAgICBPYmpldG8gb2JqZXRvUmVtb3RvID0gKE9iamV0bykgYWQuQ3JlYXRlSW5zdGFuY2VBbmRVbndyYXAodHlwZW9mKE9iamV0bykuQXNzZW1ibHkuRnVsbE5hbWUuVG9TdHJpbmcoKSwgIlJlY2V0YS5DYXAwMy5PYmpldG8iKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIG9iamV0b1JlbW90by5WZXJEb21pbmlvKCk7CiAgICAgICAgfQogICAgfQp9