Пример #1
0
        private void MergeCustomPSSnapIn(PSSnapInInfo mshsnapinInfo, CustomPSSnapIn customPSSnapIn)
        {
            if (mshsnapinInfo == null || customPSSnapIn == null)
            {
                return;
            }

            s_mshsnapinTracer.WriteLine("Merging configuration from custom mshsnapin {0}", mshsnapinInfo.Name);

            if (customPSSnapIn.Cmdlets != null)
            {
                foreach (CmdletConfigurationEntry entry in customPSSnapIn.Cmdlets)
                {
                    CmdletConfigurationEntry cmdlet = new CmdletConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                    _cmdlets.AddBuiltInItem(cmdlet);
                }
            }

            if (customPSSnapIn.Providers != null)
            {
                foreach (ProviderConfigurationEntry entry in customPSSnapIn.Providers)
                {
                    ProviderConfigurationEntry provider = new ProviderConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                    _providers.AddBuiltInItem(provider);
                }
            }

            if (customPSSnapIn.Types != null)
            {
                foreach (TypeConfigurationEntry entry in customPSSnapIn.Types)
                {
                    string path = Path.Combine(mshsnapinInfo.ApplicationBase, entry.FileName);
                    TypeConfigurationEntry type = new TypeConfigurationEntry(entry.Name, path, mshsnapinInfo);
                    _types.AddBuiltInItem(type);
                }
            }

            if (customPSSnapIn.Formats != null)
            {
                foreach (FormatConfigurationEntry entry in customPSSnapIn.Formats)
                {
                    string path = Path.Combine(mshsnapinInfo.ApplicationBase, entry.FileName);
                    FormatConfigurationEntry format = new FormatConfigurationEntry(entry.Name, path, mshsnapinInfo);
                    _formats.AddBuiltInItem(format);
                }
            }

            AssemblyConfigurationEntry assemblyEntry = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);

            this.Assemblies.AddBuiltInItem(assemblyEntry);

            s_mshsnapinTracer.WriteLine("Configuration from custom mshsnapin {0} merged", mshsnapinInfo.Name);
        }
Пример #2
0
 private void MergeCustomPSSnapIn(PSSnapInInfo mshsnapinInfo, CustomPSSnapIn customPSSnapIn)
 {
     if ((mshsnapinInfo != null) && (customPSSnapIn != null))
     {
         _mshsnapinTracer.WriteLine("Merging configuration from custom mshsnapin {0}", new object[] { mshsnapinInfo.Name });
         if (customPSSnapIn.Cmdlets != null)
         {
             foreach (CmdletConfigurationEntry entry in customPSSnapIn.Cmdlets)
             {
                 CmdletConfigurationEntry entry2 = new CmdletConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                 this._cmdlets.AddBuiltInItem(entry2);
             }
         }
         if (customPSSnapIn.Providers != null)
         {
             foreach (ProviderConfigurationEntry entry3 in customPSSnapIn.Providers)
             {
                 ProviderConfigurationEntry entry4 = new ProviderConfigurationEntry(entry3.Name, entry3.ImplementingType, entry3.HelpFileName, mshsnapinInfo);
                 this._providers.AddBuiltInItem(entry4);
             }
         }
         if (customPSSnapIn.Types != null)
         {
             foreach (TypeConfigurationEntry entry5 in customPSSnapIn.Types)
             {
                 string fileName = Path.Combine(mshsnapinInfo.ApplicationBase, entry5.FileName);
                 TypeConfigurationEntry entry6 = new TypeConfigurationEntry(entry5.Name, fileName, mshsnapinInfo);
                 this._types.AddBuiltInItem(entry6);
             }
         }
         if (customPSSnapIn.Formats != null)
         {
             foreach (FormatConfigurationEntry entry7 in customPSSnapIn.Formats)
             {
                 string str2 = Path.Combine(mshsnapinInfo.ApplicationBase, entry7.FileName);
                 FormatConfigurationEntry entry8 = new FormatConfigurationEntry(entry7.Name, str2, mshsnapinInfo);
                 this._formats.AddBuiltInItem(entry8);
             }
         }
         AssemblyConfigurationEntry item = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
         this.Assemblies.AddBuiltInItem(item);
         _mshsnapinTracer.WriteLine("Configuration from custom mshsnapin {0} merged", new object[] { mshsnapinInfo.Name });
     }
 }
