using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
namespace Pithos.Interfaces
public Dictionary<string, string> Extensions
{
get { return _extensions; }
- set { _extensions = value; }
+ set
+ {
+ _extensions = value;
+ ExtractKnownExtensions();
+ }
}
-
+ public long? Version { get; set; }
+ public DateTime? VersionTimeStamp { get; set; }
public Stream Stream { get; set; }
- public static ObjectInfo Empty=new ObjectInfo {Name=String.Empty,Hash=String.Empty,Bytes=0,Content_Type=String.Empty,Last_Modified=DateTime.MinValue};
+
+ private void ExtractKnownExtensions()
+ {
+ Version=GetLong("X-Object-Version");
+ VersionTimeStamp = GetTimestamp("X-Object-Version-TimeStamp");
+ }
+
+ private long? GetLong(string name)
+ {
+ string version;
+ long value;
+ if (_extensions.TryGetValue(name, out version) && long.TryParse(version, out value))
+ {
+ return value;
+ }
+ return null;
+ }
+
+ private DateTime? GetTimestamp(string name)
+ {
+ string version;
+ DateTime value;
+ if (_extensions.TryGetValue(name, out version) &&
+ DateTime.TryParse(version,CultureInfo.InvariantCulture,DateTimeStyles.AdjustToUniversal, out value))
+ {
+ return value;
+ }
+ return null;
+ }
+
+
+ public static ObjectInfo Empty = new ObjectInfo
+ {
+ Name = String.Empty,
+ Hash = String.Empty,
+ Bytes = 0,
+ Content_Type = String.Empty,
+ Last_Modified = DateTime.MinValue
+ };
}
}
\ No newline at end of file