Initial commit

This commit is contained in:
Mark J Price 2022-07-13 16:36:53 +01:00
parent 4a4a0b8e20
commit 0ff7fcc22e
6 changed files with 18 additions and 18 deletions

View file

@ -56,19 +56,19 @@ string newFolder = Combine(
WriteLine($"Working with: {newFolder}");
// check if it exists
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
// create directory
WriteLine("Creating it...");
CreateDirectory(newFolder);
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
Write("Confirm the directory exists, and then press ENTER: ");
ReadLine();
// delete directory
WriteLine("Deleting it...");
Delete(newFolder, recursive: true);
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
SectionTitle("Managing files");
@ -123,7 +123,7 @@ WriteLine($"File Extension: {GetExtension(textFile)}");
WriteLine($"Random File Name: {GetRandomFileName()}");
WriteLine($"Temporary File Name: {GetTempFileName()}");
SectionTitle("Getting file information ");
SectionTitle("Getting file information");
FileInfo info = new(backupFile);
WriteLine($"{backupFile}:");

View file

@ -4,7 +4,7 @@ using static System.Environment;
using static System.IO.Path;
Book mybook = new(title:
"C# 11 and .NET 7 - Modern Cross-platform Development")
"C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals")
{
Author = "Mark J Price",
PublishDate = new(year: 2022, month: 11, day: 8),
@ -35,5 +35,5 @@ WriteLine("Written {0:N0} bytes of JSON to {1}",
arg1: filePath);
WriteLine();
// Display the serialized object graph
// display the serialized object graph
WriteLine(File.ReadAllText(filePath));

View file

@ -1,6 +1,6 @@
using System.Xml.Serialization; // XmlSerializer
using Packt.Shared; // Person
using NewJson = System.Text.Json.JsonSerializer;
using FastJson = System.Text.Json.JsonSerializer;
using static System.Environment;
using static System.IO.Path;
@ -93,7 +93,7 @@ WriteLine("Written {0:N0} bytes of JSON to: {1}",
arg0: new FileInfo(jsonPath).Length,
arg1: jsonPath);
// Display the serialized object graph
// display the serialized object graph
WriteLine(File.ReadAllText(jsonPath));
WriteLine();
@ -103,7 +103,7 @@ using (FileStream jsonLoad = File.Open(jsonPath, FileMode.Open))
{
// deserialize object graph into a List of Person
List<Person>? loadedPeople =
await NewJson.DeserializeAsync(utf8Json: jsonLoad,
await FastJson.DeserializeAsync(utf8Json: jsonLoad,
returnType: typeof(List<Person>)) as List<Person>;
if (loadedPeople is not null)

View file

@ -56,19 +56,19 @@ string newFolder = Combine(
WriteLine($"Working with: {newFolder}");
// check if it exists
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
// create directory
WriteLine("Creating it...");
CreateDirectory(newFolder);
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
Write("Confirm the directory exists, and then press ENTER: ");
ReadLine();
// delete directory
WriteLine("Deleting it...");
Delete(newFolder, recursive: true);
WriteLine($"Does it exist? {Exists(newFolder)}");
WriteLine($"Does it exist? {Path.Exists(newFolder)}");
SectionTitle("Managing files");
@ -123,7 +123,7 @@ WriteLine($"File Extension: {GetExtension(textFile)}");
WriteLine($"Random File Name: {GetRandomFileName()}");
WriteLine($"Temporary File Name: {GetTempFileName()}");
SectionTitle("Getting file information ");
SectionTitle("Getting file information");
FileInfo info = new(backupFile);
WriteLine($"{backupFile}:");

View file

@ -4,7 +4,7 @@ using static System.Environment;
using static System.IO.Path;
Book mybook = new(title:
"C# 11 and .NET 7 - Modern Cross-platform Development")
"C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals")
{
Author = "Mark J Price",
PublishDate = new(year: 2022, month: 11, day: 8),
@ -35,5 +35,5 @@ WriteLine("Written {0:N0} bytes of JSON to {1}",
arg1: filePath);
WriteLine();
// Display the serialized object graph
// display the serialized object graph
WriteLine(File.ReadAllText(filePath));

View file

@ -1,6 +1,6 @@
using System.Xml.Serialization; // XmlSerializer
using Packt.Shared; // Person
using NewJson = System.Text.Json.JsonSerializer;
using FastJson = System.Text.Json.JsonSerializer;
using static System.Environment;
using static System.IO.Path;
@ -93,7 +93,7 @@ WriteLine("Written {0:N0} bytes of JSON to: {1}",
arg0: new FileInfo(jsonPath).Length,
arg1: jsonPath);
// Display the serialized object graph
// display the serialized object graph
WriteLine(File.ReadAllText(jsonPath));
WriteLine();
@ -103,7 +103,7 @@ using (FileStream jsonLoad = File.Open(jsonPath, FileMode.Open))
{
// deserialize object graph into a List of Person
List<Person>? loadedPeople =
await NewJson.DeserializeAsync(utf8Json: jsonLoad,
await FastJson.DeserializeAsync(utf8Json: jsonLoad,
returnType: typeof(List<Person>)) as List<Person>;
if (loadedPeople is not null)