4 using System.Runtime.CompilerServices;
5 using SiliconStudio.Core.IO;
6 using SiliconStudio.Core.Serialization.Serializers;
8 namespace SiliconStudio.Core.Serialization
12 private static ConditionalWeakTable<object, UrlInfo> urls =
new ConditionalWeakTable<object, UrlInfo>();
16 return contentData.Url;
21 contentData.Url = url;
24 public static string GetUrl(
object obj)
27 if (contentData != null)
28 return contentData.Url;
31 var urlInfo = urls.GetValue(obj, x =>
new UrlInfo());
35 public static void SetUrl(
object obj,
string url)
38 if (contentData != null)
40 contentData.Url = url;
45 var urlInfo = urls.GetValue(obj, x =>
new UrlInfo());
57 internal const int NullIdentifier = -1;
74 public Guid Id {
get; set; }
82 public abstract string Location {
get; set; }
88 public abstract object ObjectValue {
get; set; }
93 if (ReferenceEquals(null, other))
return false;
94 if (ReferenceEquals(
this, other))
return true;
95 return Id.Equals(other.Id) && Equals(Location, other.
Location);
98 public override bool Equals(
object obj)
100 if (ReferenceEquals(null, obj))
return false;
101 if (ReferenceEquals(
this, obj))
return true;
102 if (obj.GetType() != this.GetType())
return false;
110 return (Id.GetHashCode()*397) ^ (Location != null ? Location.GetHashCode() : 0);
116 return Equals(left, right);
121 return !Equals(left, right);
127 return string.Format(
"{0}:{1}", Id, Location);
140 get {
return typeof(T); }
172 State = ContentReferenceState.Modified;
178 public override string Location
186 return UrlServices.GetUrl(value);
190 if (this.value == null)
196 UrlServices.SetUrl(this.value, value);
201 public override object ObjectValue
203 get {
return Value; }
204 set { Value = (T)value; }
220 if (contentReference == null)
222 return contentReference.Value;
static string GetUrl(object obj)
static void SetUrl(object obj, string url)
DataSerializerGenericMode
Defines what generic parameters to pass to the serializer.
static string GetUrl(IContentData contentData)
override string ToString()
override bool Equals(object obj)
ContentReference(Guid id, string location)
The type of the serialized type will be passed as a generic arguments of the serializer. Example: serializer of A becomes instantiated as Serializer{A}.
bool Equals(ContentReference other)
abstract string Location
Gets or sets the URL of the referenced data.
A typed IContentReference
static void SetUrl(IContentData contentData, string url)
override int GetHashCode()
A content data storing its own Location.