예제 #1
0
        private static async Task Generate(string name, Type underlying, string fulleName, string ns, SvoFeatures features, string path, string formatExceptionMessage)
        {
            var arguments = new SvoArguments
            {
                Name                   = name,
                Underlying             = underlying,
                FullName               = fulleName,
                Namespace              = ns,
                Features               = features,
                FormatExceptionMessage = formatExceptionMessage ?? $"QowaivMessages.FormatException{name}"
            };

            var generator = new SvoCodeGenerator(arguments);
            var generated = await generator.GenerateAsync();

            var location = new FileInfo(path);

            if (!location.Directory.Exists)
            {
                location.Directory.Create();
            }
            using var writer = new StreamWriter(location.FullName, false, Encoding.UTF8);

            generated.WriteTo(writer);
        }
        public async Task generate_Int32_based_SVO()
        {
            var args = new SvoArguments
            {
                Name       = "Integer",
                FullName   = "Int32 wrapper",
                Underlying = typeof(int),
                Features   = SvoFeatures.Default ^ SvoFeatures.IsEmpty ^ SvoFeatures.IsUnknown,
            };
            var generator = new SvoCodeGenerator(args);

            var result = await generator.GenerateAsync();

            Console.WriteLine(result.ToFullString());
        }
        public async Task generate_initial_SVO()
        {
            var args = new SvoArguments
            {
                Name       = "Percentage",
                Namespace  = "Qowaiv",
                FullName   = "percentage",
                Underlying = typeof(decimal),
                Features   = SvoFeatures.Continuous ^ SvoFeatures.IFormattable,
            };
            var generator = new SvoCodeGenerator(args);

            var result = await generator.GenerateInitialAsync();

            Console.WriteLine(result.ToFullString());

            Console.WriteLine(new string('-', 80));

            result = await generator.GenerateUnitTestsAsync();

            Console.WriteLine(result.ToFullString());
        }