11using System ;
2- using System . Collections . Generic ;
32
43namespace ExCSS
54{
65 public sealed class AttributeSelectorFactory
76 {
87 private static readonly Lazy < AttributeSelectorFactory > Lazy = new ( ( ) => new AttributeSelectorFactory ( ) ) ;
98
10- private readonly Dictionary < string , Type > _types = new ( )
11- {
12- { Combinators . Exactly , typeof ( AttrMatchSelector ) } ,
13- { Combinators . InList , typeof ( AttrListSelector ) } ,
14- { Combinators . InToken , typeof ( AttrHyphenSelector ) } ,
15- { Combinators . Begins , typeof ( AttrBeginsSelector ) } ,
16- { Combinators . Ends , typeof ( AttrEndsSelector ) } ,
17- { Combinators . InText , typeof ( AttrContainsSelector ) } ,
18- { Combinators . Unlike , typeof ( AttrNotMatchSelector ) } ,
19- } ;
20-
219 private AttributeSelectorFactory ( )
2210 {
2311 }
@@ -34,11 +22,23 @@ public IAttrSelector Create(string combinator, string match, string value, strin
3422 _ = AttributeSelectorFactory . FormMatch ( prefix , match ) ;
3523 }
3624
37- return _types . TryGetValue ( combinator , out var type )
38- ? ( IAttrSelector ) Activator . CreateInstance ( type , name , value )
39- : new AttrAvailableSelector ( name , value ) ;
25+ if ( combinator == Combinators . Exactly )
26+ return new AttrMatchSelector ( name , value ) ;
27+ if ( combinator == Combinators . InList )
28+ return new AttrListSelector ( name , value ) ;
29+ if ( combinator == Combinators . InToken )
30+ return new AttrHyphenSelector ( name , value ) ;
31+ if ( combinator == Combinators . Begins )
32+ return new AttrBeginsSelector ( name , value ) ;
33+ if ( combinator == Combinators . Ends )
34+ return new AttrEndsSelector ( name , value ) ;
35+ if ( combinator == Combinators . InText )
36+ return new AttrContainsSelector ( name , value ) ;
37+ if ( combinator == Combinators . Unlike )
38+ return new AttrNotMatchSelector ( name , value ) ;
39+ return new AttrAvailableSelector ( name , value ) ;
4040 }
41-
41+
4242 private static string FormFront ( string prefix , string match )
4343 {
4444 return string . Concat ( prefix , Combinators . Pipe , match ) ;
0 commit comments