protected override void CheckInherits(TypeUsageInfo info) { if (info.IsClass) { throw new ArgumentOutOfRangeException("info", "Trying inherits from class"); } }
protected override void CheckInherits(TypeUsageInfo info) { if (info.IsClass && Inherits.Any(t => t.IsClass)) { throw new ArgumentOutOfRangeException("info", "Trying inherits from multiply classes"); } }
public static TypeUsageInfo CreateArray(TypeUsageInfo elementType, int arrayRank) { return(new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName, elementType._configuration, new[] { elementType }) { ArrayRank = arrayRank }); }
public static TypeUsageInfo CreateNullable(TypeUsageInfo elementType) { if (!elementType.IsValueType) { return(elementType); } return(new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName, elementType._configuration | TypeUsageInfoConfiguration.Nullable, new[] { elementType })); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> public PropertyInfo(string name, TypeUsageInfo type, PropertyInvokerInfo getter, PropertyInvokerInfo setter = null) { Contract.Requires(type != null); Contract.Requires(getter != null || setter != null); Name = name; Type = type; Getter = getter; Setter = setter; }
public static TypeUsageInfo CreateNullable(TypeUsageInfo elementType) { if (!elementType.IsValueType) { return elementType; } return new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName, elementType._configuration | TypeUsageInfoConfiguration.Nullable, new[] {elementType}); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> private TypeUsageInfo(string name, string typeNamespace, string shortName, TypeUsageInfoConfiguration configuration = TypeUsageInfoConfiguration.Class, TypeUsageInfo[] typeParameters = null, TypeArgumentConfiguration typeArgumentConfiguration = null) : base(name, typeNamespace) { _configuration = configuration; Namespace = typeNamespace; ShortName = shortName; TypeArgumentConfiguration = typeArgumentConfiguration; TypeArguments = typeParameters ?? new TypeUsageInfo[0]; }
internal MSSQLTypeDesc(short typeIndex, NativeTypes baseType, string name, TypeOptions options, TypeUsageInfo typeInfo) { Contract.Requires(typeIndex > 256); Contract.Requires(typeInfo != null); Id = typeIndex; BaseType = baseType; IsDerived = Id != (short) BaseType; Name = name; Options = options; TypeInfo = typeInfo; }
public virtual void InheritsFrom(TypeUsageInfo info) { if (Inherits.Any(t => t.Equals(info))) { throw new ArgumentOutOfRangeException("info", string.Format("Type already inherits from this type {0}", info)); } if (IsGeneric && info.IsGeneric) { if (info.TypeArguments.Where(t => t.IsTypeArgument).Any(t => !TypeArguments.Contains(t))) { throw new ArgumentOutOfRangeException("info", string.Format("Trying inherit from type {0} with unknown type argument", info)); } } CheckInherits(info); _inherits.Add(info); }
private static TypeUsageInfo CreateTypeUsageInfo(Type type, TypeUsageInfo[] typeArguments = null, string shortName = null) { var name = type.Name; if (type.IsGenericTypeDefinition) { var index = name.IndexOf('`'); if (index != -1) { name = name.Substring(0, index); } } var typeNamespace = type.Namespace; if (type.IsEnum) { return(TypeUsageInfo.CreateEnum(name, typeNamespace)); } if (type.IsGenericTypeDefinition && (typeArguments == null || type.GetGenericArguments().Length != typeArguments.Length)) { throw new ArgumentOutOfRangeException("typeArguments"); } if (type.IsClass) { return(TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.Class, shortName, typeArguments)); } if (type.IsInterface) { return(TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.Interface, shortName, typeArguments)); } if (type.IsValueType) { return(TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.ValueType, shortName, typeArguments)); } throw new NotSupportedException(string.Format("Can't convert type '{0}' to TypeUsageInfo", type.FullName)); }
private static TypeUsageInfo GenerateTypeUsageInfo(this Type type, string shortName) { Contract.Requires(type != null); Contract.Requires(!type.IsGenericTypeDefinition); #region Array if (type.IsArray) { var arrayRank = type.GetArrayRank(); type = type.GetElementType(); return(TypeUsageInfo.CreateArray(type.ToUsageInfo(), arrayRank)); } #endregion #region Nullable if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = type.GetGenericArguments()[0]; return(TypeUsageInfo.CreateNullable(type.ToUsageInfo())); } #endregion var typeParameters = type.IsGenericType ? type.GetGenericArguments().Select(ToUsageInfo).ToArray() : null; return(CreateTypeUsageInfo(type.IsGenericType ? type.GetGenericTypeDefinition() : type, typeParameters, shortName)); }
private static TypeUsageInfo CreateTypeUsageInfo(Type type, TypeUsageInfo[] typeArguments = null, string shortName = null) { var name = type.Name; if (type.IsGenericTypeDefinition) { var index= name.IndexOf('`'); if (index != -1) { name = name.Substring(0, index); } } var typeNamespace = type.Namespace; if (type.IsEnum) { return TypeUsageInfo.CreateEnum(name, typeNamespace); } if (type.IsGenericTypeDefinition && (typeArguments == null || type.GetGenericArguments().Length != typeArguments.Length)) { throw new ArgumentOutOfRangeException("typeArguments"); } if (type.IsClass) { return TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.Class, shortName, typeArguments); } if (type.IsInterface) { return TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.Interface, shortName, typeArguments); } if (type.IsValueType) { return TypeUsageInfo.Create(name, typeNamespace, TypeUsageInfoConfiguration.ValueType, shortName, typeArguments); } throw new NotSupportedException(string.Format("Can't convert type '{0}' to TypeUsageInfo", type.FullName)); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> public PropertyInfo(string name, TypeUsageInfo type, bool isReadOnly = false) : this(name, type, new PropertyInvokerInfo(), new PropertyInvokerInfo {Accessibility = isReadOnly ? AccessibilityLevels.Private : AccessibilityLevels.Public}) { }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> public PropertyInfo(string name, TypeUsageInfo type, bool isReadOnly = false) : this(name, type, new PropertyInvokerInfo(), new PropertyInvokerInfo { Accessibility = isReadOnly ? AccessibilityLevels.Private : AccessibilityLevels.Public }) { }
internal static void AddHasTitleProperty(TypeUsageInfo ihastitle, EntityInfo entity, TableContent tableContent) { var prop = new PropertyInfo("EntityTitle", new FieldInfo("EntityTitle", (typeof(string)).ToUsageInfo()), new PropertyInvokerInfo(string.Format("return {0}.ToString();", tableContent.TitleFieldName)), null); prop.ExplicitInterface = ihastitle; entity.AddProperty(prop); }
internal static void AddChangeDateProperty(PropertyInfo createDateProperty, PropertyInfo changeDateProperty, TypeUsageInfo iintervalfields, EntityInfo entity) { var getter = string.Format("return {0};", changeDateProperty.Name); if(changeDateProperty.Type.IsNullable) { var createPropertyGetter = createDateProperty.Name; if (createDateProperty.Type.IsNullable) { createPropertyGetter = createDateProperty.Name + " ?? DateTime.Now"; } getter = string.Format("if({0}.HasValue) return {0}.Value; else return {1};", changeDateProperty.Name, createPropertyGetter); } var prop = new PropertyInfo(changeDateProperty.Name, (typeof(DateTime)).ToUsageInfo(), new PropertyInvokerInfo(getter), new PropertyInvokerInfo(string.Format("{0} = value;", changeDateProperty.Name))); prop.ExplicitInterface = iintervalfields; entity.AddProperty(prop); }
internal static TypeUsageInfo Create(string name, string typeNamespace, TypeUsageInfoConfiguration configuration, string shortName = null, TypeUsageInfo[] typeArguments = null) { return new TypeUsageInfo(name, typeNamespace, shortName, configuration, typeArguments); }
public static TypeUsageInfo CreateValueType(string name, string typeNamespace, TypeUsageInfo[] typeArguments = null) { return new TypeUsageInfo(name, typeNamespace, null, TypeUsageInfoConfiguration.ValueType, typeArguments); }
internal static void AddExplicitProperty(PropertyInfo property, TypeUsageInfo iintervalfields, EntityInfo entity) { if (property.Type.IsNullable) { return; } var prop = new PropertyInfo(property.Name, TypeUsageInfo.CreateNullable(property.Type), new PropertyInvokerInfo(string.Format("return {0};", property.Name)), new PropertyInvokerInfo(string.Format("if(value.HasValue){0} = value.Value; else throw new ArgumentNullException(\"value\");", property.Name))); prop.ExplicitInterface = iintervalfields; entity.AddProperty(prop); }
public static TypeUsageInfo CreateArray(TypeUsageInfo elementType, int arrayRank) { return new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName, elementType._configuration, new[] {elementType}) {ArrayRank = arrayRank}; }
public static TypeUsageInfo CreateInterface(string name, string typeNamespace, TypeUsageInfo[] typeParameters = null) { return new TypeUsageInfo(name, typeNamespace, null, TypeUsageInfoConfiguration.Interface, typeParameters); }
public SimplePropertyEntityInfo(string name, TypeUsageInfo type) : base(name, type) { IncludeToShallowCopy = true; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> private NavigationPropertyEntityInfo(string name, TypeUsageInfo type, TypeUsageInfo initializeType) : base(name, type, false) { IsVirtual = true; InitializeType = initializeType; }
protected abstract void CheckInherits(TypeUsageInfo info);