Inheritance: EdiPathAttribute
コード例 #1
0
 public EdiPropertyDescriptor(PropertyInfo info, IEnumerable <EdiAttribute> attributes)
 {
     _Info = info;
     if (attributes == null)
     {
         attributes = info.GetCustomAttributes <EdiAttribute>()
                      .Concat(info.PropertyType.GetTypeInfo().GetCustomAttributes <EdiAttribute>());
         if (info.PropertyType.IsCollectionType())
         {
             var itemType = default(Type);
             if (info.PropertyType.HasElementType)
             {
                 itemType = info.PropertyType.GetElementType();
             }
             else
             {
                 itemType = Info.PropertyType.GetGenericArguments().First();
             }
             attributes = attributes.Concat(itemType.GetTypeInfo().GetCustomAttributes <EdiAttribute>());
         }
     }
     _Attributes    = attributes.ToList();
     _PathInfo      = Attributes.OfType <EdiPathAttribute>().FirstOrDefault();
     _ConditionInfo = Attributes.OfType <EdiConditionAttribute>().FirstOrDefault();
     _ValueInfo     = Attributes.OfType <EdiValueAttribute>().FirstOrDefault();
     if (_ValueInfo != null && _ValueInfo.Path != null && _PathInfo == null)
     {
         _PathInfo = new EdiPathAttribute(_ValueInfo.Path);
     }
 }
コード例 #2
0
 public EdiPropertyDescriptor(PropertyInfo info, IEnumerable<EdiAttribute> attributes) {
     _Info = info;
     if (attributes == null) {
         attributes = info.GetCustomAttributes<EdiAttribute>()
                          .Concat(info.PropertyType.GetTypeInfo().GetCustomAttributes<EdiAttribute>());
         if (info.PropertyType.IsCollectionType()) {
             var itemType = default(Type);
             if (info.PropertyType.HasElementType) {
                 itemType = info.PropertyType.GetElementType();
             } else {
                 itemType = Info.PropertyType.GetGenericArguments().First();
             }
             attributes = attributes.Concat(itemType.GetTypeInfo().GetCustomAttributes<EdiAttribute>());
         }
     }
     _Attributes = attributes.ToList();
     _PathInfo = Attributes.OfType<EdiPathAttribute>().FirstOrDefault();
     _ConditionInfo = Attributes.OfType<EdiConditionAttribute>().FirstOrDefault();
     _ValueInfo = Attributes.OfType<EdiValueAttribute>().FirstOrDefault();
     _SegmentGroupInfo = Attributes.OfType<EdiSegmentGroupAttribute>().FirstOrDefault();
     if (_ValueInfo != null && _ValueInfo.Path != null && _PathInfo == null) {
         _PathInfo = new EdiPathAttribute(_ValueInfo.Path);
     }
     if (_SegmentGroupInfo != null && _SegmentGroupInfo.StartInternal.Segment != null && _PathInfo == null) {
         _PathInfo = new EdiPathAttribute(_SegmentGroupInfo.StartInternal.Segment);
     }
 }