예제 #1
0
        private static void Generate(string xamlFile, string outputFile, RenderMode renderMode, string desiredNamespace, string defaultAssembly)
        {
            string xaml = string.Empty;
            using (TextReader tr = File.OpenText(xamlFile))
            {
                xaml = tr.ReadToEnd();
            }

            if (!string.IsNullOrEmpty(defaultAssembly))
                xaml = Regex.Replace(xaml,
                    @"xmlns(:\w+)?=\""clr-namespace:([.\w]+)(;assembly=)?\""",
                    $@"xmlns$1=""clr-namespace:$2;assembly=" + defaultAssembly + '"');

            UserInterfaceGenerator generator = new UserInterfaceGenerator();
            string generatedCode = string.Empty;
            try
            {
                generatedCode = generator.GenerateCode(xamlFile, xaml, renderMode, desiredNamespace);
            }
            catch (Exception ex)
            {
                generatedCode = "#error " + ex.Message;
                throw;
            }
            finally
            {
                using (StreamWriter outfile = new StreamWriter(outputFile))
                {
                    outfile.Write(generatedCode);
                }
            }
            }
예제 #2
0
        private static void Generate(string xamlFile, string outputFile, RenderMode renderMode, string desiredNamespace)
        {
            string xaml = string.Empty;
            using (TextReader tr = File.OpenText(xamlFile))
            {
                xaml = tr.ReadToEnd();
            }

            UserInterfaceGenerator generator = new UserInterfaceGenerator();
            string generatedCode = generator.GenerateCode(xamlFile, xaml, renderMode, desiredNamespace);

            using (StreamWriter outfile = new StreamWriter(outputFile))
            {
                outfile.Write(generatedCode);
            }
        }
예제 #3
0
        private static void Generate(string xamlFile, string outputFile, RenderMode renderMode, string desiredNamespace)
        {
            string xaml = string.Empty;
            using (TextReader tr = File.OpenText(xamlFile))
            {
                xaml = tr.ReadToEnd();
            }            

            UserInterfaceGenerator generator = new UserInterfaceGenerator();
            string generatedCode = string.Empty;
            try
            {
                generatedCode = generator.GenerateCode(xamlFile, xaml, renderMode, desiredNamespace);
            }
            catch (Exception ex)
            {
                generatedCode = "#error " + ex.Message;
                throw;
            }
            finally
            {
                using (StreamWriter outfile = new StreamWriter(outputFile))
                {
                    outfile.Write(generatedCode);
                }
            }
        }