loading
open in
main.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
using System.Linq;
using System;
public static class ReferenceTypeId
{
	public static readonly Guid First = new Guid("F288114A-B29E-40A2-B649-DF87B10B8E7C");
	public static readonly Guid Second = new Guid("AFE63E51-A611-426C-8226-4A98A93195DB");
	public static readonly Guid Third = new Guid("02CFDDDE-5C0E-4E65-B756-25DB72A08503");
	public static readonly Guid Fourth = new Guid("500CDF93-D1D1-4A89-A348-5A1B5265B1FA");
	public static readonly Guid Fifth = new Guid("890CD9E4-59B7-4C9B-95BF-9FFC159E169E");
}

class MainClass {
  private static string GetById(Guid id)
  {
      var dict =  typeof(ReferenceTypeId).GetFields()
          .Select(f => new {Key = (Guid)f.GetValue(null), Value = f.Name})
          .ToDictionary(item => item.Key, item => item.Value);
      return dict[id];
  }
  
  public static void Main (string[] args) {
    var refs =  typeof(ReferenceTypeId).GetFields()
                .Select(f => new {Key = f.Name, Value = f.GetValue(null)})
                .ToDictionary(item => item.Key, item => item.Value);
    foreach (var entry in refs)
    { 
        Console.WriteLine(entry.Key);
        Console.WriteLine(entry.Value);
    }
    var guid = new Guid("AFE63E51-A611-426C-8226-4A98A93195DB");
    Console.WriteLine("Get by ID: " + GetById(guid));
  }
}