-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathCSharpExportSettings.cs
More file actions
109 lines (98 loc) · 2.91 KB
/
CSharpExportSettings.cs
File metadata and controls
109 lines (98 loc) · 2.91 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
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using Waher.Content.Asn1.Model;
namespace Waher.Content.Asn1
{
/// <summary>
/// C# export settings
/// </summary>
public class CSharpExportSettings
{
private readonly Dictionary<string, KeyValuePair<Asn1Document, string>> imported =
new Dictionary<string, KeyValuePair<Asn1Document, string>>();
/// <summary>
/// What encoders and decoders to include in the generation of C# code.
/// </summary>
public EncodingSchemes Codecs;
/// <summary>
/// Base Namespace
/// </summary>
public string BaseNamespace;
/// <summary>
/// What encoders and decoders to include in the generation of C# code.
/// </summary>
/// <param name="BaseNamespace">Base namespace of generated code.</param>
public CSharpExportSettings(string BaseNamespace)
: this(BaseNamespace, EncodingSchemes.None)
{
}
/// <summary>
/// What encoders and decoders to include in the generation of C# code.
/// </summary>
/// <param name="BaseNamespace">Base namespace of generated code.</param>
/// <param name="Codecs">Encoding schemes to support.</param>
public CSharpExportSettings(string BaseNamespace, EncodingSchemes Codecs)
{
this.BaseNamespace = BaseNamespace;
this.Codecs = Codecs;
}
/// <summary>
/// Namespace for a given identifier.
/// </summary>
/// <param name="Identifier">Identifier.</param>
/// <returns>Namespace</returns>
public string Namespace(string Identifier)
{
return this.BaseNamespace + "." + Asn1Node.ToCSharp(Identifier);
}
/// <summary>
/// If C# code is available for a given identifier.
/// </summary>
/// <param name="Identifier">Identifier.</param>
/// <returns>If C# code exists.</returns>
public bool ContainsCode(string Identifier)
{
return this.imported.ContainsKey(Identifier);
}
/// <summary>
/// Adds C# code for a given identifier.
/// </summary>
/// <param name="Identifier">Identifier.</param>
/// <param name="Code">C# Code</param>
/// <param name="Document">Document</param>
public void AddCode(string Identifier, string Code, Asn1Document Document)
{
this.imported[Identifier] = new KeyValuePair<Asn1Document, string>(Document, Code);
}
/// <summary>
/// Gets C# code for a given identifier.
/// </summary>
/// <param name="Identifier">Identifier.</param>
/// <returns>C# code</returns>
public string GetCode(string Identifier)
{
return this.imported[Identifier].Value;
}
/// <summary>
/// Gets C# code for a given identifier.
/// </summary>
/// <param name="Identifier">Identifier.</param>
/// <returns>ASN.1 document.</returns>
public Asn1Document GetDocument(string Identifier)
{
return this.imported[Identifier].Key;
}
/// <summary>
/// Modules exported.
/// </summary>
public string[] Modules
{
get
{
string[] Result = new string[this.imported.Count];
this.imported.Keys.CopyTo(Result, 0);
return Result;
}
}
}
}