Принятая лаба№8
This commit is contained in:
parent
cee4fc8d77
commit
35f9ccddd2
@ -57,8 +57,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
|
|||||||
nameof(assembly));
|
nameof(assembly));
|
||||||
}
|
}
|
||||||
var types = assembly.GetTypes();
|
var types = assembly.GetTypes();
|
||||||
var method = GetType().GetMethod("SaveToFile",
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
_logger.LogDebug("Find {count} types", types.Length);
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
{
|
{
|
||||||
@ -73,8 +72,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
// вызываем метод на выполнение
|
// вызываем метод на выполнение
|
||||||
method?.MakeGenericMethod(modelType).Invoke(this, new
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
object[] { model.FolderName });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logger.LogDebug("Create zip and remove folder");
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
@ -97,8 +95,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
using var fs = new FileStream(string.Format("{0}/{1}.json",
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
|
||||||
jsonFormatter.WriteObject(fs, records);
|
jsonFormatter.WriteObject(fs, records);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user