コード例 #1
0
 protected virtual bool IsItemContainer(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "CmdletProvider_NotSupported", new object[0]);
     }
 }
コード例 #2
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the get-childitem -name cmdlet.
 /// </summary>
 /// <param name="path">
 /// If the path was specified on the command line, this is the path
 /// to the item to get the dynamic parameters for.
 /// </param>
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object GetChildNamesDynamicParameters(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 }
コード例 #3
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the New-PSDrive cmdlet.
 /// </summary>
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object NewDriveDynamicParameters()
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 }
コード例 #4
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the clear-item cmdlet.
 /// </summary>
 ///
 /// <param name="path">
 /// If the path was specified on the command line, this is the path
 /// to the item to get the dynamic parameters for.
 /// </param>
 ///
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object ClearItemDynamicParameters(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 } // ClearItemDynamicParameters
コード例 #5
0
 /// <summary>
 /// Expand a provider path that contains wildcards to a list of provider
 /// paths that the path represents.Only called for providers that declare
 /// the ExpandWildcards capability.
 /// </summary>
 ///
 /// <param name="path">
 /// The path to expand. Expansion must be consistent with the wildcarding
 /// rules of PowerShell's WildcardPattern class.
 /// </param>
 ///
 /// <returns>
 /// A list of provider paths that this path expands to. They must all exist.
 /// </returns>
 ///
 protected virtual string[] ExpandPath(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(new string[] { path });
     }
 } // IsValidPath
コード例 #6
0
ファイル: Cmdlet.cs プロジェクト: modulexcite/pash-1
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw PSTraceSource.NewArgumentNullException("baseName");
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw PSTraceSource.NewArgumentNullException("resourceId");
         }
         ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(base.GetType().Assembly, baseName);
         string          str             = null;
         try
         {
             str = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
         }
         catch (MissingManifestResourceException)
         {
             throw PSTraceSource.NewArgumentException("baseName", "GetErrorText", "ResourceBaseNameFailure", new object[] { baseName });
         }
         if (str == null)
         {
             throw PSTraceSource.NewArgumentException("resourceId", "GetErrorText", "ResourceIdFailure", new object[] { resourceId });
         }
         return(str);
     }
 }
コード例 #7
0
 /// <Content contentref="System.Management.Automation.PathIntrinsics.GetResolvedProviderPathFromPSPath" />
 public Collection <string> GetResolvedProviderPathFromPSPath(string path, out ProviderInfo provider)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(SessionState.Path.GetResolvedProviderPathFromPSPath(path, out provider));
     }
 }
コード例 #8
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the get-childitem cmdlet.
 /// </summary>
 ///
 /// <param name="path">
 /// If the path was specified on the command line, this is the path
 /// to the item to get the dynamic parameters for.
 /// </param>
 ///
 /// <param name="recurse">
 /// True if all children in a subtree should be retrieved, false if only a single
 /// level of children should be retrieved. This parameter should only be true for
 /// the NavigationCmdletProvider derived class.
 /// </param>
 ///
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object GetChildItemsDynamicParameters(string path, bool recurse)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 } // GetChildItemsDynamicParameters
コード例 #9
0
        } // InitializeDefaultDrives

        #endregion DriveCmdletProvider method wrappers

        #endregion internal members

        #region Protected methods that should be overridden by derived classes

        /// <summary>
        /// Gives the provider an opportunity to validate the drive
        /// that is being added. It also allows the provider to modify parts
        /// of the PSDriveInfo object. This may be done for performance or
        /// reliability reasons or to provide extra data to all calls using
        /// the Drive.
        /// </summary>
        ///
        /// <param name="drive">
        /// The proposed new drive.
        /// </param>
        ///
        /// <returns>
        /// The new drive that is to be added to the MSH namespace. This
        /// can either be the same <paramref name="drive"/> object that
        /// was passed in or a modified version of it.
        ///
        /// The default implementation returns the drive that was passed.
        /// </returns>
        ///
        /// <remarks>
        /// This method gives the provider an opportunity to associate
        /// provider specific data with a drive. This is done by deriving
        /// a new class from <see cref="System.Management.Automation.PSDriveInfo"/>
        /// and adding any properties, methods, or fields that are necessary.
        /// When this method gets called, the override should create an instance
        /// of the derived PSDriveInfo using the passed in PSDriveInfo. The derived
        /// PSDriveInfo should then be returned. Each subsequent call into the provider
        /// that uses this drive will have access to the derived PSDriveInfo via the
        /// PSDriveInfo property provided by the base class.
        ///
        /// Any failures should be sent to the <see cref="System.Management.Automation.Provider.CmdletProvider.WriteError(ErrorRecord)"/>
        /// method and null should be returned.
        /// </remarks>
        protected virtual PSDriveInfo NewDrive(PSDriveInfo drive)
        {
            using (PSTransactionManager.GetEngineProtectionScope())
            {
                return(drive);
            } // TraceMethod
        }     // NewDrive
コード例 #10
0
 protected virtual void InvokeDefaultAction(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "CmdletProvider_NotSupported", new object[0]);
     }
 }
コード例 #11
0
 protected virtual string[] ExpandPath(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
         return new string[1] {
                    path
         };
 }
コード例 #12
0
 protected virtual string NormalizeRelativePath(string path, string basePath)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(this.ContractRelativePath(path, basePath, false, base.Context));
     }
 }
コード例 #13
0
 protected virtual object MoveItemDynamicParameters(string path, string destination)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 }
コード例 #14
0
 protected virtual void MoveItem(string path, string destination)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "CmdletProvider_NotSupported", new object[0]);
     }
 }
コード例 #15
0
 public void WriteSecurityDescriptorObject(ObjectSecurity securityDescriptor, string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         this.WriteObject(securityDescriptor, path);
     }
 }
