コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RunSpaceInstance" /> class.
        /// </summary>
        /// <param name="snapin">Type of snapin to be loaded</param>
        /// <param name="messageCatalog">The message catalog used for conveying localized messages.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="messageCatalog"/> is null.</exception>
        public RunSpaceInstance(SnapIn snapin, ConnectorMessages messageCatalog)
        {
            Assertions.NullCheck(messageCatalog, "messageCatalog");
            _messageCatalog = messageCatalog;

            // initialize this
            this.InitRunSpace(snapin);
        }
コード例 #2
0
        /// <summary>
        /// main initialisation routine for the <see cref="Runspace"/>
        /// </summary>
        /// <param name="snapin"><see cref="SnapIn"/> to be initialized together with the <see cref="Runspace"/></param>
        private void InitRunSpace(SnapIn snapin)
        {
            const string MethodName = "InitRunSpace";

            Debug.WriteLine(MethodName + "(" + snapin + ")" + ":entry", ClassName);

            // create a new config from scratch
            PSSnapInException snapOutput = null;

            this.runSpaceConfig = RunspaceConfiguration.Create();

            switch (snapin)
            {
            case SnapIn.Exchange:
                var serverVersion = GetExchangeServerVersion();
                switch (serverVersion)
                {
                case ExchangeVersion.E2007:
                    // used for force load of the exchange dll's
                    AppDomain.CurrentDomain.AssemblyResolve +=
                        new ResolveEventHandler(ExchangeUtility.AssemblyResolver2007);

                    this.runSpaceConfig.AddPSSnapIn(Exchange2007SnapIn, out snapOutput);
                    break;

                case ExchangeVersion.E2010:
                    // used for force load of the exchange dll's
                    AppDomain.CurrentDomain.AssemblyResolve +=
                        new ResolveEventHandler(ExchangeUtility.AssemblyResolver2010);

                    this.runSpaceConfig.AddPSSnapIn(Exchange2010SnapIn, out snapOutput);
                    break;
                }
                break;
            }

            // check snapOutput
            if (snapOutput != null)
            {
                throw snapOutput;
            }

            // create the real Runspace and open it for processing
            this.runSpace = RunspaceFactory.CreateRunspace(this.runSpaceConfig);
            this.runSpace.Open();
            this.runSpaceInvoke = new RunspaceInvoke(this.runSpace);

            Debug.WriteLine(MethodName + ":exit", ClassName);
        }
コード例 #3
0
        /// <summary>
        /// main initialisation routine for the <see cref="Runspace"/>
        /// </summary>
        /// <param name="snapin"><see cref="SnapIn"/> to be initialized together with the <see cref="Runspace"/></param>
        private void InitRunSpace(SnapIn snapin)
        {
            const string MethodName = "InitRunSpace";
            Debug.WriteLine(MethodName + "(" + snapin + ")" + ":entry", ClassName);

            // create a new config from scratch
            PSSnapInException snapOutput = null;
            this.runSpaceConfig = RunspaceConfiguration.Create();

            switch (snapin)
            {
                case SnapIn.Exchange:
                    var serverVersion = GetExchangeServerVersion();
                    switch (serverVersion)
                    {
                        case ExchangeVersion.E2007:
                            // used for force load of the exchange dll's
                            AppDomain.CurrentDomain.AssemblyResolve +=
                                             new ResolveEventHandler(ExchangeUtility.AssemblyResolver2007);

                            this.runSpaceConfig.AddPSSnapIn(Exchange2007SnapIn, out snapOutput);
                            break;
                        case ExchangeVersion.E2010:
                            // used for force load of the exchange dll's
                            AppDomain.CurrentDomain.AssemblyResolve +=
                                             new ResolveEventHandler(ExchangeUtility.AssemblyResolver2010);

                            this.runSpaceConfig.AddPSSnapIn(Exchange2010SnapIn, out snapOutput);
                            break;
                    }
                    break;
            }

            // check snapOutput
            if (snapOutput != null)
            {
                throw snapOutput;
            }

            // create the real Runspace and open it for processing
            this.runSpace = RunspaceFactory.CreateRunspace(this.runSpaceConfig);
            this.runSpace.Open();
            this.runSpaceInvoke = new RunspaceInvoke(this.runSpace);

            Debug.WriteLine(MethodName + ":exit", ClassName);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RunSpaceInstance" /> class. 
        /// </summary>
        /// <param name="snapin">Type of snapin to be loaded</param>
        /// <param name="messageCatalog">The message catalog used for conveying localized messages.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="messageCatalog"/> is null.</exception>
        public RunSpaceInstance(SnapIn snapin, ConnectorMessages messageCatalog)
        {
            Assertions.NullCheck( messageCatalog, "messageCatalog" );
            _messageCatalog = messageCatalog;

            // initialize this
            this.InitRunSpace(snapin);
        }
コード例 #5
0
 public IDataContext NavigateToView(SnapIn snapIn, Form view)
 {
     return(snapIn.Console.ShowDialog(view) == DialogResult.OK ? ((IView)view).DataContext : null);
 }