예제 #1
0
        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);
                        }
                    }
                }
            }
        }
예제 #2
0
        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);
                        }
                    }
                }
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
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);
                        }
                    }
                }
            }
        }
예제 #8
0
 private PscxThreadContext.Cookie EnterContext()
 {
     return(PscxProviderContext <DirectoryServiceProvider> .Enter(this));
 }