Exemple #1
0
        protected virtual void WriteDocumentMetaConvention(ISerializationConvention convention, DocumentSerializationMeta meta)
        {
            if(convention == null)
                return;

            convention.Apply(meta, ConventionWriter);
        }
Exemple #2
0
        public DocumentJsonWriter(TextWriter textWriter, DocumentSerializationMeta documentMeta, SerializationConventions conventions, IEntityReflector entityReflector)
            : base(textWriter)
        {
            Ensure.That(documentMeta, "documentMeta").IsNotNull();
            Ensure.That(conventions, "conventions").IsNotNull();
            Ensure.That(conventions, "entityReflector").IsNotNull();

            HasWrittenDocumentMeta = false;
            DocumentMeta = documentMeta;
            Conventions = conventions;
            ConventionWriter = new SerializationConventionWriter(this);
            EntityReflector = entityReflector;
            CloseOutput = false;
        }
        protected virtual DocumentSerializationMeta CreateFor(Type docType)
        {
            var isAnonymous = CheckIfDocTypeIsAnonymous(docType);
            var metaAttr = ExtractMetaDataAttribute(docType);
            var type = metaAttr == null ? docType.Name : metaAttr.DocType ?? docType.Name;

            var meta = new DocumentSerializationMeta(docType, type, isAnonymous);
            if (metaAttr != null)
            {
                meta.DocNamespace = metaAttr.DocNamespace;
                meta.DocVersion = metaAttr.DocVersion;
            }

            return meta;
        }
Exemple #4
0
        protected virtual DocumentSerializationMeta CreateFor(Type docType)
        {
            var isAnonymous = CheckIfDocTypeIsAnonymous(docType);
            var metaAttr    = ExtractMetaDataAttribute(docType);
            var type        = metaAttr == null ? docType.Name : metaAttr.DocType ?? docType.Name;

            var meta = new DocumentSerializationMeta(docType, type, isAnonymous);

            if (metaAttr != null)
            {
                meta.DocNamespace = metaAttr.DocNamespace;
                meta.DocVersion   = metaAttr.DocVersion;
            }

            return(meta);
        }
Exemple #5
0
 protected virtual void WriteDocumentMeta(DocumentSerializationMeta meta)
 {
     WriteDocumentMetaConvention(Conventions.DocType, meta);
     WriteDocumentMetaConvention(Conventions.DocNamespace, meta);
     WriteDocumentMetaConvention(Conventions.DocVersion, meta);
 }
 public virtual void Apply(DocumentSerializationMeta meta, ISerializationConventionWriter writer)
 {
     WriteIfValueExists(Convention(meta), writer);
 }