当前位置: 首页>>代码示例>>C#>>正文


C# PropertyInfo.IsDefined方法代码示例

本文整理汇总了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;
        }
开发者ID:peterdocter,项目名称:referencesource,代码行数:26,代码来源:attribute.cs

示例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;
        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:29,代码来源:Attribute.cs

示例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;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:25,代码来源:Attribute.cs

示例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);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:10,代码来源:NameConverter.cs

示例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;
        }
开发者ID:csfinch,项目名称:miata-data-access-layer,代码行数:27,代码来源:ColumnPropertyMap.cs

示例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;
 }
开发者ID:consumentor,项目名称:Server,代码行数:14,代码来源:Attribute.cs

示例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);
     }
 }
开发者ID:nicbell,项目名称:ucreate,代码行数:21,代码来源:BaseDocType.cs

示例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;
        }
开发者ID:Kooboo,项目名称:Ecommerce,代码行数:22,代码来源:IPropertyValueResolver.cs

示例9: HasSuiteAttribute

		public static bool HasSuiteAttribute( PropertyInfo property )
		{
			return property.IsDefined( SuiteType, false );
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:4,代码来源:Reflect.cs

示例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);
 }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:9,代码来源:SchemaUtility.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:Attribute.cs

示例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;
        }
开发者ID:EugeneTikhonov,项目名称:devicehive-.net,代码行数:13,代码来源:GeneratorHelper.cs

示例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;
        }
开发者ID:KevinQiangK,项目名称:wojilu,代码行数:12,代码来源:JsonString.cs

示例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");
			}
		}
开发者ID:stefandevo,项目名称:coolstorage,代码行数:89,代码来源:CSSchemaField.cs

示例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 );
			}
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:99,代码来源:XmlSetGump.cs


注:本文中的System.Reflection.PropertyInfo.IsDefined方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。