@@ -14,8 +14,6 @@ namespace Xtensive.Sql.Model
1414 [ Serializable ]
1515 public class Catalog : Node
1616 {
17- private bool isNamesReadingDenied = false ;
18-
1917 private Schema defaultSchema ;
2018 private PairedNodeCollection < Catalog , Schema > schemas ;
2119 private PairedNodeCollection < Catalog , PartitionFunction > partitionFunctions ;
@@ -25,12 +23,12 @@ public class Catalog : Node
2523 public override string Name
2624 {
2725 get {
28- if ( ! isNamesReadingDenied )
26+ if ( ! IsNamesReadingDenied )
2927 return base . Name ;
3028 throw new InvalidOperationException ( Strings . ExNameValueReadingOrSettingIsDenied ) ;
3129 }
3230 set {
33- if ( ! isNamesReadingDenied )
31+ if ( ! IsNamesReadingDenied )
3432 base . Name = value ;
3533 else
3634 throw new InvalidOperationException ( Strings . ExNameValueReadingOrSettingIsDenied ) ;
@@ -41,50 +39,18 @@ public override string Name
4139 public override string DbName
4240 {
4341 get {
44- if ( ! isNamesReadingDenied )
42+ if ( ! IsNamesReadingDenied )
4543 return base . DbName ;
4644 throw new InvalidOperationException ( Strings . ExDbNameValueReadingOrSettingIsDenied ) ;
4745 }
4846 set {
49- if ( ! isNamesReadingDenied )
47+ if ( ! IsNamesReadingDenied )
5048 base . DbName = value ;
5149 else
5250 throw new InvalidOperationException ( Strings . ExDbNameValueReadingOrSettingIsDenied ) ;
5351 }
5452 }
5553
56- /// <summary>
57- /// Creates a schema.
58- /// </summary>
59- /// <param name="name">The name.</param>
60- /// <returns></returns>
61- public Schema CreateSchema ( string name )
62- {
63- return new Schema ( this , name ) ;
64- }
65-
66- /// <summary>
67- /// Creates the partition function.
68- /// </summary>
69- /// <param name="name">The name.</param>
70- /// <param name="dataType">Type of the input parameter.</param>
71- /// <param name="boundaryValues">The boundary values.</param>
72- public PartitionFunction CreatePartitionFunction ( string name , SqlValueType dataType , params string [ ] boundaryValues )
73- {
74- return new PartitionFunction ( this , name , dataType , boundaryValues ) ;
75- }
76-
77- /// <summary>
78- /// Creates the partition schema.
79- /// </summary>
80- /// <param name="name">The name.</param>
81- /// <param name="partitionFunction">The partition function.</param>
82- /// <param name="filegroups">The filegroups.</param>
83- public PartitionSchema CreatePartitionSchema ( string name , PartitionFunction partitionFunction , params string [ ] filegroups )
84- {
85- return new PartitionSchema ( this , name , partitionFunction , filegroups ) ;
86- }
87-
8854 /// <summary>
8955 /// Default <see cref="Schema"/> of this instance.
9056 /// </summary>
@@ -113,10 +79,7 @@ public Schema DefaultSchema
11379 /// Gets the schemas.
11480 /// </summary>
11581 /// <value>The schemas.</value>
116- public PairedNodeCollection < Catalog , Schema > Schemas
117- {
118- get { return schemas ; }
119- }
82+ public PairedNodeCollection < Catalog , Schema > Schemas => schemas ;
12083
12184 /// <summary>
12285 /// Gets the partition functions.
@@ -140,13 +103,41 @@ public PairedNodeCollection<Catalog, PartitionSchema> PartitionSchemas
140103 {
141104 get
142105 {
143- if ( partitionSchemas == null )
106+ if ( partitionSchemas == null )
144107 partitionSchemas =
145108 new PairedNodeCollection < Catalog , PartitionSchema > ( this , "PartitionSchemas" ) ;
146109 return partitionSchemas ;
147110 }
148111 }
149112
113+ internal bool IsNamesReadingDenied { get ; private set ; }
114+
115+ /// <summary>
116+ /// Creates a schema.
117+ /// </summary>
118+ /// <param name="name">The name.</param>
119+ /// <returns></returns>
120+ public Schema CreateSchema ( string name ) => new ( this , name ) ;
121+
122+ /// <summary>
123+ /// Creates the partition function.
124+ /// </summary>
125+ /// <param name="name">The name.</param>
126+ /// <param name="dataType">Type of the input parameter.</param>
127+ /// <param name="boundaryValues">The boundary values.</param>
128+ public PartitionFunction CreatePartitionFunction ( string name , SqlValueType dataType , params string [ ] boundaryValues ) =>
129+ new ( this , name , dataType , boundaryValues ) ;
130+
131+ /// <summary>
132+ /// Creates the partition schema.
133+ /// </summary>
134+ /// <param name="name">The name.</param>
135+ /// <param name="partitionFunction">The partition function.</param>
136+ /// <param name="filegroups">The filegroups.</param>
137+ public PartitionSchema CreatePartitionSchema ( string name , PartitionFunction partitionFunction , params string [ ] filegroups ) =>
138+ new ( this , name , partitionFunction , filegroups ) ;
139+
140+
150141 #region ILockable Members
151142
152143 /// <summary>
@@ -163,37 +154,32 @@ public override void Lock(bool recursive)
163154
164155 internal void MakeNamesUnreadable ( )
165156 {
166- isNamesReadingDenied = true ;
167- this . Schemas . ForEach ( s => s . MakeNamesUnreadable ( ) ) ;
168- this . PartitionFunctions . ForEach ( pf => pf . MakeNamesUnreadable ( ) ) ;
169- this . PartitionSchemas . ForEach ( ps => ps . MakeNamesUnreadable ( ) ) ;
157+ IsNamesReadingDenied = true ;
158+ Schemas . ForEach ( s => s . MakeNamesUnreadable ( ) ) ;
159+ PartitionFunctions . ForEach ( pf => pf . MakeNamesUnreadable ( ) ) ;
160+ PartitionSchemas . ForEach ( ps => ps . MakeNamesUnreadable ( ) ) ;
170161 }
171162
172163 internal string GetActualName ( IReadOnlyDictionary < string , string > catalogNameMap )
173164 {
174- if ( ! isNamesReadingDenied )
165+ if ( ! IsNamesReadingDenied )
175166 return Name ;
176167 if ( catalogNameMap == null )
177168 throw new ArgumentNullException ( "catalogNameMap" ) ;
178169
179170 var name = GetNameInternal ( ) ;
180- string actualName ;
181- if ( catalogNameMap . TryGetValue ( name , out actualName ) )
182- return actualName ;
183- return name ;
171+ return catalogNameMap . TryGetValue ( name , out var actualName ) ? actualName : name ;
184172 }
185173
186174 internal string GetActualDbName ( IReadOnlyDictionary < string , string > catalogNameMap )
187175 {
188- if ( ! isNamesReadingDenied )
176+ if ( ! IsNamesReadingDenied )
189177 return DbName ;
190178 if ( catalogNameMap == null )
191179 throw new ArgumentNullException ( "Unable to calculate real name for catalog" ) ;
180+
192181 var name = GetDbNameInternal ( ) ;
193- string actualName ;
194- if ( catalogNameMap . TryGetValue ( name , out actualName ) )
195- return actualName ;
196- return name ;
182+ return catalogNameMap . TryGetValue ( name , out var actualName ) ? actualName : name ;
197183 }
198184
199185 // Constructors
@@ -212,6 +198,5 @@ public Catalog(string name, bool caseSensitiveNames = false)
212198 ? new PairedNodeCollection < Catalog , Schema > ( this , "Schemas" , 1 , StringComparer . Ordinal )
213199 : new PairedNodeCollection < Catalog , Schema > ( this , "Schemas" , 1 , StringComparer . OrdinalIgnoreCase ) ;
214200 }
215-
216201 }
217202}
0 commit comments