public void Initialize(Contract.Type bootstrapper, ServerContext context, string[] args) { Logger.Info("Initializing bootstrapper " + bootstrapper.AssemblyQualifiedName + "..."); this._bootstrapper = this.CreateInstance(bootstrapper.AssemblyQualifiedName); SymbolExtensions.GetMethodInfo <IBootstrapper>(b => b.Initialize(null, null)).Invoke(this._bootstrapper, new object[] { context, args }); Logger.Info("Initialized"); }
public static TInstance CreateInstance <TInstance>(AppDomain appDomain, Contract.Type type, params object[] parameters) where TInstance : class { string assemblyFile = type.Assembly.File; if (assemblyFile == null) { throw new ArgumentException("Type must include assembly location"); } string assemblyName = type.Assembly.Name; object proxy = appDomain.CreateInstanceAndUnwrap(assemblyName, type.FullName, false, BindingFlags.CreateInstance, null, parameters, null, null); TInstance instance = proxy as TInstance; if (instance == null) { throw new Exception("Type " + type.FullName + " cannot be cast to " + typeof(TInstance).FullName); } Logger.Info("Created instance of " + type.FullName + " from " + assemblyFile + " in app domain " + appDomain.FriendlyName); return(instance); }
public static TInstance CreateSponsoredInstance <TInstance>(AppDomain appDomain, Contract.Type type, params object[] parameters) where TInstance : MarshalByRefObject { TInstance instance = CreateInstance <TInstance>(appDomain, type, parameters); RemoteObjectFactory.Sponsor(instance); return(instance); }