protected override void GetItem(string path) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { WriteDebug("GetItem: " + path); path = NormalizePath(path); ICollection <AssemblyName> assemblyNames = GetAssemblyNames(path); // FIXME: PowerShell Connect #387048 if (path == BACKSLASH) { // root, e.g. GAC:\ WriteItemObject(assemblyNames, String.Empty, true); } else { // a path, e.g. gac:system.web foreach (AssemblyName assemblyName in assemblyNames) { if (MatchesDynamicParameterFilters(assemblyName)) { WriteItemObject(assemblyName, path, false); } } } } }
protected virtual void WritePathItems(string path, bool namesOnly) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { if (namesOnly) { // note: // dynamic parameters are NOT used here // due to the "one to many" relationship. // write out keys in cache AssemblyNameCache cache = GetCache(path); foreach (string cachedPath in cache.Paths) { WriteItemObject(cachedPath, cachedPath, false); } } else { // write out values in cache ICollection <AssemblyName> assemblyNames = GetAssemblyNames(path); foreach (AssemblyName assemblyName in assemblyNames) { if (MatchesDynamicParameterFilters(assemblyName)) { WriteItemObject(assemblyName, assemblyName.Name, false); } } } } }
protected override void GetChildNames(string path, ReturnContainers returnContainers) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { WriteDebug(String.Format("GetChildNames: {0} ; returnContainers: {1}", path, returnContainers)); path = NormalizePath(path); WritePathItems(path, true); } }
protected override void GetChildItems(string path, bool recurse) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { WriteDebug(String.Format("GetChildItems: {0} ; recurse: {1}", path, recurse)); path = NormalizePath(path); WritePathItems(path, false); } }
protected override bool HasChildItems(string path) { // oisin: undid shortcut hack here (assumed gac and never empty) // because provider qualified paths in future will allow // zap/download cache querying which may or may not be empty. using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { path = NormalizePath(path); if (path == BACKSLASH) { return(GetAssemblyNames(path).Count > 0); } return(false); } }
protected override bool ItemExists(string path) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { WriteDebug("ItemExists: " + path); path = NormalizePath(path); if (path == BACKSLASH) { return(true); } return(GetAssemblyNames(path).Count > 0); } }
protected override void InvokeDefaultAction(string path) { using (PscxProviderContext <AssemblyCacheProvider> .Enter(this)) { path = NormalizePath(path); if (path == BACKSLASH) { if (!ShouldContinue(Properties.Resources.AssemblyCacheLoadEntireGac, "Invoke-Item")) { // OK, so we're NOT going to load the entire GAC. return; } } ICollection <AssemblyName> names = GetAssemblyNames(path); string operation = IsParameterReflectionOnlySet ? "ReflectionOnlyLoad" : "Load"; foreach (AssemblyName name in names) { if (MatchesDynamicParameterFilters(name)) { if (ShouldProcess(name.FullName, operation)) { Assembly assembly = IsParameterReflectionOnlySet ? Assembly.ReflectionOnlyLoad(name.FullName) : Assembly.Load(name); if (IsParameterReflectionOnlySet) { PromptToPreloadReferences(assembly); } WriteItemObject(assembly, path, false); } } } } }
private PscxThreadContext.Cookie EnterContext() { return(PscxProviderContext <DirectoryServiceProvider> .Enter(this)); }