Exemplo n.º 1
0
        /// <summary>
        /// Convert a list of Obganism object into a Nap container.
        /// If the provided <paramref name="obganismSource"/> starts with a modifier list
        /// not attached to an object (as per the example below):
        ///
        /// <list type="bullet">
        /// <item> The optional <c>name</c> modifier will define the name of the container. </item>
        /// </list>
        ///
        /// Example using loose/detached modifiers:
        /// <code>
        /// -- (
        ///    name(the container name)
        /// )
        ///
        /// cat {
        ///    name : string -- in(1, 30)
        ///    is grumpy : bool -- default(true)
        /// }
        /// </code>
        /// </summary>
        ///
        /// <exception cref="ObganismException">
        /// Thrown when <paramref name="obganismSource"/> isn't valid Obganism.
        /// </exception>
        public static PartialContainer ObjectsToContainer(string obganismSource)
        {
            if (obganismSource.TrimStart().StartsWith("--"))
            {
                var obganismObjects = ObganismSerializer.Deserialize("c{}" + obganismSource);

                obganismObjects[0].Type.Name = string.Empty;

                return(ObjectsToContainer(obganismObjects));
            }

            else
            {
                return(ObjectsToContainer(ObganismSerializer.Deserialize(obganismSource)));
            }
        }
Exemplo n.º 2
0
 /// <exception cref="ObganismException">
 /// Thrown when <paramref name="obganismSource"/> isn't valid Obganism.
 /// </exception>
 public static IReadOnlyCollection <PartialResource> ObjectsToResources(string obganismSource) =>
 ObjectsToResources(ObganismSerializer.Deserialize(obganismSource));