@@ -252,9 +252,10 @@ private void SetSource()
252
252
{
253
253
while ( BindingPath . Contains ( "." ) && Source != null )
254
254
{
255
- var refName = BindingPath . Substring ( 0 , BindingPath . IndexOf ( "." ) ) ;
255
+ var dotIndex = BindingPath . IndexOf ( '.' ) ;
256
+ var refName = BindingPath . Substring ( 0 , dotIndex ) ;
256
257
_sources . Add ( new SourceReference ( this , Source , refName ) ) ;
257
- BindingPath = BindingPath . Substring ( BindingPath . IndexOf ( "." ) + 1 ) ;
258
+ BindingPath = BindingPath . Substring ( dotIndex + 1 ) ;
258
259
Source = MethodCaller . CallPropertyGetter ( Source , refName ) ;
259
260
}
260
261
}
@@ -416,7 +417,7 @@ protected virtual void SetSource(object dataItem)
416
417
}
417
418
}
418
419
419
- if ( BindingPath . IndexOf ( '.' ) > 0 )
420
+ if ( BindingPath . Contains ( '.' ) )
420
421
BindingPath = BindingPath . Substring ( BindingPath . LastIndexOf ( '.' ) + 1 ) ;
421
422
422
423
if ( isDataLoaded )
@@ -460,18 +461,19 @@ protected object GetRealSource(object source, string bindingPath)
460
461
{
461
462
if ( source is ICollectionView icv )
462
463
source = icv . CurrentItem ;
463
- if ( source != null && bindingPath . IndexOf ( '.' ) > 0 )
464
+ var dotIndex = bindingPath . IndexOf ( '.' ) ;
465
+ if ( source != null && dotIndex > 0 )
464
466
{
465
- var firstProperty = bindingPath . Substring ( 0 , bindingPath . IndexOf ( '.' ) ) ;
467
+ var firstProperty = bindingPath . Substring ( 0 , dotIndex ) ;
466
468
var p = MethodCaller . GetProperty ( source . GetType ( ) , firstProperty ) ;
467
469
if ( p != null )
468
470
{
469
471
source = GetRealSource (
470
472
MethodCaller . GetPropertyValue ( source , p ) ,
471
- bindingPath . Substring ( bindingPath . IndexOf ( '.' ) + 1 ) ) ;
473
+ bindingPath . Substring ( dotIndex + 1 ) ) ;
472
474
}
473
475
}
474
-
476
+
475
477
return source ;
476
478
}
477
479
@@ -484,15 +486,16 @@ protected PropertyPath GetRelativePath(object source, string bindingPath)
484
486
{
485
487
if ( source != null )
486
488
{
487
- if ( bindingPath . IndexOf ( '.' ) > 0 )
489
+ var dotIndex = bindingPath . IndexOf ( '.' ) ;
490
+ if ( dotIndex > 0 )
488
491
{
489
- var firstProperty = bindingPath . Substring ( 0 , bindingPath . IndexOf ( '.' ) ) ;
492
+ var firstProperty = bindingPath . Substring ( 0 , dotIndex ) ;
490
493
var p = MethodCaller . GetProperty ( source . GetType ( ) , firstProperty ) ;
491
494
492
495
if ( p != null )
493
496
return new PropertyPath ( firstProperty ) ;
494
497
else
495
- return GetRelativePath ( source , bindingPath . Substring ( bindingPath . IndexOf ( '.' ) + 1 ) ) ;
498
+ return GetRelativePath ( source , bindingPath . Substring ( dotIndex + 1 ) ) ;
496
499
}
497
500
else
498
501
return new PropertyPath ( bindingPath ) ;
0 commit comments