ListBucketVersions.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Xml.Serialization;
  5. namespace COSXML.Model.Tag
  6. {
  7. [XmlRoot("ListVersionsResult")]
  8. public sealed class ListBucketVersions
  9. {
  10. [XmlElement("EncodingType")]
  11. public string encodingType;
  12. [XmlElement("Name")]
  13. public string name;
  14. [XmlElement("Prefix")]
  15. public string prefix;
  16. [XmlElement("KeyMarker")]
  17. public string keyMarker;
  18. [XmlElement("VersionIdMarker")]
  19. public string versionIdMarker;
  20. [XmlElement("MaxKeys")]
  21. public long maxKeys;
  22. [XmlElement("IsTruncated")]
  23. public bool isTruncated;
  24. [XmlElement("NextKeyMarker")]
  25. public string nextKeyMarker;
  26. [XmlElement("Delimiter")]
  27. public string delimiter;
  28. [XmlElement("NextVersionIdMarker")]
  29. public string nextVersionIdMarker;
  30. [XmlElement("Version")]
  31. public List<Version> objectVersionList;
  32. [XmlElement("CommonPrefixes")]
  33. public List<CommonPrefixes> commonPrefixesList;
  34. [XmlElement("DeleteMarker")]
  35. public List<DeleteMarker> deleteMarkers;
  36. public string GetInfo()
  37. {
  38. StringBuilder stringBuilder = new StringBuilder("{ListVersionsResult:\n");
  39. stringBuilder.Append("Name:").Append(name).Append("\n");
  40. stringBuilder.Append("EncodingType:").Append(encodingType).Append("\n");
  41. stringBuilder.Append("Prefix:").Append(prefix).Append("\n");
  42. stringBuilder.Append("Delimiter:").Append(delimiter).Append("\n");
  43. stringBuilder.Append("KeyMarker:").Append(keyMarker).Append("\n");
  44. stringBuilder.Append("VersionIdMarker:").Append(versionIdMarker).Append("\n");
  45. stringBuilder.Append("MaxKeys:").Append(maxKeys).Append("\n");
  46. stringBuilder.Append("IsTruncated:").Append(isTruncated).Append("\n");
  47. stringBuilder.Append("NextKeyMarker:").Append(nextKeyMarker).Append("\n");
  48. stringBuilder.Append("NextVersionIdMarker:").Append(nextVersionIdMarker).Append("\n");
  49. if (objectVersionList != null)
  50. {
  51. foreach (Version objectVersion in objectVersionList)
  52. {
  53. if (objectVersion != null)
  54. {
  55. stringBuilder.Append(objectVersion.GetInfo()).Append("\n");
  56. }
  57. }
  58. }
  59. if (commonPrefixesList != null)
  60. {
  61. foreach (CommonPrefixes commonPrefixes in commonPrefixesList)
  62. {
  63. if (commonPrefixes != null)
  64. {
  65. stringBuilder.Append(commonPrefixes.GetInfo()).Append("\n");
  66. }
  67. }
  68. }
  69. if (deleteMarkers != null)
  70. {
  71. foreach (DeleteMarker deleteMarker in deleteMarkers)
  72. {
  73. if (deleteMarker != null)
  74. {
  75. stringBuilder.Append(deleteMarker.GetInfo()).Append("\n");
  76. }
  77. }
  78. }
  79. stringBuilder.Append("}");
  80. return stringBuilder.ToString();
  81. }
  82. public class ObjectVersion
  83. {
  84. [XmlElement("Key")]
  85. public string key;
  86. [XmlElement("VersionId")]
  87. public string versionId;
  88. [XmlElement("IsLatest")]
  89. public bool isLatest;
  90. [XmlElement("LastModified")]
  91. public string lastModified;
  92. [XmlElement("Owner")]
  93. public Owner owner;
  94. }
  95. public sealed class Owner
  96. {
  97. [XmlElement("ID")]
  98. public string uid;
  99. [XmlElement("DisplayName")]
  100. public string displayName;
  101. public string GetInfo()
  102. {
  103. StringBuilder stringBuilder = new StringBuilder("{Owner:\n");
  104. stringBuilder.Append("Uid:").Append(uid).Append("\n");
  105. stringBuilder.Append("}");
  106. return stringBuilder.ToString();
  107. }
  108. }
  109. public sealed class DeleteMarker : ObjectVersion
  110. {
  111. public string GetInfo()
  112. {
  113. StringBuilder stringBuilder = new StringBuilder("{DeleteMarker:\n");
  114. stringBuilder.Append("Key:").Append(key).Append("\n");
  115. stringBuilder.Append("VersionId:").Append(versionId).Append("\n");
  116. stringBuilder.Append("IsLatest:").Append(isLatest).Append("\n");
  117. stringBuilder.Append("LastModified:").Append(lastModified).Append("\n");
  118. if (owner != null)
  119. {
  120. stringBuilder.Append(owner.GetInfo()).Append("\n");
  121. }
  122. stringBuilder.Append("}");
  123. return stringBuilder.ToString();
  124. }
  125. }
  126. public sealed class Version : ObjectVersion
  127. {
  128. [XmlElement("ETag")]
  129. public string eTag;
  130. [XmlElement("Size")]
  131. public long size;
  132. [XmlElement("StorageClass")]
  133. public string storageClass;
  134. public string GetInfo()
  135. {
  136. StringBuilder stringBuilder = new StringBuilder("{Version:\n");
  137. stringBuilder.Append("Key:").Append(key).Append("\n");
  138. stringBuilder.Append("VersionId:").Append(versionId).Append("\n");
  139. stringBuilder.Append("IsLatest:").Append(isLatest).Append("\n");
  140. stringBuilder.Append("LastModified:").Append(lastModified).Append("\n");
  141. stringBuilder.Append("ETag:").Append(eTag).Append("\n");
  142. stringBuilder.Append("Size:").Append(size).Append("\n");
  143. stringBuilder.Append("StorageClass:").Append(storageClass).Append("\n");
  144. if (owner != null)
  145. {
  146. stringBuilder.Append(owner.GetInfo()).Append("\n");
  147. }
  148. stringBuilder.Append("}");
  149. return stringBuilder.ToString();
  150. }
  151. }
  152. public sealed class CommonPrefixes
  153. {
  154. /// <summary>
  155. /// 显示具体的 CommonPrefixes
  156. /// </summary>
  157. [XmlElement("Prefix")]
  158. public string prefix;
  159. public string GetInfo()
  160. {
  161. StringBuilder stringBuilder = new StringBuilder("{CommonPrefixes:\n");
  162. stringBuilder.Append("Prefix:").Append(prefix).Append("\n");
  163. stringBuilder.Append("}");
  164. return stringBuilder.ToString();
  165. }
  166. }
  167. }
  168. }