/// <summary> /// Gets the property bags 'ApplicationSettings' and 'BuiltinSettings' along with the bag information. /// </summary> /// <returns>Property bags 'ApplicationSettings' and 'BuiltinSettings' along with the bag information.</returns> public static IEnumerable <PropertyBagWithInformation> GetPropertyBagsStartingFromApplicationSettings() { // then the application settings { var bagInfo = new PropertyBagInformation("ApplicationSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.ApplicationSettings)); } // and finally the built-in settings { var bagInfo = new PropertyBagInformation("BuiltinSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.BuiltinSettings)); } }
/// <summary> /// Gets the property bags in the hierarchy. The first bag in the enumeration is the bag that owns the <paramref name="owner"/>. Then the bags of the folders /// in which the owner is located, its parent folders, and then UserSettings, ApplicationSettings, and BuiltinSettings follow. /// </summary> /// <param name="owner">The owner of a property bag with which to start the enumeration.</param> /// <returns>Enumeration of the property bags in the project hierarchy.</returns> public static IEnumerable <PropertyBagWithInformation> GetPropertyBags(this IPropertyBagOwner owner) { if (null != owner && !(owner is ProjectFolderPropertyDocument)) // Project folder bags are handled further down { var bagInfo = new PropertyBagInformation(owner.GetType().Name, PropertyLevel.Document, owner.GetType()); yield return(new PropertyBagWithInformation(bagInfo, owner.PropertyBagNotNull)); } var namedOwner = owner as Main.INameOwner; var proj = Current.Project; ProjectFolderPropertyDocument bag; if (null != namedOwner && !string.IsNullOrEmpty(namedOwner.Name)) { var folder = Main.ProjectFolder.GetFolderPart(namedOwner.Name); while (!string.IsNullOrEmpty(folder)) { if (proj.ProjectFolderProperties.TryGetValue(folder, out bag) && bag.PropertyBag != null) { var bagInfo = new PropertyBagInformation(string.Format("Folder \"{0}\"", folder), PropertyLevel.ProjectFolder); yield return(new PropertyBagWithInformation(bagInfo, bag.PropertyBag)); } folder = Main.ProjectFolder.GetFoldersParentFolder(folder); } } // now return the project's property bag even for unnamed items if (proj.ProjectFolderProperties.TryGetValue(string.Empty, out bag) && bag.PropertyBag != null) { var bagInfo = new PropertyBagInformation("Project (RootFolder)", PropertyLevel.Project); yield return(new PropertyBagWithInformation(bagInfo, bag.PropertyBag)); } // and now the user's settings { var bagInfo = new PropertyBagInformation("UserSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.UserSettings)); } // then the application settings { var bagInfo = new PropertyBagInformation("ApplicationSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.ApplicationSettings)); } // and finally the built-in settings { var bagInfo = new PropertyBagInformation("BuiltinSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.BuiltinSettings)); } }
/// <summary> /// Gets the property bags in the hierarchy. The first bag in the enumeration is the bag that is a project folder bag belonging to the provided folder name. Then the bags in its /// parent folders, and then UserSettings, ApplicationSettings, and BuiltinSettings follow. /// </summary> /// <param name="folder">A project folder to start the enumeration with.</param> /// <returns>Enumeration of the property bags in the project hierarchy.</returns> public static IEnumerable <PropertyBagWithInformation> GetPropertyBagsStartingFromFolder(string folder) { var proj = Current.Project; ProjectFolderPropertyDocument bag; while (!string.IsNullOrEmpty(folder)) { if (proj.ProjectFolderProperties.TryGetValue(folder, out bag) && bag.PropertyBag != null) { var bagInfo = new PropertyBagInformation(string.Format("Folder \"{0}\"", folder), PropertyLevel.ProjectFolder); yield return(new PropertyBagWithInformation(bagInfo, bag.PropertyBag)); } folder = Main.ProjectFolder.GetFoldersParentFolder(folder); } // now return the project's property bag even for unnamed items if (proj.ProjectFolderProperties.TryGetValue(string.Empty, out bag) && bag.PropertyBag != null) { var bagInfo = new PropertyBagInformation("Project (RootFolder)", PropertyLevel.Project); yield return(new PropertyBagWithInformation(bagInfo, bag.PropertyBag)); } // and now the user's settings { var bagInfo = new PropertyBagInformation("UserSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.UserSettings)); } // then the application settings { var bagInfo = new PropertyBagInformation("ApplicationSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.ApplicationSettings)); } // and finally the built-in settings { var bagInfo = new PropertyBagInformation("BuiltinSettings", PropertyLevel.Application); yield return(new PropertyBagWithInformation(bagInfo, Current.PropertyService.BuiltinSettings)); } }