public static int ParseAndValidateRequiredResourceIndex(this IThreeMfPropertyResource propertyResource, XElement element, string attributeName) { var index = element.AttributeIntValueOrThrow(attributeName); propertyResource.ValidatePropertyIndex(index); return(index); }
public static int?ParseAndValidateOptionalResourceIndex(this IThreeMfPropertyResource propertyResource, XElement element, string attributeName) { var attribute = element.Attribute(attributeName); if (attribute == null) { return(null); } if (!int.TryParse(attribute.Value, out var index)) { throw new ThreeMfParseException($"Property index '{attribute.Value}' is not an int."); } propertyResource.ValidatePropertyIndex(index); return(index); }