public KmlParser( Options options, IPropertyDescriber propertyDescriber, ITypeDescriber typeDescriber ) { Options = new ReadOnlyOptions(options); this.propertyDescriber = propertyDescriber; this.typeDescriber = typeDescriber; typeStart = Options.TypeStart; }
public PropertyDescriber(Options options) { Options = new ReadOnlyOptions(options); foreach (var property in Options.Properties) { if (noPropertyFallback is null && property.Description == Options.NoPropertyFallback) { noPropertyFallback = property; } if (noOptionsFallback is null && property.Description == Options.NoOptionsFallback) { noOptionsFallback = property; } if (snippetType is null && property.Description == Options.SnippetType) { snippetType = property; } } if (noPropertyFallback is null) { throw new ParsingException($"'{nameof(noPropertyFallback)}' does not have a value."); } if (noOptionsFallback is null) { throw new ParsingException($"'{nameof(noOptionsFallback)}' does not have a value."); } if (snippetType is null) { throw new ParsingException($"'{nameof(snippetType)}' does not have a value."); } requiredOptions = () => new List <OptionParsingState <DescribesAccessibleProperty> >() { { new OptionParsingState <DescribesAccessibleProperty>(false, Options.Required.ToString().AsMemory(), description => description.Required = true) } }; rangeOption = () => new RangeParsingState <DescribesList>(false, (description, minimum, maximum) => { description.Minimum = minimum; description.Maximum = maximum; }); assetOptions = () => new List <OptionParsingState <AssetPropertyDescription> >() { { new OptionParsingState <AssetPropertyDescription>(false, "images".AsMemory(), description => description.AssetMode = AssetMode.Images) }, { new OptionParsingState <AssetPropertyDescription>(false, Options.Required.ToString().AsMemory(), description => description.Required = true) } }; textOptions = () => new List <OptionParsingState <TextPropertyDescription> >() { { new OptionParsingState <TextPropertyDescription>(false, Options.Required.ToString().AsMemory(), description => description.Required = true) } }; textDetailedOptions = () => new List <DetailsParsingState <TextPropertyDescription> >() { { new DetailsParsingState <TextPropertyDescription>(false, "words".AsMemory(), (description, details) => { if (details is not null) { var detailFound = false; foreach (var detail in details) { if (detailFound) { throw new ParsingException($"Option 'words' can only have one value."); } var detailSpan = detail.Span; if (int.TryParse(detailSpan, out var parsedDetail)) { detailFound = true; description.Words = parsedDetail; } } } }) },
public KontentTypeActivator( Options options ) { Options = new ReadOnlyOptions(options); }
public TypeDescriber( Options options ) { Options = new ReadOnlyOptions(options); }
private static bool ComparePropertiesAreEqual(PropertyInfo propInfo, ReadOnlyOptions obj1, object obj2) { return(ComparePropertiesAreEqual(propInfo, GetListOptions(obj1), obj2)); }
private static ListOptions GetListOptions(ReadOnlyOptions inOptions) { return(inOptions.GetType() .GetField("BaseOptions", BindingFlags.Instance | BindingFlags.NonPublic)? .GetValue(inOptions) as ListOptions ?? throw new Exception("Could not get BaseOptionsField")); }
private static List <PropertyInfo> CompareSetsAreEqual(ReadOnlyOptions a, ListOptions b, PropertyInfo ignore = null) { return(CompareSetsAreEqual(GetListOptions(a), b, ignore)); }