/// <summary> /// Initializes a new instance of the TsProperty class with the specific CLR property. /// </summary> /// <param name="memberInfo">The CLR property represented by this instance of the TsProperty.</param> public TsProperty(System.Reflection.PropertyInfo memberInfo) { this.MemberInfo = memberInfo; this.Name = memberInfo.Name; var propertyType = memberInfo.PropertyType; if (propertyType.IsNullable()) { propertyType = propertyType.GetNullableValueType(); } this.GenericArguments = propertyType.IsGenericType ? propertyType.GetGenericArguments().Select(o => new TsType(o)).ToArray() : new TsType[0]; this.PropertyType = propertyType.IsEnum ? new TsEnum(propertyType) : new TsType(propertyType); var attribute = memberInfo.GetCustomAttribute <TsPropertyAttribute>(false); if (attribute != null) { if (!string.IsNullOrEmpty(attribute.Name)) { this.Name = attribute.Name; } this.IsOptional = attribute.IsOptional; } this.IsIgnored = (memberInfo.GetCustomAttribute <TsIgnoreAttribute>(false) != null); // Only fields can be constants. this.ConstantValue = null; }
internal static IFieldMapper <T> Build <T>(System.Reflection.PropertyInfo p, Version version, Analyzer externalAnalyzer) { var boost = p.GetCustomAttribute <DocumentBoostAttribute>(true); if (boost != null) { return(new ReflectionDocumentBoostMapper <T>(p)); } var score = p.GetCustomAttribute <QueryScoreAttribute>(true); if (score != null) { return(new ReflectionScoreMapper <T>(p)); } var metadata = p.GetCustomAttribute <FieldAttribute>(true); var numericFieldAttribute = p.GetCustomAttribute <NumericFieldAttribute>(true); Type type; var isCollection = IsCollection(p.PropertyType, out type); ReflectionFieldMapper <T> mapper; if (numericFieldAttribute != null) { mapper = NumericFieldMappingInfoBuilder.BuildNumeric <T>(p, type, numericFieldAttribute); } else { mapper = BuildPrimitive <T>(p, type, metadata, version, externalAnalyzer); } return(isCollection ? new CollectionReflectionFieldMapper <T>(mapper, type) : mapper); }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { var classAttribute = property.DeclaringType.GetCustomAttributeByReflection<AuthorizePropertyAttribute>(); var propertyAttribute = property.GetCustomAttribute<AuthorizePropertyAttribute>(); if (classAttribute != null && propertyAttribute != null) { Log.WarnFormat("Class and property level AuthorizeAttributes applied to class {0} - ignoring attribute on property {1}", property.DeclaringType.FullName, property.Name); } return Create(classAttribute ?? propertyAttribute, holder); }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { if ((property.PropertyType.IsPrimitive || TypeUtils.IsEnum(property.PropertyType)) && property.GetCustomAttribute<OptionallyAttribute>() != null) { Log.Warn("Ignoring Optionally annotation on primitive or un-readable parameter on " + property.ReflectedType + "." + property.Name); return false; } if (property.GetGetMethod() != null && !property.PropertyType.IsPrimitive) { return Process(property, holder); } return false; }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { UpdateScratchPad(property.ReflectedType); Attribute attribute = property.GetCustomAttribute<DisplayNameAttribute>() ?? (Attribute) property.GetCustomAttribute<NamedAttribute>(); return FacetUtils.AddFacet(CreateProperty(attribute, holder)); }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { var attribute = property.GetCustomAttribute<EnumDataTypeAttribute>(); return AddEnumFacet(attribute, holder, property.PropertyType); }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { Attribute attribute = property.GetCustomAttribute<ConcurrencyCheckAttribute>(); return FacetUtils.AddFacet(Create(attribute, holder)); }
public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) { var attribute = property.GetCustomAttribute<EagerlyAttribute>(); return FacetUtils.AddFacet(Create(attribute, holder)); }