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)); }
/// <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)); }