コード例 #1
0
        /// <summary>
        /// Adds the specified shared group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.Telerik().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddShareGroup("SharedGroup1"))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetCollectionBuilder AddSharedGroup(string name)
        {
            Guard.IsNotNullOrEmpty(name, "name");

            WebAssetGroup group = (assetType == WebAssetType.StyleSheet) ?
                                  SharedWebAssets.FindStyleSheetGroup(name) :
                                  SharedWebAssets.FindScriptGroup(name);

            if (group == null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameDoesNotExistInAssetTypeOfSharedWebAssets.FormatWith(name, assetType), "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
                WebAssetGroup localGroup = new WebAssetGroup(group.Name, true)
                {
                    DefaultPath = group.DefaultPath,
                    UseTelerikContentDeliveryNetwork = group.UseTelerikContentDeliveryNetwork,
                    ContentDeliveryNetworkUrl        = group.ContentDeliveryNetworkUrl,
                    Enabled             = group.Enabled,
                    Version             = group.Version,
                    Compress            = group.Compress,
                    CacheDurationInDays = group.CacheDurationInDays,
                    Combined            = group.Combined
                };

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

                assets.Add(localGroup);
            }

            return(this);
        }
コード例 #2
0
        public void Should_set_content_type_for_javascript_groups()
        {
            var group = SharedWebAssets.FindScriptGroup("bar");

            group.ContentType.ShouldEqual("text/javascript");
        }