Stabilize initialization of XmlPropertyTokens
This commit is contained in:
parent
77dff70e4b
commit
0a6c8f38d4
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
@ -14,13 +15,16 @@ namespace RobloxFiles.XmlFormat
|
|||||||
{
|
{
|
||||||
// Initialize the PropertyToken handler singletons.
|
// Initialize the PropertyToken handler singletons.
|
||||||
Type IXmlPropertyToken = typeof(IXmlPropertyToken);
|
Type IXmlPropertyToken = typeof(IXmlPropertyToken);
|
||||||
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
var handlerTypes = AppDomain.CurrentDomain.GetAssemblies()
|
var handlerTypes = assembly.GetTypes()
|
||||||
.SelectMany(assembly => assembly.GetTypes())
|
.Where(type => IXmlPropertyToken.IsAssignableFrom(type))
|
||||||
.Where(type => type != IXmlPropertyToken)
|
.Where(type => type != IXmlPropertyToken);
|
||||||
.Where(type => IXmlPropertyToken.IsAssignableFrom(type));
|
|
||||||
|
var propTokens = handlerTypes
|
||||||
|
.Select(handlerType => Activator.CreateInstance(handlerType))
|
||||||
|
.Cast<IXmlPropertyToken>();
|
||||||
|
|
||||||
var propTokens = handlerTypes.Select(handlerType => Activator.CreateInstance(handlerType) as IXmlPropertyToken);
|
|
||||||
var tokenHandlers = new Dictionary<string, IXmlPropertyToken>();
|
var tokenHandlers = new Dictionary<string, IXmlPropertyToken>();
|
||||||
|
|
||||||
foreach (IXmlPropertyToken propToken in propTokens)
|
foreach (IXmlPropertyToken propToken in propTokens)
|
||||||
|
Loading…
Reference in New Issue
Block a user