internal static string GetFieldName( System.Reflection.MemberInfo member ) { string name; if ( _fieldNameCache.TryGetValue( member, out name ) ) return name; name = member.Name; var columnAttribute = member.GetCustomAttribute<ColumnAttribute>( false ); if ( columnAttribute != null ) name = columnAttribute.Name; if ( _fieldNameCache.TryAdd( member, name ) ) return name; return _fieldNameCache[ member ]; }
public static bool IsTupleType(System.Type type) { return type.GetCustomAttribute(typeof(Type.TupleAttribute), true) != null; }
private static EnumerationType ExploreEnum(System.Type type) { EnumerationType ddsType = new EnumerationTypeImpl(); TypeProperty typeProp = new TypePropertyImpl(); typeProp.SetName(type.FullName); typeProp.SetTypeId(type.GetHashCode()); TypeFlag flag = default(TypeFlag); //TODO flag |= (type.IsSealed? TypeFlag.IS_FINAL : 0); typeProp.SetFlag(flag); ddsType.SetProperty(typeProp); var bitbound = type.GetCustomAttribute<BitBoundAttribute>(); if (bitbound != null) { Debug.Assert(bitbound.Value >= 1 && bitbound.Value <= 32, "The Value member may Take any Value from 1 to 32, inclusive, when this annotation is applied to an enumerated type."); ddsType.SetBitBound(bitbound.Value); } else { var ut = type.GetEnumUnderlyingType(); if (ut == typeof(int) || ut == typeof(uint)) { ddsType.SetBitBound(32); } else if (ut == typeof(byte) || ut == typeof(sbyte)) { ddsType.SetBitBound(8); } else if (ut == typeof(short) || ut == typeof(ushort)) { ddsType.SetBitBound(16); } else if (ut == typeof(long) || ut == typeof(ulong)) { ddsType.SetBitBound(64); } else { throw new NotSupportedException(ut.ToString()); } } IList<EnumeratedConstant> listConstants = new List<EnumeratedConstant>(); var fields = type.GetFields(); var constantNames = type.GetEnumNames(); var constantValues = type.GetEnumValues(); for (int i = 0; i < constantNames.Length; i++) { EnumeratedConstant constant = new EnumeratedConstantImpl(); constant.SetName(constantNames[i]); constant.SetValue((int)constantValues.GetValue(i)); listConstants.Add(constant); } ddsType.SetConstant(listConstants); return ddsType; }