예제 #1
0
 protected override void CheckInherits(TypeUsageInfo info)
 {
     if (info.IsClass)
     {
         throw new ArgumentOutOfRangeException("info", "Trying inherits from class");
     }
 }
예제 #2
0
 protected override void CheckInherits(TypeUsageInfo info)
 {
     if (info.IsClass && Inherits.Any(t => t.IsClass))
     {
         throw new ArgumentOutOfRangeException("info", "Trying inherits from multiply classes");
     }
 }
예제 #3
0
 protected override void CheckInherits(TypeUsageInfo info)
 {
     if (info.IsClass)
     {
         throw new ArgumentOutOfRangeException("info", "Trying inherits from class");
     }
 }
예제 #4
0
 public static TypeUsageInfo CreateArray(TypeUsageInfo elementType, int arrayRank)
 {
     return(new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName,
                              elementType._configuration, new[] { elementType })
     {
         ArrayRank = arrayRank
     });
 }
예제 #5
0
 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 }));
 }
예제 #6
0
        /// <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;
        }
예제 #7
0
 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});
 }
예제 #8
0
        /// <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;
        }
예제 #9
0
 /// <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];
 }
예제 #10
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;
        }
예제 #11
0
 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);
 }
예제 #12
0
        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));
        }
예제 #13
0
 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));
 }
예제 #14
0
        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));
        }
예제 #15
0
 /// <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})
 {
 }
예제 #16
0
 /// <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
 })
 {
 }
예제 #17
0
 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);
 }
예제 #18
0
        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);
        }
예제 #19
0
 internal static TypeUsageInfo Create(string name, string typeNamespace, TypeUsageInfoConfiguration configuration, string shortName = null, TypeUsageInfo[] typeArguments = null)
 {
     return new TypeUsageInfo(name, typeNamespace, shortName, configuration, typeArguments);
 }
예제 #20
0
 public static TypeUsageInfo CreateValueType(string name, string typeNamespace, TypeUsageInfo[] typeArguments = null)
 {
     return new TypeUsageInfo(name, typeNamespace, null, TypeUsageInfoConfiguration.ValueType, typeArguments);
 }
예제 #21
0
 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);
 }
예제 #22
0
 public static TypeUsageInfo CreateArray(TypeUsageInfo elementType, int arrayRank)
 {
     return new TypeUsageInfo(elementType.Name, elementType.Namespace, elementType.ShortName,
         elementType._configuration, new[] {elementType}) {ArrayRank = arrayRank};
 }
예제 #23
0
 public static TypeUsageInfo CreateInterface(string name, string typeNamespace, TypeUsageInfo[] typeParameters = null)
 {
     return new TypeUsageInfo(name, typeNamespace, null, TypeUsageInfoConfiguration.Interface, typeParameters);
 }
예제 #24
0
 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;
 }
예제 #26
0
 protected abstract void CheckInherits(TypeUsageInfo info);