X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/3c43ec9b31676dfbeb6f413a93bd64488d6e0e28..1caef52ee05a66de6404903b1d1191afee6a4704:/trunk/Pithos.Interfaces/ObjectInfo.cs diff --git a/trunk/Pithos.Interfaces/ObjectInfo.cs b/trunk/Pithos.Interfaces/ObjectInfo.cs index a30d902..1675be1 100644 --- a/trunk/Pithos.Interfaces/ObjectInfo.cs +++ b/trunk/Pithos.Interfaces/ObjectInfo.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; namespace Pithos.Interfaces @@ -23,13 +24,56 @@ namespace Pithos.Interfaces public Dictionary 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