Mercurial > repos > snowblizz-super-API-ideas
changeset 17:a99d3b8466ba
Change "CreateFactory" method to "GetFactory" method to allow for caching
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Jan 2009 20:29:37 +0000 |
parents | bf518618eb69 |
children | 3c228f093a71 |
files | api/Factories/WarFoundryFactoryFactory.cs api/Factories/Xml/WarFoundryXmlFactory.cs |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/WarFoundryFactoryFactory.cs Sun Jan 25 14:51:24 2009 +0000 +++ b/api/Factories/WarFoundryFactoryFactory.cs Mon Jan 26 20:29:37 2009 +0000 @@ -45,11 +45,11 @@ if (factory == null) { factory = null; - MethodInfo method = cls.GetMethod("CreateFactory"); + MethodInfo method = cls.GetMethod("GetFactory"); if (method!=null) { - LogNotifier.Debug(GetType(), "Found CreateFactory method on " + cls.Name); + LogNotifier.Debug(GetType(), "Found GetFactory method on " + cls.Name); object temp = method.Invoke(null, new object[]{}); if (temp is IWarFoundryFactory)
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Jan 25 14:51:24 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Mon Jan 26 20:29:37 2009 +0000 @@ -24,12 +24,18 @@ /// </summary> public class WarFoundryXmlFactory : AbstractNativeWarFoundryFactory { + private static WarFoundryXmlFactory factory; private Dictionary<IWarFoundryObject, XmlDocument> extraData = new Dictionary<IWarFoundryObject, XmlDocument>(); private XmlResolver xmlResolver; - public static AbstractNativeWarFoundryFactory CreateFactory() + public static AbstractNativeWarFoundryFactory GetFactory() { - return new WarFoundryXmlFactory(); + if (factory == null) + { + factory = new WarFoundryXmlFactory(); + } + + return factory; } protected WarFoundryXmlFactory() : base()