} // GetContentReaderPrivate /// <summary> /// Gets the dynamic parameters for the get-content cmdlet. /// </summary> /// /// <param name="path"> /// The path to the item if it was specified on the command line. /// </param> /// /// <param name="context"> /// The context which the core command is running. /// </param> /// /// <returns> /// An object that has properties and fields decorated with /// parsing attributes similar to a cmdlet class. /// </returns> /// /// <exception cref="ProviderNotFoundException"> /// If the <paramref name="path"/> refers to a provider that could not be found. /// </exception> /// /// <exception cref="DriveNotFoundException"> /// If the <paramref name="path"/> refers to a drive that could not be found. /// </exception> /// /// <exception cref="NotSupportedException"> /// If the provider that the <paramref name="path"/> refers to does /// not support this operation. /// </exception> /// /// <exception cref="ProviderInvocationException"> /// If the provider threw an exception. /// </exception> /// /// <exception cref="ItemNotFoundException"> /// If <paramref name="path"/> does not contain glob characters and /// could not be found. /// </exception> /// internal object GetContentReaderDynamicParameters( string path, CmdletProviderContext context) { if (path == null) { return(null); } ProviderInfo provider = null; CmdletProvider providerInstance = null; CmdletProviderContext newContext = new CmdletProviderContext(context); newContext.SetFilters( new Collection <string>(), new Collection <string>(), null); Collection <string> providerPaths = Globber.GetGlobbedProviderPathsFromMonadPath( path, true, newContext, out provider, out providerInstance); if (providerPaths.Count > 0) { // Get the dynamic parameters for the first resolved path return(GetContentReaderDynamicParameters(providerInstance, providerPaths[0], newContext)); } return(null); } // GetContentReaderDynamicParameters
/// <summary> /// Clears the specified item. Depending on the provider that the path /// maps to, this could mean the properties and/or content and/or value is /// cleared. /// </summary> /// <param name="paths"> /// The path(s) to the object. It can be either a relative (most common) /// or absolute path. /// </param> /// <param name="context"> /// The context which the core command is running. /// </param> /// <exception cref="ArgumentNullException"> /// If <paramref name="path"/> is null. /// </exception> /// <exception cref="ProviderNotFoundException"> /// If the <paramref name="path"/> refers to a provider that could not be found. /// </exception> /// <exception cref="DriveNotFoundException"> /// If the <paramref name="path"/> refers to a drive that could not be found. /// </exception> /// <exception cref="NotSupportedException"> /// If the provider that the <paramref name="path"/> refers to does /// not support this operation. /// </exception> /// <exception cref="ProviderInvocationException"> /// If the provider threw an exception. /// </exception> /// <exception cref="ItemNotFoundException"> /// If <paramref name="path"/> does not contain glob characters and /// could not be found. /// </exception> internal void ClearItem( string[] paths, CmdletProviderContext context) { if (paths == null) { throw PSTraceSource.NewArgumentNullException("paths"); } ProviderInfo provider = null; CmdletProvider providerInstance = null; foreach (string path in paths) { if (path == null) { throw PSTraceSource.NewArgumentNullException("paths"); } Collection <string> providerPaths = Globber.GetGlobbedProviderPathsFromMonadPath( path, false, context, out provider, out providerInstance); if (providerPaths != null) { foreach (string providerPath in providerPaths) { ClearItemPrivate(providerInstance, providerPath, context); } } } }