Tanoda
pb_ObjectContainer.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Runtime.Serialization;
3
5{
9 public interface pb_ObjectWrapper
10 {
14 object GetValue();
15 }
16
23 public class pb_ObjectContainer<T> : ISerializable, pb_ObjectWrapper
24 {
26 public T value;
27
32 {
33 this.value = value;
34 }
35
39 public static implicit operator T(pb_ObjectContainer<T> container)
40 {
41 return container.value;
42 }
43
47 public new System.Type GetType()
48 {
49 return typeof(T);
50 }
51
55 public object GetValue()
56 {
57 return (T) value;
58 }
59
63 public pb_ObjectContainer(SerializationInfo info, StreamingContext context)
64 {
65 value = (T) info.GetValue("value", typeof(T));
66 }
67
71 public void GetObjectData(SerializationInfo info, StreamingContext context)
72 {
73 info.AddValue("value", value, typeof(T));
74 }
75
76 public override string ToString()
77 {
78 return "Container: " + this.value.ToString();
79 }
80 }
81}
void GetObjectData(SerializationInfo info, StreamingContext context)
pb_ObjectContainer(SerializationInfo info, StreamingContext context)
T value
The value to be serialized.