From: jpbruyere Date: Thu, 11 Feb 2016 02:48:13 +0000 (+0100) Subject: pick custom attribute one by one, not in a loop X-Git-Tag: 0.3~5^2 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=15d9566610e189451da4cdbda2eee99d4bc828ae;p=jp%2Fcrow.git pick custom attribute one by one, not in a loop --- diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 4bf1ccff..76d03c49 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1381,26 +1381,15 @@ namespace Crow Debug.WriteLine ("GOML: Read only property in " + thisType.ToString() + " : " + attName); continue; } - - bool isAttribute = false; - object defaultValue = null; - - foreach (object attrib in pi.GetCustomAttributes ()) { - XmlAttributeAttribute xaa = attrib as XmlAttributeAttribute; - if (xaa != null) { - isAttribute = true; - if (!string.IsNullOrEmpty (xaa.AttributeName)) - attName = xaa.AttributeName; - continue; - } - if (attrib is XmlIgnoreAttribute) - break; - DefaultValueAttribute dv = attrib as DefaultValueAttribute; - if (dv != null) - defaultValue = dv.Value; + XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute)); + if (xaa != null) { + if (!string.IsNullOrEmpty (xaa.AttributeName)) + attName = xaa.AttributeName; } - - + DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute)); + object defaultValue = null; + if (dv != null) + defaultValue = dv.Value; if (attValue.StartsWith("{")) { //binding if (!attValue.EndsWith("}")) @@ -1409,8 +1398,9 @@ namespace Crow this.Bindings.Add (new Binding (new MemberReference(this, pi), attValue.Substring (1, attValue.Length - 2))); continue; } - - if (!isAttribute) + if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null) + continue; + if (xaa == null)//not define as xmlAttribute continue; if (pi.PropertyType == typeof(string)) {