using System; using System.Collections.Generic; using ZeroLevel.Services.Serialization; namespace ZeroLevel.DocumentObjectModel { public sealed class DescriptiveMetadata : IBinarySerializable { public DescriptiveMetadata() { Initialize(); } public DescriptiveMetadata(IBinaryReader reader) { Deserialize(reader); } private void Initialize() { Created = DateTime.Now; Headers = new List
(); Priority = Priority.Normal; Source = new Agency(); Publisher = new Agency(); Original = new Tag(); Language = "ru"; } #region Fields /// /// Авторы (подпись) /// public string Byline; /// /// Копирайт /// public string CopyrightNotice; /// /// Дата создания /// public DateTime Created; /// /// Основной язык /// public string Language; /// /// Важность /// public Priority Priority; /// /// Источник документа (например, информационное агентство) /// public Agency Source; /// /// Издатель (Агентство) /// public Agency Publisher; /// /// Ссылка на оригинальную новость, если текущая создана на ее основе /// public Tag Original; /// /// Опциональные заголовки /// public List
Headers; #endregion #region IBinarySerializable public void Serialize(IBinaryWriter writer) { writer.WriteString(this.Byline); writer.WriteString(this.CopyrightNotice); writer.WriteDateTime(this.Created); writer.WriteCollection
(this.Headers); writer.WriteString(this.Language); this.Original.Serialize(writer); writer.WriteInt32((Int32)this.Priority); this.Publisher.Serialize(writer); this.Source.Serialize(writer); } public void Deserialize(IBinaryReader reader) { this.Byline = reader.ReadString(); this.CopyrightNotice = reader.ReadString(); this.Created = reader.ReadDateTime().Value; this.Headers = reader.ReadCollection
(); this.Language = reader.ReadString(); this.Original = new Tag(); this.Original.Deserialize(reader); this.Priority = (Priority)reader.ReadInt32(); this.Publisher = new Agency(); this.Publisher.Deserialize(reader); this.Source = new Agency(); this.Source.Deserialize(reader); } #endregion } }