예제 #1
0
 internal Resource(ResourceSet parent, XElement xe)
 {
     ParentSet     = parent;
     Path          = xe.Attr <string>(SchemaConstants.Resource.Path);
     Mode          = xe.Attr(SchemaConstants.Resource.Mode, Default.Resource.Mode);
     ForwardCookie = xe.Attr(SchemaConstants.Resource.ForwardCookie,
                             Default.Resource.ForwardCookie);
     Minifier = ParentSet.Type == ResourceType.JS
         ? ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.JSMinifierMap)
         : ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.CssMinifierMap);
     if (Mode == ResourceMode.Static && ForwardCookie)
     {
         throw new XmlSchemaException("ForwardCookie must not be True when Mode is Static");
     }
 }
예제 #2
0
        internal Resource(ResourceSet parent, XElement xe)
        {
            ParentSet = parent;
            Path      = xe.Attr <string>(SchemaConstants.Resource.Path);
            if (Path.Contains("${"))
            {
                Path.Split('$').ToList().ForEach(p =>
                {
                    if (p.Contains('{'))
                    {
                        string resourceSetting = p.Split(new char[] { '{', '}' })[1];
                        String resourceContent = ConfigurationManager.AppSettings[resourceSetting];
                        if (String.IsNullOrEmpty(resourceContent))
                        {
                            resourceContent = "empty";
                        }
                        Path = Path.Replace("${" + resourceSetting + "}", resourceContent);
                    }
                });
            }
            Mode = xe.Attr(SchemaConstants.Resource.Mode, Default.Resource.Mode);
            if (Mode == ResourceMode.Auto)
            {
                Mode = Path.StartsWith("http") ? ResourceMode.Dynamic : ResourceMode.Static;
            }

            ForwardCookie = xe.Attr(SchemaConstants.Resource.ForwardCookie,
                                    Default.Resource.ForwardCookie);
            Minifier = ParentSet.Type == ResourceType.JS
                ? ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.JSMinifierMap)
                : ModelUtils.LoadMinifier(xe, SchemaConstants.Resource.MinifierRef, ParentSet.Minifier.Name, ParentSet.Settings.CssMinifierMap);
            if (Mode == ResourceMode.Static && ForwardCookie)
            {
                throw new XmlSchemaException("ForwardCookie must not be True when Mode is Static");
            }
        }
예제 #3
0
 private void InitializeMinifier(XElement xe)
 {
     Minifier = Type == ResourceType.JS
                    ? ModelUtils.LoadMinifier(xe, SchemaConstants.Set.MinifierRef, Settings.DefaultJSMinifierRef, Settings.JSMinifierMap)
                    : ModelUtils.LoadMinifier(xe, SchemaConstants.Set.MinifierRef, Settings.DefaultCssMinifierRef, Settings.CssMinifierMap);
 }