-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyTagDictionary.CS
More file actions
102 lines (95 loc) · 2.81 KB
/
Copy pathKeyTagDictionary.CS
File metadata and controls
102 lines (95 loc) · 2.81 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
namespace VINE
{
using System;
using System . Collections . Generic;
using System . Linq;
using System . Numerics;
using System . Text;
using System . Text . Json;
using System . Threading . Tasks;
public class KeyTagDictionary
{
public BigInteger Identifier = BigInteger.Zero;
public Dictionary<string, string> KeyIdentity = new Dictionary<string, string>();
public Dictionary<string, List<string>> IdentityGroup = new Dictionary<string, List<string>>();
public KeyTagDictionary ( )
{}
public BigInteger Identify ( string Key )
{
BigInteger Identity = this. Identity ( Key );
try
{
this . Identifier += 1;
this . KeyIdentity . Add ( Key , this . Identifier . ToString ( ) );
Identity = this . Identifier;
} catch { }
return Identity;
}
public BigInteger Identity ( string Key )
{
BigInteger Identity = BigInteger . MinusOne;
if ( this . KeyIdentity . ContainsKey ( Key ) )
{
try
{
Identity = BigInteger . Parse ( this . KeyIdentity [ Key ] );
} catch { }
}
return Identity;
}
public string Identity ( BigInteger Key )
{
string Identity = string.Empty;
if ( this . KeyIdentity . ContainsValue ( Key . ToString ( ) ) )
{
try
{
Identity = this . KeyIdentity . Where ( i => i . Value == Key . ToString ( ) ) . ToArray ( ) . First ( ) . Key;
} catch { }
}
return Identity;
}
public void KeyTags ( string Key , params string [ ] Tags )
{
BigInteger keyIdentity = this . Identify ( Key );
if ( keyIdentity . Equals ( BigInteger . MinusOne ) is false )
{
foreach ( string Tag in Tags )
{
BigInteger tagIdentity = this . Identify ( Tag );
if ( this . IdentityGroup . ContainsKey ( keyIdentity . ToString ( ) ) )
{
this . IdentityGroup [ keyIdentity . ToString ( ) ] . Add ( tagIdentity . ToString ( ) );
} else
{
this . IdentityGroup . Add ( keyIdentity . ToString ( ) , new List<string> ( new [ ] { tagIdentity . ToString ( ) } ) );
}
if ( this . IdentityGroup . ContainsKey ( tagIdentity . ToString ( ) ) )
{
this . IdentityGroup [ tagIdentity . ToString ( ) ] . Add ( keyIdentity . ToString ( ) );
} else
{
this . IdentityGroup . Add ( tagIdentity . ToString ( ) , new List<string> ( new [ ] { keyIdentity . ToString ( ) } ) );
}
}
}
}
public List<string> Tags ( string Key )
{
List<string> Tags = new List<string>();
BigInteger keyIdentity = this . Identity ( Key );
if ( keyIdentity . Equals ( BigInteger . MinusOne ) is false )
{
foreach ( string tagIdentity in this . IdentityGroup [ keyIdentity . ToString ( ) ] )
{
string Tag = this . Identity ( BigInteger.Parse(tagIdentity ));
if ( string . IsNullOrEmpty ( Tag ) is false )
{
Tags . Add ( Tag );
}
}
}
return Tags;
}
}
}