// PUBLIC METHODS ///////////////////////////////////////////////////
        #region Factory Methods
        public static DomReadOnlyMeta Create(Meta meta)
        {
            Contract.Requires(meta != null);

            var domReadOnlyMeta = new DomReadOnlyMeta(meta);

            return(domReadOnlyMeta);
        }
        public static DomReadOnlyMeta Create(IGetMeta getMeta)
        {
            Contract.Requires(getMeta.HasMeta());

            var meta = getMeta.Meta;

            var domReadOnlyMeta = new DomReadOnlyMeta(meta);

            return(domReadOnlyMeta);
        }
        // INTERNAL METHODS /////////////////////////////////////////////////
        #region Builder Methods
        internal DomReadOnlyMeta SetDomReadOnlyMeta(Meta meta)
        {
            Contract.Requires(meta != null);

            // Validation
            this.ValidateMetaDoesNotExist();

            // Add the one allowed DOM meta node to the DOM document node.
            var domReadOnlyMeta = this.CreateAndAddNode(() => DomReadOnlyMeta.Create(meta));

            return(domReadOnlyMeta);
        }
Exemplo n.º 4
0
        private static void ParseDocumentMeta(DomDocument domDocument, Document apiDocument)
        {
            Contract.Requires(domDocument != null);
            Contract.Requires(apiDocument != null);

            if (apiDocument.HasMeta() == false)
            {
                return;
            }

            domDocument.CreateAndAddNode(() => DomReadOnlyMeta.Create(apiDocument));
        }
Exemplo n.º 5
0
        internal DomReadWriteLink AddDomReadWriteLink(string rel, Meta meta = null)
        {
            Contract.Requires(String.IsNullOrWhiteSpace(rel) == false);

            this.ValidateLinkDoesNotExist(rel);

            var domReadWriteLink = this.CreateAndAddNode(() => DomReadWriteLink.Create(rel));

            if (meta == null)
            {
                return(domReadWriteLink);
            }

            domReadWriteLink.CreateAndAddNode(() => DomReadOnlyMeta.Create(meta));
            return(domReadWriteLink);
        }
        internal DomReadWriteRelationship AddDomReadWriteRelationship(string rel, IEnumerable <string> linkRelCollection, Meta meta = null)
        {
            Contract.Requires(String.IsNullOrWhiteSpace(rel) == false);
            Contract.Requires(linkRelCollection != null);

            this.ValidateRelationshipDoesNotExist(rel);

            var domReadWriteRelationship = this.CreateAndAddNode(() => DomReadWriteRelationship.Create(rel));

            foreach (var linkRel in linkRelCollection)
            {
                var domReadWriteLinks = domReadWriteRelationship.GetOrAddNode(DomNodeType.Links, () => DomReadWriteLinks.Create());
                domReadWriteLinks.AddDomReadWriteLink(linkRel);
            }

            if (meta == null)
            {
                return(domReadWriteRelationship);
            }

            domReadWriteRelationship.CreateAndAddNode(() => DomReadOnlyMeta.Create(meta));
            return(domReadWriteRelationship);
        }