Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JsIncludeDescriptor" /> class.
        /// </summary>
        /// <param name="module">The container module.</param>
        /// <param name="name">The module name.</param>
        /// <param name="fileName">Name of the module file.</param>
        /// <param name="minFileName">Name of the minified file.</param>
        /// <param name="isAutoGenerated">if set to <c>true</c> then it indicates that this JS include file is auto generated and is not going to be minimized or loaded from CDN.</param>
        public JsIncludeDescriptor(ModuleDescriptor module, string name, string fileName = null, string minFileName = null, 
            bool isAutoGenerated = false, bool isExternal = false, JsShimConfigDescriptor shimConfig = null)
        {
            Links = new List<IActionProjection>();
            Globalization = new List<IActionProjection>();

            Module = module;
            Name = name;
            IsAutoGenerated = isAutoGenerated;
            ShimConfiguration = shimConfig;

            if (isExternal)
            {
                if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(minFileName))
                {
                    throw new CmsException("Paths for the external JS file and minified JS file can not by empty");
                }

                FileName = System.IO.Path.GetFileName(fileName);
                Path = fileName;
                MinPath = minFileName;
            }
            else
            {
                FileName = fileName ?? name + ".js";
                Path = VirtualPath.Combine(module.JsBasePath, fileName ?? name + ".js");

                // If minFileName is not given then CMS will try to load it from a bcms.[module-name].min.js file.
                if (!string.IsNullOrEmpty(minFileName))
                {
                    MinPath = VirtualPath.Combine(module.JsBasePath, minFileName);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JsIncludeDescriptor" /> class.
        /// </summary>
        /// <param name="module">The container module.</param>
        /// <param name="name">The module name.</param>
        /// <param name="fileName">Name of the module file.</param>
        /// <param name="minFileName">Name of the minified file.</param>
        /// <param name="isAutoGenerated">if set to <c>true</c> then it indicates that this JS include file is auto generated and is not going to be minimized or loaded from CDN.</param>
        public JsIncludeDescriptor(ModuleDescriptor module, string name, string fileName = null, string minFileName = null,
                                   bool isAutoGenerated = false, bool isExternal = false, JsShimConfigDescriptor shimConfig = null)
        {
            Links         = new List <IActionProjection>();
            Globalization = new List <IActionProjection>();

            Module            = module;
            Name              = name;
            IsAutoGenerated   = isAutoGenerated;
            ShimConfiguration = shimConfig;

            if (isExternal)
            {
                if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(minFileName))
                {
                    throw new CmsException("Paths for the external JS file and minified JS file can not by empty");
                }

                FileName = System.IO.Path.GetFileName(fileName);
                Path     = fileName;
                MinPath  = minFileName;
            }
            else
            {
                FileName = fileName ?? name + ".js";
                Path     = VirtualPath.Combine(module.JsBasePath, fileName ?? name + ".js");

                // If minFileName is not given then CMS will try to load it from a bcms.[module-name].min.js file.
                if (!string.IsNullOrEmpty(minFileName))
                {
                    MinPath = VirtualPath.Combine(module.JsBasePath, minFileName);
                }
            }
        }