19
19
using MS . Utility ;
20
20
21
21
22
- // Disabling 1634 and 1691:
23
- // In order to avoid generating warnings about unknown message numbers and
24
- // unknown pragmas when compiling C# source code with the C# compiler,
22
+ // Disabling 1634 and 1691:
23
+ // In order to avoid generating warnings about unknown message numbers and
24
+ // unknown pragmas when compiling C# source code with the C# compiler,
25
25
// you need to disable warnings 1634 and 1691. (Presharp Documentation)
26
26
#pragma warning disable 1634 , 1691
27
27
@@ -82,7 +82,7 @@ internal InternalBamlLocalizabilityResolver Resolver
82
82
83
83
/// <summary>
84
84
/// Maps a key to a baml tree node in the given tree
85
- /// </summary>
85
+ /// </summary>
86
86
internal BamlTreeNode MapKeyToBamlTreeNode ( BamlLocalizableResourceKey key , BamlTree tree )
87
87
{
88
88
if ( _keyToBamlNodeIndexMap . Contains ( key ) )
@@ -95,7 +95,7 @@ internal BamlTreeNode MapKeyToBamlTreeNode(BamlLocalizableResourceKey key, BamlT
95
95
96
96
/// <summary>
97
97
/// Maps a uid to a baml tree node in the given tree
98
- /// </summary>
98
+ /// </summary>
99
99
internal BamlStartElementNode MapUidToBamlTreeElementNode ( string uid , BamlTree tree )
100
100
{
101
101
if ( _uidToBamlNodeIndexMap . Contains ( uid ) )
@@ -126,7 +126,7 @@ internal void EnsureMap()
126
126
{
127
127
BamlTreeNode currentNode = _tree [ i ] ;
128
128
129
- // a node may be marked as unidentifiable if it or its parent has a duplicate uid.
129
+ // a node may be marked as unidentifiable if it or its parent has a duplicate uid.
130
130
if ( currentNode . Unidentifiable ) continue ; // skip unidentifiable nodes
131
131
132
132
if ( currentNode . NodeType == BamlNodeType . StartElement )
@@ -153,7 +153,7 @@ internal void EnsureMap()
153
153
)
154
154
) ;
155
155
156
- // Mark this element and its properties unidentifiable.
156
+ // Mark this element and its properties unidentifiable.
157
157
currentNode . Unidentifiable = true ;
158
158
if ( currentNode . Children != null )
159
159
{
@@ -164,7 +164,7 @@ internal void EnsureMap()
164
164
}
165
165
}
166
166
167
- continue ; // skip the duplicate node
167
+ continue ; // skip the duplicate node
168
168
}
169
169
else
170
170
{
@@ -179,7 +179,7 @@ internal void EnsureMap()
179
179
&& currentNode . Parent != null
180
180
&& currentNode . Parent . NodeType == BamlNodeType . StartDocument )
181
181
{
182
- // remember the key to the root element so that
182
+ // remember the key to the root element so that
183
183
// users can further add modifications to the root that would have a global impact.
184
184
// such as FlowDirection or CultureInfo
185
185
_localizableResources . SetRootElementKey ( key ) ;
@@ -204,7 +204,7 @@ internal void EnsureMap()
204
204
//-------------------------------------------------
205
205
206
206
/// <summary>
207
- /// Return the localizable resource key for this baml tree node.
207
+ /// Return the localizable resource key for this baml tree node.
208
208
/// If this node shouldn't be localized, the key returned will be null.
209
209
/// </summary>
210
210
internal static BamlLocalizableResourceKey GetKey ( BamlTreeNode node )
@@ -241,15 +241,11 @@ internal static BamlLocalizableResourceKey GetKey(BamlTreeNode node)
241
241
}
242
242
else
243
243
{
244
- // This node is auto-numbered. This has to do with the fact that
245
- // the compiler may compile duplicated properties into Baml under the same element.
246
- uid = string . Format (
244
+ // This node is auto-numbered. This has to do with the fact that
245
+ // the compiler may compile duplicated properties into Baml under the same element.
246
+ uid = string . Create (
247
247
TypeConverterHelper . InvariantEnglishUS ,
248
- "{0}.{1}_{2}" ,
249
- parent . Uid ,
250
- propertyNode . PropertyName ,
251
- propertyNode . Index
252
- ) ;
248
+ $ "{ parent . Uid } .{ propertyNode . PropertyName } _{ propertyNode . Index } ") ;
253
249
}
254
250
255
251
key = new BamlLocalizableResourceKey (
@@ -310,7 +306,7 @@ internal class InternalBamlLocalizabilityResolver : BamlLocalizabilityResolver
310
306
private Dictionary < string , LocalizabilityAttribute > _propertyAttributeTable ;
311
307
312
308
//
313
- // cached localization comments
309
+ // cached localization comments
314
310
// Normally, we only need to use comments of a single element at one time.
315
311
// In case of formatting inline tags we might be grabing comments of a few more elements.
316
312
// A small cached would be enough
@@ -398,7 +394,7 @@ internal void ReleaseLocalizabilityCache()
398
394
_commentsDocument = null ;
399
395
}
400
396
401
- // Grab the comments on a BamlTreeNode for the value.
397
+ // Grab the comments on a BamlTreeNode for the value.
402
398
internal LocalizabilityGroup GetLocalizabilityComment (
403
399
BamlStartElementNode node ,
404
400
string localName
@@ -423,7 +419,7 @@ internal string GetStringComment(
423
419
string localName
424
420
)
425
421
{
426
- // get all the comments declares on this node
422
+ // get all the comments declares on this node
427
423
ElementComments comment = LookupCommentForElement ( node ) ;
428
424
for ( int i = 0 ; i < comment . LocalizationComments . Length ; i ++ )
429
425
{
@@ -443,14 +439,14 @@ internal void RaiseErrorNotifyEvent(BamlLocalizerErrorNotifyEventArgs e)
443
439
444
440
//--------------------------------------
445
441
// BamlLocalizabilityResolver interface
446
- //--------------------------------------
442
+ //--------------------------------------
447
443
public override ElementLocalizability GetElementLocalizability ( string assembly , string className )
448
444
{
449
445
if ( _externalResolver == null
450
446
|| assembly == null || assembly . Length == 0
451
447
|| className == null || className . Length == 0 )
452
448
{
453
- // return the default value
449
+ // return the default value
454
450
return new ElementLocalizability (
455
451
null ,
456
452
DefaultAttribute
@@ -616,7 +612,7 @@ private ElementComments LookupCommentForElement(BamlStartElementNode node)
616
612
//
617
613
// The baml itself might contain comments too
618
614
// Grab the missing comments from Baml if there is any.
619
- //
615
+ //
620
616
621
617
for ( int i = 0 ;
622
618
i < node . Children . Count && ( comment . LocalizationComments . Length == 0 || comment . LocalizationAttributes . Length == 0 ) ;
@@ -636,14 +632,14 @@ private ElementComments LookupCommentForElement(BamlStartElementNode node)
636
632
else if ( LocComments . IsLocLocalizabilityProperty ( propertyNode . OwnerTypeFullName , propertyNode . PropertyName )
637
633
&& comment . LocalizationAttributes . Length == 0 )
638
634
{
639
- // grab comments from Baml
635
+ // grab comments from Baml
640
636
SetLocalizationAttributes ( node , comment , propertyNode . Value ) ;
641
637
}
642
638
}
643
639
}
644
640
}
645
641
646
- // cached it
642
+ // cached it
647
643
_comments [ _commentsIndex ] = comment ;
648
644
_commentsIndex = ( _commentsIndex + 1 ) % _comments . Length ;
649
645
@@ -652,8 +648,8 @@ private ElementComments LookupCommentForElement(BamlStartElementNode node)
652
648
653
649
private static XmlElement FindElementByID ( XmlDocument doc , string uid )
654
650
{
655
- // Have considered using XPATH. However, XPATH doesn't have a way to escape single quote within
656
- // single quotes, here we iterate through the document by ourselves
651
+ // Have considered using XPATH. However, XPATH doesn't have a way to escape single quote within
652
+ // single quotes, here we iterate through the document by ourselves
657
653
if ( doc != null && doc . DocumentElement != null )
658
654
{
659
655
foreach ( XmlNode node in doc . DocumentElement . ChildNodes )
@@ -722,13 +718,13 @@ string stringComment
722
718
}
723
719
724
720
/// <summary>
725
- /// Data structure for all the comments declared on a particular element
721
+ /// Data structure for all the comments declared on a particular element
726
722
/// </summary>
727
723
private class ElementComments
728
724
{
729
725
internal string ElementId ; // element's uid
730
726
internal PropertyComment [ ] LocalizationAttributes ; // Localization.Attributes
731
- internal PropertyComment [ ] LocalizationComments ; // Localization.Comments
727
+ internal PropertyComment [ ] LocalizationComments ; // Localization.Comments
732
728
733
729
internal ElementComments ( )
734
730
{
0 commit comments