Skip to content

Commit

Permalink
IResourceFactory: use new ObservableStringDictionary class
Browse files Browse the repository at this point in the history
  • Loading branch information
maul.esel committed Apr 22, 2012
1 parent 674891b commit 41e96ef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ChameleonCoder.ComponentCore/IntegratedFactory.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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"));
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions 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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 41e96ef

Please sign in to comment.