Esempio n. 1
0
 private void UpdateFormats()
 {
     using (RunspaceConfiguration.tracer.TraceMethod())
     {
         Collection <string> independentErrors = new Collection <string>();
         Collection <PSSnapInTypeAndFormatErrors> formatAndTypesErrors = FormatAndTypeDataHelper.GetFormatAndTypesErrors(this, this._host, (IEnumerable)this.Formats, RunspaceConfigurationCategory.Formats, independentErrors);
         this.FormatDBManager.UpdateDataBase(formatAndTypesErrors, this.AuthorizationManager, this._host);
         FormatAndTypeDataHelper.ThrowExceptionOnError("ErrorsUpdatingFormats", independentErrors, formatAndTypesErrors, RunspaceConfigurationCategory.Formats);
     }
 }
        internal void UpdateTypes(bool preValidated)
        {
            Collection <string> independentErrors    = new Collection <string>();
            Collection <int>    entryIndicesToRemove = new Collection <int>();
            Collection <PSSnapInTypeAndFormatErrors> psSnapinTypes = FormatAndTypeDataHelper.GetFormatAndTypesErrors(this, this._host, this.Types, RunspaceConfigurationCategory.Types, independentErrors, entryIndicesToRemove);

            if (entryIndicesToRemove.Count > 0)
            {
                this.RemoveNeedlessEntries(RunspaceConfigurationCategory.Types, entryIndicesToRemove);
            }
            this.TypeTable.Update(psSnapinTypes, this._authorizationManager, this._host, preValidated);
            FormatAndTypeDataHelper.ThrowExceptionOnError("ErrorsUpdatingTypes", independentErrors, psSnapinTypes, RunspaceConfigurationCategory.Types);
        }
        private void UpdateFormats(bool preValidated)
        {
            Collection <string> independentErrors               = new Collection <string>();
            Collection <int>    entryIndicesToRemove            = new Collection <int>();
            Collection <PSSnapInTypeAndFormatErrors> mshsnapins = FormatAndTypeDataHelper.GetFormatAndTypesErrors(this, this._host, this.Formats, RunspaceConfigurationCategory.Formats, independentErrors, entryIndicesToRemove);

            if (entryIndicesToRemove.Count > 0)
            {
                this.RemoveNeedlessEntries(RunspaceConfigurationCategory.Formats, entryIndicesToRemove);
            }
            this.FormatDBManager.UpdateDataBase(mshsnapins, this.AuthorizationManager, this._host, preValidated);
            FormatAndTypeDataHelper.ThrowExceptionOnError("ErrorsUpdatingFormats", independentErrors, mshsnapins, RunspaceConfigurationCategory.Formats);
        }
        internal static Collection <PSSnapInTypeAndFormatErrors> GetFormatAndTypesErrors(
            RunspaceConfiguration runspaceConfiguration,
            PSHost host,
            IEnumerable configurationEntryCollection,
            RunspaceConfigurationCategory category,
            Collection <string> independentErrors)
        {
            Collection <PSSnapInTypeAndFormatErrors> collection = new Collection <PSSnapInTypeAndFormatErrors>();
            string    baseFolder       = FormatAndTypeDataHelper.GetBaseFolder(runspaceConfiguration, independentErrors);
            Hashtable fullFileNameHash = new Hashtable((IEqualityComparer)StringComparer.OrdinalIgnoreCase);

            foreach (object configurationEntry1 in configurationEntryCollection)
            {
                string fileName;
                string str;
                if (category == RunspaceConfigurationCategory.Types)
                {
                    TypeConfigurationEntry configurationEntry2 = (TypeConfigurationEntry)configurationEntry1;
                    fileName = configurationEntry2.FileName;
                    str      = configurationEntry2.PSSnapIn == null ? runspaceConfiguration.ShellId : configurationEntry2.PSSnapIn.Name;
                }
                else
                {
                    FormatConfigurationEntry configurationEntry2 = (FormatConfigurationEntry)configurationEntry1;
                    fileName = configurationEntry2.FileName;
                    str      = configurationEntry2.PSSnapIn == null ? runspaceConfiguration.ShellId : configurationEntry2.PSSnapIn.Name;
                }
                string checkFullFileName1 = FormatAndTypeDataHelper.GetAndCheckFullFileName(str, fullFileNameHash, runspaceConfiguration, baseFolder, fileName, independentErrors);
                if (checkFullFileName1 != null)
                {
                    if (checkFullFileName1.EndsWith("filelist.ps1xml", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (string readFile in runspaceConfiguration.TypeTable.ReadFiles(str, checkFullFileName1, independentErrors, runspaceConfiguration.AuthorizationManager, host))
                        {
                            string checkFullFileName2 = FormatAndTypeDataHelper.GetAndCheckFullFileName(str, fullFileNameHash, runspaceConfiguration, baseFolder, readFile, independentErrors);
                            if (checkFullFileName2 != null)
                            {
                                collection.Add(new PSSnapInTypeAndFormatErrors(str, checkFullFileName2));
                            }
                        }
                    }
                    else
                    {
                        collection.Add(new PSSnapInTypeAndFormatErrors(str, checkFullFileName1));
                    }
                }
            }
            return(collection);
        }