示例#1
0
        protected override AppServerMetadata GetAppServerMetadata(IServerConfig serverConfig)
        {
            AppDomain         validateDomain = null;
            AppServerMetadata metadata       = null;

            try
            {
                validateDomain = AppDomain.CreateDomain("ValidationDomain", AppDomain.CurrentDomain.Evidence, IsolationApp.GetAppWorkingDir(serverConfig.Name), string.Empty, false);

                AssemblyImport.RegisterAssembplyImport(validateDomain);

                validateDomain.SetData(typeof(IsolationMode).Name, ConfigSource.Isolation);

                var validatorType = typeof(RemoteAppTypeValidator);
                var validator     = (RemoteAppTypeValidator)validateDomain.CreateInstanceAndUnwrap(validatorType.Assembly.FullName, validatorType.FullName);

                var result = validator.GetServerMetadata(serverConfig.Type);

                if (!result.Result)
                {
                    Logger.Error(result.Message);
                    return(null);
                }

                metadata = result.Value;
            }
            finally
            {
                if (validateDomain != null)
                {
                    AppDomain.Unload(validateDomain);
                }
            }

            return(metadata);
        }