2 using System.Collections.Generic;
3 using System.Globalization;
6 namespace Pithos.Interfaces
8 public class ObjectInfo
10 public string Name { get; set; }
11 public string Hash { get; set; }
12 public long Bytes { get; set; }
13 public string Content_Type { get; set; }
14 public DateTime Last_Modified { get; set; }
16 private Dictionary<string, string> _tags=new Dictionary<string, string>();
17 public Dictionary<string, string> Tags
20 set { _tags = value; }
23 private Dictionary<string, string> _extensions=new Dictionary<string, string>();
24 public Dictionary<string, string> Extensions
26 get { return _extensions; }
30 ExtractKnownExtensions();
34 private long? _version;
37 get { return _version; }
38 set { _version = value; }
41 //Alias for version, for Json deserialization purposes
42 public long? X_Object_Version
44 get { return _version; }
45 set { _version = value; }
48 //Alias for VersionTimestamp, for Json deserialization purposes
49 //The x_object_version_timestamp returned by GET on a container is
50 //a float, probably due to a bug.
51 public double? X_Object_Version_Timestamp
55 if (_versionTimestamp.HasValue)
56 return (_versionTimestamp.Value-_epoch).TotalSeconds;
63 _versionTimestamp = _epoch.AddSeconds(value.Value);
67 _versionTimestamp = null;
72 private DateTime? _versionTimestamp;
73 public DateTime? VersionTimestamp
75 get { return _versionTimestamp; }
76 set { _versionTimestamp = value; }
79 public string ModifiedBy
81 get{ return _modifiedBy; }
82 set{ _modifiedBy = value; }
85 //Alias for ModifiedBy, for Json deserialization purposes
86 public string X_Object_Modified_By
88 get{ return _modifiedBy; }
89 set{ _modifiedBy = value; }
92 public Stream Stream { get; set; }
95 private void ExtractKnownExtensions()
97 Version=GetLong(KnownExtensions.X_Object_Version);
98 VersionTimestamp = GetTimestamp(KnownExtensions.X_Object_Version_Timestamp);
99 ModifiedBy = GetString(KnownExtensions.X_Object_Modified_By);
102 private string GetString(string name)
104 var value=String.Empty;
105 _extensions.TryGetValue(name, out value);
109 private long? GetLong(string name)
113 return _extensions.TryGetValue(name, out version) && long.TryParse(version, out value)
118 private DateTime? GetTimestamp(string name)
122 if (_extensions.TryGetValue(name, out version) &&
123 DateTime.TryParse(version,CultureInfo.InvariantCulture,DateTimeStyles.AdjustToUniversal, out value))
131 public static ObjectInfo Empty = new ObjectInfo
136 Content_Type = String.Empty,
137 Last_Modified = DateTime.MinValue
140 private string _modifiedBy;
141 private DateTime _epoch = new DateTime(1970, 1, 1);