Принятая лаба№8

This commit is contained in:
Артем Харламов 2023-06-03 16:42:08 +04:00
parent cee4fc8d77
commit 35f9ccddd2
2 changed files with 3 additions and 6 deletions

View File

@ -57,8 +57,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile",
BindingFlags.NonPublic | BindingFlags.Instance);
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
_logger.LogDebug("Find {count} types", types.Length);
foreach (var type in types)
{
@ -73,8 +72,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
}
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
// вызываем метод на выполнение
method?.MakeGenericMethod(modelType).Invoke(this, new
object[] { model.FolderName });
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
}
}
_logger.LogDebug("Create zip and remove folder");
@ -97,8 +95,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
return;
}
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
using var fs = new FileStream(string.Format("{0}/{1}.json",
folderName, typeof(T).Name), FileMode.OpenOrCreate);
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
jsonFormatter.WriteObject(fs, records);
}
}