Browse files

IResourceFactory: use new ObservableStringDictionary class

  • Loading branch information...
1 parent 674891b commit 41e96efd3ec917866198b5c20fc5c8ba84f99b09 @maul-esel committed Apr 22, 2012
View
3 ChameleonCoder.ComponentCore/IntegratedFactory.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using System.Collections.Specialized;
using ChameleonCoder.ComponentCore.Resources;
using ChameleonCoder.Plugins;
using ChameleonCoder.Resources.Interfaces;
@@ -177,7 +178,7 @@ public Brush GetBackground(Type type)
/// <param name="parent">the new resource's parent resource</param>
/// <returns>the 'blueprint' in form of a dictionary,
/// containing the attributes the resource's XmlElement should have</returns>
- public System.Collections.Specialized.StringDictionary CreateResource(Type type, string name, IResource parent)
+ public ObservableStringDictionary CreateResource(Type type, string name, IResource parent)
{
string parent_name = parent != null ? parent.Name : string.Empty;
ResourceCreator creator = new ResourceCreator(type, parent_name, name, App);
View
4 ChameleonCoder.ComponentCore/Resources/ResourceCreator.xaml.cs
@@ -198,9 +198,9 @@ private void CreateResource(object sender, EventArgs e)
/// gets the resource's future attributes
/// </summary>
/// <returns>a Dictionary&lt;string, string&gt; instance containing the attributes</returns>
- public System.Collections.Specialized.StringDictionary GetXmlAttributes()
+ public System.Collections.Specialized.ObservableStringDictionary GetXmlAttributes()
{
- var dict = new System.Collections.Specialized.StringDictionary();
+ var dict = new System.Collections.Specialized.ObservableStringDictionary();
dict.Add("name", ResName);
dict.Add("id", ResGuid.ToString("b"));
View
3 ChameleonCoder.Core/Plugins/IResourceFactory.cs
@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Windows.Media;
+using System.Collections.Specialized;
using ChameleonCoder.Resources.Interfaces;
namespace ChameleonCoder.Plugins
@@ -41,7 +42,7 @@ public interface IResourceFactory : IPlugin
/// <param name="parent">the parent resource</param>
/// <returns>a dictionary containing the attributes the resource's XML element should have</returns>
/// <remarks>this function must not create an instance of the specified resource!</remarks>
- System.Collections.Specialized.StringDictionary CreateResource(Type type, string name, IResource parent);
+ ObservableStringDictionary CreateResource(Type type, string name, IResource parent);
/// <summary>
/// gets a list of all types registered by this factory
View
16 ChameleonCoder.Core/Resources/Management/ResourceTypeManager.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Runtime.InteropServices;
using System.Windows.Media;
using ChameleonCoder.Files;
@@ -58,13 +59,15 @@ internal Guid GetKey(Type type)
return ResourceTypes.GetAlias(type);
}
+ /*
/// <summary>
/// creates an instance of the type registered with the specified alias, using the given data
/// </summary>
/// <param name="key">the resource type key of the resource type</param>
/// <param name="data">the XmlElement representing the resource</param>
/// <param name="parent">the resource's parent</param>
/// <returns>the new instance</returns>
+ [Obsolete]
internal IResource CreateInstanceOf(Guid key, System.Xml.XmlElement data, IResource parent, IDataFile file)
{
Type resourceType = GetResourceType(key);
@@ -76,6 +79,19 @@ internal IResource CreateInstanceOf(Guid key, System.Xml.XmlElement data, IResou
}
return null;
}
+ */
+
+ internal IResource CreateInstanceOf(Guid key, ObservableStringDictionary data, IResource parent, IDataFile file)
+ {
+ Type resourceType = GetResourceType(key);
+ if (resourceType != null)
+ {
+ var factory = GetFactory(resourceType);
+ if (factory != null)
+ return factory.CreateInstance(resourceType, data, parent, file);
+ }
+ return null;
+ }
/// <summary>
/// creates an instance of the specified type,

0 comments on commit 41e96ef

Please sign in to comment.