Пример #3
0
 private void LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
 {
     if (mshsnapinInfo != null)
     {
         if (!string.IsNullOrEmpty(mshsnapinInfo.CustomPSSnapInType))
         {
             this.LoadCustomPSSnapIn(mshsnapinInfo);
         }
         else
         {
             Assembly assembly = null;
             _mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0}", new object[] { mshsnapinInfo.Name });
             assembly = this.LoadMshSnapinAssembly(mshsnapinInfo);
             if (assembly == null)
             {
                 _mshsnapinTracer.TraceError("Loading assembly for mshsnapin {0} failed", new object[] { mshsnapinInfo.Name });
             }
             else
             {
                 _mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0} succeeded", new object[] { mshsnapinInfo.Name });
                 this.AnalyzeMshSnapinAssembly(assembly, mshsnapinInfo);
                 foreach (string str in mshsnapinInfo.Types)
                 {
                     string name = Path.Combine(mshsnapinInfo.ApplicationBase, str);
                     TypeConfigurationEntry entry = new TypeConfigurationEntry(name, name, mshsnapinInfo);
                     this.Types.AddBuiltInItem(entry);
                 }
                 foreach (string str3 in mshsnapinInfo.Formats)
                 {
                     string str4 = Path.Combine(mshsnapinInfo.ApplicationBase, str3);
                     FormatConfigurationEntry entry2 = new FormatConfigurationEntry(str4, str4, mshsnapinInfo);
                     this.Formats.AddBuiltInItem(entry2);
                 }
                 AssemblyConfigurationEntry item = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
                 this.Assemblies.AddBuiltInItem(item);
             }
         }
     }
 }
        private void MergeCustomPSSnapIn(PSSnapInInfo mshsnapinInfo, CustomPSSnapIn customPSSnapIn)
        {
            if (mshsnapinInfo == null || customPSSnapIn == null)
                return;

            s_mshsnapinTracer.WriteLine("Merging configuration from custom mshsnapin {0}", mshsnapinInfo.Name);

            if (customPSSnapIn.Cmdlets != null)
            {
                foreach (CmdletConfigurationEntry entry in customPSSnapIn.Cmdlets)
                {
                    CmdletConfigurationEntry cmdlet = new CmdletConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                    _cmdlets.AddBuiltInItem(cmdlet);
                }
            }

            if (customPSSnapIn.Providers != null)
            {
                foreach (ProviderConfigurationEntry entry in customPSSnapIn.Providers)
                {
                    ProviderConfigurationEntry provider = new ProviderConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                    _providers.AddBuiltInItem(provider);
                }
            }

            if (customPSSnapIn.Types != null)
            {
                foreach (TypeConfigurationEntry entry in customPSSnapIn.Types)
                {
                    string path = Path.Combine(mshsnapinInfo.ApplicationBase, entry.FileName);
                    TypeConfigurationEntry type = new TypeConfigurationEntry(entry.Name, path, mshsnapinInfo);
                    _types.AddBuiltInItem(type);
                }
            }

            if (customPSSnapIn.Formats != null)
            {
                foreach (FormatConfigurationEntry entry in customPSSnapIn.Formats)
                {
                    string path = Path.Combine(mshsnapinInfo.ApplicationBase, entry.FileName);
                    FormatConfigurationEntry format = new FormatConfigurationEntry(entry.Name, path, mshsnapinInfo);
                    _formats.AddBuiltInItem(format);
                }
            }

            AssemblyConfigurationEntry assemblyEntry = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
            this.Assemblies.AddBuiltInItem(assemblyEntry);

            s_mshsnapinTracer.WriteLine("Configuration from custom mshsnapin {0} merged", mshsnapinInfo.Name);
        }
        private void LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
        {
            if (mshsnapinInfo == null)
                return;

#if !CORECLR // CustomPSSnapIn Not Supported On CSS. 
            if (!String.IsNullOrEmpty(mshsnapinInfo.CustomPSSnapInType))
            {
                LoadCustomPSSnapIn(mshsnapinInfo);
                return;
            }
#endif
            Assembly assembly = null;

            s_mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0}", mshsnapinInfo.Name);

            assembly = LoadMshSnapinAssembly(mshsnapinInfo);

            if (assembly == null)
            {
                s_mshsnapinTracer.TraceError("Loading assembly for mshsnapin {0} failed", mshsnapinInfo.Name);
                return;
            }

            s_mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0} succeeded", mshsnapinInfo.Name);

            Dictionary<string, SessionStateCmdletEntry> cmdlets = null;
            Dictionary<string, List<SessionStateAliasEntry>> aliases = null;
            Dictionary<string, SessionStateProviderEntry> providers = null;
            string throwAwayHelpFile = null;
            PSSnapInHelpers.AnalyzePSSnapInAssembly(assembly, assembly.Location, mshsnapinInfo, null, false, out cmdlets, out aliases, out providers, out throwAwayHelpFile);
            if (cmdlets != null)
            {
                foreach (var c in cmdlets)
                {
                    CmdletConfigurationEntry cmdlet = new CmdletConfigurationEntry(c.Key, c.Value.ImplementingType,
                                                                                   c.Value.HelpFileName, mshsnapinInfo);
                    _cmdlets.AddBuiltInItem(cmdlet);
                }
            }
            if (providers != null)
            {
                foreach (var p in providers)
                {
                    ProviderConfigurationEntry provider = new ProviderConfigurationEntry(p.Key, p.Value.ImplementingType,
                                                                                         p.Value.HelpFileName,
                                                                                         mshsnapinInfo);
                    _providers.AddBuiltInItem(provider);
                }
            }

            foreach (string file in mshsnapinInfo.Types)
            {
                string path = Path.Combine(mshsnapinInfo.ApplicationBase, file);

                TypeConfigurationEntry typeEntry = new TypeConfigurationEntry(path, path, mshsnapinInfo);
                this.Types.AddBuiltInItem(typeEntry);
            }

            foreach (string file in mshsnapinInfo.Formats)
            {
                string path = Path.Combine(mshsnapinInfo.ApplicationBase, file);

                FormatConfigurationEntry formatEntry = new FormatConfigurationEntry(path, path, mshsnapinInfo);
                this.Formats.AddBuiltInItem(formatEntry);
            }

            AssemblyConfigurationEntry assemblyEntry = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
            this.Assemblies.AddBuiltInItem(assemblyEntry);

            return;
        }
