private static void LoadFeature( ContentFeatureConfiguration contentFeatureConfig, XmlNode node ) { ContentFeature.LoadFeature(contentFeatureConfig, node); }
public static ContentFeatureConfiguration GetConfig(string applicationFolderName) { ContentFeatureConfiguration contentFeatureConfig = null; //if ( // (HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName] != null) // && (HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName] is ContentFeatureConfiguration) //) //{ // return (ContentFeatureConfiguration)HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName]; //} //else //{ contentFeatureConfig = new ContentFeatureConfiguration(); String configFolderName = "~/Setup/applications/" + applicationFolderName + "/FeatureDefinitions/"; string pathToConfigFolder = HttpContext.Current.Server.MapPath(configFolderName); if (!Directory.Exists(pathToConfigFolder)) return contentFeatureConfig; DirectoryInfo directoryInfo = new DirectoryInfo(pathToConfigFolder); FileInfo[] featureFiles = directoryInfo.GetFiles("*.config"); foreach (FileInfo fileInfo in featureFiles) { XmlDocument featureConfigFile = new XmlDocument(); featureConfigFile.Load(fileInfo.FullName); LoadFeature( contentFeatureConfig, featureConfigFile.DocumentElement); } // cache can be cleared by touching Web.config //CacheDependency cacheDependency // = new CacheDependency(HttpContext.Current.Server.MapPath("~/Web.config")); //HttpRuntime.Cache.Insert( // "contentFeatureConfig-" + applicationFolderName, // contentFeatureConfig, // cacheDependency, // DateTime.Now.AddYears(1), // TimeSpan.Zero, // CacheItemPriority.Default, // null); //return (ContentFeatureConfiguration)HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName]; return contentFeatureConfig; //} }
public static void LoadFeature( ContentFeatureConfiguration contentFeatureConfig, XmlNode documentElement) { if (HttpContext.Current == null) { return; } if (documentElement.Name != "featureDefinitions") { return; } foreach (XmlNode node in documentElement.ChildNodes) { if (node.Name == "featureDefinition") { ContentFeature feature = new ContentFeature(); XmlAttributeCollection attributeCollection = node.Attributes; if (attributeCollection["featureGuid"] != null) { feature.featureGuid = new Guid(attributeCollection["featureGuid"].Value); } if (attributeCollection["supportedDatabases"] != null) { feature.supportedDatabases = attributeCollection["supportedDatabases"].Value; } if (attributeCollection["resourceFile"] != null) { feature.resourceFile = attributeCollection["resourceFile"].Value; } if (attributeCollection["excludeFromFeatureList"] != null) { try { feature.excludeFromFeatureList = Convert.ToBoolean(attributeCollection["excludeFromFeatureList"].Value); } catch { } } if (attributeCollection["featureNameReasourceKey"] != null) { feature.featureNameReasourceKey = attributeCollection["featureNameReasourceKey"].Value; } if (attributeCollection["isSearchable"] != null) { try { feature.isSearchable = Convert.ToBoolean(attributeCollection["isSearchable"].Value); } catch { } } if (attributeCollection["supportsPageReuse"] != null) { try { feature.supportsPageReuse = Convert.ToBoolean(attributeCollection["supportsPageReuse"].Value); } catch { } } if (attributeCollection["isCacheable"] != null) { try { feature.isCacheable = Convert.ToBoolean(attributeCollection["isCacheable"].Value); } catch { } } if (attributeCollection["deleteProvider"] != null) { feature.deleteProvider = attributeCollection["deleteProvider"].Value; } if (attributeCollection["partialView"] != null) { feature.partialView = attributeCollection["partialView"].Value; } if (attributeCollection["searchListNameResourceKey"] != null) { feature.searchListNameResourceKey = attributeCollection["searchListNameResourceKey"].Value; } if (attributeCollection["controlSource"] != null) { feature.controlSource = attributeCollection["controlSource"].Value; } if (!feature.controlSource.EndsWith(".ascx")) { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid ControlSource Setting"); return; } if (attributeCollection["icon"] != null) { feature.icon = attributeCollection["icon"].Value; } if (attributeCollection["sortOrder"] != null) { int sort = 300; if (int.TryParse(attributeCollection["sortOrder"].Value, out sort)) { feature.sortOrder = sort; } } if (attributeCollection["defaultCacheTime"] != null) { int cacheTime = 300; if (int.TryParse(attributeCollection["defaultCacheTime"].Value, out cacheTime)) { feature.defaultCacheTime = cacheTime; } } foreach (XmlNode featureSettingNode in node.ChildNodes) { if (featureSettingNode.Name == "featureSetting") { ContentFeatureSetting.LoadFeatureSetting( feature, featureSettingNode); } } if (feature.FeatureGuid == Guid.Empty) { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid FeatureGuid."); return; } string controlPath = feature.controlSource; if (!controlPath.StartsWith("/")) { controlPath = "~/" + controlPath; } else { controlPath = "~" + controlPath; } if (File.Exists(HttpContext.Current.Server.MapPath(controlPath))) { contentFeatureConfig.ContentFeatures.Add(feature); } else { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid ControlSource Setting. Filenot found: " + controlPath); } } } }
public static ContentFeatureConfiguration GetConfig(string applicationFolderName) { ContentFeatureConfiguration contentFeatureConfig = null; //if ( // (HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName] != null) // && (HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName] is ContentFeatureConfiguration) //) //{ // return (ContentFeatureConfiguration)HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName]; //} //else //{ contentFeatureConfig = new ContentFeatureConfiguration(); String configFolderName = "~/Setup/applications/" + applicationFolderName + "/FeatureDefinitions/"; string pathToConfigFolder = HttpContext.Current.Server.MapPath(configFolderName); if (!Directory.Exists(pathToConfigFolder)) { return(contentFeatureConfig); } DirectoryInfo directoryInfo = new DirectoryInfo(pathToConfigFolder); FileInfo[] featureFiles = directoryInfo.GetFiles("*.config"); foreach (FileInfo fileInfo in featureFiles) { XmlDocument featureConfigFile = new XmlDocument(); featureConfigFile.Load(fileInfo.FullName); LoadFeature( contentFeatureConfig, featureConfigFile.DocumentElement); } // cache can be cleared by touching Web.config //CacheDependency cacheDependency // = new CacheDependency(HttpContext.Current.Server.MapPath("~/Web.config")); //HttpRuntime.Cache.Insert( // "contentFeatureConfig-" + applicationFolderName, // contentFeatureConfig, // cacheDependency, // DateTime.Now.AddYears(1), // TimeSpan.Zero, // CacheItemPriority.Default, // null); //return (ContentFeatureConfiguration)HttpRuntime.Cache["contentFeatureConfig-" + applicationFolderName]; return(contentFeatureConfig); //} }
public static void LoadFeature( ContentFeatureConfiguration contentFeatureConfig, XmlNode documentElement) { if (HttpContext.Current == null) return; if (documentElement.Name != "featureDefinitions") return; foreach (XmlNode node in documentElement.ChildNodes) { if (node.Name == "featureDefinition") { ContentFeature feature = new ContentFeature(); XmlAttributeCollection attributeCollection = node.Attributes; if (attributeCollection["featureGuid"] != null) { feature.featureGuid = new Guid(attributeCollection["featureGuid"].Value); } if (attributeCollection["supportedDatabases"] != null) { feature.supportedDatabases = attributeCollection["supportedDatabases"].Value; } if (attributeCollection["resourceFile"] != null) { feature.resourceFile = attributeCollection["resourceFile"].Value; } if (attributeCollection["excludeFromFeatureList"] != null) { try { feature.excludeFromFeatureList = Convert.ToBoolean(attributeCollection["excludeFromFeatureList"].Value); } catch { } } if (attributeCollection["featureNameReasourceKey"] != null) { feature.featureNameReasourceKey = attributeCollection["featureNameReasourceKey"].Value; } if (attributeCollection["isSearchable"] != null) { try { feature.isSearchable = Convert.ToBoolean(attributeCollection["isSearchable"].Value); } catch { } } if (attributeCollection["supportsPageReuse"] != null) { try { feature.supportsPageReuse = Convert.ToBoolean(attributeCollection["supportsPageReuse"].Value); } catch { } } if (attributeCollection["isCacheable"] != null) { try { feature.isCacheable = Convert.ToBoolean(attributeCollection["isCacheable"].Value); } catch { } } if (attributeCollection["deleteProvider"] != null) { feature.deleteProvider = attributeCollection["deleteProvider"].Value; } if (attributeCollection["partialView"] != null) { feature.partialView = attributeCollection["partialView"].Value; } if (attributeCollection["searchListNameResourceKey"] != null) { feature.searchListNameResourceKey = attributeCollection["searchListNameResourceKey"].Value; } if (attributeCollection["controlSource"] != null) { feature.controlSource = attributeCollection["controlSource"].Value; } if (!feature.controlSource.EndsWith(".ascx")) { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid ControlSource Setting"); return; } if (attributeCollection["icon"] != null) { feature.icon = attributeCollection["icon"].Value; } if (attributeCollection["sortOrder"] != null) { int sort = 300; if (int.TryParse(attributeCollection["sortOrder"].Value, out sort)) { feature.sortOrder = sort; } } if (attributeCollection["defaultCacheTime"] != null) { int cacheTime = 300; if (int.TryParse(attributeCollection["defaultCacheTime"].Value, out cacheTime)) { feature.defaultCacheTime = cacheTime; } } foreach (XmlNode featureSettingNode in node.ChildNodes) { if (featureSettingNode.Name == "featureSetting") { ContentFeatureSetting.LoadFeatureSetting( feature, featureSettingNode); } } if (feature.FeatureGuid == Guid.Empty) { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid FeatureGuid."); return; } string controlPath = feature.controlSource; if (!controlPath.StartsWith("/")) { controlPath = "~/" + controlPath; } else { controlPath = "~" + controlPath; } if (File.Exists(HttpContext.Current.Server.MapPath(controlPath))) { contentFeatureConfig.ContentFeatures.Add(feature); } else { log.Error("could not install feature " + feature.FeatureNameReasourceKey + ". Invalid ControlSource Setting. Filenot found: " + controlPath); } } } }