public static IEnumerable <object[]> Get() { return(new List <object[]> { new object[] { DotNetType.Boolean(), "System.Boolean", }, new object[] { DotNetType.Byte(), "System.Byte" }, new object[] { DotNetType.ByteArray(), "System.Byte[]" }, new object[] { DotNetType.Char(), "System.Char", }, new object[] { DotNetType.DateTime(), "System.DateTime", }, new object[] { DotNetType.DateTimeOffset(), "System.DateTimeOffset", }, new object[] { DotNetType.Decimal(), "System.Decimal", }, new object[] { DotNetType.Double(), "System.Double", }, new object[] { DotNetType.Guid(), "System.Guid", }, new object[] { DotNetType.IDbConnection(), typeof(System.Data.IDbConnection).FullName, }, new object[] { DotNetType.Integer(), "System.Int32", }, new object[] { DotNetType.Long(), "System.Int64", }, new object[] { DotNetType.Short(), "System.Int16", }, new object[] { DotNetType.Single(), "System.Single", }, new object[] { DotNetType.String(), "System.String", }, new object[] { DotNetType.TimeSpan(), "System.TimeSpan", }, new object[] { DotNetType.Void(), "void", }, new object[] { DotNetType.MakeIEnumerable(DotNetType.String()), "System.Collections.Generic.IEnumerable<System.String>" }, new object[] { new DotNetType("System.Int32", true, false, null), "System.Int32[]" }, new object[] { DotNetType.MakeNullable(DotNetType.Integer()), "System.Nullable<System.Int32>" }, }); }
public static IEnumerable <object[]> GetTestCases() { Parameter[] parameters = new Parameter[] { new Parameter { Name = "a", Type = DotNetType.Integer(), }, new Parameter { Name = "b", Type = DotNetType.String(), }, }; return(new List <object[]> { new object[] { new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Body = new CodeBlock("int i = 100;"), }, NormalConstructor.RemoveCarriageReturn(), }, new object[] { new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, }, ParameterizedConstructor.RemoveCarriageReturn(), }, new object[] { new Constructor { Static = true, Name = "Test", Body = new CodeBlock("int i = 100;"), }, StaticConstructor.RemoveCarriageReturn(), }, new object[] { new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, Body = new CodeBlock("int i = 100;"), BaseConstructor = new Constructor { Name = "base", Parameters = parameters, } }, BaseConstructor.RemoveCarriageReturn(), }, new object[] { new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, Body = new CodeBlock("int i = 100;"), BaseConstructor = new Constructor { Name = "this", Parameters = parameters, } }, ChainConstructor.RemoveCarriageReturn(), }, }); }
public static IEnumerable <object[]> GetTestCases() { return(new List <object[]> { new object[] { new Field { Modifier = AccessModifier.Public, Name = "Test", Type = DotNetType.Integer(), }, NormalMethod.RemoveCarriageReturn(), }, new object[] { new Field { Modifier = AccessModifier.Public, Name = "a", Static = true, Type = DotNetType.String(), }, StaticMethod.RemoveCarriageReturn(), }, }); }
public Class Convert(Type type) { Class converted = new Class() { Partial = true, Imports = new string[] { "System", "System.Net.Http", "System.Threading.Tasks", "Microsoft.Extensions.Logging", "Albatross.WebClient", "System.Collections.Generic" }, AccessModifier = AccessModifier.Public, Namespace = GetNamespace(type), Name = GetClassName(type), BaseClass = GetBaseClass(), Fields = new Field[] { new Field { Name = ControllerPath, Type = DotNetType.String(), Const = true, Value = new StringWriter().Literal(GetControllerRoute(type)).ToString(), Modifier = AccessModifier.Public, }, }, Constructors = new Constructor[] { new Constructor { AccessModifier = AccessModifier.Public, Name = GetClassName(type), Parameters = GetConstructorParameters(type), BaseConstructor = new Constructor { Name = "base", Parameters = GetConstructorParameters(type), } } }, }; List <Method> list = new List <Method>(); foreach (MethodInfo methodInfo in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { foreach (var attrib in methodInfo.GetCustomAttributes()) { if (attrib is HttpMethodAttribute) { list.Add(GetMethod((HttpMethodAttribute)attrib, methodInfo)); break; } } } converted.Methods = list.ToArray(); return(converted); }
public static IEnumerable <object[]> GetTestCases() { return(new List <object[]> { new object[] { new Method { AccessModifier = AccessModifier.Public, Name = "Test", Body = new CodeBlock("int i = 100;"), Override = false, ReturnType = DotNetType.Integer(), }, NormalMethod.RemoveCarriageReturn(), }, new object[] { new Method { AccessModifier = AccessModifier.Public, Name = "Test", Override = false, ReturnType = DotNetType.Integer(), Parameters = new Parameter[] { new Parameter { Name = "a", Type = DotNetType.Integer(), }, new Parameter { Name = "b", Type = DotNetType.String(), }, }, }, ParameterizedMethod.RemoveCarriageReturn(), }, new object[] { new Method { AccessModifier = AccessModifier.Public, Name = "Test", Static = true, ReturnType = DotNetType.Void(), }, StaticMethod.RemoveCarriageReturn(), }, new object[] { new Method { AccessModifier = AccessModifier.Public, Name = "Test", Override = true, ReturnType = DotNetType.Void(), }, OverrideMethod.RemoveCarriageReturn(), }, new object[] { new Method { AccessModifier = AccessModifier.Public, Name = "Test", Virtual = true, ReturnType = DotNetType.Void(), }, VirtualMethod.RemoveCarriageReturn(), }, }); }
public static IEnumerable <object[]> GetTestCases() { return(new List <object[]> { new object[] { new Class { AccessModifier = AccessModifier.Public, Name = "ClassA", Namespace = "Albatross.Sample", Imports = new string[] { "System", "System.IO", }, Properties = new Property[] { new Property { Name = "P1", Type = DotNetType.String(), CanRead = true, CanWrite = true, Modifier = AccessModifier.Public, } }, }, ClassA.RemoveCarriageReturn(), }, new object[] { new Class { AccessModifier = AccessModifier.Public, Name = "ClassB", Static = true, Partial = true, Namespace = "Albatross.Sample", Properties = new Property[] { new Property { Name = "P1", Type = DotNetType.String(), CanRead = true, CanWrite = true, Modifier = AccessModifier.Public, } }, }, ClassB.RemoveCarriageReturn(), }, }); }
public static IEnumerable <TestCaseData> GetTestCases() { return(new TestCaseData[] { new TestCaseData(new Field { Modifier = AccessModifier.Public, Name = "Test", Type = DotNetType.Integer(), }) { ExpectedResult = NormalMethod.RemoveCarriageReturn(), }, new TestCaseData(new Field { Modifier = AccessModifier.Public, Name = "a", Static = true, Type = DotNetType.String(), }) { ExpectedResult = StaticMethod.RemoveCarriageReturn(), }, }); }
public static IEnumerable <TestCaseData> GetTestData() { Type type = typeof(TestClass); return(new TestCaseData[] { new TestCaseData(type.GetProperty(nameof(TestClass.Text)), new Property(nameof(TestClass.Text)) { Type = DotNetType.String(), CanWrite = true, CanRead = true, }), new TestCaseData(type.GetProperty(nameof(TestClass.ReadOnlyText)), new Property(nameof(TestClass.ReadOnlyText)) { Type = DotNetType.String(), CanWrite = false, CanRead = true, }), new TestCaseData(type.GetProperty(nameof(TestClass.Number)), new Property(nameof(TestClass.Number)) { Type = DotNetType.Integer(), CanWrite = true, CanRead = true, Static = true, }), new TestCaseData(type.GetProperty(nameof(TestClass.Double)), new Property(nameof(TestClass.Double)) { Type = DotNetType.Double(), CanWrite = true, CanRead = true, SetModifier = AccessModifier.Private, }), }); }
public static IEnumerable <TestCaseData> GetTestCases() { Parameter[] parameters = new Parameter[] { new Parameter { Name = "a", Type = DotNetType.Integer(), }, new Parameter { Name = "b", Type = DotNetType.String(), }, }; return(new TestCaseData[] { new TestCaseData(new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Body = new CodeBlock("int i = 100;"), }) { ExpectedResult = NormalConstructor.RemoveCarriageReturn(), }, new TestCaseData(new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, }) { ExpectedResult = ParameterizedConstructor.RemoveCarriageReturn(), }, new TestCaseData(new Constructor { Static = true, Name = "Test", Body = new CodeBlock("int i = 100;"), }) { ExpectedResult = StaticConstructor.RemoveCarriageReturn(), }, new TestCaseData(new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, Body = new CodeBlock("int i = 100;"), BaseConstructor = new Constructor { Name = "base", Parameters = parameters, } }) { ExpectedResult = BaseConstructor.RemoveCarriageReturn(), }, new TestCaseData(new Constructor { AccessModifier = AccessModifier.Public, Name = "Test", Parameters = parameters, Body = new CodeBlock("int i = 100;"), BaseConstructor = new Constructor { Name = "this", Parameters = parameters, } }) { ExpectedResult = ChainConstructor.RemoveCarriageReturn(), }, }); }
static IEnumerable <TestCaseData> Get() { return(new TestCaseData[] { new TestCaseData(DotNetType.Boolean()) { ExpectedResult = "System.Boolean", }, new TestCaseData(DotNetType.Byte()) { ExpectedResult = "System.Byte" }, new TestCaseData(DotNetType.ByteArray()) { ExpectedResult = "System.Byte[]" }, new TestCaseData(DotNetType.Char()) { ExpectedResult = "System.Char", }, new TestCaseData(DotNetType.DateTime()) { ExpectedResult = "System.DateTime", }, new TestCaseData(DotNetType.DateTimeOffset()) { ExpectedResult = "System.DateTimeOffset", }, new TestCaseData(DotNetType.Decimal()) { ExpectedResult = "System.Decimal", }, new TestCaseData(DotNetType.Double()) { ExpectedResult = "System.Double", }, new TestCaseData(DotNetType.Guid()) { ExpectedResult = "System.Guid", }, new TestCaseData(DotNetType.IDbConnection()) { ExpectedResult = typeof(System.Data.IDbConnection).FullName, }, new TestCaseData(DotNetType.Integer()) { ExpectedResult = "System.Int32", }, new TestCaseData(DotNetType.Long()) { ExpectedResult = "System.Int64", }, new TestCaseData(DotNetType.Short()) { ExpectedResult = "System.Int16", }, new TestCaseData(DotNetType.Single()) { ExpectedResult = "System.Single", }, new TestCaseData(DotNetType.String()) { ExpectedResult = "System.String", }, new TestCaseData(DotNetType.TimeSpan()) { ExpectedResult = "System.TimeSpan", }, new TestCaseData(DotNetType.Void()) { ExpectedResult = "void", }, new TestCaseData(DotNetType.MakeIEnumerable(DotNetType.String())) { ExpectedResult = "System.Collections.Generic.IEnumerable<System.String>" }, new TestCaseData(new DotNetType("System.Int32", true, false, null)) { ExpectedResult = "System.Int32[]" }, new TestCaseData(DotNetType.MakeNullable(DotNetType.Integer())) { ExpectedResult = "System.Nullable<System.Int32>" }, }); }