-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
74 lines (61 loc) · 2.14 KB
/
Copy pathProgram.cs
File metadata and controls
74 lines (61 loc) · 2.14 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using Npgg;
namespace Example
{
class Program
{
class Item
{
public string Name { get; set; }
public Rarity Rarity { get; set; }
public string Slot { get; set; }
}
enum Rarity
{
Normal,
Magic,
Unique,
Legendary,
}
static void Main(string[] args)
{
var items = new[]
{
new Item(){ Name= "Leoric's Crown", Rarity = Rarity.Normal, Slot ="Helm"},
new Item(){ Name= "Thunderfury", Rarity = Rarity.Unique, Slot ="One Handed Weapon"},
new Item(){ Name= null, Rarity = Rarity.Legendary, Slot ="Two Handed Weapon"},
new Item(){ Name= "WINDFORCE", Rarity = Rarity.Magic, Slot ="양손무기"},
};
ConsoleTable.Write(items.Select(item => (item.Name, item.Rarity)));
//or
ConsoleTable.Write(items.Select(item => new { item.Name, item.Rarity }));
#region ColorByRarity
ConsoleTable.Write(items, item => item.Rarity switch
{
Rarity.Magic => ConsoleColor.DarkCyan,
Rarity.Unique => ConsoleColor.DarkMagenta,
Rarity.Legendary => ConsoleColor.DarkYellow,
_ => ConsoleColor.White
});
#endregion
ConsoleTable.TableColor = ConsoleColor.Red;
ConsoleTable.ColumnColor = ConsoleColor.Cyan;
ConsoleTable.RowColor = ConsoleColor.White;
var obj = new Item() { Name = "Leoric's Crown", Rarity = Rarity.Normal, Slot = "Helm" };
ConsoleTable.WriteSingle(obj);
var dictionary = new Dictionary<string, object>()
{
{ "dictionary", "convert"},
{ "to", "key/value pair"},
{ "length", 3},
};
ConsoleTable.Write(dictionary);
ConsoleTable.Write(dictionary, (kvp)=>
{
return ConsoleColor.Red;
});
}
}
}