public static int Main() { Eval(GenClass <FooClass> .ConvertToConstraint(new FooClass()).GetType().Equals(typeof(FooClass))); Eval(GenClass <FooStruct> .ConvertToConstraint(new FooStruct()).GetType().Equals(typeof(FooStruct))); Eval(GenStruct <FooClass> .ConvertToConstraint(new FooClass()).GetType().Equals(typeof(FooClass))); Eval(GenStruct <FooStruct> .ConvertToConstraint(new FooStruct()).GetType().Equals(typeof(FooStruct))); TypeFilter myFilter = new TypeFilter(MyInterfaceFilter); Console.WriteLine(typeof(FooClass).FindInterfaces(myFilter, typeof(XFoo))); foreach (var iface in typeof(FooStruct).GetInterfaces()) { Console.WriteLine(iface); } Console.WriteLine(typeof(FooStruct).GetInterfaces()); Console.WriteLine(typeof(FooStruct).IsInterface); Console.WriteLine(typeof(XFoo).IsInterface); if (result) { Console.WriteLine("Test Passed"); return(0); } else { Console.WriteLine("Test Failed"); return(1); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "JsArrayNumber", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "JsArrayNumber", false, genClass)); if (_prop.CanRead) { yield return (string.Format( "\t@Override public final IJsArrayNumber get{0}() {{ return new JsArrayNumberWrapper(get{0}Raw()); }}", _prop.Name)); } if (_prop.CanWrite) { yield return (string.Format( "\t@Override public final {1} set{0}(Iterable<Double> list) {{ get{0}Raw().setLength(0); for(double i : list) {{ get{0}Raw().push(i); }} return this; }}", _prop.Name, genClass.Name)); yield return (string.Format( "\t@Override public final {1} set{0}(IJsArrayNumber list) {{ set{0}(JsArrayNumberWrapper.unwrap(list)); return this; }}", _prop.Name, genClass.Name)); } }
static void DoTest_Inner <T1, T2, T3>(int max, GenClass <T1> o1, GenClass <T2> o2, GenClass <T3> o3) { Console.WriteLine("TEST: FuncOnGenClass<{0}>", typeof(T1).Name); for (int i = 0; i < max; i++) { Assert.AreEqual(o1.FuncOnGenClass(i).ToString(), i == 0 ? $"{typeof(T1)}" : $"TestType{i}`1[{typeof(T1)}]"); } Console.WriteLine("TEST: FuncOnGenClass<{0}>", typeof(T2).Name); for (int i = 0; i < max; i++) { Assert.AreEqual(o2.FuncOnGenClass(i).ToString(), i == 0 ? $"{typeof(T2)}" : $"TestType{i}`1[{typeof(T2)}]"); } Console.WriteLine("TEST: FuncOnGenClass2<{0}>", typeof(T2).Name); for (int i = 0; i < max; i++) { Assert.AreEqual(o2.FuncOnGenClass2(i).ToString(), i == 0 ? $"{typeof(T2)}" : $"TestType{i}`1[{typeof(T2)}]"); } Console.WriteLine("TEST: FuncOnGenClass<{0}>", typeof(T3).Name); for (int i = 0; i < max; i++) { Assert.AreEqual(o3.FuncOnGenClass(i).ToString(), i == 0 ? $"{typeof(T3)}" : $"TestType{i}`1[{typeof(T3)}]"); } }
public IEnumerable <string> GenerateTModelProperties(string sourceNamespace, GenClass genClass) { yield return (string.Format( "\t// object datatype ignored. Use a specific datatype if you want it in the Tessell Model. Property: {0}", _prop.Name)); }
public IEnumerable <string> GenerateTModelProperties(string sourceNamespace, GenClass genClass) { yield return (string.Format( "\t// long datatype shouldn't be used for data transfer since javascript doesn't support them. Property: {0}", _prop.Name)); }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", false, string.Format("set{0}Raw", _prop.Name), genClass)); yield return(DtGenUtil.GenNativeGetIsNullMethod(_prop)); yield return(DtGenUtil.GenNativeSetIsNullMethod(_prop)); if (_prop.CanRead) { yield return (string.Format( "\tpublic final NullableInteger get{0}() {{ return get{0}IsNull() ? NullableInteger.getNull() : new NullableInteger(get{0}Raw()); }}", _prop.Name)); } if (_prop.CanWrite) { yield return (string.Format( "\tpublic final {1} set{0}(NullableInteger val) {{ if (val.isNull()) {{ set{0}IsNull(); }} else {{ set{0}Raw(val.getInt()); }} return this; }}", _prop.Name, genClass.Name)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", false, string.Format("set{0}Raw", _prop.Name), genClass)); yield return(DtGenUtil.GenNativeGetIsNullMethod(_prop)); yield return(DtGenUtil.GenNativeSetIsNullMethod(_prop)); var nameWoKey = _prop.Name.Substring(0, _prop.Name.Length - 3); if (_prop.CanRead) { yield return (string.Format( "\tpublic final NullableDate get{0}() {{ return get{1}IsNull() ? new NullableDate() : new NullableDate(Utils.fromDateKey(get{1}Raw())); }}", nameWoKey, _prop.Name)); } if (_prop.CanWrite) { yield return (string.Format( "\tpublic final {2} set{0}(NullableDate val) {{ if (val.isNull()) {{ set{1}IsNull(); }} else {{ set{1}Raw(Utils.toDateKey(val.getDate())); }} return this; }}", nameWoKey, _prop.Name, genClass.Name)); } if (_prop.DateTimeSisterProperty != null) { yield return(DtGenUtil.GenNativeDeleteMethod(_prop.DateTimeSisterProperty)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", false, string.Format("set{0}Raw", _prop.Name), genClass)); yield return(DtGenUtil.GenNativeGetIsNullMethod(_prop)); yield return(DtGenUtil.GenNativeSetIsNullMethod(_prop)); if (_prop.CanRead) { yield return (string.Format( "\tpublic final NullableEnum<{1}> get{0}() {{ return get{0}IsNull() ? new NullableEnum<{1}>() : new NullableEnum<{1}>({1}.fromValue(get{0}Raw())); }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name)); } if (_prop.CanWrite) { yield return (string.Format( "\tpublic final {2} set{0}(NullableEnum<{1}> val) {{ if (val.isNull()) {{ set{0}IsNull(); }} else {{ set{0}Raw(val.getValue().getValue()); }} return this; }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name, genClass.Name)); yield return(string.Format("\tpublic final {2} set{0}({1} val) {{ set{0}Raw(val.getValue()); return this; }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name, genClass.Name)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int", false)); yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", false, genClass)); var nameWoKey = _prop.Name.Length > 3 ? _prop.Name.Substring(0, _prop.Name.Length - 3) : ""; if (_prop.CanRead) { yield return (string.Format("\tpublic final Date get{0}() {{ return Utils.fromDateKey(get{1}()); }}", nameWoKey, _prop.Name)); } if (_prop.CanWrite) { yield return (string.Format("\tpublic final {2} set{0}(Date d) {{ set{1}(Utils.toDateKey(d)); return this; }}", nameWoKey, _prop.Name, genClass.Name)); } if (_prop.DateTimeSisterProperty != null) { yield return(DtGenUtil.GenNativeDeleteMethod(_prop.DateTimeSisterProperty)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return (DtGenUtil.GenNativeGetMethod(_prop, string.Format("JsArray<{0}>", _prop.PropType.GenericTypeArguments[0].Name), false, string.Format("get{0}Raw", _prop.Name))); yield return (DtGenUtil.GenNativeSetMethod(_prop, string.Format("JsArray<{0}>", _prop.PropType.GenericTypeArguments[0].Name), false, string.Format("set{0}", _prop.Name), genClass)); if (_prop.CanRead) { yield return (string.Format( "\t@Override public final IJsArray<I{1}> get{0}() {{ return new JsArrayWrapper<{1}, I{1}>(get{0}Raw()); }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name)); } if (_prop.CanWrite) { yield return (string.Format( "\t@Override public final {2} set{0}(Iterable<I{1}> list) {{ get{0}Raw().setLength(0); for(I{1} item : list) {{ get{0}Raw().push(({1})item); }} return this; }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name, genClass.Name)); yield return (string.Format( "\t@Override public final {2} set{0}(IJsArray<I{1}> list) {{ set{0}(JsArrayWrapper.<{1}, I{1}>unwrap(list)); return this; }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name, genClass.Name)); } }
public void Generate(Type type) { if (!type.IsClass && !type.IsInterface) { return; } if (_GeneratedList.ContainsKey(type)) { return; } GenClass gc = new GenClass(type); _GeneratedList.Add(type, gc); if (type.IsInterface) { GenerateTemplate(gc, "ProxyInterface.txt", OutPath + "\\include\\" + type.Name + "ProxyI.h"); GenerateTemplate(gc, "ProxyHeader.txt", OutPath + "\\code\\" + type.Name + "Proxy.h"); GenerateTemplate(gc, "ProxyBody.txt", OutPath + "\\code\\" + type.Name + "Proxy.cpp"); } else { GenerateTemplate(gc, "WrapperInterface.txt", OutPath + "\\include\\" + type.Name + "I.h"); GenerateTemplate(gc, "WrapperHeader.txt", OutPath + "\\code\\" + type.Name + ".h"); GenerateTemplate(gc, "WrapperBody.txt", OutPath + "\\code\\" + type.Name + ".cpp"); } foreach (var usedType in gc.UsedTypes) { Generate(usedType); } }
public CriarAgendaAutomatica(GenClass prContextoExecucao) : base(prContextoExecucao) { acoAgendaDTO = new List <AgendaDTO>(); aParametrizacaoAgendaRepository = new ParametrizacaoAgendaRepository(); aIncluirAgenda = new IncluirAgenda(); aClienteFixoRepository = new ClienteFixoRepository(); aAgendaRepository = new AgendaRepository(); }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, string.Format("JsArray<{0}>", _prop.PropType.GenericTypeArguments[0].Name), false, string.Format("get{0}Raw", _prop.Name))); if (_prop.CanRead) { yield return (string.Format( "\t@Override public final IJsArray<I{1}> get{0}() {{ return new JsArrayWrapper<{1}, I{1}>(get{0}Raw()); }}", _prop.Name, _prop.PropType.GenericTypeArguments[0].Name)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, _prop.PropType.Name)); yield return(DtGenUtil.GenNativeSetMethod(_prop, _prop.PropType.Name, false, string.Format("set{0}Raw", _prop.Name), genClass)); if (_prop.CanWrite) { yield return (string.Format( "\t@Override public final {2} set{0}(I{1} val) {{ set{0}Raw(({1})val); return this; }}", _prop.Name, _prop.PropType.Name, genClass.Name)); } }
public static int Main() { GenClass <int> gci = new GenClass <int> (); GenStruct <int> gsi = new GenStruct <int> (123, 456); if (!gsi.isEqualTo((GenStruct <int>)gci.boxStruct(gsi))) { return(1); } /* * if (!gsi.isEqualTo ((GenStruct<int>)gci.boxNullableStruct (gsi))) * return 1; * if (gci.boxNullableStruct (null) != null) * return 1; */ GenClass <ClassA> gca = new GenClass <ClassA> (); GenStruct <ClassA> gsa = new GenStruct <ClassA> (new ClassA(), 789); if (!gsa.isEqualTo((GenStruct <ClassA>)gca.boxStruct(gsa))) { return(1); } /* * if (!gsa.isEqualTo ((GenStruct<ClassA>)gca.boxNullableStruct (gsa))) * return 1; * if (gca.boxNullableStruct (null) != null) * return 1; */ UnboxerStruct <ClassA> us; Boxer <ClassA> b = new Boxer <ClassA> (); us.field = 123; if (((UnboxerStruct <ClassA>?)b.boxNullable(us)).Value.field != 123) { return(1); } if (b.boxNullable(null) != null) { return(1); } return(0); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Unicode; //pdf book list GenClass <PdfBook> MyPdfBookList = new GenClass <PdfBook>(5); MyPdfBookList.AddBook(new PdfBook("The Comple Referance C#", "Herbert Schildt", 950)); MyPdfBookList.AddBook(new PdfBook("test", "test1", 33)); MyPdfBookList.ShowBookList(); MyPdfBookList.FindBookByNameOrAuthor("test"); // pubbook list GenClass <PubBook> MyPubBookList = new GenClass <PubBook>(4); MyPdfBookList.AddBook(new PdfBook("The Comple Referance C++", "Herbert Schildt", 1022)); MyPubBookList.ShowBookList(); Console.ReadKey(); }
public static int Main() { Eval(GenClass <FooClass> .CallOnConstraint(new FooClass())); Eval(GenClass <FooStruct> .CallOnConstraint(new FooStruct())); Eval(GenStruct <FooClass> .CallOnConstraint(new FooClass())); Eval(GenStruct <FooStruct> .CallOnConstraint(new FooStruct())); if (result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(1); } }
public static int Main() { Eval(GenClass <FooClass> .TransitiveConstraint().GetType().Equals(typeof(Transition <FooClass>))); Eval(GenClass <FooStruct> .TransitiveConstraint().GetType().Equals(typeof(Transition <FooStruct>))); Eval(GenStruct <FooClass> .TransitiveConstraint().GetType().Equals(typeof(Transition <FooClass>))); Eval(GenStruct <FooStruct> .TransitiveConstraint().GetType().Equals(typeof(Transition <FooStruct>))); if (result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(1); } }
public static int Main() { Eval(GenClass <FooClass> .ConvertToConstraint(new FooClass()).GetType().Equals(typeof(FooClass))); Eval(GenClass <FooStruct> .ConvertToConstraint(new FooStruct()).GetType().Equals(typeof(FooStruct))); Eval(GenStruct <FooClass> .ConvertToConstraint(new FooClass()).GetType().Equals(typeof(FooClass))); Eval(GenStruct <FooStruct> .ConvertToConstraint(new FooStruct()).GetType().Equals(typeof(FooStruct))); if (result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(1); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", false, string.Format("set{0}Raw", _prop.Name), genClass)); if (_prop.CanRead) { yield return (string.Format("\tpublic final {1} get{0}() {{ return {1}.fromValue(get{0}Raw()); }}", _prop.Name, _prop.PropType.Name)); } if (_prop.CanWrite) { yield return (string.Format("\tpublic final {2} set{0}({1} val) {{ set{0}Raw(val.getValue()); return this; }}", _prop.Name, _prop.PropType.Name, genClass.Name)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "String", false, "get" + _prop.Name + "Str")); yield return(DtGenUtil.GenNativeSetMethod(_prop, "String", false, "set" + _prop.Name + "Str", genClass)); if (_prop.CanRead) { yield return (string.Format( "\tpublic final Date get{0}() {{ return Utils.parseLosslessDateTime(get{0}Str()).getDate(); }}", _prop.Name)); } if (_prop.CanWrite) { yield return (string.Format( "\tpublic final {1} set{0}(Date d) {{ set{0}Str(Utils.formatLosslessDateTime(d)); return this; }}", _prop.Name, genClass.Name)); } }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "JsArrayInteger", false, string.Format("get{0}Raw", _prop.Name))); yield return(DtGenUtil.GenNativeSetMethod(_prop, "JsArrayInteger", false, string.Format("set{0}Raw", _prop.Name), genClass)); if (_prop.CanRead) { yield return(string.Format("\tpublic final List<{0}> get{1}() {{ " + "\t\tArrayList<{0}> r = new ArrayList<{0}>(); " + "\t\tfor(int i : new JsArrayIntegerIterable(get{1}Raw())) {{ " + "\t\t\tr.add({0}.fromValue(i)); " + "\t\t}} " + "\t\treturn r; " + "\t}}", _prop.PropType.GenericTypeArguments[0].Name, _prop.Name)); } if (_prop.CanWrite) { yield return(string.Format("\tpublic final {2} set{1}(Iterable<{0}> val) {{ set{1}Raw(JsArrayIntegerWrapper.from(JavaOnlyUtils.select(val, new Func<{0}, Integer>() {{ @Override public Integer call({0} val) {{ return val.getValue(); }}}}))); return this; }}", _prop.PropType.GenericTypeArguments[0].Name, _prop.Name, genClass.Name)); } }
private void GenerateTemplate(GenClass gc, string templateName, string outPath) { if (!_TemplateList.ContainsKey(templateName)) { String tempContent = File.ReadAllText("Templates\\" + templateName); _TemplateList.Add(templateName, Template.Parse(tempContent)); } String output = _TemplateList[templateName].Render(Hash.FromAnonymousObject(new { c = gc })); ////tfs issues if (File.Exists(outPath)) { File.SetAttributes(outPath, File.GetAttributes(outPath) & ~FileAttributes.ReadOnly); File.Delete(outPath); } using (StreamWriter outFile = new StreamWriter(outPath)) { outFile.Write(output); } _BuildFiles.Add(outPath); }
public IEnumerable <string> GenerateTModelToDtoStatements(string sourceNamespace, GenClass genClass) { yield return(string.Format("\t\tresult.set{1}({0}.get());", DtGenUtil.ToJavaMemberName(_prop.Name), _prop.Name)); }
public IEnumerable <string> GenerateTModelFromDtoStatements(string sourceNamespace, GenClass genClass, List <string> constructorParams) { yield return(string.Format("\t\tto.{0}.set(from.get{1}());", DtGenUtil.ToJavaMemberName(_prop.Name), _prop.Name)); }
public IEnumerable <string> GenerateTModelConstructorStatements(string sourceNamespace, GenClass genClass, List <string> constructorParams) { yield return(string.Format("\t\t{0}.addRule(new Required(\"required field\"));", DtGenUtil.ToJavaMemberName(_prop.Name))); yield return(string.Format("\t\t{0}.addRule(new Range(\"The number must be between 0 and 255\", 0, 255));", DtGenUtil.ToJavaMemberName(_prop.Name))); }
public IEnumerable <string> GenerateTModelProperties(string sourceNamespace, GenClass genClass) { yield return(string.Format("\tpublic final IntegerProperty {0} = integerProperty(\"{0}\");", DtGenUtil.ToJavaMemberName(_prop.Name))); }
public IEnumerable <string> GenerateStubPropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenStubPrivateMember(_prop, "int", "0")); yield return(DtGenUtil.GenStubGetMethod(_prop, "int")); yield return(DtGenUtil.GenStubSetMethod(_prop, "int", genClass)); }
public IEnumerable <string> GenerateInterfacePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenInterfaceGetMethod(_prop, "int")); yield return(DtGenUtil.GenInterfaceSetMethod(_prop, "int", genClass)); }
public IEnumerable <string> GeneratePropertyMethods(string sourceNamespace, GenClass genClass) { yield return(DtGenUtil.GenNativeGetMethod(_prop, "int")); // java bytes are signed yield return(DtGenUtil.GenNativeSetMethod(_prop, "int", genClass)); }