コード例 #16
0
        }     // RemoveDrive

        /// <summary>
        /// Gives the provider the ability to map drives after initialization.
        /// </summary>
        ///
        /// <returns>
        /// A collection of the drives the provider wants to be added to the session upon initialization.
        ///
        /// The default implementation returns an empty <see cref="System.Management.Automation.PSDriveInfo"/> collection.
        /// </returns>
        ///
        /// <remarks>
        /// After the Start method is called on a provider, the InitializeDefaultDrives
        /// method is called. This is an opportunity for the provider to
        /// mount drives that are important to it. For instance, the Active Directory
        /// provider might mount a drive for the defaultNamingContext if the
        /// machine is joined to a domain.
        ///
        /// All providers should mount a root drive to help the user with discoverability.
        /// This root drive might contain a listing of a set of locations that would be
        /// interesting as roots for other mounted drives. For instance, the Active
        /// Directory provider my create a drive that lists the naming contexts found
        /// in the namingContext attributes on the RootDSE. This will help users
        /// discover interesting mount points for other drives.
        /// </remarks>
        protected virtual Collection <PSDriveInfo> InitializeDefaultDrives()
        {
            using (PSTransactionManager.GetEngineProtectionScope())
            {
                return(new Collection <PSDriveInfo>());
            } // TraceMethod
        }     // InitializeDefaultDrives
コード例 #17
0
 public void WriteWarning(string text)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         this.Context.WriteWarning(text);
     }
 }
コード例 #18
0
 public bool ShouldContinue(string query, string caption, ref bool yesToAll, ref bool noToAll)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(this.Context.ShouldContinue(query, caption, ref yesToAll, ref noToAll));
     }
 }
コード例 #19
0
 /// <Content contentref="System.Management.Automation.PathIntrinsics.GetUnresolvedProviderPathFromPSPath" />
 public string GetUnresolvedProviderPathFromPSPath(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(SessionState.Path.GetUnresolvedProviderPathFromPSPath(path));
     }
 }
コード例 #20
0
 public bool ShouldProcess(string target, string action)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(this.Context.ShouldProcess(target, action));
     }
 }
コード例 #21
0
        /// <Content contentref="System.Management.Automation.VariableIntrinsics.GetValue" />

        public object GetVariableValue(string name, object defaultValue)
        {
            using (PSTransactionManager.GetEngineProtectionScope())
            {
                return(this.SessionState.PSVariable.GetValue(name, defaultValue));
            }
        }
コード例 #22
0
 public bool ShouldProcess(string verboseDescription, string verboseWarning, string caption, out ShouldProcessReason shouldProcessReason)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(this.Context.ShouldProcess(verboseDescription, verboseWarning, caption, out shouldProcessReason));
     }
 }
コード例 #23
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the invoke-item cmdlet.
 /// </summary>
 ///
 /// <param name="path">
 /// If the path was specified on the command line, this is the path
 /// to the item to get the dynamic parameters for.
 /// </param>
 ///
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object InvokeDefaultActionDynamicParameters(string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 } // InvokeDefaultActionDynamicParameters
コード例 #24
0
 protected virtual System.Management.Automation.ProviderInfo Start(System.Management.Automation.ProviderInfo providerInfo)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(providerInfo);
     }
 }
コード例 #25
0
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(baseName));
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(resourceId));
         }
         ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(this.GetType().Assembly, baseName);
         string          str;
         try
         {
             str = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
         }
         catch (MissingManifestResourceException ex)
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(baseName), "GetErrorText", "ResourceBaseNameFailure", (object)baseName);
         }
         return(str != null ? str : throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(resourceId), "GetErrorText", "ResourceIdFailure", (object)resourceId));
     }
 }
コード例 #26
0
 public void WriteItemObject(object item, string path, bool isContainer)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         this.WriteObject(item, path, isContainer);
     }
 }
コード例 #27
0
 /// <summary>
 /// Gives the provider an opportunity to attach additional parameters to
 /// the rename-item cmdlet.
 /// </summary>
 /// <param name="path">
 /// If the path was specified on the command line, this is the path
 /// to the item to get the dynamic parameters for.
 /// </param>
 /// <param name="newName">
 /// The name to which the item should be renamed. This name should always be
 /// relative to the parent container.
 /// </param>
 /// <returns>
 /// Overrides of this method should return an object that has properties and fields decorated with
 /// parsing attributes similar to a cmdlet class or a
 /// <see cref="System.Management.Automation.RuntimeDefinedParameterDictionary"/>.
 ///
 /// The default implementation returns null. (no additional parameters)
 /// </returns>
 protected virtual object RenameItemDynamicParameters(string path, string newName)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(null);
     }
 }
コード例 #28
0
 public void WritePropertyObject(object propertyValue, string path)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         this.WriteObject(propertyValue, path);
     }
 }
コード例 #29
0
 /// <summary>
 /// Gives the provider an opportunity to clean up any provider specific data
 /// for the drive that is going to be removed.
 /// </summary>
 /// <param name="drive">
 /// The Drive object the represents the mounted drive.
 /// </param>
 /// <returns>
 /// If the drive can be removed it should return the drive that was passed
 /// in. If the drive cannot be removed, null should be returned or an exception
 /// should be thrown.
 ///
 /// The default implementation returns the drive that was passed.
 /// </returns>
 /// <remarks>
 /// A provider should override this method to free any resources that may be associated with
 /// the drive being removed.
 /// </remarks>
 protected virtual PSDriveInfo RemoveDrive(PSDriveInfo drive)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         return(drive);
     }
 }
コード例 #30
0
 protected virtual object CopyItemDynamicParameters(
     string path,
     string destination,
     bool recurse)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
         return((object)null);
 }