Skip to content

Commit e8b9c41

Browse files
committed
TypeStringからTypeを取得する処理でErrorになった場合のcatch句を書いて、NULLを返しても無視するように修正。catch句の中身は現状は空にしてある。
1 parent 09e8f03 commit e8b9c41

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

Assets/XmlStorage/Scripts/Components/Aggregations/Aggregation.cs

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public void AddData(Elements list)
103103
var type = e.ValueType;
104104
var saveType = e.SaveType;
105105

106+
if(e.ValueType == null || saveType == null)
107+
{
108+
continue;
109+
}
106110
if(this.dictionary.ContainsKey(saveType) == false)
107111
{
108112
this.dictionary[saveType] = new Dictionary<string, object>();

Assets/XmlStorage/Scripts/Components/Data/DataElement.cs

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Reflection;
34

45
namespace XmlStorage.Components.Data
@@ -126,24 +127,27 @@ private Type GetType(string typeName)
126127
}
127128

128129
// If the TypeName is a full name, then we can try loading the defining assembly directly
129-
if(typeName.Contains("."))
130+
if(typeName.Contains(".") == true)
130131
{
131132
// Get the name of the assembly (Assumption is that we are using
132133
// fully-qualified type names)
133134
var assemblyName = typeName.Substring(0, typeName.IndexOf('.'));
134135

135136
// Attempt to load the indicated Assembly
136-
var assembly = Assembly.Load(assemblyName);
137-
if(assembly == null)
137+
try
138138
{
139-
return null;
140-
}
139+
var assembly = Assembly.Load(assemblyName);
141140

142-
// Ask that assembly to return the proper Type
143-
type = assembly.GetType(typeName);
144-
if(type != null)
141+
// Ask that assembly to return the proper Type
142+
type = assembly.GetType(typeName);
143+
if(type != null)
144+
{
145+
return type;
146+
}
147+
}
148+
catch(SystemException e) when(e is FileNotFoundException || e is NullReferenceException)
145149
{
146-
return type;
150+
return null;
147151
}
148152
}
149153

@@ -153,19 +157,22 @@ private Type GetType(string typeName)
153157

154158
foreach(var assemblyName in referencedAssemblies)
155159
{
156-
// Load the referenced assembly
157-
var assembly = Assembly.Load(assemblyName);
158-
159-
if(assembly != null)
160+
try
160161
{
162+
// Load the referenced assembly
163+
var assembly = Assembly.Load(assemblyName);
164+
161165
// See if that assembly defines the named type
162166
type = assembly.GetType(typeName);
163-
164167
if(type != null)
165168
{
166169
return type;
167170
}
168171
}
172+
catch(SystemException e) when(e is FileNotFoundException || e is NullReferenceException)
173+
{
174+
continue;
175+
}
169176
}
170177

171178
// The type just couldn't be found...

Assets/XmlStorage/Version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.0.0
1+
7.0.1
160 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)