/// <summary>
        /// </summary>
        /// <param name="connectionInfo"></param>
        /// <param name="host"></param>
        /// <param name="typeTable">
        /// The TypeTable to use while deserializing/serializing remote objects.
        /// TypeTable has the following information used by serializer:
        ///   1. SerializationMethod
        ///   2. SerializationDepth
        ///   3. SpecificSerializationProperties
        /// TypeTable has the following information used by deserializer:
        ///   1. TargetTypeForDeserialization
        ///   2. TypeConverter
        /// </param>
        /// <param name="applicationArguments">
        /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/>
        /// </param>
        /// <param name="name">Name for remote runspace.</param>
        /// <returns></returns>
        public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments, string name)
        {
            if (connectionInfo is WSManConnectionInfo)
            {
                RemotingCommandUtil.CheckHostRemotingPrerequisites();
            }

            return(new RemoteRunspace(typeTable, connectionInfo, host, applicationArguments, name));
        }
Exemple #2
0
 public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments)
 {
     if (!(connectionInfo is WSManConnectionInfo) && !(connectionInfo is NewProcessConnectionInfo))
     {
         throw new NotSupportedException();
     }
     if (connectionInfo is WSManConnectionInfo)
     {
         RemotingCommandUtil.CheckHostRemotingPrerequisites();
     }
     return(new RunspacePool(minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo, null));
 }
        /// <summary>
        /// </summary>
        /// <param name="connectionInfo"></param>
        /// <param name="host"></param>
        /// <param name="typeTable">
        /// The TypeTable to use while deserializing/serializing remote objects.
        /// TypeTable has the following information used by serializer:
        ///   1. SerializationMethod
        ///   2. SerializationDepth
        ///   3. SpecificSerializationProperties
        /// TypeTable has the following information used by deserializer:
        ///   1. TargetTypeForDeserialization
        ///   2. TypeConverter
        /// </param>
        /// <param name="applicationArguments">
        /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/>
        /// </param>
        /// <param name="name">Name for remote runspace.</param>
        /// <returns></returns>
        public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments, string name)
        {
            if ((!(connectionInfo is WSManConnectionInfo)) &&
                (!(connectionInfo is NewProcessConnectionInfo)) &&
                (!(connectionInfo is NamedPipeConnectionInfo)) &&
                (!(connectionInfo is SSHConnectionInfo)) &&
                (!(connectionInfo is VMConnectionInfo)) &&
                (!(connectionInfo is ContainerConnectionInfo)))
            {
                throw new NotSupportedException();
            }

            if (connectionInfo is WSManConnectionInfo)
            {
                RemotingCommandUtil.CheckHostRemotingPrerequisites();
            }

            return(new RemoteRunspace(typeTable, connectionInfo, host, applicationArguments, name));
        }
        internal static SafeTransactionHandle Create(Transaction managedTransaction)
        {
            IntPtr ptr;

            if (managedTransaction == null)
            {
                throw new InvalidOperationException(RegistryProviderStrings.InvalidOperation_NeedTransaction);
            }
            if (RemotingCommandUtil.IsWinPEHost() || PsUtils.IsRunningOnProcessorArchitectureARM())
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }
            IKernelTransaction dtcTransaction = TransactionInterop.GetDtcTransaction(managedTransaction) as IKernelTransaction;

            if (dtcTransaction == null)
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }
            HandleError(dtcTransaction.GetHandle(out ptr));
            return(new SafeTransactionHandle(ptr));
        }