Пример #1
0
        /// <summary>
        /// Configures the <see cref="ScriptRegistrar.DefaultGroup"/>.
        /// </summary>
        /// <param name="configureAction">The configure action.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.Telerik().ScriptRegistrar()
        ///            .DefaultGroup(group => group
        ///                 .Add("script1.js")
        ///                 .Add("script2.js")
        ///                 .Combined(true)
        ///            )
        /// %&gt;
        /// </code>
        /// </example>
        public virtual ScriptRegistrarBuilder DefaultGroup(Action <WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(scriptRegistrar.DefaultGroup);

            configureAction(builder);

            return(this);
        }
        /// <summary>
        /// Adds the group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <returns></returns>
        public virtual SharedWebAssetGroupBuilder AddGroup(string name, Action<WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup group;

            if (assets.TryGetValue(name, out group))
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameAlreadyExistsPleaseSpecifyADifferentName.FormatWith(name));
            }

            group = new WebAssetGroup(name, true) { DefaultPath = defaultPath };
            assets.Add(name, group);

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(group);
            configureAction(builder);

            return this;
        }
Пример #3
0
        /// <summary>
        /// Executes the provided delegate that is used to configure the group fluently.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        public virtual WebAssetCollectionBuilder GetGroup(string name, Action <WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup itemGroup = assets.FindGroupByName(name);

            if (itemGroup == null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameDoesNotExistPleaseMakeSureYouHaveSpecifiedACorrectName.FormatWith(name));
            }

            if (itemGroup.IsShared)
            {
                throw new InvalidOperationException(TextResource.YouCannotConfigureASharedWebAssetGroup);
            }

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(itemGroup);

            configureAction(builder);

            return(this);
        }
Пример #4
0
        /// <summary>
        /// Adds a new web asset group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.Telerik().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddGroup("Group1", group =>
        ///                 {
        ///                     group.Add("script1.js");
        ///                 }
        ///            ))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetCollectionBuilder AddGroup(string name, Action <WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup itemGroup = assets.FindGroupByName(name);

            if (itemGroup != null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameAlreadyExistsPleaseSpecifyADifferentName.FormatWith(name));
            }

            itemGroup = new WebAssetGroup(name, false)
            {
                DefaultPath = assets.DefaultPath
            };
            assets.Add(itemGroup);

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(itemGroup);

            configureAction(builder);

            return(this);
        }
 public WebAssetGroupBuilderTests()
 {
     group = new WebAssetGroup("foo", false) { DefaultPath = WebAssetDefaultSettings.ScriptFilesPath };
     builder = new WebAssetGroupBuilder(group);
 }
        /// <summary>
        /// Gets the group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <returns></returns>
        public virtual SharedWebAssetGroupBuilder GetGroup(string name, Action<WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup group;

            if (!assets.TryGetValue(name, out group))
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameDoesNotExistPleaseMakeSureYouHaveSpecifiedACorrectName.FormatWith(name));
            }

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(group);

            configureAction(builder);

            return this;
        }
        /// <summary>
        /// Adds a new web asset group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.Telerik().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddGroup("Group1", group => 
        ///                 {
        ///                     group.Add("script1.js");
        ///                 }
        ///            ))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetCollectionBuilder AddGroup(string name, Action<WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup itemGroup = assets.FindGroupByName(name);

            if (itemGroup != null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameAlreadyExistsPleaseSpecifyADifferentName.FormatWith(name));
            }

            itemGroup = new WebAssetGroup(name, false) { DefaultPath = assets.DefaultPath };
            assets.Add(itemGroup);

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(itemGroup);
            configureAction(builder);

            return this;
        }
        /// <summary>
        /// Executes the provided delegate that is used to configure the group fluently.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        public virtual WebAssetCollectionBuilder GetGroup(string name, Action<WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup itemGroup = assets.FindGroupByName(name);

            if (itemGroup == null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameDoesNotExistPleaseMakeSureYouHaveSpecifiedACorrectName.FormatWith(name));
            }

            if (itemGroup.IsShared)
            {
                throw new InvalidOperationException(TextResource.YouCannotConfigureASharedWebAssetGroup);
            }

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(itemGroup);

            configureAction(builder);

            return this;
        }