Exemple #1
0
 public AppServerMetadata GetServerTypeMetadata(string typeName)
 {
     try
     {
         return(AppServerMetadata.GetAppServerMetadata(Type.GetType(typeName, false)));
     }
     catch
     {
         return(null);
     }
 }
Exemple #2
0
        public RemoteTypeLoadResult <AppServerMetadata> GetServerMetadata(string serverTypeName)
        {
            Lazy <IAppServer, IAppServerMetadata> lazyServerFactory = null;

            try
            {
                lazyServerFactory = m_ExportProvider.GetExports <IAppServer, IAppServerMetadata>()
                                    .FirstOrDefault(f => f.Metadata.Name.Equals(serverTypeName, StringComparison.OrdinalIgnoreCase));
            }
            catch (ReflectionTypeLoadException e)
            {
                var msg = e.Message;

                foreach (var le in e.LoaderExceptions)
                {
                    msg += Environment.NewLine + le.Message;
                }

                return(new RemoteTypeLoadResult <AppServerMetadata> {
                    Message = msg
                });
            }

            AppServerMetadata metadata = null;

            try
            {
                if (lazyServerFactory != null)
                {
                    metadata = new AppServerMetadata(lazyServerFactory.Metadata, lazyServerFactory.GetExportType());
                }
                else
                {
                    metadata = AppServerMetadata.GetAppServerMetadata(Type.GetType(serverTypeName, true, true));
                }
            }
            catch (Exception e)
            {
                return(new RemoteTypeLoadResult <AppServerMetadata> {
                    Message = e.Message + Environment.NewLine + e.StackTrace
                });
            }

            return(new RemoteTypeLoadResult <AppServerMetadata> {
                Result = true, Value = metadata
            });
        }