AssetBase.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using OpenMetaverse;
  29. namespace OpenSim.Framework
  30. {
  31. [Serializable]
  32. public class AssetBase
  33. {
  34. private byte[] m_data;
  35. private AssetMetadata m_metadata;
  36. public AssetBase()
  37. {
  38. m_metadata = new AssetMetadata();
  39. }
  40. public AssetBase(UUID assetId, string name)
  41. {
  42. m_metadata = new AssetMetadata();
  43. m_metadata.FullID = assetId;
  44. m_metadata.Name = name;
  45. }
  46. public virtual byte[] Data
  47. {
  48. get { return m_data; }
  49. set { m_data = value; }
  50. }
  51. public UUID FullID
  52. {
  53. get { return m_metadata.FullID; }
  54. set { m_metadata.FullID = value; }
  55. }
  56. public string ID
  57. {
  58. get { return m_metadata.ID; }
  59. set { m_metadata.ID = value; }
  60. }
  61. public string Name
  62. {
  63. get { return m_metadata.Name; }
  64. set { m_metadata.Name = value; }
  65. }
  66. public string Description
  67. {
  68. get { return m_metadata.Description; }
  69. set { m_metadata.Description = value; }
  70. }
  71. public sbyte Type
  72. {
  73. get { return m_metadata.Type; }
  74. set { m_metadata.Type = value; }
  75. }
  76. public bool Local
  77. {
  78. get { return m_metadata.Local; }
  79. set { m_metadata.Local = value; }
  80. }
  81. public bool Temporary
  82. {
  83. get { return m_metadata.Temporary; }
  84. set { m_metadata.Temporary = value; }
  85. }
  86. // We have methods here because properties are serialized, and we don't
  87. // want that.
  88. public virtual AssetMetadata getMetadata()
  89. {
  90. return m_metadata;
  91. }
  92. public virtual void setMetadata(AssetMetadata metadata)
  93. {
  94. m_metadata = metadata;
  95. }
  96. }
  97. public class AssetMetadata
  98. {
  99. private UUID m_fullid;
  100. private string m_name = String.Empty;
  101. private string m_description = String.Empty;
  102. private DateTime m_creation_date;
  103. private sbyte m_type;
  104. private string m_content_type;
  105. private byte[] m_sha1;
  106. private bool m_local = false;
  107. private bool m_temporary = false;
  108. //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>();
  109. //private OSDMap m_extra_data;
  110. public UUID FullID
  111. {
  112. get { return m_fullid; }
  113. set { m_fullid = value; }
  114. }
  115. public string ID
  116. {
  117. get { return m_fullid.ToString(); }
  118. set { m_fullid = new UUID(value); }
  119. }
  120. public string Name
  121. {
  122. get { return m_name; }
  123. set { m_name = value; }
  124. }
  125. public string Description
  126. {
  127. get { return m_description; }
  128. set { m_description = value; }
  129. }
  130. public DateTime CreationDate
  131. {
  132. get { return m_creation_date; }
  133. set { m_creation_date = value; }
  134. }
  135. public sbyte Type
  136. {
  137. get { return m_type; }
  138. set { m_type = value; }
  139. }
  140. public string ContentType
  141. {
  142. get { return m_content_type; }
  143. set { m_content_type = value; }
  144. }
  145. public byte[] SHA1
  146. {
  147. get { return m_sha1; }
  148. set { m_sha1 = value; }
  149. }
  150. public bool Local
  151. {
  152. get { return m_local; }
  153. set { m_local = value; }
  154. }
  155. public bool Temporary
  156. {
  157. get { return m_temporary; }
  158. set { m_temporary = value; }
  159. }
  160. //public Dictionary<string, Uri> Methods
  161. //{
  162. // get { return m_methods; }
  163. // set { m_methods = value; }
  164. //}
  165. //public OSDMap ExtraData
  166. //{
  167. // get { return m_extra_data; }
  168. // set { m_extra_data = value; }
  169. //}
  170. }
  171. }