public MainWindow(params string[] _args) { textBox = new TextBox(); textBox.Multiline = true; Assembly ass_ = Assembly.Load("ReflectionCore"); Type loadedType_ = ass_.GetType("ReflectionCore.MyClass"); MethodInfo methodFrom_ = ConverterMethod.getFromStringMethod(loadedType_); MethodInfo methodTo_ = ConverterMethod.getToStringMethod(loadedType_); object obj_ = methodFrom_.Invoke(null, new object[] { "2" }); MyClass cl_ = obj_ as MyClass; string text_ = "From " + methodFrom_.Name + " " + cl_.getInteger() + "\r\n"; text_ += "To " + methodTo_.Name + " " + methodTo_.Invoke(cl_, new object[] { }) + "\r\n"; foreach (PropertyInfo f in ConverterMethod.getFields(loadedType_)) { text_ += f.Name + ": " + f.PropertyType + "\r\n"; } Type loadedGenericType_ = ass_.GetType("ReflectionCore.GenericType`1"); if (loadedGenericType_ == null) { text_ += "type not found: ReflectionCore.GenericType\r\n"; } else { text_ += loadedGenericType_.ToString() + "\r\n"; text_ += loadedGenericType_.BaseType.ToString() + "\r\n"; } Aliments <Nourriture> n; n = new Aliments <Nourriture>(); n.Add(new Pomme()); n.Add(new BoudinNoir()); foreach (Nourriture no in n) { text_ += no.GetType() + "\r\n"; } textBox.Text = text_; textBox.Size = new Size(300, 100); Controls.Add(textBox); }
private async Task <bool> ProcessAliment(int row, IList <AlimentCategory> categories) { string alimentLabel = GetCellValue(row, AlimentLabelCol); var result = false; if (!string.IsNullOrEmpty(alimentLabel)) { Aliment aliment = Aliments.FirstOrDefault(x => x.Label == alimentLabel); if (aliment == null) { aliment = new Aliment { Id = Guid.NewGuid(), Label = alimentLabel }; await _alimentRepository.Insert(aliment); } foreach (var category in categories) { await _alimentRepository.InsertCategoryToAliment(aliment.Id, category.Id); } await ProcessNutritionalValues(row, WaterCol, aliment, NutritionalInfoType.Water); await ProcessNutritionalValues(row, EnergyKCalCol, aliment, NutritionalInfoType.EnergyKCal); await ProcessNutritionalValues(row, EnergyKJCol, aliment, NutritionalInfoType.EnergyKJ); await ProcessNutritionalValues(row, ProteinCol, aliment, NutritionalInfoType.Protein); await ProcessNutritionalValues(row, CarbohydrateCol, aliment, NutritionalInfoType.Carbohydrate); await ProcessNutritionalValues(row, AlimentaryFiberCol, aliment, NutritionalInfoType.AlimentaryFiber); await ProcessNutritionalValues(row, SugarCol, aliment, NutritionalInfoType.Sugar); await ProcessNutritionalValues(row, StarchCol, aliment, NutritionalInfoType.Starch); await ProcessNutritionalValues(row, LipidCol, aliment, NutritionalInfoType.Lipid); await ProcessNutritionalValues(row, SaturatedFattyAcidCol, aliment, NutritionalInfoType.SaturatedFattyAcid); await ProcessNutritionalValues(row, PolyUnsaturatedFattyAcidCol, aliment, NutritionalInfoType.PolyUnsaturatedFattyAcid); await ProcessNutritionalValues(row, MonoUnsaturatedFattyAcidCol, aliment, NutritionalInfoType.MonoUnsaturatedFattyAcid); await ProcessNutritionalValues(row, CholesterolCol, aliment, NutritionalInfoType.Cholesterol); await ProcessNutritionalValues(row, AlcoholCol, aliment, NutritionalInfoType.Alcohol); await ProcessNutritionalValues(row, AshesCol, aliment, NutritionalInfoType.Ashes); await ProcessNutritionalValues(row, SaltCol, aliment, NutritionalInfoType.Salt); await ProcessNutritionalValues(row, CalciumCol, aliment, NutritionalInfoType.Calcium); await ProcessNutritionalValues(row, ChlorureCol, aliment, NutritionalInfoType.Chlorure); await ProcessNutritionalValues(row, CopperCol, aliment, NutritionalInfoType.Copper); await ProcessNutritionalValues(row, IronCol, aliment, NutritionalInfoType.Iron); await ProcessNutritionalValues(row, IodineCol, aliment, NutritionalInfoType.Iodine); await ProcessNutritionalValues(row, MagnesiumCol, aliment, NutritionalInfoType.Magnesium); await ProcessNutritionalValues(row, ManganeseCol, aliment, NutritionalInfoType.Manganese); await ProcessNutritionalValues(row, PhosphorusCol, aliment, NutritionalInfoType.Phosphorus); await ProcessNutritionalValues(row, PotassiumCol, aliment, NutritionalInfoType.Potassium); await ProcessNutritionalValues(row, SeleniumCol, aliment, NutritionalInfoType.Selenium); await ProcessNutritionalValues(row, SodiumCol, aliment, NutritionalInfoType.Sodium); await ProcessNutritionalValues(row, ZincCol, aliment, NutritionalInfoType.Zinc); await ProcessNutritionalValues(row, RetinolCol, aliment, NutritionalInfoType.Retinol); await ProcessNutritionalValues(row, BetaCaroteneCol, aliment, NutritionalInfoType.BetaCarotene); await ProcessNutritionalValues(row, VitaminDCol, aliment, NutritionalInfoType.VitaminD); await ProcessNutritionalValues(row, VitaminECol, aliment, NutritionalInfoType.VitaminE); await ProcessNutritionalValues(row, VitaminK1Col, aliment, NutritionalInfoType.VitaminK1); await ProcessNutritionalValues(row, VitaminCCol, aliment, NutritionalInfoType.VitaminC); await ProcessNutritionalValues(row, VitaminB1Col, aliment, NutritionalInfoType.VitaminB1); await ProcessNutritionalValues(row, VitaminB2Col, aliment, NutritionalInfoType.VitaminB2); await ProcessNutritionalValues(row, VitaminB3Col, aliment, NutritionalInfoType.VitaminB3); await ProcessNutritionalValues(row, VitaminB5Col, aliment, NutritionalInfoType.VitaminB5); await ProcessNutritionalValues(row, VitaminB6Col, aliment, NutritionalInfoType.VitaminB6); await ProcessNutritionalValues(row, VitaminB9Col, aliment, NutritionalInfoType.VitaminB9); await ProcessNutritionalValues(row, VitaminB12Col, aliment, NutritionalInfoType.VitaminB12); } return(result); }