From d217b6b6294c68b8bf56638a324ef06d319d5a5e Mon Sep 17 00:00:00 2001 From: alcexhim Date: Wed, 27 Jan 2016 17:02:31 -0500 Subject: [PATCH] Separate custom properties by data format --- .../UniversalEditor.Core/ObjectModel.cs | 27 ++++++++++++------- .../Microsoft/WindowsImage/WIMDataFormat.cs | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs b/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs index efff06fb..8730c03e 100644 --- a/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs +++ b/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs @@ -66,26 +66,33 @@ namespace UniversalEditor } } - private Dictionary _customProperties = new Dictionary(); - public T GetCustomProperty(string name, T defaultValue = default(T)) + private Dictionary> _customProperties = new Dictionary>(); + public T GetCustomProperty(DataFormatReference dfr, string name, T defaultValue = default(T)) { - if (_customProperties.ContainsKey(name)) + if (_customProperties.ContainsKey(dfr)) { - return (T)_customProperties[name]; + if (_customProperties[dfr].ContainsKey(name)) + { + return (T)_customProperties[dfr][name]; + } } return defaultValue; } - public object GetCustomProperty(string name, object defaultValue = null) + public object GetCustomProperty(DataFormatReference dfr, string name, object defaultValue = null) { - return GetCustomProperty(name, defaultValue); + return GetCustomProperty(dfr, name, defaultValue); } - public void SetCustomProperty(string name, T value) + public void SetCustomProperty(DataFormatReference dfr, string name, T value) { - _customProperties[name] = value; + if (!_customProperties.ContainsKey(dfr)) + { + _customProperties.Add(dfr, new Dictionary()); + } + _customProperties[dfr][name] = value; } - public void SetCustomProperty(string name, object value) + public void SetCustomProperty(DataFormatReference dfr, string name, object value) { - SetCustomProperty(name, value); + SetCustomProperty(dfr, name, value); } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Microsoft/DataFormats/FileSystem/Microsoft/WindowsImage/WIMDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Microsoft/DataFormats/FileSystem/Microsoft/WindowsImage/WIMDataFormat.cs index e9d3eed1..ea3efa50 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Microsoft/DataFormats/FileSystem/Microsoft/WindowsImage/WIMDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Microsoft/DataFormats/FileSystem/Microsoft/WindowsImage/WIMDataFormat.cs @@ -107,7 +107,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Microsoft.WindowsImage UniversalEditor.DataFormats.Markup.XML.XMLDataFormat xdf = new Markup.XML.XMLDataFormat(); Document.Load(mom, xdf, new Accessors.StringAccessor(xmlData)); - fsom.CustomProperties.Add(MakeReference(), "XMLDescriptor", mom); + fsom.SetCustomProperty(MakeReference(), "XMLDescriptor", mom); } #endregion }