Пример #6
0
 private void MergeCustomPSSnapIn(PSSnapInInfo mshsnapinInfo, CustomPSSnapIn customPSSnapIn)
 {
     if ((mshsnapinInfo != null) && (customPSSnapIn != null))
     {
         _mshsnapinTracer.WriteLine("Merging configuration from custom mshsnapin {0}", new object[] { mshsnapinInfo.Name });
         if (customPSSnapIn.Cmdlets != null)
         {
             foreach (CmdletConfigurationEntry entry in customPSSnapIn.Cmdlets)
             {
                 CmdletConfigurationEntry entry2 = new CmdletConfigurationEntry(entry.Name, entry.ImplementingType, entry.HelpFileName, mshsnapinInfo);
                 this._cmdlets.AddBuiltInItem(entry2);
             }
         }
         if (customPSSnapIn.Providers != null)
         {
             foreach (ProviderConfigurationEntry entry3 in customPSSnapIn.Providers)
             {
                 ProviderConfigurationEntry entry4 = new ProviderConfigurationEntry(entry3.Name, entry3.ImplementingType, entry3.HelpFileName, mshsnapinInfo);
                 this._providers.AddBuiltInItem(entry4);
             }
         }
         if (customPSSnapIn.Types != null)
         {
             foreach (TypeConfigurationEntry entry5 in customPSSnapIn.Types)
             {
                 string fileName = Path.Combine(mshsnapinInfo.ApplicationBase, entry5.FileName);
                 TypeConfigurationEntry entry6 = new TypeConfigurationEntry(entry5.Name, fileName, mshsnapinInfo);
                 this._types.AddBuiltInItem(entry6);
             }
         }
         if (customPSSnapIn.Formats != null)
         {
             foreach (FormatConfigurationEntry entry7 in customPSSnapIn.Formats)
             {
                 string str2 = Path.Combine(mshsnapinInfo.ApplicationBase, entry7.FileName);
                 FormatConfigurationEntry entry8 = new FormatConfigurationEntry(entry7.Name, str2, mshsnapinInfo);
                 this._formats.AddBuiltInItem(entry8);
             }
         }
         AssemblyConfigurationEntry item = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
         this.Assemblies.AddBuiltInItem(item);
         _mshsnapinTracer.WriteLine("Configuration from custom mshsnapin {0} merged", new object[] { mshsnapinInfo.Name });
     }
 }
