Stabilize initialization of XmlPropertyTokens

This commit is contained in:
CloneTrooper1019 2020-07-31 10:14:48 -05:00
parent 77dff70e4b
commit 0a6c8f38d4
2 changed files with 9 additions and 5 deletions

Binary file not shown.

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.ComponentModel;
using System.Linq;
using System.Xml;
@ -14,13 +15,16 @@ namespace RobloxFiles.XmlFormat
{
// Initialize the PropertyToken handler singletons.
Type IXmlPropertyToken = typeof(IXmlPropertyToken);
var assembly = Assembly.GetExecutingAssembly();
var handlerTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => type != IXmlPropertyToken)
.Where(type => IXmlPropertyToken.IsAssignableFrom(type));
var handlerTypes = assembly.GetTypes()
.Where(type => IXmlPropertyToken.IsAssignableFrom(type))
.Where(type => type != IXmlPropertyToken);
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>();
foreach (IXmlPropertyToken propToken in propTokens)