コード例 #1
0
        public ConstantValue GetFieldValue(string name)
        {
            FieldInfo field = attrib.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public);

            if (field != null && ReflectorAttributeUtils.IsAttributeField(Reflector.Wrap(field)))
            {
                return(ConstantValue.FromNative(field.GetValue(attrib)));
            }

            throw new ArgumentException(String.Format("The attribute does not have a writable instance field named '{0}'.", name));
        }
コード例 #2
0
        /// <inheritdoc />
        public ConstantValue GetFieldValue(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            foreach (KeyValuePair <StaticFieldWrapper, ConstantValue> entry in FieldArguments)
            {
                if (entry.Key.Name == name)
                {
                    return(entry.Value);
                }
            }

            IFieldInfo field = Type.GetField(name, BindingFlags.Public | BindingFlags.Instance);

            if (field != null && ReflectorAttributeUtils.IsAttributeField(field))
            {
                return(ConstantValue.FromNative(ReflectionUtils.GetDefaultValue(field.ValueType.TypeCode)));
            }

            throw new ArgumentException(String.Format("The attribute does not have a writable instance field named '{0}'.", name));
        }