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


C# PropertyInfo.HasAttribute方法代码示例

本文整理汇总了C#中System.Reflection.PropertyInfo.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.HasAttribute方法的具体用法?C# PropertyInfo.HasAttribute怎么用?C# PropertyInfo.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.PropertyInfo的用法示例。


在下文中一共展示了PropertyInfo.HasAttribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldSerialize

        static bool ShouldSerialize(PropertyInfo pi)
        {
            var ts = pi.GetCustomAttribute<InTypeScriptAttribute>();
            if (ts != null)
            {
                var v = ts.GetInTypeScript();

                if (v.HasValue)
                    return v.Value;
            }
            if (pi.HasAttribute<HiddenPropertyAttribute>() || pi.HasAttribute<ExpressionFieldAttribute>())
                return false;

            return true;
        }
开发者ID:signumsoftware,项目名称:framework,代码行数:15,代码来源:EntityJsonConverter.cs

示例2: createParameter

        public static Parameter createParameter(PropertyInfo propertyInfo, IRouteDefinition route)
        {
            var parameter = new Parameter
                                {
                                    name = propertyInfo.Name,
                                    dataType = propertyInfo.PropertyType.Name,
                                    paramType = "post",
                                    allowMultiple = false,
                                    required = propertyInfo.HasAttribute<RequiredAttribute>(),
                                    description = propertyInfo.GetAttribute<DescriptionAttribute>(a => a.Description),
                                    defaultValue = propertyInfo.GetAttribute<DefaultValueAttribute>(a => a.Value.ToString()),
                                    allowableValues = getAllowableValues(propertyInfo)
                                };

            if (route.Input.RouteParameters.Any(r => r.Name == propertyInfo.Name))
                parameter.paramType = "path";

            if (route.Input.QueryParameters.Any(r => r.Name == propertyInfo.Name))
                parameter.paramType = "query";

            return parameter;
        }
开发者ID:styson,项目名称:fubumvc-swagger,代码行数:22,代码来源:SwaggerMapper.cs

示例3: Matches

 public override bool Matches(PropertyInfo property)
 {
     return property.HasAttribute<ConnectionStringAttribute>();
 }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:4,代码来源:ResolveConnectionStringFamily.cs

示例4: Matches

 public bool Matches(PropertyInfo property)
 {
     return property.HasAttribute<MapFromWebPathAttribute>();
 }
开发者ID:cmdrkeem,项目名称:fubumvc,代码行数:4,代码来源:MapFromWebPathFamily.cs

示例5: Matches

 public override bool Matches(PropertyInfo property)
 {
     return property.HasAttribute<MapWebToPhysicalPathAttribute>();
 }
开发者ID:nieve,项目名称:fubucore,代码行数:4,代码来源:MapWebToPhysicalPathFamily.cs

示例6: InspectedProperty

        /// <summary>
        /// Initializes a new instance of the <see cref="InspectedProperty"/> class.
        /// </summary>
        /// <param name="type">
        /// The inspected type.
        /// </param>
        /// <param name="propertyInfo">
        /// The property info.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="type"/> is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="propertyInfo"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If <paramref name="propertyInfo"/> 's declaring type has not been set.
        /// </exception>
        internal InspectedProperty(Type type, PropertyInfo propertyInfo)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (propertyInfo == null)
            {
                throw new ArgumentNullException("propertyInfo");
            }

            if (propertyInfo.DeclaringType == null)
            {
                throw new ArgumentException("fieldInfo declaring type has not been set");
            }

            this.Name = propertyInfo.SerializableName();
            this.InspectedType = type;
            this.PropertyType = propertyInfo.PropertyType;
            this.IsNotNullableValueType = this.PropertyType.IsNotNullableValueType();

            if (propertyInfo.DeclaringType != propertyInfo.ReflectedType)
            {
                propertyInfo = propertyInfo.DeclaringType.GetProperty(propertyInfo.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            }

            try
            {
                this.Getter = DelegateFactory.CreateGetter(propertyInfo);
                this.Setter = DelegateFactory.CreateSetter(propertyInfo);
            }
            catch (Exception exception)
            {
                Logging.TraceException(exception);
            }

            this.Member = propertyInfo;

#if!HT4O_SERIALIZATION

            this.IdAttribute = propertyInfo.GetAttribute<IdAttribute>();

#endif

            this.IsTransient = propertyInfo.HasAttribute<TransientAttribute>() || propertyInfo.HasAttribute<IgnoreDataMemberAttribute>();
            this.Ignore = propertyInfo.HasAttribute<IgnoreAttribute>();
        }
开发者ID:andysoftdev,项目名称:ht4o,代码行数:66,代码来源:InspectedProperty.cs

示例7: Matches

 public bool Matches(PropertyInfo property)
 {
     return property.HasAttribute<BindingAttribute>();
 }
开发者ID:NTCoding,项目名称:DizzleRasta,代码行数:4,代码来源:AttributePropertyBinder.cs

示例8: Matches

 public bool Matches(PropertyInfo property)
 {
     return property.HasAttribute<ExpandEnvironmentVariablesAttribute>();
 }
开发者ID:JamieDraperUK,项目名称:fubumvc,代码行数:4,代码来源:ExpandEnvironmentVariablesFamily.cs

示例9: ShouldBeIncluded

 bool ShouldBeIncluded(PropertyInfo info)
 {
     return info.HasAttribute<ArgumentAttribute>();
 }
开发者ID:rebus-org,项目名称:GoCommando,代码行数:4,代码来源:Helper.cs

示例10: CreateValueProvider

        public static IValueProvider CreateValueProvider(object editableObject, PropertyInfo propertyInfo)
        {
            IValueProvider result = null;

            if (propertyInfo.HasAttribute<PropertyGridCustomValueProvider>())
            {
                var attribute = propertyInfo.GetAttribute<PropertyGridCustomValueProvider>();
                var derivedType = attribute.CustomValueProviderType;
                var instance = (PropertyValue)Activator.CreateInstance(derivedType);
                instance.Property = propertyInfo;
                instance.Parent = editableObject;
                instance.Type = propertyInfo.PropertyType;
                return instance;
            }
            else if (propertyInfo.PropertyType.HasInterface<IValueProvider>()
                && (result = (IValueProvider)propertyInfo.GetValue(editableObject, null)) != null)
            {
                return result;
            }
            else
            {
                return new PropertyValue(propertyInfo, editableObject);
            }
        }
开发者ID:ondrej11,项目名称:o106,代码行数:24,代码来源:ValueDiscoveryStrategy.cs

示例11: HasDoNotWireAttribute

		private static bool HasDoNotWireAttribute(PropertyInfo property)
		{
			return property.HasAttribute<DoNotWireAttribute>();
		}
开发者ID:rtr0mdrn,项目名称:Windsor,代码行数:4,代码来源:PropertiesDependenciesModelInspector.cs

示例12: IsDecoratedWithDoNotNotifyChangesAttribute

 private static bool IsDecoratedWithDoNotNotifyChangesAttribute(PropertyInfo propertyInfo)
 {
     return (propertyInfo != null && propertyInfo.HasAttribute<DoNotNotifyChangesAttribute>());
 }
开发者ID:felixthehat,项目名称:Limo,代码行数:4,代码来源:AutoNotifyProxyGenerationHook.cs


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