private static int CompareControlPanelItems(ControlPanelItem x, ControlPanelItem y) { if (x.CanonicalName != null || y.CanonicalName != null) { if (x.CanonicalName != null) { if (y.CanonicalName != null) { return(string.Compare(x.CanonicalName, y.CanonicalName, StringComparison.OrdinalIgnoreCase)); } else { return(-1); } } else { return(1); } } else { return(0); } }
private static int CompareControlPanelItems(ControlPanelItem x, ControlPanelItem y) { if (x.CanonicalName != null || y.CanonicalName != null) { if (x.CanonicalName != null) { if (y.CanonicalName != null) { return string.Compare(x.CanonicalName, y.CanonicalName, StringComparison.OrdinalIgnoreCase); } else { return -1; } } else { return 1; } } else { return 0; } }
protected override void ProcessRecord() { string str; base.GetCategoryMap(); List <ShellFolderItem> controlPanelItemByCategory = base.GetControlPanelItemByCategory(base.AllControlPanelItems); if (!this._nameSpecified) { if (this._canonicalNameSpecified) { controlPanelItemByCategory = base.GetControlPanelItemByCanonicalName(controlPanelItemByCategory, this._categorySpecified); } } else { controlPanelItemByCategory = base.GetControlPanelItemByName(controlPanelItemByCategory, this._categorySpecified); } List <ControlPanelItem> controlPanelItems = new List <ControlPanelItem>(); foreach (ShellFolderItem variable in controlPanelItemByCategory) { string name = variable.Name; string path = variable.Path; string str1 = (string)((dynamic)variable.ExtendedProperty("InfoTip")); string str2 = (string)((dynamic)variable.ExtendedProperty("System.ApplicationName")); if (str2 != null) { str = str2.Substring(0, str2.IndexOf("\0", StringComparison.OrdinalIgnoreCase)); } else { str = null; } str2 = str; int[] numArray = (int[])((dynamic)variable.ExtendedProperty("System.ControlPanel.Category")); string[] item = new string[(int)numArray.Length]; for (int i = 0; i < (int)numArray.Length; i++) { string str3 = (string)LanguagePrimitives.ConvertTo(numArray[i], typeof(string), CultureInfo.InvariantCulture); item[i] = this.CategoryMap[str3]; } ControlPanelItem controlPanelItem = new ControlPanelItem(name, str2, item, str1, path); controlPanelItems.Add(controlPanelItem); } controlPanelItems.Sort(new Comparison <ControlPanelItem>(GetControlPanelItemCommand.CompareControlPanelItems)); foreach (ControlPanelItem controlPanelItem1 in controlPanelItems) { base.WriteObject(controlPanelItem1); } }
/// <summary> /// </summary> protected override void ProcessRecord() { GetCategoryMap(); List <ShellFolderItem> items = GetControlPanelItemByCategory(AllControlPanelItems); if (_nameSpecified) { items = GetControlPanelItemByName(items, _categorySpecified); } else if (_canonicalNameSpecified) { items = GetControlPanelItemByCanonicalName(items, _categorySpecified); } List <ControlPanelItem> results = new List <ControlPanelItem>(); foreach (ShellFolderItem item in items) { string name = item.Name; string path = item.Path; string description = (string)item.ExtendedProperty("InfoTip"); string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); canonicalName = canonicalName != null ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) : null; int[] categories = (int[])item.ExtendedProperty("System.ControlPanel.Category"); string[] cateStrings = new string[categories.Length]; for (int i = 0; i < categories.Length; i++) { string catStr = (string)LanguagePrimitives.ConvertTo(categories[i], typeof(string), CultureInfo.InvariantCulture); Dbg.Assert(CategoryMap.ContainsKey(catStr), "the category should be contained in CategoryMap"); cateStrings[i] = CategoryMap[catStr]; } ControlPanelItem controlPanelItem = new ControlPanelItem(name, canonicalName, cateStrings, description, path); results.Add(controlPanelItem); } // Sort the results by Canonical Name results.Sort(CompareControlPanelItems); foreach (ControlPanelItem controlPanelItem in results) { WriteObject(controlPanelItem); } }
private static int CompareControlPanelItems(ControlPanelItem x, ControlPanelItem y) { // In the case that at least one of them is null if (x.CanonicalName == null && y.CanonicalName == null) { return(0); } if (x.CanonicalName == null) { return(1); } if (y.CanonicalName == null) { return(-1); } // In the case that both are not null return(string.Compare(x.CanonicalName, y.CanonicalName, StringComparison.OrdinalIgnoreCase)); }
internal List <ShellFolderItem> GetControlPanelItemsByInstance(List <ShellFolderItem> controlPanelItems) { bool flag = false; List <ShellFolderItem> collection = new List <ShellFolderItem>(); HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); ControlPanelItem[] controlPanelItemArray = this.ControlPanelItems; for (int i = 0; i < (int)controlPanelItemArray.Length; i++) { ControlPanelItem controlPanelItem = controlPanelItemArray[i]; foreach (ShellFolderItem variable in controlPanelItems) { string path = variable.Path; if (!controlPanelItem.Path.Equals(path, StringComparison.OrdinalIgnoreCase)) { continue; } if (!strs.Contains(path)) { flag = true; strs.Add(path); collection.Add(variable); break; } else { flag = true; break; } } if (!flag) { string str = StringUtil.Format(ControlPanelResources.NoControlPanelItemFoundForGivenInstance, controlPanelItem.GetType().Name); ErrorRecord errorRecord = new ErrorRecord(new InvalidOperationException(str), "NoControlPanelItemFoundForGivenInstance", ErrorCategory.InvalidArgument, controlPanelItem); base.WriteError(errorRecord); } } return(collection); }
private static int CompareControlPanelItems(ControlPanelItem x, ControlPanelItem y) { // In the case that at least one of them is null if (x.CanonicalName == null && y.CanonicalName == null) return 0; if (x.CanonicalName == null) return 1; if (y.CanonicalName == null) return -1; // In the case that both are not null return string.Compare(x.CanonicalName, y.CanonicalName, StringComparison.OrdinalIgnoreCase); }
/// <summary> /// /// </summary> protected override void ProcessRecord() { GetCategoryMap(); List<ShellFolderItem> items = GetControlPanelItemByCategory(AllControlPanelItems); if (_nameSpecified) { items = GetControlPanelItemByName(items, _categorySpecified); } else if (_canonicalNameSpecified) { items = GetControlPanelItemByCanonicalName(items, _categorySpecified); } List<ControlPanelItem> results = new List<ControlPanelItem>(); foreach (ShellFolderItem item in items) { string name = item.Name; string path = item.Path; string description = (string)item.ExtendedProperty("InfoTip"); string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); canonicalName = canonicalName != null ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) : null; int[] categories = (int[])item.ExtendedProperty("System.ControlPanel.Category"); string[] cateStrings = new string[categories.Length]; for (int i = 0; i < categories.Length; i++) { string catStr = (string)LanguagePrimitives.ConvertTo(categories[i], typeof(string), CultureInfo.InvariantCulture); Dbg.Assert(CategoryMap.ContainsKey(catStr), "the category should be contained in CategoryMap"); cateStrings[i] = CategoryMap[catStr]; } ControlPanelItem controlPanelItem = new ControlPanelItem(name, canonicalName, cateStrings, description, path); results.Add(controlPanelItem); } // Sort the results by Canonical Name results.Sort(CompareControlPanelItems); foreach (ControlPanelItem controlPanelItem in results) { WriteObject(controlPanelItem); } }
protected override void ProcessRecord() { string str; base.GetCategoryMap(); List<ShellFolderItem> controlPanelItemByCategory = base.GetControlPanelItemByCategory(base.AllControlPanelItems); if (!this._nameSpecified) { if (this._canonicalNameSpecified) { controlPanelItemByCategory = base.GetControlPanelItemByCanonicalName(controlPanelItemByCategory, this._categorySpecified); } } else { controlPanelItemByCategory = base.GetControlPanelItemByName(controlPanelItemByCategory, this._categorySpecified); } List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>(); foreach (ShellFolderItem variable in controlPanelItemByCategory) { string name = variable.Name; string path = variable.Path; string str1 = (string)((dynamic)variable.ExtendedProperty("InfoTip")); string str2 = (string)((dynamic)variable.ExtendedProperty("System.ApplicationName")); if (str2 != null) { str = str2.Substring(0, str2.IndexOf("\0", StringComparison.OrdinalIgnoreCase)); } else { str = null; } str2 = str; int[] numArray = (int[])((dynamic)variable.ExtendedProperty("System.ControlPanel.Category")); string[] item = new string[(int)numArray.Length]; for (int i = 0; i < (int)numArray.Length; i++) { string str3 = (string)LanguagePrimitives.ConvertTo(numArray[i], typeof(string), CultureInfo.InvariantCulture); item[i] = this.CategoryMap[str3]; } ControlPanelItem controlPanelItem = new ControlPanelItem(name, str2, item, str1, path); controlPanelItems.Add(controlPanelItem); } controlPanelItems.Sort(new Comparison<ControlPanelItem>(GetControlPanelItemCommand.CompareControlPanelItems)); foreach (ControlPanelItem controlPanelItem1 in controlPanelItems) { base.WriteObject(controlPanelItem1); } }