private UnitRef ParseUnitRef(JsonEntity o) { EntityMixin.CheckType(o, UNIT_REF); EntityMixin.ValueMustNotBeNull(o); if (string.IsNullOrEmpty(o.Value)) { throw new JsonFormatException(o, "Unit Ref must not be empty"); } return(new UnitRef(new Identifier(o.Value))); }
private Identifier ParseIdentifier(JsonEntity o) { EntityMixin.CheckType(o, IDENTIFIER); EntityMixin.ValueMustNotBeNull(o); if (string.IsNullOrEmpty(o.Value)) { throw new JsonFormatException(o, "Identifier must not be empty"); } return(new Identifier(o.Value)); }
private Literal ParseLiteral(JsonEntity o) { EntityMixin.CheckType(o, LITERAL); EntityMixin.ValueMustNotBeNull(o); var unitRef = ParseChildren(o).OfType <UnitRef>().FirstOrDefault(); if (unitRef == null) { throw new JsonFormatException(o, "literal unit reference not found"); } return(new Literal(o.Value, unitRef)); }
private UnitDeclaration.RefValSpec ParseRefValSpec(JsonEntity o) { EntityMixin.CheckType(o, REF_VAL_SPEC); EntityMixin.ValueMustNotBeNull(o); switch (o.Value) { case "ref": return(new UnitDeclaration.RefValSpec(isRef: true)); case "val": return(new UnitDeclaration.RefValSpec(isRef: false)); default: throw new JsonFormatException(o, $"{REF_VAL_SPEC} must be either ref or val"); } }