コード例 #1
0
        protected XmlTypeBehaviorAttribute GetXmlTypeBehaviorOf(object instance)
        {
            Debug.Assert(instance != null);

            Type type = instance.GetType();
            XmlTypeBehaviorAttribute ret = type.GetXmlTypeBehavior();

            return(ret);
        }
コード例 #2
0
        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);
        }