private void ScanAssembly(Assembly assembly) { this.Assemblies.Add(assembly); foreach (var Cls in assembly.GetExportedTypes()) { var Attr = Cls.GetCustomAttributes(typeof(Attributes.Entity), false); if (Attr.Length > 0 && this.ClassMetadata.ContainsKey(Cls.FullName) == false) { var EntityAttr = Attr[0] as Attributes.Entity; Log.Info("Entity found on " + Cls.FullName); var ClsMeta = new Mapping.ClassMetadata() { Name = Cls.Name, TableName = EntityAttr.TableName, Columns = this.ScanClass(Cls) }; ClsMeta.ObjectInfo = new Mapping.ObjectInfo(Cls, ClsMeta); if (string.IsNullOrWhiteSpace(EntityAttr.IdFieldName) == false) { // Overide id column name at table level, for compatibility with some ORMs ClsMeta.Columns.GetIdColumns()[0].Name = EntityAttr.IdFieldName; } this.ClassMetadata.Add(Cls.FullName, ClsMeta); } } this.FillAssociationInfo(); }
public static unsafe void Entry() { char *[] cc = null; int *[] ii = null; short *[] ss = null; var cls = new Sub2(); cls.Foo(cc, ii); cls.Foo(cc, ss); Inf <int *[]> inf = cls; inf.Foo(cc, ii); Inf2 <short *[]> inf2 = cls; inf2.Foo(cc, ss); var cls2 = new Cls <long *[]>(); Sub1 <int *[]> s1 = cls; s1.Foo(cc, ii); s1.Foo(cc, ss); new Cls <int *[]>(); }
public static void Entry() { var c = new Cls <int, int>(); Inf <int, int> i = c; i.Foo(c); }
private void GenerateOwnFields() { IList <string> interfaces = Cls.CSharpInterfaces; foreach (Field of in Cls.GetOrderedFields().Where(_ => !_.NoCode)) { string hideCondition = of.Definition.GetSmartValue("qorpent-hide", "hide"); string qorpentOverride = of.Definition.Attr("override"); bool hide = interfaces.Contains(hideCondition); if (hide) { continue; } bool over = interfaces.Contains(qorpentOverride); string name = of.Name; if (of.IsReference) { GenerateRef(of); } else { GenerateField(of, "", name, over: over); } } }
protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender) { thisRef = DotNetObjectReference.Create(this); clsBuilder = HtmlPropertyBuilder.CreateCssClassBuilder() .Add("blazor-animation") .Add(Cls?.Split(' ') ?? new string[0]); await JSRuntime.InvokeVoidAsync("RegisterAnimationBegin", thisRef, animationElement); styleBuilder = HtmlPropertyBuilder.CreateCssStyleBuilder() .Add(InitialStyle?.Split(';') ?? new string[0]) .AddIf(IsAbsolute, "position:absolute") .Add("transition:all 1s ease"); if (paths.Any()) { var firstStyle = paths.Peek(); styleBuilder.Remove("transition").Add($"transition:all {(firstStyle.Duration <= 0 ? 1000 : firstStyle.Duration)}ms ease"); } MarkAsRequireRender(); StateHasChanged(); return; } if (!animationBegined) { animationBegined = true; await AnimationElementLoadAsync(); } }
public void Test01() { using (Cls cls = new Cls()) { cls.Dispose(); } }
public static void Entry() { Inf <object> i = new Cls <string>(); Inf <Inf <object> > ii = new Cls <Cls <string> >(); i.Foo(); ii.Foo(); }
private void WriteWrappers() { var wrappers = Cls.FindObjects <SqlFunction>("cs-wrap"); foreach (var function in wrappers) { WriteWrapper(function); } }
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listBox1.SelectedIndex != -1) { Cls cls = (Cls)listBox1.Items[listBox1.SelectedIndex]; NavigationService.Navigate(new Uri("/CourseDetail.xaml?courseid=" + cls.ClassName, UriKind.Relative)); } }
public static void Entry() { Inf <long> i = new Cls(); i.Foo(1.2f, (long)999999); Inf <char> i2 = null; i2.Foo(1234, 'a'); }
public static int Entry() { char *[] cc = new char *[1]; int *[] ii = new int *[1]; short *[] ss = new short *[1]; var cls = new Sub2(); cls.Foo(cc, ii); if (path != 1) { return(1); } cls.Foo(cc, ss); if (path != 2) { return(2); } Inf <int *[]> inf = cls; inf.Foo(cc, ii); if (path != 1) { return(3); } Inf2 <short *[]> inf2 = cls; inf2.Foo(cc, ss); if (path != 2) { return(4); } var cls2 = new Cls <long *[]>(); Sub1 <int *[]> s1 = cls; s1.Foo(cc, ii); if (path != 1) { return(5); } s1.Foo(cc, ss); if (path != 2) { return(6); } new Cls <int *[]>(); return(0); }
public void Test1() { var a = new Cls { A = 123, B = 234 }; ObjectEx.AcceptPropValues(a, new { A = 111 }); Assert.Equal(111, a.A); Assert.Equal(234, a.B); }
public static void Entry() { Inf i = new Cls(); i.Foo("nice"); Res res = i.Foo <Res>(); Res2 res2 = i.Foo <Res2>(); i.Foo(res, res2); }
static void Main(string[] args) { var cls = new Cls { prop1 = { "lorem", "ipsum", "dolor" }, prop2 = { "lorem", "ipsum", "dolor" }, prop3 = { "lorem", "ipsum", "dolor" }, }; System.Console.WriteLine(JsonConvert.SerializeObject(cls)); //Output: }
static void Main(string[] args) { var cls = new Cls { prop1 = "lorem", prop2 = "ipsum", prop3 = "dolor" }; System.Console.WriteLine(JsonConvert.SerializeObject(cls)); //Output: {"prop1":"lorem","prop2":"ipsum"} }
public static int Entry() { Inf <int, short> inf = new Cls(); int n = inf.Foo(123); if (n != 123) { return(1); } return(0); }
private void WriteGetSelectQuery() { o.WriteLine("\t\t///<summary>Implementation of PrepareSelectQuery</summary>"); o.WriteLine("#if NOQORPENT"); o.WriteLine("\t\tpublic string PrepareSelectQuery(object conditions = null, object hints = null) {"); o.WriteLine("#else"); o.WriteLine("\t\tpublic override string PrepareSelectQuery(object conditions = null, object hints = null) {"); o.WriteLine("#endif"); o.WriteLine("\t\t\tvar sb = new StringBuilder();"); o.Write("\t\t\tsb.Append(\"select "); bool fst = true; foreach (Field of in Cls.GetOrderedFields().Where(_ => !_.NoSql && !_.NoCode)) { if (fst) { fst = false; } else { o.Write(", "); } string n = of.Name.SqlQuoteName(); string rn = n; if (of.IsReference) { rn += of.ReferenceField; } rn = rn.SqlQuoteName().Replace("\"", "\\\""); n = n.Replace("\"", "\\\""); //геометрический тип трансформируем в nvarchar(max) if (of.DataType.ResolveSqlDataType(DbDialect.SqlServer).Name.StartsWith("geo")) { n = "CAST(" + n + " as nvarchar(max))"; } o.Write(n); if (rn != n) { o.Write(" as " + rn + ""); } } o.Write(" from " + Cls.FullSqlName.Replace("\"", "\\\"") + " \");"); o.WriteLine(); o.WriteLine("\t\t\tvar where = conditions as string;"); o.WriteLine("\t\t\tif ( null != where ) {"); o.WriteLine("\t\t\t\tsb.Append(\" where \");"); o.WriteLine("\t\t\t\tsb.Append(where);"); o.WriteLine("\t\t\t}"); o.WriteLine("\t\t\treturn sb.ToString();"); o.WriteLine("\t\t}"); }
public int Test_Nested(Cls Nested_Cls){ int mi_RetCode = 100; ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// // ACCESS NESTED FIELDS/MEMBERS ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////// // Test instance field access Nested_Cls.NestFldPubInst = 100; if(Nested_Cls.NestFldPubInst != 100) mi_RetCode = 0; Nested_Cls.NestFldAsmInst = 100; if(Nested_Cls.NestFldAsmInst != 100) mi_RetCode = 0; ///////////////////////////////// // Test static field access Cls.NestFldPubStat = 100; if(Cls.NestFldPubStat != 100) mi_RetCode = 0; Cls.NestFldAsmStat = 100; if(Cls.NestFldAsmStat != 100) mi_RetCode = 0; ///////////////////////////////// // Test instance method access if(Nested_Cls.NestMethPubInst() != 100) mi_RetCode = 0; if(Nested_Cls.NestMethAsmInst() != 100) mi_RetCode = 0; ///////////////////////////////// // Test static method access if(Cls.NestMethPubStat() != 100) mi_RetCode = 0; if(Cls.NestMethAsmStat() != 100) mi_RetCode = 0; //////////////////////////////////////////// // Test access from within the nested class if(Nested_Cls.Test() != 100) mi_RetCode = 0; return mi_RetCode; }
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listBox1.SelectedIndex != -1) { Cls selectedDept = (Cls)listBox1.Items[listBox1.SelectedIndex]; //TextBlock tb = (TextBlock)sender; NavigationService.Navigate(new Uri("/ByClass.xaml?courseid=" + selectedDept.ClassName, UriKind.Relative)); } }
static void Test2() { Console.WriteLine("--- Test1"); try { Cls obj = new Cls(); ((I <object, Cls, string>)obj).H("aaa"); Console.WriteLine("ok"); } catch (Exception e) { Console.WriteLine("error " + e.GetType()); } }
static void Test1() { Console.WriteLine("--- Test1"); try { Cls obj = new Cls(); obj.H(obj); Console.WriteLine("ok"); } catch (Exception e) { Console.WriteLine("error " + e.GetType()); } }
public static int Entry() { Inf0 <int> inf = new Cls <int>(); inf.Foo(123); if (((Cls <int>)inf).field2 != 2 || ((Cls <int>)inf).field1 != 0) { return(1); } return(0); }
private void GenerateIncomeReferences() { Field[] incomerefs = Cls.GetOrderedReverse().Where(_ => _.IsReverese && !_.NoCode).ToArray(); foreach (Field incomeref in incomerefs) { string name = incomeref.ReverseCollectionName; IBSharpClass cls = incomeref.Table.TargetClass; string clsname = cls.Name; if (cls.Namespace != Cls.Namespace) { clsname = cls.FullName; } GenerateField(incomeref, "ICollection<" + clsname + ">", name, "(" + incomeref.Name + " привязка )", "?? (Native" + name + " = new List<" + clsname + ">())"); } }
public static void Main() { var obj = new Cls() { Prop1 = "abc", Prop3 = 5 }; var props = obj .GetType() .GetProperties() .Select(p => p.GetValue(obj)) .Where(x => x != null || (x is string && (string)x != "")) .ToList(); Console.WriteLine(string.Join(",", props)); }
private void WriteWriteAccessors() { var fields = Cls.GetOrderedFields().Where(_ => !_.NoSql && !_.NoCode).ToArray(); if (Cls.AccessMode.HasFlag(DbAccessMode.Write)) { WriteSummary("Insert a record", 2, "Affected rows"); o.WriteLine("\t\tpublic int InsertRecord(IDbConnection connection, " + Cls.Name + " record) {"); o.WriteLine("\t\t\tvar sqlCommand = connection.CreateCommand();"); o.Write("\t\t\tconst string command = @\"INSERT INTO " + Cls.FullSqlName.SqlQuoteName().Replace("\"", "\"\"") + " ("); for (var i = 0; i < fields.Length; i++) { o.Write(fields[i].Name.ToLowerInvariant()); if (i != fields.Length - 1) { o.Write(", "); } } o.Write(") VALUES ("); for (var i = 0; i < fields.Length; i++) { o.Write("@" + fields[i].Name.ToLowerInvariant()); if (i != fields.Length - 1) { o.Write(", "); } } o.WriteLine(")\";"); o.WriteLine("\t\t\tsqlCommand.CommandText = command;"); for (var i = 0; i < fields.Length; i++) { o.WriteLine("\t\t\tsqlCommand.Parameters.Add(record." + fields[i].Name + ");"); } o.WriteLine("\t\t\tsqlCommand.Connection.Open();"); o.WriteLine("\t\t\tvar affected = sqlCommand.ExecuteNonQuery();"); o.WriteLine("\t\t\tsqlCommand.Connection.Close();"); o.WriteLine("\t\t\treturn affected;"); o.WriteLine("\t\t}"); } if (Cls.AccessMode.HasFlag(DbAccessMode.ReadWrite)) { foreach (var uniqueField in GetFields().Where(_ => _.IsUnique)) { WriteUpdateMethod(uniqueField); } } }
static void Main(string[] args) { var cls = new Cls { prop1 = new List <string> { "lorem", "ipsum", "dolor" }, prop2 = new List <string> { "lorem", "ipsum", "dolor" }, prop3 = new List <string> { "lorem", "ipsum", "dolor" }, }; System.Console.WriteLine(JsonConvert.SerializeObject(cls)); //Output: {"prop1":["lorem"],"prop2":["lorem"],"prop3":null} }
void TextStructVClass() { var st1 = new Srt("Struct", 0); var cl1 = new Cls("Class", 0); print(st1); print(cl1); var st2 = st1; var cl2 = cl1; cl2.Value = 1; st2.Value = 1; print(st1 + " ?= " + st2); print(cl1 + " ?= " + cl2); // Passing structs into fucntions makes a copy, which is inherently more expensive }
public int Test_Nested(Cls Nested_Cls) { int mi_RetCode = 100; ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// // ACCESS NESTED FIELDS/MEMBERS ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////// // Test instance field access Nested_Cls.NestFldPubInst = 100; if(Nested_Cls.NestFldPubInst != 100) mi_RetCode = 0; //@csharp - Note, CSharp won't allow access of family or private members of a nested class... //from it's enclosing class. Nested_Cls.NestFldAsmInst = 100; if(Nested_Cls.NestFldAsmInst != 100) mi_RetCode = 0; Nested_Cls.NestFldFoaInst = 100; if(Nested_Cls.NestFldFoaInst != 100) mi_RetCode = 0; ///////////////////////////////// // Test static field access Cls.NestFldPubStat = 100; if(Cls.NestFldPubStat != 100) mi_RetCode = 0; //@csharp - See last @csharp Cls.NestFldAsmStat = 100; if(Cls.NestFldAsmStat != 100) mi_RetCode = 0; Cls.NestFldFoaStat = 100; if(Cls.NestFldFoaStat != 100) mi_RetCode = 0; ///////////////////////////////// // Test instance method access if(Nested_Cls.NestMethPubInst() != 100) mi_RetCode = 0; //@csharp - See last @csharp if(Nested_Cls.NestMethAsmInst() != 100) mi_RetCode = 0; if(Nested_Cls.NestMethFoaInst() != 100) mi_RetCode = 0; ///////////////////////////////// // Test static method access if(Cls.NestMethPubStat() != 100) mi_RetCode = 0; //@csharp - See last @csharp if(Cls.NestMethAsmStat() != 100) mi_RetCode = 0; if(Cls.NestMethFoaStat() != 100) mi_RetCode = 0; ///////////////////////////////// // Test virtual method access if(Nested_Cls.NestMethPubVirt() != 100) mi_RetCode = 0; //@csharp - See last @csharp if(Nested_Cls.NestMethAsmVirt() != 100) mi_RetCode = 0; if(Nested_Cls.NestMethFoaVirt() != 100) mi_RetCode = 0; //////////////////////////////////////////// // Test access from within the nested class if(Nested_Cls.Test() != 100) mi_RetCode = 0; //////////////////////////////////////////// // Test accessing the second nested class if(Test_Nested2(Nested_Cls.Cls2PubInst) != 100) mi_RetCode = 0; if(Test_Nested2(Nested_Cls.Cls2AsmInst) != 100) mi_RetCode = 0; if(Test_Nested2(Nested_Cls.Cls2FoaInst) != 100) mi_RetCode = 0; return mi_RetCode; }
public int Test_Nested(Cls Nested_Cls) { int mi_RetCode = 100; ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// // ACCESS NESTED FIELDS/MEMBERS ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////// // Test instance field access Nested_Cls.NestFldPubInst = 100; if (Nested_Cls.NestFldPubInst != 100) { mi_RetCode = 0; } //@csharp - Note, CSharp won't allow access of family or private members of a nested class... //from it's enclosing class. Nested_Cls.NestFldAsmInst = 100; if (Nested_Cls.NestFldAsmInst != 100) { mi_RetCode = 0; } Nested_Cls.NestFldFoaInst = 100; if (Nested_Cls.NestFldFoaInst != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test static field access Cls.NestFldPubStat = 100; if (Cls.NestFldPubStat != 100) { mi_RetCode = 0; } //@csharp - See last @csharp Cls.NestFldAsmStat = 100; if (Cls.NestFldAsmStat != 100) { mi_RetCode = 0; } Cls.NestFldFoaStat = 100; if (Cls.NestFldFoaStat != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test instance method access if (Nested_Cls.NestMethPubInst() != 100) { mi_RetCode = 0; } //@csharp - See last @csharp if (Nested_Cls.NestMethAsmInst() != 100) { mi_RetCode = 0; } if (Nested_Cls.NestMethFoaInst() != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test static method access if (Cls.NestMethPubStat() != 100) { mi_RetCode = 0; } //@csharp - See last @csharp if (Cls.NestMethAsmStat() != 100) { mi_RetCode = 0; } if (Cls.NestMethFoaStat() != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test virtual method access if (Nested_Cls.NestMethPubVirt() != 100) { mi_RetCode = 0; } //@csharp - See last @csharp if (Nested_Cls.NestMethAsmVirt() != 100) { mi_RetCode = 0; } if (Nested_Cls.NestMethFoaVirt() != 100) { mi_RetCode = 0; } //////////////////////////////////////////// // Test access from within the nested class if (Nested_Cls.Test() != 100) { mi_RetCode = 0; } return(mi_RetCode); }
public int Test_Nested(Cls Nested_Cls) { int mi_RetCode = 100; ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// // ACCESS NESTED FIELDS/MEMBERS ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////// // Test instance field access Nested_Cls.NestFldPubInst = 100; if (Nested_Cls.NestFldPubInst != 100) { mi_RetCode = 0; } Nested_Cls.NestFldAsmInst = 100; if (Nested_Cls.NestFldAsmInst != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test static field access Cls.NestFldPubStat = 100; if (Cls.NestFldPubStat != 100) { mi_RetCode = 0; } Cls.NestFldAsmStat = 100; if (Cls.NestFldAsmStat != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test instance method access if (Nested_Cls.NestMethPubInst() != 100) { mi_RetCode = 0; } if (Nested_Cls.NestMethAsmInst() != 100) { mi_RetCode = 0; } ///////////////////////////////// // Test static method access if (Cls.NestMethPubStat() != 100) { mi_RetCode = 0; } if (Cls.NestMethAsmStat() != 100) { mi_RetCode = 0; } //////////////////////////////////////////// // Test access from within the nested class if (Nested_Cls.Test() != 100) { mi_RetCode = 0; } return(mi_RetCode); }
public bool IsTypeOf(int cls) { return(Cls.Equals(cls)); }
private static ClsClass GetCls( List <string> nmbs, string imageName, IFaultManager faultManager, IClsNmbManager clsNmbManager) { List <ICls> clss = new List <ICls>(); List <string> present = new List <string>(); foreach (string nmb in nmbs) { string[] individualNmbArray = nmb.Split(clsTick); if (individualNmbArray.Length != 2) { faultManager.AddFault( "Numbers Incorrect", imageName); continue; } present.Add(individualNmbArray[1]); // Go to nmb manager and get all associated nmbs //List<string> foundNmbs = new List<string>() { individualNmbArray[1] }; List <string> foundNmbs = clsNmbManager.FindAllNmbs( individualNmbArray[0], individualNmbArray[1]); bool foundCls = false; foreach (ICls cls in clss) { if (cls.Name == individualNmbArray[0]) { foreach (string foundNmb in foundNmbs) { cls.AddNmb(foundNmb); } foundCls = true; break; } } if (!foundCls) { ICls newCls = new Cls( individualNmbArray[0]); foreach (string foundNmb in foundNmbs) { newCls.AddNmb(foundNmb); } clss.Add(newCls); } } return (new ClsClass( clss, present)); }