forked from AngleSharp/AngleSharp.Css
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlowRelativeValueConverter.cs
More file actions
45 lines (38 loc) · 1.12 KB
/
FlowRelativeValueConverter.cs
File metadata and controls
45 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#nullable disable
namespace AngleSharp.Css.Converters
{
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Css.Values;
using AngleSharp.Text;
using System;
sealed class FlowRelativeValueConverter : IValueConverter
{
private readonly IValueConverter _converter;
public FlowRelativeValueConverter(IValueConverter converter)
{
_converter = converter;
}
public ICssValue Convert(StringSource source)
{
var options = new ICssValue[2];
var length = 0;
for (var i = 0; i < options.Length; i++)
{
options[i] = _converter.Convert(source);
source.SkipSpacesAndComments();
if (options[length] != null)
{
length++;
}
}
if (length > 0)
{
var values = new ICssValue[length];
Array.Copy(options, values, length);
return new CssFlowRelativeValue(values);
}
return null;
}
}
}