@@ -108,9 +108,9 @@ public ICssValue Convert(StringSource source)
108108 return null ;
109109 }
110110
111- private sealed class ContentValue : ICssValue
111+ private sealed class ContentValue : ICssValue , IEquatable < ContentValue >
112112 {
113- private ICssValue [ ] _modes ;
113+ private readonly ICssValue [ ] _modes ;
114114
115115 public ContentValue ( ICssValue [ ] modes )
116116 {
@@ -124,6 +124,30 @@ public ICssValue Compute(ICssComputeContext context)
124124 var modes = _modes . Select ( mode => mode . Compute ( context ) ) . ToArray ( ) ;
125125 return new ContentValue ( modes ) ;
126126 }
127+ public Boolean Equals ( ContentValue other )
128+ {
129+ var l = _modes . Length ;
130+
131+ if ( l == other . _modes . Length )
132+ {
133+ for ( var i = 0 ; i < l ; i ++ )
134+ {
135+ var a = _modes [ i ] ;
136+ var b = other . _modes [ i ] ;
137+
138+ if ( ! a . Equals ( b ) )
139+ {
140+ return false ;
141+ }
142+ }
143+
144+ return true ;
145+ }
146+
147+ return false ;
148+ }
149+
150+ Boolean IEquatable < ICssValue > . Equals ( ICssValue other ) => other is ContentValue value && Equals ( value ) ;
127151 }
128152
129153 private abstract class ContentMode : ICssValue
@@ -134,10 +158,9 @@ private abstract class ContentMode : ICssValue
134158
135159 public abstract String GetCssText ( ) ;
136160
137- ICssValue ICssValue . Compute ( ICssComputeContext context )
138- {
139- return this ;
140- }
161+ ICssValue ICssValue . Compute ( ICssComputeContext context ) => this ;
162+
163+ public virtual Boolean Equals ( ICssValue other ) => Object . ReferenceEquals ( this , other ) ;
141164 }
142165
143166 /// <summary>
@@ -209,6 +232,16 @@ public TextContentMode(String text)
209232 public override String GetCssText ( ) => _text . CssString ( ) ;
210233
211234 public override String Stringify ( IElement element ) => _text ;
235+
236+ public override Boolean Equals ( ICssValue other )
237+ {
238+ if ( other is TextContentMode o )
239+ {
240+ return _text . Equals ( o . _text ) ;
241+ }
242+
243+ return false ;
244+ }
212245 }
213246
214247 /// <summary>
@@ -228,6 +261,16 @@ public CounterContentMode(CssCounterDefinitionValue counter)
228261 public override String GetCssText ( ) => _counter . CssText ;
229262
230263 public override String Stringify ( IElement element ) => String . Empty ;
264+
265+ public override Boolean Equals ( ICssValue other )
266+ {
267+ if ( other is CounterContentMode o )
268+ {
269+ return _counter . Equals ( o . _counter ) ;
270+ }
271+
272+ return false ;
273+ }
231274 }
232275
233276 /// <summary>
@@ -246,6 +289,16 @@ public AttributeContentMode(String attribute)
246289 public override String GetCssText ( ) => FunctionNames . Attr . CssFunction ( _attribute ) ;
247290
248291 public override String Stringify ( IElement element ) => element . GetAttribute ( _attribute ) ?? String . Empty ;
292+
293+ public override Boolean Equals ( ICssValue other )
294+ {
295+ if ( other is AttributeContentMode o )
296+ {
297+ return _attribute . Equals ( o . _attribute ) ;
298+ }
299+
300+ return false ;
301+ }
249302 }
250303
251304 /// <summary>
@@ -265,6 +318,16 @@ public UrlContentMode(CssUrlValue url)
265318 public override String GetCssText ( ) => _url . CssText ;
266319
267320 public override String Stringify ( IElement element ) => String . Empty ;
321+
322+ public override Boolean Equals ( ICssValue other )
323+ {
324+ if ( other is UrlContentMode o )
325+ {
326+ return _url . Equals ( o . _url ) ;
327+ }
328+
329+ return false ;
330+ }
268331 }
269332 }
270333 }
0 commit comments