Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private static MergedAsset CreateMergedAssetFromConfiguration(string id)
        {
            WebAssetItemGroup assetGroup  = SharedGroup.FindScriptGroup(id);
            string            contentType = "application/x-javascript";

            if (assetGroup == null)
            {
                assetGroup  = SharedGroup.FindStyleSheetGroup(id);
                contentType = "text/css";
            }

            return((assetGroup != null) ? CreateMergedAssetWith(contentType, assetGroup) : null);
        }
        /// <summary>
        /// Adds the specified shared group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.NequeoUI().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddShareGroup("SharedGroup1"))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetItemCollectionBuilder AddSharedGroup(string name)
        {
            WebAssetItemGroup group = (_assetType == WebAssetType.StyleSheet) ?
                                      SharedGroup.FindStyleSheetGroup(name) :
                                      SharedGroup.FindScriptGroup(name);

            if (group == null)
            {
                throw new ArgumentException("GroupWithSpecifiedNameDoesNotExistInAssetTypeOfSharedWebAssets", "name");
            }

            if (_assets.FindGroupByName(name) == null)
            {
                // People might have the same group reference in multiple place.
                // So we will skip it once it is added.

                // throw new ArgumentException(TextResource.LocalGroupWithSpecifiedNameAlreadyExists.FormatWith(name));

                // Add a copy of the shared asset
                WebAssetItemGroup localGroup = new WebAssetItemGroup(group.Name, true)
                {
                    DefaultPath         = group.DefaultPath,
                    Version             = group.Version,
                    Compress            = group.Compress,
                    CacheDurationInDays = group.CacheDurationInDays,
                    Combined            = group.Combined
                };

                foreach (WebAssetItem item in group.Items)
                {
                    localGroup.Items.Add(new WebAssetItem(item.Source));
                }

                _assets.Add(localGroup);
            }

            return(this);
        }