@@ -72,7 +72,7 @@ public OptionCollection(
7272 public ReadOnlyCollection < IOption > Options => _options . AsReadOnly ( ) ;
7373 public int Count => _options . Count ;
7474
75- public void SetTypeContextKeyPrefix < TTarget > ( string prefix )
75+ public void SetTypePrefix < TTarget > ( string prefix )
7676 where TTarget : class , new ( )
7777 {
7878 var type = typeof ( TTarget ) ;
@@ -83,15 +83,15 @@ public void SetTypeContextKeyPrefix<TTarget>(string prefix)
8383 _typePrefixes . Add ( type , prefix ) ;
8484 }
8585
86- public string GetContextPathPrefix < TTarget > ( )
86+ public string GetTypePrefix < TTarget > ( )
8787 where TTarget : class , new ( )
8888 {
8989 var type = typeof ( TTarget ) ;
9090
91- if ( _typePrefixes . ContainsKey ( type ) )
92- return _typePrefixes [ type ] ;
91+ if ( _typePrefixes . ContainsKey ( type ) )
92+ return $ " { _typePrefixes [ type ] } :" ;
9393
94- return type . Name ;
94+ return TargetsMultipleTypes ? $ " { type . Name } :" : string . Empty ;
9595 }
9696
9797 public bool TargetsMultipleTypes => _options . Cast < ITypeBoundOption > ( ) . Distinct ( _comparer ) . Count ( ) > 1 ;
@@ -105,14 +105,11 @@ public IOption Add(string contextPath)
105105 return retVal ;
106106 }
107107
108- public bool Bind < TTarget , TProp > (
108+ public Option ? Bind < TTarget , TProp > (
109109 Expression < Func < TTarget , TProp > > propertySelector ,
110- out Option ? result ,
111110 params string [ ] cmdLineKeys )
112111 where TTarget : class , new ( )
113112 {
114- result = null ;
115-
116113 // walk the expression tree to extract the PropertyInfo objects defining
117114 // the path to the property of interest
118115 var propElements = new List < PropertyInfo > ( ) ;
@@ -129,7 +126,7 @@ public bool Bind<TTarget, TProp>(
129126 if ( ! ValidateProperty ( propInfo , out var curStyle ) )
130127 {
131128 Log . LogError ( $ "Property '{ propInfo . Name } ' is invalid") ;
132- return false ;
129+ return null ;
133130 }
134131
135132 firstStyle ??= curStyle ;
@@ -149,7 +146,7 @@ public bool Bind<TTarget, TProp>(
149146 if ( ! ValidateProperty ( propInfo2 , out var curStyle2 ) )
150147 {
151148 Log . LogError ( $ "Property '{ propInfo2 . Name } ' is invalid") ;
152- return false ;
149+ return null ;
153150 }
154151
155152 firstStyle ??= curStyle2 ;
@@ -172,18 +169,18 @@ public bool Bind<TTarget, TProp>(
172169
173170 propElements . Reverse ( ) ;
174171
175- result = new TypeBoundOption < TTarget > ( this , GetContextPath ( propElements ) , MasterText ) ;
172+ var retVal = new TypeBoundOption < TTarget > ( this , GetContextPath ( propElements ) , MasterText ) ;
176173
177- result . SetStyle ( firstStyle ! . Value ) ;
174+ retVal . SetStyle ( firstStyle ! . Value ) ;
178175
179176 foreach ( var key in ValidateCommandLineKeys ( cmdLineKeys ) )
180177 {
181- result . AddCommandLineKey ( key ) ;
178+ retVal . AddCommandLineKey ( key ) ;
182179 }
183180
184- _options . Add ( result ) ;
181+ _options . Add ( retVal ) ;
185182
186- return true ;
183+ return retVal ;
187184 }
188185
189186 // determines whether or not a key is being used by an existing option, honoring whatever
0 commit comments