本文整理汇总了C#中System.Reflection.PropertyInfo.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.IsDefined方法的具体用法?C# PropertyInfo.IsDefined怎么用?C# PropertyInfo.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.IsDefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalIsDefined
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
{
// walk up the hierarchy chain
if (element.IsDefined(attributeType, inherit))
return true;
if (inherit)
{
AttributeUsageAttribute usage = InternalGetAttributeUsage(attributeType);
if (!usage.Inherited)
return false;
PropertyInfo baseProp = GetParentDefinition(element);
while (baseProp != null)
{
if (baseProp.IsDefined(attributeType, false))
return true;
baseProp = GetParentDefinition(baseProp);
}
}
return false;
}
示例2: InternalIsDefined
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
{
// walk up the hierarchy chain
if (element.IsDefined(attributeType, inherit))
return true;
if (inherit)
{
AttributeUsageAttribute usage = InternalGetAttributeUsage(attributeType);
if (!usage.Inherited)
return false;
//if this is an index we need to get the parameter types to help disambiguate
Type[] indexParamTypes = GetIndexParameterTypes(element);
PropertyInfo baseProp = GetParentDefinition(element, indexParamTypes);
while (baseProp != null)
{
if (baseProp.IsDefined(attributeType, false))
return true;
baseProp = GetParentDefinition(baseProp, indexParamTypes);
}
}
return false;
}
示例3: InternalIsDefined
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
{
if (element.IsDefined(attributeType, inherit))
{
return true;
}
if (inherit)
{
AttributeUsageAttribute attributeUsageAttribute = Attribute.InternalGetAttributeUsage(attributeType);
if (!attributeUsageAttribute.Inherited)
{
return false;
}
PropertyInfo parentDefinition = Attribute.GetParentDefinition(element);
while (parentDefinition != null)
{
if (parentDefinition.IsDefined(attributeType, false))
{
return true;
}
parentDefinition = Attribute.GetParentDefinition(parentDefinition);
}
}
return false;
}
示例4: TryGetName
public static NameType TryGetName(PythonType dt, PropertyInfo pi, MethodInfo prop, out string name) {
if (pi.IsDefined(typeof(PythonHiddenAttribute), false)) {
name = null;
return NameType.None;
}
name = pi.Name;
return GetNameFromMethod(dt, prop, NameType.Property, ref name);
}
示例5: ColumnPropertyMap
/// <summary>
/// Create a new map based on the PropertyInfo provided
/// </summary>
/// <param name="property">The object property to create a map for</param>
/// <exception cref="ArgumentNullException">Thrown when the supplied property is null</exception>
public ColumnPropertyMap(PropertyInfo property)
{
if (property == null)
throw new ArgumentNullException("The property provided was null");
if (property.IsDefined(typeof(System.Data.Linq.Mapping.ColumnAttribute), true))
{
System.Data.Linq.Mapping.ColumnAttribute column = (System.Data.Linq.Mapping.ColumnAttribute)property.GetCustomAttributes(typeof(System.Data.Linq.Mapping.ColumnAttribute), true)[0];
this.ColumnName = column.Name.ToUpper();
}
else if (property.IsDefined(typeof(System.ComponentModel.DataAnnotations.Schema.ColumnAttribute), true))
{
System.ComponentModel.DataAnnotations.Schema.ColumnAttribute column = (System.ComponentModel.DataAnnotations.Schema.ColumnAttribute)property.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.Schema.ColumnAttribute), true)[0];
this.ColumnName = column.Name.ToUpper();
}
this.Property = property;
this.ObjectPropertyType = property.PropertyType;
this.GetMethod = this.CreateGetMethod();
this.SetMethod = this.CreateSetMethod();
this.SQLExists = false;
}
示例6: InternalIsDefined
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
{
if (element.IsDefined(attributeType, inherit))
return true;
if (inherit && Attribute.InternalGetAttributeUsage(attributeType).Inherited)
{
for (PropertyInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
{
if (parentDefinition.IsDefined(attributeType, false))
return true;
}
}
return false;
}
示例7: SetValue
/// <summary>
/// Set value for a property.
/// </summary>
/// <param name="property"></param>
/// <param name="value"></param>
private void SetValue(PropertyInfo property, object value)
{
//Check for type converter..
if (property.IsDefined(typeof(TypeConverterAttribute)))
{
var converterAttr = property.GetCustomAttribute<TypeConverterAttribute>();
var converter = Activator.CreateInstance(Type.GetType(converterAttr.ConverterTypeName)) as TypeConverter;
property.SetValue(this, converter.ConvertFrom(value ?? string.Empty));
}
else
{
var convert = value.TryConvertTo(property.PropertyType);
if (convert.Success)
property.SetValue(this, convert.Result);
}
}
示例8: Resolve
public override object Resolve(PropertyInfo property, object container, MappingContext context)
{
var value = base.Resolve(property, container, context);
if (property.PropertyType != typeof(String))
{
return value;
}
var localizable = container as ILocalizable;
if (localizable != null && property.IsDefined(typeof(LocalizableAttribute), false))
{
var localizedValue = localizable.GetText(property.Name, context.ApiContext.Culture);
if (!String.IsNullOrEmpty(localizedValue))
{
return localizedValue;
}
}
return value;
}
示例9: HasSuiteAttribute
public static bool HasSuiteAttribute( PropertyInfo property )
{
return property.IsDefined( SuiteType, false );
}
示例10: PropertyIsValid
static bool PropertyIsValid(PropertyInfo property)
{
return
!property.DeclaringType.IsValueType &&
!property.IsSpecialName &&
property.DeclaringType != typeof(object) &&
!property.IsDefined(typeof(CompilerGeneratedAttribute), true) &&
!property.IsDefined(typeof(ObsoleteAttribute), true);
}
示例11: InternalIsDefined
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
{
if (element.IsDefined(attributeType, inherit))
{
return true;
}
if (inherit)
{
if (!InternalGetAttributeUsage(attributeType).Inherited)
{
return false;
}
for (PropertyInfo info = GetParentDefinition(element); info != null; info = GetParentDefinition(info))
{
if (info.IsDefined(attributeType, false))
{
return true;
}
}
}
return false;
}
示例12: IsRequired
public bool IsRequired(PropertyInfo property)
{
if (property.IsDefined(typeof(RequiredAttribute), true))
return true;
if (property.IsDefined(typeof(DefaultValueAttribute), true))
return false;
if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
return false;
return property.PropertyType.IsValueType;
}
示例13: isSkip
private static Boolean isSkip( PropertyInfo info )
{
if (info.IsDefined( typeof( NotSerializeAttribute ), false )) {
return true;
}
if (info.IsDefined( typeof( NotSaveAttribute ), false )) {
return true;
}
return false;
}
示例14: CSSchemaField
internal CSSchemaField(PropertyInfo propInfo , CSSchema schema)
{
_propertyInfo = propInfo;
_schema = schema;
_fieldType = _propertyInfo.PropertyType;
_realType = _fieldType.Inspector().RealType;
RelationAttribute attRelation = (RelationAttribute) Attribute.GetCustomAttribute(propInfo,typeof(RelationAttribute),true);
_prefetch = propInfo.IsDefined(typeof(PrefetchAttribute), true);
if (attRelation != null)
{
_relation = new CSRelation(schema,attRelation);
return;
}
_lazy = propInfo.IsDefined(typeof(LazyAttribute) , true);
_noCreate = propInfo.IsDefined(typeof(NoCreateAttribute) , true);
_trim = propInfo.IsDefined(typeof(TrimAttribute), true);
_optimisticLock = propInfo.IsDefined(typeof(OptimisticLockAttribute), true);
_clientGenerated = propInfo.IsDefined(typeof(ClientGeneratedAttribute), true);
_serverGenerated = propInfo.IsDefined(typeof(ServerGeneratedAttribute), true);
_notMapped = propInfo.IsDefined(typeof (NotMappedAttribute), true);
MapToAttribute attMapTo = (MapToAttribute) Attribute.GetCustomAttribute(propInfo,typeof(MapToAttribute),true);
NullValueAttribute attNull = (NullValueAttribute) Attribute.GetCustomAttribute(propInfo,typeof(NullValueAttribute),true);
IdentityAttribute attIdentity = (IdentityAttribute)Attribute.GetCustomAttribute(propInfo, typeof(IdentityAttribute), true);
if (!_notMapped)
{
if (CSConfig.ColumnMappingOverrideMap.ContainsValue(propInfo.DeclaringType.Name + ":" + propInfo.Name))
_mappedColumn =
schema.Columns[
CSConfig.ColumnMappingOverrideMap[propInfo.DeclaringType.Name + ":" + propInfo.Name]];
else if (attMapTo != null)
_mappedColumn = schema.Columns[attMapTo.Name];
else
_mappedColumn = schema.Columns[propInfo.Name];
if (_mappedColumn != null)
_mappedColumn.MappedField = this;
}
SequenceAttribute sequenceAttribute = (SequenceAttribute) Attribute.GetCustomAttribute(propInfo,typeof(SequenceAttribute), true);
if (sequenceAttribute != null && _schema.DB.SupportsSequences)
{
_sequenceName = sequenceAttribute.SequenceName;
if (_mappedColumn != null && sequenceAttribute.Identity)
{
_mappedColumn.Identity = true;
_schema.IdentityColumn = _mappedColumn;
}
}
if (attIdentity != null)
{
if (_mappedColumn != null)
{
_mappedColumn.Identity = true;
_schema.IdentityColumn = _mappedColumn;
}
}
if (attNull != null)
{
_nullValue = attNull.NullValue;
}
else
{
Type fieldType = FieldType;
if (fieldType == typeof(string))
_nullValue = String.Empty;
else if (fieldType.IsValueType)
_nullValue = Activator.CreateInstance(fieldType);
}
if (_mappedColumn != null && _mappedColumn.ReadOnly)
{
if (_propertyInfo.CanWrite)
throw new CSException("Property [" + Name + "] for class [" + _schema.ClassType.Name + "] should be read-only");
}
}
示例15: XmlSetGump
public XmlSetGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
bool canNull = !prop.PropertyType.IsValueType;
bool canDye = prop.IsDefined( typeof( HueAttribute ), false );
bool isBody = prop.IsDefined( typeof( BodyAttribute ), false );
int xextend = 0;
if(prop.PropertyType == typeof(string))
{
xextend = 300;
}
object val = prop.GetValue( m_Object, null );
string initialText;
if ( val == null )
initialText = "";
else
initialText = val.ToString();
AddPage( 0 );
AddBackground( 0, 0, BackWidth+xextend, BackHeight + (canNull ? (EntryHeight + OffsetSize) : 0) + (canDye ? (EntryHeight + OffsetSize) : 0) + (isBody ? (EntryHeight + OffsetSize) : 0), BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth+xextend - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight + (canNull ? (EntryHeight + OffsetSize) : 0) + (canDye ? (EntryHeight + OffsetSize) : 0) + (isBody ? (EntryHeight + OffsetSize) : 0), OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth+xextend, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth+xextend - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth+xextend + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth+xextend, EntryHeight, EntryGumpID );
AddTextEntry( x + TextOffsetX, y, EntryWidth+xextend - TextOffsetX, EntryHeight, TextHue, 0, initialText );
x += EntryWidth+xextend + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
if ( canNull )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth+xextend, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth+xextend - TextOffsetX, EntryHeight, TextHue, "Null" );
x += EntryWidth+xextend + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
}
if ( canDye )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth+xextend, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth+xextend - TextOffsetX, EntryHeight, TextHue, "Hue Picker" );
x += EntryWidth+xextend + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
if ( isBody )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth+xextend, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth+xextend - TextOffsetX, EntryHeight, TextHue, "Body Picker" );
x += EntryWidth+xextend + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0 );
}
}