internal override SoapAttribute GetSoapAttributeNoLock()
        {
            SoapAttribute tempSoapAttr = null;

            Object[] attrs = RI.GetCustomAttributes(typeof(SoapTypeAttribute), true);
            if ((attrs != null) && (attrs.Length != 0))
            {
                tempSoapAttr = (SoapAttribute)attrs[0];
            }
            else
            {
                tempSoapAttr = new SoapTypeAttribute();
            }

            // IMPORTANT: This has to be done for certain values to be automatically
            //   generated in the attribute.
            tempSoapAttr.SetReflectInfo(RI);

            return(tempSoapAttr);
        }
示例#2
0
        public EnumMap(
            Type type, QName qname, KnownTypeCollection knownTypes)
            : base(type, qname, knownTypes)
        {
            bool has_dc = false;

            object [] atts = RuntimeType.GetCustomAttributes(
                typeof(DataContractAttribute), false);
            if (atts.Length != 0)
            {
                has_dc = true;
            }
            flag_attr = type.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0;

            enum_members = new List <EnumMemberInfo> ();
            BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static;

            foreach (FieldInfo fi in RuntimeType.GetFields(flags))
            {
                string name = fi.Name;
                if (has_dc)
                {
                    EnumMemberAttribute ema =
                        GetEnumMemberAttribute(fi);
                    if (ema == null)
                    {
                        continue;
                    }

                    if (ema.Value != null)
                    {
                        name = ema.Value;
                    }
                }

                enum_members.Add(new EnumMemberInfo(name, fi.GetValue(null)));
            }
        }
示例#3
0
 /// <summary>
 /// Get all custom attributes of type <typeparamref name="A"/>.
 /// </summary>
 /// <param name="inherit">True to find inherited attribute.</param>
 /// <param name="condition">Optional predicate to check attribute properties.</param>
 /// <returns>All attributes associated with type <typeparamref name="T"/>.</returns>
 public static IEnumerable <A> GetAll(bool inherit = false, Predicate <A>?condition = null)
 => from attr in RuntimeType.GetCustomAttributes <A>(inherit)
     where condition is null || condition(attr)
 select attr;