-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathD365ODataClient.tt
78 lines (66 loc) · 3.01 KB
/
D365ODataClient.tt
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
<#@ include file="D365ODataClient.ttinclude" #>
<#+
public static class Configuration
{
// The URI of the metadata document. The value must be set to a valid service document URI or a local file path
// eg : "http://services.odata.org/V4/OData/OData.svc/", "File:///C:/Odata.edmx", or @"C:\Odata.edmx"
// ### Notice ### If the OData service requires authentication for accessing the metadata document, the value of
// MetadataDocumentUri has to be set to a local file path, or the client code generation process will fail.
public const string MetadataDocumentUri = "file:///C:/Temp/data$metadata.xml";
//This will create a new file once it reaches this size. NOTE: the "Resources" class will still end up being around 15MB, because
public const int xxceRestartFileSizeInKB = 1024 * 5;
// The use of DataServiceCollection enables entity and property tracking. The value must be set to true or false.
public const bool UseDataServiceCollection = true;
// The namespace of the client code generated. It replaces the original namespace in the metadata document,
// unless the model has several namespaces.
public const string NamespacePrefix = "D365ODataClient";
// The target language of the generated client code. The value must be set to "CSharp" or "VB".
public const string TargetLanguage = "CSharp";
// This flag indicates whether to enable naming alias. The value must be set to true or false.
public const bool EnableNamingAlias = true;
// This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate
// the client code if any. The value must be set to true or false.
public const bool IgnoreUnexpectedElementsAndAttributes = true;
}
public static class Customization
{
/// <summary>
/// Changes the text to use upper camel case, which upper case for the first character.
/// </summary>
/// <param name="text">Text to convert.</param>
/// <returns>The converted text in upper camel case</returns>
internal static string CustomizeNaming(string text)
{
if (string.IsNullOrEmpty(text))
{
return text;
}
if (text.Length == 1)
{
return Char.ToUpperInvariant(text[0]).ToString(CultureInfo.InvariantCulture);
}
return Char.ToUpperInvariant(text[0]) + text.Substring(1);
}
/// <summary>
/// Changes the namespace to use upper camel case, which upper case for the first character of all segments.
/// </summary>
/// <param name="fullNamespace">Namespace to convert.</param>
/// <returns>The converted namespace in upper camel case</returns>
internal static string CustomizeNamespace(string fullNamespace)
{
if (string.IsNullOrEmpty(fullNamespace))
{
return fullNamespace;
}
string[] segs = fullNamespace.Split('.');
string upperNamespace = string.Empty;
int n = segs.Length;
for (int i = 0; i < n; ++i)
{
upperNamespace += Customization.CustomizeNaming(segs[i]);
upperNamespace += (i == n - 1 ? string.Empty : ".");
}
return upperNamespace;
}
}
#>