Esempio n. 1
0
        /// <summary>
        /// Gets the group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <returns>The shared asset builder.</returns>
        public virtual SharedGroupBuilder GetGroup(string name, Action <WebAssetItemGroupBuilder> configureAction)
        {
            WebAssetItemGroup group;

            if (!_assets.TryGetValue(name, out group))
            {
                throw new ArgumentException("Group with specified name does not exist please make sure you have specified a correct name", "name");
            }

            WebAssetItemGroupBuilder builder = new WebAssetItemGroupBuilder(group);

            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 WebAssetItemCollectionBuilder GetGroup(string name, Action <WebAssetItemGroupBuilder> configureAction)
        {
            WebAssetItemGroup itemGroup = _assets.FindGroupByName(name);

            if (itemGroup == null)
            {
                throw new ArgumentException("Group with specified name does not exist please make sure you have specified a correct name", "name");
            }

            if (itemGroup.IsShared)
            {
                throw new InvalidOperationException("You cannot configure a shared web asset group");
            }

            WebAssetItemGroupBuilder builder = new WebAssetItemGroupBuilder(itemGroup);

            configureAction(builder);
            return(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <returns>The shared asset builder.</returns>
        public virtual SharedGroupBuilder AddGroup(string name, Action <WebAssetItemGroupBuilder> configureAction)
        {
            WebAssetItemGroup group;

            if (_assets.TryGetValue(name, out group))
            {
                throw new ArgumentException("Group with specified name already exists please specify a different name", "name");
            }

            group = new WebAssetItemGroup(name, true)
            {
                DefaultPath = _defaultPath
            };
            _assets.Add(name, group);

            WebAssetItemGroupBuilder builder = new WebAssetItemGroupBuilder(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.NequeoUI().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddGroup("Group1", group =>
        ///                 {
        ///                     group.Add("script1.js");
        ///                 }
        ///            ))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetItemCollectionBuilder AddGroup(string name, Action <WebAssetItemGroupBuilder> configureAction)
        {
            WebAssetItemGroup itemGroup = _assets.FindGroupByName(name);

            if (itemGroup != null)
            {
                throw new ArgumentException("Group with specified name already exists please specify a different name", "name");
            }

            itemGroup = new WebAssetItemGroup(name)
            {
                DefaultPath = _assets.DefaultPath
            };
            _assets.Add(itemGroup);

            WebAssetItemGroupBuilder builder = new WebAssetItemGroupBuilder(itemGroup);

            configureAction(builder);

            return(this);
        }