diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-12 17:17:05 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-12 17:17:05 +0200 |
| commit | 86acbb4902a25100a183da7ce9e7a5662de8b4cb (patch) | |
| tree | 6fb2b3897704267d3fdb5b260df51b29135577f2 /src/GraphicObjects/TemplatedControl.cs | |
| parent | ed815a31113235890cf6c902c754fb3dc7536708 (diff) | |
default template searched in embedded resources with .template extension
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 422a45ec..4745b87b 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -31,27 +31,6 @@ using System.Reflection; namespace Crow { - [AttributeUsage(AttributeTargets.Class)] - public class TemplateAttribute : Attribute - { - public string Path = ""; - public TemplateAttribute(string path) - { - Path = path; - } - } - - [AttributeUsage(AttributeTargets.Class)] - public class DefaultTemplate : TemplateAttribute - { - public DefaultTemplate(string path) : base(path){} - } - [AttributeUsage(AttributeTargets.Class)] - public class DefaultItemTemplate : TemplateAttribute - { - public DefaultItemTemplate(string path) : base(path){} - } - public abstract class TemplatedControl : PrivateContainer, IXmlSerializable { #region CTOR @@ -116,8 +95,9 @@ namespace Crow protected virtual void loadTemplate(GraphicObject template = null) { if (template == null) { - DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault(); - this.SetChild (Interface.Load (dt.Path)); + if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName)) + throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName)); + this.SetChild (Interface.Load (Interface.DefaultTemplates[this.GetType ().FullName])); }else this.SetChild (template); |