@@ -17,6 +17,7 @@ public class OptionsDialogPage : DialogPage
1717
1818 internal const bool _defClassInsteadOfInterface = false ;
1919 internal const string _defModuleName = "Server.Dtos" ;
20+ internal const bool _defUseNamespace = true ;
2021 internal const bool _defDeclareModule = true ;
2122 internal const bool _defIgnoreIntellisense = true ;
2223
@@ -34,7 +35,7 @@ public class OptionsDialogPage : DialogPage
3435 [ DisplayName ( "Camel case type names" ) ]
3536 [ DefaultValue ( _defCamelCaseTypeNames ) ]
3637 public bool CamelCaseTypeNames { get ; set ; } = _defCamelCaseTypeNames ;
37-
38+
3839 [ Category ( "Compatibilty" ) ]
3940 [ DisplayName ( "Web Essentials 2015 file names" ) ]
4041 [ Description ( "Web Essentials 2015 format is <filename>.cs.d.ts instead of <filename>.d.ts" ) ]
@@ -46,6 +47,11 @@ public class OptionsDialogPage : DialogPage
4647 [ Description ( "Set the top-level module name for the generated .d.ts file. Default is \" Server.Dtos\" " ) ]
4748 public string DefaultModuleName { get ; set ; } = _defModuleName ;
4849
50+ [ Category ( "Settings" ) ]
51+ [ DisplayName ( "Use Namespace" ) ]
52+ [ Description ( "Use Namespace by default, otherwise \" Default Module name\" will be taken." ) ]
53+ public bool UseNamespace { get ; set ; } = _defUseNamespace ;
54+
4955 [ Category ( "Settings" ) ]
5056 [ DisplayName ( "Class instead of Interface" ) ]
5157 [ Description ( "Controls whether to generate a class or an interface: default is an Interface" ) ]
@@ -67,71 +73,27 @@ public class OptionsDialogPage : DialogPage
6773
6874 public class Options
6975 {
70- const string OVERRIDE_FILE_NAME = "tsdefgen.json" ;
71- static OptionsOverride overrides { get ; set ; } = null ;
72- public static bool CamelCaseEnumerationValues
73- {
74- get
75- {
76- return overrides != null ? overrides . CamelCaseEnumerationValues : DtsPackage . Options . CamelCaseEnumerationValues ;
77- }
78- }
76+ private const string OVERRIDE_FILE_NAME = "tsdefgen.json" ;
7977
80- public static bool CamelCasePropertyNames
81- {
82- get
83- {
84- return overrides != null ? overrides . CamelCasePropertyNames : DtsPackage . Options . CamelCasePropertyNames ;
85- }
86- }
78+ private static OptionsOverride overrides { get ; set ; } = null ;
8779
88- public static bool CamelCaseTypeNames
89- {
90- get
91- {
92- return overrides != null ? overrides . CamelCaseTypeNames : DtsPackage . Options . CamelCaseTypeNames ;
93- }
94- }
95- //todo: set to server namespace
96- public static string DefaultModuleName
97- {
98- get
99- {
100- return overrides != null ? overrides . DefaultModuleName : DtsPackage . Options . DefaultModuleName ;
101- }
102- }
80+ public static bool CamelCaseEnumerationValues => overrides ? . CamelCaseEnumerationValues ?? DtsPackage . Options . CamelCaseEnumerationValues ;
10381
104- public static bool ClassInsteadOfInterface
105- {
106- get
107- {
108- return overrides != null ? overrides . ClassInsteadOfInterface : DtsPackage . Options . ClassInsteadOfInterface ;
109- }
110- }
82+ public static bool CamelCasePropertyNames => overrides ? . CamelCasePropertyNames ?? DtsPackage . Options . CamelCasePropertyNames ;
11183
112- public static bool DeclareModule
113- {
114- get
115- {
116- return overrides != null ? overrides . DeclareModule : DtsPackage . Options . DeclareModule ;
117- }
118- }
84+ public static bool CamelCaseTypeNames => overrides ? . CamelCaseTypeNames ?? DtsPackage . Options . CamelCaseTypeNames ;
11985
120- public static bool IgnoreIntellisense
121- {
122- get
123- {
124- return overrides != null ? overrides . IgnoreIntellisense : DtsPackage . Options . IgnoreIntellisense ;
125- }
126- }
86+ public static string DefaultModuleName => overrides ? . DefaultModuleName ?? DtsPackage . Options . DefaultModuleName ;
12787
128- public static bool WebEssentials2015
129- {
130- get
131- {
132- return overrides != null ? overrides . WebEssentials2015 : DtsPackage . Options . WebEssentials2015 ;
133- }
134- }
88+ public static bool UseNamespace => overrides ? . UseNamespace ?? DtsPackage . Options . UseNamespace ;
89+
90+ public static bool ClassInsteadOfInterface => overrides ? . ClassInsteadOfInterface ?? DtsPackage . Options . ClassInsteadOfInterface ;
91+
92+ public static bool DeclareModule => overrides ? . DeclareModule ?? DtsPackage . Options . DeclareModule ;
93+
94+ public static bool IgnoreIntellisense => overrides ? . IgnoreIntellisense ?? DtsPackage . Options . IgnoreIntellisense ;
95+
96+ public static bool WebEssentials2015 => overrides ? . WebEssentials2015 ?? DtsPackage . Options . WebEssentials2015 ;
13597
13698 public static void ReadOptionOverrides ( ProjectItem sourceItem , bool display = true )
13799 {
@@ -141,7 +103,7 @@ public static void ReadOptionOverrides(ProjectItem sourceItem, bool display = tr
141103
142104 foreach ( ProjectItem item in proj . ProjectItems )
143105 {
144- if ( item . Name . ToLower ( ) == OVERRIDE_FILE_NAME . ToLower ( ) )
106+ if ( string . Equals ( item . Name , OVERRIDE_FILE_NAME , StringComparison . InvariantCultureIgnoreCase ) )
145107 {
146108 jsonName = item . FileNames [ 0 ] ;
147109 break ;
@@ -205,6 +167,9 @@ internal class OptionsOverride
205167 // [JsonRequired]
206168 public string DefaultModuleName { get ; set ; } = OptionsDialogPage . _defModuleName ;
207169
170+ // [JsonRequired]
171+ public bool UseNamespace { get ; set ; } = OptionsDialogPage . _defUseNamespace ;
172+
208173 // [JsonRequired]
209174 public bool ClassInsteadOfInterface { get ; set ; } = OptionsDialogPage . _defClassInsteadOfInterface ;
210175
0 commit comments