You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/DOM/Model/DescriptiveMetadata.cs

113 lines
2.9 KiB

6 years ago
using System;
using System.Collections.Generic;
using ZeroLevel.Services.Serialization;
namespace ZeroLevel.DocumentObjectModel
{
public sealed class DescriptiveMetadata :
6 years ago
IBinarySerializable
{
public DescriptiveMetadata()
{
Initialize();
}
public DescriptiveMetadata(IBinaryReader reader)
{
Deserialize(reader);
}
6 years ago
private void Initialize()
{
Created = DateTime.Now;
Headers = new List<Header>();
Priority = Priority.Normal;
Source = new Agency();
Publisher = new Agency();
Original = new Tag();
Language = "ru";
}
#region Fields
6 years ago
/// <summary>
/// Authors
6 years ago
/// </summary>
public string Byline;
6 years ago
/// <summary>
/// Copyright
6 years ago
/// </summary>
public string CopyrightNotice;
6 years ago
/// <summary>
/// Creation date
6 years ago
/// </summary>
public DateTime Created;
6 years ago
/// <summary>
/// Main language
6 years ago
/// </summary>
public string Language;
6 years ago
/// <summary>
/// Priority
6 years ago
/// </summary>
public Priority Priority;
6 years ago
/// <summary>
/// Document source
6 years ago
/// </summary>
public Agency Source;
6 years ago
/// <summary>
/// Document publisher
6 years ago
/// </summary>
public Agency Publisher;
6 years ago
/// <summary>
/// Reference to original document
6 years ago
/// </summary>
public Tag Original;
6 years ago
/// <summary>
/// Headers (optional)
6 years ago
/// </summary>
public List<Header> Headers;
#endregion Fields
6 years ago
#region IBinarySerializable
6 years ago
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.Byline);
writer.WriteString(this.CopyrightNotice);
writer.WriteDateTime(this.Created);
writer.WriteCollection<Header>(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;
6 years ago
this.Headers = reader.ReadCollection<Header>();
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 IBinarySerializable
6 years ago
}
}

Powered by TurnKey Linux.