private static Type GetBinderType(XElement child) { var binderTypeName = child.Attr <string>(SchemaConstants.Binder.Type); return(binderTypeName == null ? Default.Binder.Type : ModelUtils.LoadType("Binder", binderTypeName, SchemaConstants.Binder.ValidTypes)); }
private void LoadResourceSets(XContainer xe) { var rsXe = xe.Element(XName.Get(SchemaConstants.Setting.ResourceSets, SchemaConstants.Namespace)); Url = rsXe.Attr <string>(SchemaConstants.Setting.Url); Host = rsXe.Attr <string>(SchemaConstants.Setting.Host); SslHost = rsXe.Attr <string>(SchemaConstants.Setting.SslHost); DefaultDuration = rsXe.Attr <int?>(SchemaConstants.Setting.DefaultDuration); DefaultVersion = rsXe.Attr <string>(SchemaConstants.Setting.DefaultVersion); var generatorType = rsXe.Attr <string>(SchemaConstants.Setting.DefaultVersionGenerator); DefaultVersionGeneratorType = string.IsNullOrEmpty(generatorType) ? Default.ResourceSet.VersionGeneratorType : ModelUtils.LoadType("Generator", generatorType, SchemaConstants.VersionGenerator.ValidTypes); LocalChangeMonitorInterval = rsXe.Attr <int?>(SchemaConstants.Setting.LocalChangeMonitorInterval); RemoteChangeMonitorInterval = rsXe.Attr <int?>(SchemaConstants.Setting.RemoteChangeMonitorInterval); var debugEnabled = rsXe.Attr <string>(SchemaConstants.Setting.DefaultDebugEnabled); DefaultDebugEnabled = string.IsNullOrEmpty(debugEnabled) ? Default.ResourceSet.DebugEnabled : debugEnabled.Equals(SchemaConstants.Set.Auto, StringComparison.OrdinalIgnoreCase) ? HttpContext.Current.IsDebuggingEnabled : bool.Parse(debugEnabled); var fileErrorsEnabled = rsXe.Attr <string>(SchemaConstants.Setting.ShownotFoundFilesError); ShownotFoundFilesError = string.IsNullOrEmpty(fileErrorsEnabled) ? Default.ResourceSet.FileErrorsEnabled : fileErrorsEnabled.Equals(SchemaConstants.Set.Auto, StringComparison.OrdinalIgnoreCase) ? HttpContext.Current.IsDebuggingEnabled : bool.Parse(fileErrorsEnabled); DefaultIgnorePipelineWhenDebug = (bool)rsXe.Attr <string>(SchemaConstants.Setting.DefaultIgnorePipelineWhenDebug) .ConvertToType(typeof(bool), Default.ResourceSet.IgnorePipelineWhenDebug); DefaultCompressionEnabled = (bool)rsXe.Attr <string>(SchemaConstants.Setting.DefaultCompressionEnabled) .ConvertToType(typeof(bool), Default.ResourceSet.CompressionEnabled); DefaultJSMinifierRef = GetMinifier(rsXe, SchemaConstants.Setting.DefaultJSMinifierRef, JSMinifierMap); DefaultCssMinifierRef = GetMinifier(rsXe, SchemaConstants.Setting.DefaultCssMinifierRef, CssMinifierMap); ResourceSets = new List <ResourceSet>(); foreach (var node in rsXe.Elements()) { var rs = new ResourceSet(this, node); if (ResourceSets.Contains(rs)) { throw new XmlSchemaException("Duplicated resource set"); } ResourceSets.Add(rs); } ResourceSets = ResourceSets.ToList().AsReadOnly(); }
private void InitializeVersion(XElement xe, Settings parent) { Version = ModelUtils.GetString(xe, SchemaConstants.Set.Version, parent.DefaultVersion); var generatorType = xe.Attr <string>(SchemaConstants.Set.VersionGenerator); if (string.IsNullOrEmpty(generatorType)) { VersionGeneratorType = parent.DefaultVersionGeneratorType; } else { VersionGeneratorType = ModelUtils.LoadType("Generator", generatorType, SchemaConstants.VersionGenerator.ValidTypes); } if (IsAutoVersion) { Hash = ComputeHash(); } }
private static void LoadMinifiers(XElement xe, string elementName, IDictionary <string, MinifierInfo> map) { foreach (var childXe in xe.ChildrenOfChild(elementName, SchemaConstants.Namespace)) { var name = childXe.Attr <string>(SchemaConstants.Minifier.Name); if (map.ContainsKey(name)) { throw new XmlSchemaException(string.Format(CultureInfo.InvariantCulture, "Minifier {0} already exists", name)); } var typeName = childXe.Attr <string>(SchemaConstants.Minifier.Type); var type = ModelUtils.LoadType("Minifier", typeName, SchemaConstants.Minifier.ValidTypes); var minifier = new MinifierInfo { Name = name, Type = type, Parameters = childXe.Elements(XName.Get(SchemaConstants.Param.Root, SchemaConstants.Namespace)).ToList(), BinderType = GetBinderType(childXe), }; map.Add(name, minifier); } }
private void LoadCacheVaryProvider(XElement xe) { var providerInfoList = new List <CacheVaryProviderInfo>(); foreach (var child in xe.ChildrenOfChild(SchemaConstants.Setting.CacheVaryProviders, SchemaConstants.Namespace)) { var typeName = child.Attr <string>(SchemaConstants.CacheVaryProvider.Type); var type = ModelUtils.LoadType("CacheVaryProvider", typeName, SchemaConstants.CacheVaryProvider.ValidTypes); var acceptedResourceSets = child.Attr <string>(SchemaConstants.CacheVaryProvider.AcceptedResourceSets); var setNameList = acceptedResourceSets == null ? null : acceptedResourceSets.Trim(';', ' ').Split(';').ToList(); var provider = new CacheVaryProviderInfo { Type = type, Parameters = child.Elements(XName.Get(SchemaConstants.Param.Root, SchemaConstants.Namespace)).ToList(), BinderType = GetBinderType(child), ResourceSetNames = setNameList }; providerInfoList.Add(provider); } CacheVaryProviderInfoList = providerInfoList.AsReadOnly(); }