예제 #1
0
파일: Platform.cs 프로젝트: hksonngan/Xian
        /// <summary>
        /// Starts the application matching the specified fully or partially qualified class name.
        /// </summary>
        /// <param name="appRootClassName">The name of an application root class, which need not be fully qualified.</param>
        /// <param name="args"></param>
        public static void StartApp(string appRootClassName, string[] args)
        {
            ExtensionInfo[] appRoots = new ApplicationRootExtensionPoint().ListExtensions();

            // try an exact match
            List <ExtensionInfo> matchingRoots = CollectionUtils.Select(appRoots,
                                                                        delegate(ExtensionInfo info) { return(info.ExtensionClass.FullName == appRootClassName); });

            if (matchingRoots.Count == 0)
            {
                // try a partial match
                matchingRoots = CollectionUtils.Select(appRoots,
                                                       delegate(ExtensionInfo info)
                {
                    return(info.ExtensionClass.FullName.EndsWith(
                               appRootClassName, StringComparison.InvariantCultureIgnoreCase));
                });
            }

            if (matchingRoots.Count == 0)
            {
                throw new NotSupportedException(
                          string.Format(SR.ExceptionApplicationRootNoMatches, appRootClassName));
            }
            if (matchingRoots.Count > 1)
            {
                throw new NotSupportedException(
                          string.Format(SR.ExceptionApplicationRootMultipleMatches, appRootClassName));
            }

            // start app
            StartApp(new ClassNameExtensionFilter(CollectionUtils.FirstElement(matchingRoots).ExtensionClass.FullName), args);
        }
예제 #2
0
파일: Platform.cs 프로젝트: hksonngan/Xian
        /// <summary>
        /// Starts the application.
        /// </summary>
        /// <param name="applicationRootFilter">An extension filter that selects the application root extension to execute.</param>
        /// <param name="args">The set of arguments passed from the command line.</param>
        /// <remarks>
        /// A ClearCanvas based application is started by calling this convenience method from
        /// a bootstrap executable of some kind.  Calling this method results in the loading
        /// of all plugins and creation of an <see cref="IApplicationRoot"/> extension.
        /// This method is not thread-safe as it should only ever be invoked once per execution, by a single thread.
        /// </remarks>
        public static void StartApp(ExtensionFilter applicationRootFilter, string[] args)
        {
            FatalExceptionHandler.Initialize();

            ApplicationRootExtensionPoint xp = new ApplicationRootExtensionPoint();

            _applicationRoot = (applicationRootFilter == null) ?
                               (IApplicationRoot)xp.CreateExtension() :
                               (IApplicationRoot)xp.CreateExtension(applicationRootFilter);
            _applicationRoot.RunApplication(args);
        }
예제 #3
0
        /// <summary>
        /// Starts the application.
        /// </summary>
        /// <param name="applicationRootFilter">An extension filter that selects the application root extension to execute.</param>
        /// <param name="args">The set of arguments passed from the command line.</param>
        /// <remarks>
        /// A ClearCanvas based application is started by calling this convenience method from
        /// a bootstrap executable of some kind.  Calling this method results in the loading
        /// of all plugins and creation of an <see cref="IApplicationRoot"/> extension.
        /// This method is not thread-safe as it should only ever be invoked once per execution, by a single thread.
        /// </remarks>
        public static void StartApp(ExtensionFilter applicationRootFilter, string[] args)
        {
#if !DEBUG
            try
            {
#endif
            ApplicationRootExtensionPoint xp = new ApplicationRootExtensionPoint();
            _applicationRoot = (applicationRootFilter == null) ?
                               (IApplicationRoot)xp.CreateExtension() :
                               (IApplicationRoot)xp.CreateExtension(applicationRootFilter);
            _applicationRoot.RunApplication(args);

#if !DEBUG
        }
        catch (Exception e)
        {
            Platform.Log(LogLevel.Fatal, e);

            // for convenience, if this is console app, also print the message to the console
            Console.WriteLine(e.Message);
        }
#endif
        }