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 /// /// Authors /// public string Byline; /// /// Copyright /// public string CopyrightNotice; /// /// Creation date /// public DateTime Created; /// /// Main language /// public string Language; /// /// Priority /// public Priority Priority; /// /// Document source /// public Agency Source; /// /// Document publisher /// public Agency Publisher; /// /// Reference to original document /// public Tag Original; /// /// Headers (optional) /// 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 } }