예제 #1
0
        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)));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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");
            }
        }