本文整理汇总了C#中System.Management.Automation.CmdletProviderContext.SetFilters方法的典型用法代码示例。如果您正苦于以下问题:C# CmdletProviderContext.SetFilters方法的具体用法?C# CmdletProviderContext.SetFilters怎么用?C# CmdletProviderContext.SetFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.CmdletProviderContext
的用法示例。
在下文中一共展示了CmdletProviderContext.SetFilters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyProperty
internal void CopyProperty(string[] sourcePaths, string sourceProperty, string destinationPath, string destinationProperty, CmdletProviderContext context)
{
if (sourcePaths == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
if (sourceProperty == null)
{
throw PSTraceSource.NewArgumentNullException("sourceProperty");
}
if (destinationPath == null)
{
throw PSTraceSource.NewArgumentNullException("destinationPath");
}
if (destinationProperty == null)
{
throw PSTraceSource.NewArgumentNullException("destinationProperty");
}
foreach (string str in sourcePaths)
{
if (str == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
ProviderInfo info = null;
CmdletProvider providerInstance = null;
Collection<string> collection = this.Globber.GetGlobbedProviderPathsFromMonadPath(str, false, context, out info, out providerInstance);
if (collection.Count > 0)
{
Collection<string> include = context.Include;
Collection<string> exclude = context.Exclude;
string filter = context.Filter;
context.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> collection4 = this.Globber.GetGlobbedProviderPathsFromMonadPath(destinationPath, false, context, out info, out providerInstance);
context.SetFilters(include, exclude, filter);
foreach (string str3 in collection)
{
foreach (string str4 in collection4)
{
this.CopyProperty(providerInstance, str3, sourceProperty, str4, destinationProperty, context);
}
}
}
}
}
示例2: SetPropertyDynamicParameters
internal object SetPropertyDynamicParameters(string path, PSObject propertyValue, CmdletProviderContext context)
{
if (path != null)
{
ProviderInfo info = null;
CmdletProvider providerInstance = null;
CmdletProviderContext context2 = new CmdletProviderContext(context);
context2.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> collection = this.Globber.GetGlobbedProviderPathsFromMonadPath(path, true, context2, out info, out providerInstance);
if (collection.Count > 0)
{
return this.SetPropertyDynamicParameters(providerInstance, collection[0], propertyValue, context2);
}
}
return null;
}
示例3: CopyItemDynamicParameters
internal object CopyItemDynamicParameters(string path, string destination, bool recurse, CmdletProviderContext context)
{
if (path != null)
{
ProviderInfo info = null;
CmdletProvider providerInstance = null;
CmdletProviderContext context2 = new CmdletProviderContext(context);
context2.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> collection = this.Globber.GetGlobbedProviderPathsFromMonadPath(path, true, context2, out info, out providerInstance);
if (collection.Count > 0)
{
return this.CopyItemDynamicParameters(providerInstance, collection[0], destination, recurse, context2);
}
}
return null;
}
示例4: ItemExistsDynamicParameters
internal object ItemExistsDynamicParameters(string path, CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
}
ProviderInfo info = null;
CmdletProvider providerInstance = null;
CmdletProviderContext context2 = new CmdletProviderContext(context);
context2.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> collection = this.Globber.GetGlobbedProviderPathsFromMonadPath(path, true, context2, out info, out providerInstance);
if (collection.Count > 0)
{
return this.ItemExistsDynamicParameters(providerInstance, collection[0], context2);
}
return null;
}
示例5: MoveProperty
internal void MoveProperty(string[] sourcePaths, string sourceProperty, string destinationPath, string destinationProperty, CmdletProviderContext context)
{
if (sourcePaths == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
if (sourceProperty == null)
{
throw PSTraceSource.NewArgumentNullException("sourceProperty");
}
if (destinationPath == null)
{
throw PSTraceSource.NewArgumentNullException("destinationPath");
}
if (destinationProperty == null)
{
throw PSTraceSource.NewArgumentNullException("destinationProperty");
}
ProviderInfo info = null;
CmdletProvider providerInstance = null;
CmdletProviderContext context2 = new CmdletProviderContext(context);
context2.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> targetObject = this.Globber.GetGlobbedProviderPathsFromMonadPath(destinationPath, false, context2, out info, out providerInstance);
if (targetObject.Count > 1)
{
ArgumentException exception = PSTraceSource.NewArgumentException("destinationPath", "SessionStateStrings", "MovePropertyDestinationResolveToSingle", new object[0]);
context.WriteError(new ErrorRecord(exception, exception.GetType().FullName, ErrorCategory.InvalidArgument, targetObject));
}
else
{
foreach (string str in sourcePaths)
{
if (str == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
foreach (string str2 in this.Globber.GetGlobbedProviderPathsFromMonadPath(str, false, context, out info, out providerInstance))
{
this.MoveProperty(providerInstance, str2, sourceProperty, targetObject[0], destinationProperty, context);
}
}
}
}
示例6: GetChildNames
//.........这里部分代码省略.........
CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
}
// Construct the include filter
Collection<WildcardPattern> includeMatcher =
SessionStateUtilities.CreateWildcardsFromStrings(
context.Include,
WildcardOptions.IgnoreCase);
// Construct the exclude filter
Collection<WildcardPattern> excludeMatcher =
SessionStateUtilities.CreateWildcardsFromStrings(
context.Exclude,
WildcardOptions.IgnoreCase);
if (LocationGlobber.ShouldPerformGlobbing(path, context))
{
ProviderInfo provider = null;
CmdletProvider providerInstance = null;
// We don't want to process include/exclude filters
// when globbing the targets of the operation, so
// copy the context without the filters.
CmdletProviderContext resolvePathContext =
new CmdletProviderContext(context);
resolvePathContext.SetFilters(
new Collection<string>(),
new Collection<string>(),
null);
// Resolve the path
Collection<string> providerPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
path,
false,
resolvePathContext,
out provider,
out providerInstance);
if (resolvePathContext.Drive != null)
{
context.Drive = resolvePathContext.Drive;
}
bool pathContainsGlobCharacters = LocationGlobber.StringContainsGlobCharacters(path);
foreach (string providerPath in providerPaths)
{
// Making sure to obey the StopProcessing.
if (context.Stopping)
{
return;
}
if ((!pathContainsGlobCharacters || recurse) && IsItemContainer(providerInstance, providerPath, context))
{
// Since the path contained glob characters or we are recursing and the
示例7: GetChildNamesDynamicParameters
internal object GetChildNamesDynamicParameters(string path, CmdletProviderContext context)
{
if (path == null)
{
return null;
}
ProviderInfo info = null;
CmdletProvider providerInstance = null;
CmdletProviderContext context2 = new CmdletProviderContext(context);
context2.SetFilters(new Collection<string>(), new Collection<string>(), null);
Collection<string> collection = null;
try
{
collection = this.Globber.GetGlobbedProviderPathsFromMonadPath(path, true, context2, out info, out providerInstance);
}
catch (ItemNotFoundException)
{
if (providerInstance == null)
{
throw;
}
}
object obj2 = null;
if ((collection != null) && (collection.Count > 0))
{
return this.GetChildNamesDynamicParameters(providerInstance, collection[0], context2);
}
if (providerInstance != null)
{
PSDriveInfo drive = null;
string str = this.Globber.GetProviderPath(path, context, out info, out drive);
if (str != null)
{
obj2 = this.GetChildNamesDynamicParameters(providerInstance, str, context2);
}
}
return obj2;
}
示例8: RemovePropertyDynamicParameters
} // RemoveProperty
/// <summary>
/// Gets the dynamic parameters for the remove-itemproperty cmdlet.
/// </summary>
///
/// <param name="path">
/// The path to the item if it was specified on the command line.
/// </param>
///
/// <param name="propertyName">
/// The name of the property that should be created.
/// </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 RemovePropertyDynamicParameters(
string path,
string propertyName,
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 RemovePropertyDynamicParameters(providerInstance, providerPaths[0], propertyName, newContext);
}
return null;
} // RemovePropertyDynamicParameters
示例9: GetChildItems
internal void GetChildItems(string path, bool recurse, CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
}
if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
}
ProviderInfo info = null;
if (recurse || LocationGlobber.ShouldPerformGlobbing(path, context))
{
bool flag = false;
try
{
if ((recurse && ((context.Include == null) || (context.Include.Count == 0))) && (!string.IsNullOrEmpty(path) && !this.IsItemContainer(path)))
{
string childName = this.GetChildName(path, context);
if (!string.Equals(childName, "*", StringComparison.OrdinalIgnoreCase) && (context.Include != null))
{
context.Include.Add(childName);
flag = true;
}
path = path.Substring(0, path.Length - childName.Length);
}
Collection<string> include = context.Include;
Collection<string> exclude = context.Exclude;
string filter = context.Filter;
if (recurse)
{
context.SetFilters(new Collection<string>(), new Collection<string>(), null);
}
CmdletProvider providerInstance = null;
Collection<string> collection3 = null;
try
{
collection3 = this.Globber.GetGlobbedProviderPathsFromMonadPath(path, false, context, out info, out providerInstance);
}
finally
{
context.SetFilters(include, exclude, filter);
}
if (recurse)
{
this.GetContainerProviderInstance(info);
}
bool flag2 = !LocationGlobber.StringContainsGlobCharacters(path);
if ((((recurse && !flag2) && ((include != null) && (include.Count == 0))) || ((include != null) && (include.Count > 0))) || ((exclude != null) && (exclude.Count > 0)))
{
foreach (string str4 in collection3)
{
if (context.Stopping)
{
return;
}
this.DoManualGetChildItems(providerInstance, str4, recurse, context, false);
}
}
else
{
foreach (string str5 in collection3)
{
if (context.Stopping)
{
return;
}
if ((flag2 || recurse) && this.IsItemContainer(providerInstance, str5, context))
{
this.GetChildItems(providerInstance, str5, recurse, context);
}
else
{
this.GetItemPrivate(providerInstance, str5, context);
}
}
}
}
finally
{
if (flag)
{
context.Include.Clear();
}
}
}
else
{
PSDriveInfo drive = null;
path = this.Globber.GetProviderPath(path, context, out info, out drive);
if (drive != null)
{
context.Drive = drive;
}
ContainerCmdletProvider containerProviderInstance = this.GetContainerProviderInstance(info);
if ((path != null) && this.ItemExists(containerProviderInstance, path, context))
{
if (this.IsItemContainer(containerProviderInstance, path, context))
{
this.GetChildItems(containerProviderInstance, path, recurse, context);
//.........这里部分代码省略.........
示例10: CopyProperty
//.........这里部分代码省略.........
/// </exception>
///
/// <exception cref="NotSupportedException">
/// If the provider that the <paramref name="sourcePath"/> 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 CopyProperty(
string[] sourcePaths,
string sourceProperty,
string destinationPath,
string destinationProperty,
CmdletProviderContext context)
{
if (sourcePaths == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
if (sourceProperty == null)
{
throw PSTraceSource.NewArgumentNullException("sourceProperty");
}
if (destinationPath == null)
{
throw PSTraceSource.NewArgumentNullException("destinationPath");
}
if (destinationProperty == null)
{
throw PSTraceSource.NewArgumentNullException("destinationProperty");
}
foreach (string sourcePath in sourcePaths)
{
if (sourcePath == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
ProviderInfo provider = null;
CmdletProvider providerInstance = null;
Collection<string> providerPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
sourcePath,
false,
context,
out provider,
out providerInstance);
if (providerPaths.Count > 0)
{
// Save off the original filters
Collection<string> includeFilters = context.Include;
Collection<string> excludeFilters = context.Exclude;
string filterString = context.Filter;
// now modify the filters so that the destination isn't filtered
context.SetFilters(
new Collection<string>(),
new Collection<string>(),
null);
Collection<string> providerDestinationPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
destinationPath,
false,
context,
out provider,
out providerInstance);
// Now reapply the filters
context.SetFilters(
includeFilters,
excludeFilters,
filterString);
foreach (string providerPath in providerPaths)
{
foreach (string providerDestinationPath in providerDestinationPaths)
{
CopyProperty(providerInstance, providerPath, sourceProperty, providerDestinationPath, destinationProperty, context);
}
}
}
}
} // CopyProperty
示例11: MoveProperty
} // MoveProperty
/// <summary>
/// Moves the specified property on the specified item to the specified property
/// on the destination item. The source and destination items can be the same item.
/// </summary>
///
/// <param name="sourcePaths">
/// The path(s) to the item(s) to move the property from.
/// </param>
///
/// <param name="sourceProperty">
/// The name of the property to be moved.
/// </param>
///
/// <param name="destinationPath">
/// The path to the item to move the property to.
/// </param>
///
/// <param name="destinationProperty">
/// The name of the property to move the property to.
/// </param>
///
/// <param name="context">
/// The context which the core command is running.
/// </param>
///
/// <exception cref="ArgumentNullException">
/// If <paramref name="sourcePath"/>, <paramref name="sourceProperty"/>,
/// <paramref name="destinationPath"/>, or <paramref name="destinationProperty"/>
/// is null.
/// </exception>
///
/// <exception cref="ArgumentException">
/// If <paramref name="destinationPath"/> resolves to more than one item.
/// </exception>
///
/// <exception cref="ProviderNotFoundException">
/// If the <paramref name="sourcePath"/> refers to a provider that could not be found.
/// </exception>
///
/// <exception cref="DriveNotFoundException">
/// If the <paramref name="sourcePath"/> refers to a drive that could not be found.
/// </exception>
///
/// <exception cref="NotSupportedException">
/// If the provider that the <paramref name="sourcePath"/> 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 MoveProperty(
string[] sourcePaths,
string sourceProperty,
string destinationPath,
string destinationProperty,
CmdletProviderContext context)
{
if (sourcePaths == null)
{
throw PSTraceSource.NewArgumentNullException("sourcePaths");
}
if (sourceProperty == null)
{
throw PSTraceSource.NewArgumentNullException("sourceProperty");
}
if (destinationPath == null)
{
throw PSTraceSource.NewArgumentNullException("destinationPath");
}
if (destinationProperty == null)
{
throw PSTraceSource.NewArgumentNullException("destinationProperty");
}
ProviderInfo provider = null;
CmdletProvider providerInstance = null;
// We shouldn't be filtering the destination path
CmdletProviderContext destinationContext = new CmdletProviderContext(context);
destinationContext.SetFilters(
new Collection<string>(),
new Collection<string>(),
null);
Collection<string> destinationProviderPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
//.........这里部分代码省略.........
示例12: CopyItemDynamicParameters
} // CopyRecurseToSingleContainer
/// <summary>
/// Gets the dynamic parameters for the copy-item cmdlet.
/// </summary>
///
/// <param name="path">
/// The path to the item if it was specified on the command line.
/// </param>
///
/// <param name="destination">
/// The path of the item to copy to.
/// </param>
///
/// <param name="recurse">
/// Tells the provider to recurse sub-containers when copying.
/// </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 CopyItemDynamicParameters(
string path,
string destination,
bool recurse,
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);
string providerPath = null;
bool pathNotFoundOnClient = false;
try
{
Collection<string> providerPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
path,
true,
newContext,
out provider,
out providerInstance);
if (providerPaths.Count > 0)
providerPath = providerPaths[0];
}
catch (DriveNotFoundException)
{
// This exception is expected for remote sessions where drives exist in a remote session but not
// on the client.
pathNotFoundOnClient = true;
}
catch (ItemNotFoundException)
{
// This exception is expected for remote sessions where item exist in a remote session but not
// on the client.
pathNotFoundOnClient = true;
}
if (pathNotFoundOnClient)
//.........这里部分代码省略.........
示例13: GetChildNamesDynamicParameters
} // GetChildNames
/// <summary>
/// Gets the dynamic parameters for the get-childitem -name 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 GetChildNamesDynamicParameters(
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 = null;
try
{
providerPaths =
Globber.GetGlobbedProviderPathsFromMonadPath(
path,
true,
newContext,
out provider,
out providerInstance);
}
catch (ItemNotFoundException)
{
// If the provided path is like c:\fakepath\aa*, since we cannot resolve c:\fakepath, an
// ItemNotFoundException will be thrown out. In this case, we catch the exception
// and check if the "providerInstance" is identified. If providerInstance is not null,
// we can carry on with the get-dynamic-parameters method.
if (providerInstance == null)
{
throw;
}
}
object result = null;
if (providerPaths != null && providerPaths.Count > 0)
{
// Get the dynamic parameters for the first resolved path
result = GetChildNamesDynamicParameters(providerInstance, providerPaths[0], newContext);
}
else
{
if (providerInstance != null)
{
PSDriveInfo drive = null;
// If we get here, the GetProviderPath should always succeed. This method was already invoked
// in the call to GetGlobbedProviderPathsFromMonadPath, and since "providerInstance" is not null,
// the invocation in method GetGlobbedProviderPathsFromMonadPath should succeed.
string providerPath = Globber.GetProviderPath(path, context, out provider, out drive);
if (providerPath != null)
//.........这里部分代码省略.........
示例14: ItemExistsDynamicParameters
} // Exists
/// <summary>
/// Gets the dynamic parameters for the test-path 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="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 object ItemExistsDynamicParameters(string path, CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
}
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 ItemExistsDynamicParameters(providerInstance, providerPaths[0], newContext);
}
return null;
} // ItemExistsDynamicParameters
示例15: GetChildNamesInDir
//.........这里部分代码省略.........
out string modifiedDirPath)
{
// See if the provider wants to convert the path and filter
string convertedPath = null;
string convertedFilter = null;
string originalFilter = context.Filter;
bool changedPathOrFilter = provider.ConvertPath(leafElement, context.Filter, ref convertedPath, ref convertedFilter, context);
if (changedPathOrFilter)
{
if (s_tracer.IsEnabled)
{
s_tracer.WriteLine("Provider converted path and filter.");
s_tracer.WriteLine("Original path: {0}", leafElement);
s_tracer.WriteLine("Converted path: {0}", convertedPath);
s_tracer.WriteLine("Original filter: {0}", context.Filter);
s_tracer.WriteLine("Converted filter: {0}", convertedFilter);
}
leafElement = convertedPath;
context.Filter = convertedFilter;
}
ReturnContainers returnContainers = ReturnContainers.ReturnAllContainers;
if (!getAllContainers)
{
returnContainers = ReturnContainers.ReturnMatchingContainers;
}
CmdletProviderContext getChildNamesContext =
new CmdletProviderContext(context);
// Remove the include/exclude filters from the new context
getChildNamesContext.SetFilters(
new Collection<string>(),
new Collection<string>(),
context.Filter);
try
{
// Use the provider to get the children
string unescapedDir = null;
modifiedDirPath = null;
if (dirIsProviderPath)
{
modifiedDirPath = unescapedDir = context.SuppressWildcardExpansion ? dir : RemoveGlobEscaping(dir);
}
else
{
Dbg.Diagnostics.Assert(
drive != null,
"Caller should verify that drive is not null when dirIsProviderPath is false");
// If the directory is an MSH path we must resolve it before calling GetChildNames()
// -- If the path is passed in by LiteralPath (context.SuppressWildcardExpansion == false), we surely should use 'dir' unchanged.
// -- If the path is passed in by Path (context.SuppressWildcardExpansion == true), we still should use 'dir' unchanged, in case that the special character
// in 'dir' is escaped
modifiedDirPath = GetMshQualifiedPath(dir, drive);
ProviderInfo providerIgnored = null;
CmdletProvider providerInstanceIgnored = null;
Collection<string> resolvedPaths =
GetGlobbedProviderPathsFromMonadPath(
modifiedDirPath,
false,