Пример #7
0
 private void LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
 {
     if (mshsnapinInfo != null)
     {
         if (!string.IsNullOrEmpty(mshsnapinInfo.CustomPSSnapInType))
         {
             this.LoadCustomPSSnapIn(mshsnapinInfo);
         }
         else
         {
             Assembly assembly = null;
             _mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0}", new object[] { mshsnapinInfo.Name });
             assembly = this.LoadMshSnapinAssembly(mshsnapinInfo);
             if (assembly == null)
             {
                 _mshsnapinTracer.TraceError("Loading assembly for mshsnapin {0} failed", new object[] { mshsnapinInfo.Name });
             }
             else
             {
                 _mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0} succeeded", new object[] { mshsnapinInfo.Name });
                 this.AnalyzeMshSnapinAssembly(assembly, mshsnapinInfo);
                 foreach (string str in mshsnapinInfo.Types)
                 {
                     string name = Path.Combine(mshsnapinInfo.ApplicationBase, str);
                     TypeConfigurationEntry entry = new TypeConfigurationEntry(name, name, mshsnapinInfo);
                     this.Types.AddBuiltInItem(entry);
                 }
                 foreach (string str3 in mshsnapinInfo.Formats)
                 {
                     string str4 = Path.Combine(mshsnapinInfo.ApplicationBase, str3);
                     FormatConfigurationEntry entry2 = new FormatConfigurationEntry(str4, str4, mshsnapinInfo);
                     this.Formats.AddBuiltInItem(entry2);
                 }
                 AssemblyConfigurationEntry item = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
                 this.Assemblies.AddBuiltInItem(item);
             }
         }
     }
 }
Пример #8
0
        private void LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
        {
            if (mshsnapinInfo == null)
            {
                return;
            }

#if !CORECLR // CustomPSSnapIn Not Supported On CSS.
            if (!String.IsNullOrEmpty(mshsnapinInfo.CustomPSSnapInType))
            {
                LoadCustomPSSnapIn(mshsnapinInfo);
                return;
            }
#endif
            Assembly assembly = null;

            s_mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0}", mshsnapinInfo.Name);

            assembly = LoadMshSnapinAssembly(mshsnapinInfo);

            if (assembly == null)
            {
                s_mshsnapinTracer.TraceError("Loading assembly for mshsnapin {0} failed", mshsnapinInfo.Name);
                return;
            }

            s_mshsnapinTracer.WriteLine("Loading assembly for mshsnapin {0} succeeded", mshsnapinInfo.Name);

            Dictionary <string, SessionStateCmdletEntry>        cmdlets   = null;
            Dictionary <string, List <SessionStateAliasEntry> > aliases   = null;
            Dictionary <string, SessionStateProviderEntry>      providers = null;
            string throwAwayHelpFile = null;
            PSSnapInHelpers.AnalyzePSSnapInAssembly(assembly, assembly.Location, mshsnapinInfo, null, false, out cmdlets, out aliases, out providers, out throwAwayHelpFile);
            if (cmdlets != null)
            {
                foreach (var c in cmdlets)
                {
                    CmdletConfigurationEntry cmdlet = new CmdletConfigurationEntry(c.Key, c.Value.ImplementingType,
                                                                                   c.Value.HelpFileName, mshsnapinInfo);
                    _cmdlets.AddBuiltInItem(cmdlet);
                }
            }
            if (providers != null)
            {
                foreach (var p in providers)
                {
                    ProviderConfigurationEntry provider = new ProviderConfigurationEntry(p.Key, p.Value.ImplementingType,
                                                                                         p.Value.HelpFileName,
                                                                                         mshsnapinInfo);
                    _providers.AddBuiltInItem(provider);
                }
            }

            foreach (string file in mshsnapinInfo.Types)
            {
                string path = Path.Combine(mshsnapinInfo.ApplicationBase, file);

                TypeConfigurationEntry typeEntry = new TypeConfigurationEntry(path, path, mshsnapinInfo);
                this.Types.AddBuiltInItem(typeEntry);
            }

            foreach (string file in mshsnapinInfo.Formats)
            {
                string path = Path.Combine(mshsnapinInfo.ApplicationBase, file);

                FormatConfigurationEntry formatEntry = new FormatConfigurationEntry(path, path, mshsnapinInfo);
                this.Formats.AddBuiltInItem(formatEntry);
            }

            AssemblyConfigurationEntry assemblyEntry = new AssemblyConfigurationEntry(mshsnapinInfo.AssemblyName, mshsnapinInfo.AbsoluteModulePath, mshsnapinInfo);
            this.Assemblies.AddBuiltInItem(assemblyEntry);

            return;
        }