From dd6682973fa16921b7ebaf5faa416290c3211c63 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Thu, 25 Feb 2016 11:35:03 +0100 Subject: [PATCH] replace StyleAttribute=>DefaultStyle --- src/GraphicObjects/GraphicObject.cs | 15 +++++++-------- src/GraphicObjects/TemplatedControl.cs | 16 +++------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 23748b3a..e8453937 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -438,7 +438,7 @@ namespace Crow (LogicalParent as GraphicObject).DataSource : dataSource; } } - [XmlAttributeAttribute][DefaultValue(null)] + [XmlAttributeAttribute] public virtual string Style { get { return style; } set { @@ -484,8 +484,6 @@ namespace Crow il.Emit(OpCodes.Nop); - StyleAttribute[] style = thisType.GetCustomAttributes().OfType().ToArray(); - foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { string name = ""; object defaultValue = null; @@ -504,16 +502,17 @@ namespace Crow else name = xaa.AttributeName; } - - StyleAttribute piStyle = style.Where(s => s.PropertyName == pi.Name).FirstOrDefault(); - if (piStyle != null){ - defaultValue = piStyle.DefaultValue; + if (name == "Style"){ + //retrieve default value from class attribute + DefaultStyle defStyle = thisType.GetCustomAttribute(); + if (defStyle != null) + defaultValue = defStyle.Path; }else{ DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute)); if (dv == null) continue; defaultValue = dv.Value; - } + } #endregion il.Emit (OpCodes.Ldarg_0); diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index c1c48fc7..f09d10aa 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -28,7 +28,7 @@ using System.Diagnostics; namespace Crow { -// [AttributeUsage(AttributeTargets.Class)] + [AttributeUsage(AttributeTargets.Class)] public class TemplateAttribute : Attribute { public string Path = ""; @@ -38,14 +38,9 @@ namespace Crow } } [AttributeUsage(AttributeTargets.Class)] - public class StyleAttribute : Attribute + public class DefaultStyle : TemplateAttribute { - public string PropertyName = ""; - public object DefaultValue = null; - public StyleAttribute(string _property, object _defValue){ - PropertyName = _property; - DefaultValue = _defValue; - } + public DefaultStyle(string path) : base(path){} } [AttributeUsage(AttributeTargets.Class)] public class DefaultTemplate : TemplateAttribute @@ -53,11 +48,6 @@ namespace Crow public DefaultTemplate(string path) : base(path){} } [AttributeUsage(AttributeTargets.Class)] - public class DefaultOverlayTemplate : TemplateAttribute - { - public DefaultOverlayTemplate(string path) : base(path){} - } - [AttributeUsage(AttributeTargets.Class)] public class DefaultItemTemplate : TemplateAttribute { public DefaultItemTemplate(string path) : base(path){} -- 2.47.3