-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Program.cs
34 lines (32 loc) · 1.09 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using Amadevus.RecordGenerator;
namespace QuickDemo
{
[Record(Features.Default | Features.Equality)]
public sealed partial class Contact
{
public int Id { get; }
public string Name { get; }
public string Email { get; }
public DateTime? Birthday { get; }
}
public static class Program
{
public static void Main()
{
var adam = new Contact.Builder
{
Id = 1,
Name = "Adam Demo",
Email = "[email protected]"
}.ToImmutable();
var adamWithBday = adam.WithBirthday(DateTime.UtcNow);
Console.WriteLine("Pretty display: " + adamWithBday);
// Pretty display: { Id = 1, Name = Adam Demo, Email = [email protected], Birthday = 06.01.2020 23:17:06 }
Console.WriteLine("Check equality: " + adam.Equals(adamWithBday));
// Check equality: False
Console.WriteLine("Check equality: " + adam.Equals(new Contact(1, "Adam Demo", "[email protected]", null)));
// Check equality: True
}
}
}