Time Rewizer  v.1.1
Created by: Mark Oostveen
MarkOostveen.TimeRewizer.ObjectSerializer Struct Reference

Struct used to keep serialized data to survive unity hotswapp More...

+ Collaboration diagram for MarkOostveen.TimeRewizer.ObjectSerializer:

Public Member Functions

 ObjectSerializer (object value, ISerializeableObjectContainer linkedobj, bool serializeSnapshot, string tag="")
 creates a new instance, and serializes object to a string. More...
 
bool Deserialize (string[] assemblies, Module[] unreferencedmodules=null)
 Deserializes object internaly, object can be obtained using the GetValue More...
 
bool Deserialize (ref Module[] manifestModules)
 Deserialize object from string using given assembly modules More...
 

Static Public Member Functions

static Module [] AssemblyNamesToManifestModules (string[] assemblies)
 Create Assembly module array from assembly name array More...
 
static Type SearchType (ref Module[] modules, string typename)
 Search a type using assembly modules More...
 

Public Attributes

string ValueString => m_Value
 get Serialized string value More...
 
string TagName => m_Tag
 Get tag of object serializer More...
 
string TypeName => m_TypeName
 fullname of containing type More...
 

Properties

object GetValue [get]
 Returns Value More...
 

Detailed Description

Struct used to keep serialized data to survive unity hotswapp

Constructor & Destructor Documentation

◆ ObjectSerializer()

MarkOostveen.TimeRewizer.ObjectSerializer.ObjectSerializer ( object  value,
ISerializeableObjectContainer  linkedobj,
bool  serializeSnapshot,
string  tag = "" 
)

creates a new instance, and serializes object to a string.

Parameters
value
linkedobj
serializeSnapshot
tag
23  {
24  Type[] types;
25 
26  if (serializeSnapshot)
27  {
28  m_Value = Serialization.SerializeSnapshot(value, out types);
29  }
30  else
31  {
32  m_Value = Serialization.SerializeNormal(value, out types);
33  }
34 
35  List<Module> manifestList = new List<Module>()
36  {
37  value.GetType().Assembly.ManifestModule
38  };
39 
40  for (int i = 0; i < types.Length; i++)
41  {
42  if (!manifestList.Contains(types[i].Assembly.ManifestModule))
43  {
44  manifestList.Add(types[i].Assembly.ManifestModule);
45  }
46  }
47 
48  for (int i = 0; i < manifestList.Count; i++)
49  {
50  if (manifestList[i].Assembly.GetName().Name != Assembly.GetExecutingAssembly().GetName().Name
51  && !linkedobj.Assemblies.Contains(manifestList[i].Assembly.GetName().Name))
52  {
53  linkedobj.Assemblies.Add(manifestList[i].Assembly.GetName().Name);
54  }
55  }
56 
57  m_TypeName = value.GetType().ToString();
58 
59  GetValue = value;
60  m_Tag = tag;
61  m_SerializedSnapshot = serializeSnapshot;
62  }
+ Here is the call graph for this function:

Member Function Documentation

◆ AssemblyNamesToManifestModules()

static Module [] MarkOostveen.TimeRewizer.ObjectSerializer.AssemblyNamesToManifestModules ( string []  assemblies)
static

Create Assembly module array from assembly name array

Parameters
assemblies
Returns
157  {
158  List<Module> modules = new List<Module>();
159 
160  for (int i = 0; i < assemblies.Length; i++)
161  {
162  Module assembly = Assembly.Load(assemblies[i]).ManifestModule;
163  if (!modules.Contains(assembly))
164  {
165  modules.Add(assembly);
166  }
167  }
168 
169  return modules.ToArray();
170  }

◆ Deserialize() [1/2]

bool MarkOostveen.TimeRewizer.ObjectSerializer.Deserialize ( string []  assemblies,
Module []  unreferencedmodules = null 
)

Deserializes object internaly, object can be obtained using the GetValue

Parameters
assemblies
unreferencedmodules
98  {
99  bool references = unreferencedmodules != null;
100 
101  Module[] manifestmodules;
102 
103  if (references)
104  {
105  manifestmodules = new Module[assemblies.Length + unreferencedmodules.Length];
106 
107  for (int i = 0; i < unreferencedmodules.Length; i++)
108  {
109  manifestmodules[i] = unreferencedmodules[i];
110  }
111  }
112  else
113  {
114  manifestmodules = new Module[assemblies.Length];
115  }
116 
117  for (int i = 0; i < assemblies.Length; i++)
118  {
119  if (references)
120  {
121  manifestmodules[unreferencedmodules.Length + i] = Assembly.Load(assemblies[i]).ManifestModule;
122  }
123  else
124  {
125  manifestmodules[i] = Assembly.Load(assemblies[i]).ManifestModule;
126  }
127  }
128 
129  return Deserialize(ref manifestmodules);
130  }
+ Here is the caller graph for this function:

◆ Deserialize() [2/2]

bool MarkOostveen.TimeRewizer.ObjectSerializer.Deserialize ( ref Module []  manifestModules)

Deserialize object from string using given assembly modules

Parameters
manifestModules
Returns
138  {
139  if (m_SerializedSnapshot)
140  {
141  GetValue = Serialization.DeserializeSnapshot(m_Value, manifestModules);
142  }
143  else
144  {
145  GetValue = Serialization.DeserializeObject(m_Value, manifestModules);
146  }
147 
148  return GetValue != null;
149  }
+ Here is the call graph for this function:

◆ SearchType()

static Type MarkOostveen.TimeRewizer.ObjectSerializer.SearchType ( ref Module []  modules,
string  typename 
)
static

Search a type using assembly modules

Parameters
modules
typename
Returns
179  {
180  return Serialization.GetType(ref modules, typename);
181  }
+ Here is the call graph for this function:

Member Data Documentation

◆ TagName

string MarkOostveen.TimeRewizer.ObjectSerializer.TagName => m_Tag

Get tag of object serializer

◆ TypeName

string MarkOostveen.TimeRewizer.ObjectSerializer.TypeName => m_TypeName

fullname of containing type

◆ ValueString

string MarkOostveen.TimeRewizer.ObjectSerializer.ValueString => m_Value

get Serialized string value

Property Documentation

◆ GetValue

object MarkOostveen.TimeRewizer.ObjectSerializer.GetValue
get

Returns Value

85 { get; private set; }