protected XmlTypeBehaviorAttribute GetXmlTypeBehaviorOf(object instance) { Debug.Assert(instance != null); Type type = instance.GetType(); XmlTypeBehaviorAttribute ret = type.GetXmlTypeBehavior(); return(ret); }
public static XmlTypeBehaviorAttribute GetXmlTypeBehavior(this Type type) { var attrs = type.GetCustomAttributes(false); XmlTypeBehaviorAttribute ret = (XmlTypeBehaviorAttribute) attrs.FirstOrDefault(i => i is XmlTypeBehaviorAttribute); if (ret == null) { ret = new XmlTypeBehaviorAttribute(); } else { ret.DoValidityTest(); } return(ret); }