@@ -17,7 +17,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations.Expressions
17
17
public abstract class ExpressionNode : IDisposable
18
18
{
19
19
private List < ReferenceInfo > _objRefList = null ;
20
- private Dictionary < CompositionObject , string > _compObjToParamNameMap = null ;
20
+ private Dictionary < CompositionObject , string > _compObjToNodeNameMap = null ;
21
21
private Dictionary < string , object > _constParamMap = new Dictionary < string , object > ( StringComparer . CurrentCultureIgnoreCase ) ;
22
22
23
23
/// <summary>
@@ -144,7 +144,7 @@ public void SetMatrix4x4Parameter(string parameterName, Matrix4x4 value)
144
144
public void Dispose ( )
145
145
{
146
146
_objRefList = null ;
147
- _compObjToParamNameMap = null ;
147
+ this . _compObjToNodeNameMap = null ;
148
148
_constParamMap = null ;
149
149
Subchannels = null ;
150
150
PropertyName = null ;
@@ -227,16 +227,16 @@ internal static T CreateValueKeyword<T>(ValueKeywordKind keywordKind)
227
227
{
228
228
T node = CreateExpressionNode < T > ( ) ;
229
229
230
- ( node as ExpressionNode ) . ParamName = null ;
230
+ node . ParamName = null ;
231
231
232
232
switch ( keywordKind )
233
233
{
234
234
case ValueKeywordKind . CurrentValue :
235
- ( node as ExpressionNode ) . NodeType = ExpressionNodeType . CurrentValueProperty ;
235
+ node . NodeType = ExpressionNodeType . CurrentValueProperty ;
236
236
break ;
237
237
238
238
case ValueKeywordKind . StartingValue :
239
- ( node as ExpressionNode ) . NodeType = ExpressionNodeType . StartingValueProperty ;
239
+ node . NodeType = ExpressionNodeType . StartingValueProperty ;
240
240
break ;
241
241
242
242
default :
@@ -263,11 +263,11 @@ internal string ToExpressionString()
263
263
/// <summary>
264
264
/// Clears the reference information.
265
265
/// </summary>
266
- /// <exception cref="System. Exception">Reference and paramName can't both be null</exception>
266
+ /// <exception cref="Exception">Reference and paramName can't both be null</exception>
267
267
internal void ClearReferenceInfo ( )
268
268
{
269
269
_objRefList = null ;
270
- ParamName = null ;
270
+ this . NodeName = null ;
271
271
foreach ( var child in Children )
272
272
{
273
273
child . ClearReferenceInfo ( ) ;
@@ -277,7 +277,7 @@ internal void ClearReferenceInfo()
277
277
/// <summary>
278
278
/// Ensures the reference information.
279
279
/// </summary>
280
- /// <exception cref="System. Exception">Reference and paramName can't both be null</exception>
280
+ /// <exception cref="Exception">Reference and paramName can't both be null</exception>
281
281
internal void EnsureReferenceInfo ( )
282
282
{
283
283
if ( _objRefList == null )
@@ -290,42 +290,42 @@ internal void EnsureReferenceInfo()
290
290
HashSet < CompositionObject > compObjects = new HashSet < CompositionObject > ( ) ;
291
291
foreach ( var refNode in referenceNodes )
292
292
{
293
- if ( ( refNode . Reference != null ) && ( refNode . GetReferenceParamString ( ) == null ) )
293
+ if ( ( refNode . Reference != null ) && ( refNode . GetReferenceNodeString ( ) == null ) )
294
294
{
295
295
compObjects . Add ( refNode . Reference ) ;
296
296
}
297
297
}
298
298
299
299
// Create a map to store the generated paramNames for each CompObj
300
- _compObjToParamNameMap = new Dictionary < CompositionObject , string > ( ) ;
300
+ this . _compObjToNodeNameMap = new Dictionary < CompositionObject , string > ( ) ;
301
301
var paramCount = 0u ;
302
302
foreach ( var compObj in compObjects )
303
303
{
304
- string paramName = CreateUniqueParamNameFromIndex ( paramCount ++ ) ;
304
+ string nodeName = ! string . IsNullOrWhiteSpace ( ParamName ) ? ParamName : CreateUniqueNodeNameFromIndex ( paramCount ++ ) ;
305
305
306
- _compObjToParamNameMap . Add ( compObj , paramName ) ;
306
+ this . _compObjToNodeNameMap . Add ( compObj , nodeName ) ;
307
307
}
308
308
309
309
// Go through all reference nodes again to create our full list of referenceInfo. This time, if
310
310
// the param name is null, look it up from our new map and store it.
311
311
_objRefList = new List < ReferenceInfo > ( ) ;
312
312
foreach ( var refNode in referenceNodes )
313
313
{
314
- string paramName = refNode . GetReferenceParamString ( ) ;
314
+ string nodeName = refNode . GetReferenceNodeString ( ) ;
315
315
316
- if ( ( refNode . Reference == null ) && ( paramName == null ) )
316
+ if ( ( refNode . Reference == null ) && ( nodeName == null ) )
317
317
{
318
318
// This can't happen - if the ref is null it must be because it's a named param
319
- throw new Exception ( " Reference and paramName can't both be null") ;
319
+ throw new Exception ( $ " { nameof ( refNode . Reference ) } and { nameof ( nodeName ) } can't both be null") ;
320
320
}
321
321
322
- if ( paramName == null )
322
+ if ( nodeName == null )
323
323
{
324
- paramName = _compObjToParamNameMap [ refNode . Reference ] ;
324
+ nodeName = this . _compObjToNodeNameMap [ refNode . Reference ] ;
325
325
}
326
326
327
- _objRefList . Add ( new ReferenceInfo ( paramName , refNode . Reference ) ) ;
328
- refNode . ParamName = paramName ;
327
+ _objRefList . Add ( new ReferenceInfo ( nodeName , refNode . Reference ) ) ;
328
+ refNode . NodeName = nodeName ;
329
329
}
330
330
}
331
331
@@ -335,7 +335,7 @@ internal void EnsureReferenceInfo()
335
335
// important in this context as the only critical property to maintain is to have
336
336
// a unique mapping to each input value to the resulting sequence of letters.
337
337
[ SkipLocalsInit ]
338
- static unsafe string CreateUniqueParamNameFromIndex ( uint i )
338
+ static unsafe string CreateUniqueNodeNameFromIndex ( uint i )
339
339
{
340
340
const int alphabetLength = 'Z' - 'A' + 1 ;
341
341
@@ -592,7 +592,7 @@ private string ToExpressionStringInternal()
592
592
throw new Exception ( "References cannot have children" ) ;
593
593
}
594
594
595
- ret = ( this as ReferenceNode ) . GetReferenceParamString ( ) ;
595
+ ret = ( this as ReferenceNode ) . GetReferenceNodeString ( ) ;
596
596
}
597
597
else if ( NodeType == ExpressionNodeType . ReferenceProperty )
598
598
{
@@ -700,11 +700,17 @@ public ReferenceInfo(string paramName, CompositionObject compObj)
700
700
internal List < ExpressionNode > Children { get ; set ; } = new List < ExpressionNode > ( ) ;
701
701
702
702
/// <summary>
703
- /// Gets or sets the name of the parameter.
703
+ /// Gets or sets the user-defined name of the parameter.
704
704
/// </summary>
705
705
/// <value>The name of the parameter.</value>
706
706
internal string ParamName { get ; set ; }
707
707
708
+ /// <summary>
709
+ /// Gets or sets the unique name for the expression node. Can be user-defined or generated.
710
+ /// </summary>
711
+ /// <value>The name of the parameter.</value>
712
+ internal string NodeName { get ; set ; }
713
+
708
714
/// <summary>
709
715
/// Gets or sets the expression animation.
710
716
/// </summary>
0 commit comments