예제 #1
0
        public static string BuildRequiredJsConfig()
        {
            string stringTemplate = "'{0}'";
            string propStringTemplate = "{0}: '{1}',";
            string proPArrayTemplate = "{0}: [{1}],";
            string PAths = string.Empty, shim = string.Empty;

            StringBuilderPool.Process((sb1, sb2) =>
            {
                foreach (var module in RequiredJsModules)
                {
                    string PAth = !module.WithoutVersion ? GetVersionPAth(module.PAth) : module.PAth;
                    sb1.AppendFormat(propStringTemplate, module.Name, PAth);
                    if (module.Dependencies != null)
                    {
                        sb2.AppendFormat(
                            proPArrayTemplate,
                            module.Name,
                            String.Join(",", module.Dependencies.Select(x => string.Format(stringTemplate, x)))
                            );
                    }
                }
                PAths = sb1.ToString();
                shim  = sb2.ToString();
            });

            return(StringBuilderPool.ProcessWithResult(sb =>
            {
                sb.Append("require.config({");
                sb.Append("    baseUrl: '/Content/js',");
                sb.Append("    PAths: {");
                sb.Append(PAths);
                sb.Append("    },");
                sb.Append("    shim: {");
                sb.Append(shim);
                sb.Append("    }");
                sb.Append("});");
            }));
        }