@@ -40,29 +40,59 @@ public SmartFormatter(ErrorAction errorAction)
4040
4141 public List < ISource > SourceExtensions { get ; private set ; }
4242 public List < IFormatter > FormatterExtensions { get ; private set ; }
43+
44+ /// <summary>
45+ /// Adds each extensions to this formatter.
46+ /// Each extension must implement ISource, IFormatter, or both.
47+ ///
48+ /// An exception will be thrown if the extension doesn't implement those interfaces.
49+ /// </summary>
50+ /// <param name="extensions"></param>
51+ [ Obsolete ( "Please use the specific overloads of AddExtensions()." ) ]
52+ public void AddExtensions ( params object [ ] extensions )
53+ {
54+ foreach ( var extension in extensions )
55+ {
56+ // We need to filter each extension to the correct list:
57+ var source = extension as ISource ;
58+ var formatter = extension as IFormatter ;
59+
60+ // If this object ISN'T a extension, throw an exception:
61+ if ( source == null && formatter == null )
62+ throw new ArgumentException ( string . Format ( "{0} does not implement ISource nor IFormatter." , extension . GetType ( ) . FullName ) , "extensions" ) ;
63+
64+ if ( source != null )
65+ SourceExtensions . Add ( source ) ;
66+ if ( formatter != null )
67+ FormatterExtensions . Add ( formatter ) ;
68+ }
69+ }
70+
71+ /// <summary>
72+ /// Adds each extensions to this formatter.
73+ /// Each extension must implement ISource.
74+ /// </summary>
75+ /// <param name="sourceExtensions"></param>
76+ public void AddExtensions ( params ISource [ ] sourceExtensions )
77+ {
78+ foreach ( var extension in sourceExtensions )
79+ {
80+ if ( extension != null )
81+ SourceExtensions . Add ( extension ) ;
82+ }
83+ }
84+
4385 /// <summary>
4486 /// Adds each extensions to this formatter.
45- /// Each extension must implement ISource, IFormatter, or both.
46- ///
47- /// An exception will be thrown if the extension doesn't implement those interfaces.
87+ /// Each extension must implement IFormatter.
4888 /// </summary>
49- /// <param name="extensions "></param>
50- public void AddExtensions ( params object [ ] extensions )
89+ /// <param name="formatterExtensions "></param>
90+ public void AddExtensions ( params IFormatter [ ] formatterExtensions )
5191 {
52- foreach ( var extension in extensions )
92+ foreach ( var extension in formatterExtensions )
5393 {
54- // We need to filter each extension to the correct list:
55- var source = extension as ISource ;
56- var formatter = extension as IFormatter ;
57-
58- // If this object ISN'T a extension, throw an exception:
59- if ( source == null && formatter == null )
60- throw new ArgumentException ( string . Format ( "{0} does not implement ISource nor IFormatter." , extension . GetType ( ) . FullName ) , "extensions" ) ;
61-
62- if ( source != null )
63- SourceExtensions . Add ( source ) ;
64- if ( formatter != null )
65- FormatterExtensions . Add ( formatter ) ;
94+ if ( extension != null )
95+ FormatterExtensions . Add ( extension ) ;
6696 }
6797 }
6898
0 commit comments