public static ResourceDocumentMetadata?FromMetadata(ResourceMetadata?resourceMetadata)
        {
            if (resourceMetadata == null)
            {
                return(null);
            }

            var ret = new ResourceDocumentMetadata();

            foreach (var field in resourceMetadata.Fields)
            {
                ret.Fields.Add(ResourceDocumentField.FromField(field));
            }
            return(ret);
        }
        public static ResourceDocument FromResourceDocument(Kinds.Resources.ResourceDocument resourceDocument)
        {
            var document = new ResourceDocument
            {
                Metadata   = ResourceDocumentMetadata.FromMetadata(resourceDocument.Metadata),
                Definition = ResourceDocumentDefinition.FromDefinition(resourceDocument.Definition),
                Spec       = ResourceDocumentSpec.FromSpec(resourceDocument.Spec),
                State      = ResourceDocumentState.FromState(resourceDocument.State)
            };

            if (resourceDocument.Kind != null)
            {
                document.Kind = new KindIdentifier
                {
                    KindName       = resourceDocument.Kind.Value.KindName,
                    KindGroup      = resourceDocument.Kind.Value.Group,
                    KindApiVersion = resourceDocument.Kind.Value.ApiVersion
                };
            }

            return(document);
        }