Ejemplo n.º 1
0
        public void CompileJavaScriptFileTest()
        {
            var assembly = typeof(SchoolViewModel).Assembly;

            using (var kernel = new ConversionKernel(assembly).LoadXmlDocumentation())
            {
                foreach (var model in kernel.Models)
                {
                    var converter = kernel.CreateConverterForJavaScript(JavaScriptVersion.V5, Wrap.SIAF);
                    var converted = converter.Convert(x => x.Type == model.Type);
                    var fileName  = model.Name + ".model";

                    converter.WriteToFile(converted, FilePath, fileName);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Compile a model for JavaScript.
        /// </summary>
        protected static void CompileJavaScript(ConversionKernel kernel,
                                                JavaScriptVersion version,
                                                Func <ClassDescriptor, bool> predicate = null,
                                                string fileName = "ecmascript",
                                                bool minify     = false,
                                                Wrap wrap       = Wrap.None)
        {
            var converter = kernel.CreateConverterForJavaScript(version, wrap);
            var converted = converter.Convert(predicate);

            fileName += $".{version.ToString().ToLowerInvariant()}";

            if (wrap != Wrap.None)
            {
                fileName += "." + wrap;
            }

            if (minify)
            {
                fileName += ".min";
            }

            converter.WriteToFile(converted, FilePath, fileName, minify);
        }