Exemplo n.º 1
0
		internal static Type[] GetReferencedTypes(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo, Type[] referencedTypes)
		{
			var retval = new List<Type>();

			if (configuration.ReferencedTypes != null)
			{
				retval.AddRange(configuration.ReferencedTypes);
			}

			if (referencedTypes != null)
			{
				retval.AddRange(referencedTypes);
			}

			if (propertyInfo?.PropertyType != null)
			{
				retval.Add(propertyInfo.PropertyType);
			}

			if (propertyInfo?.DeclaringType != null)
			{
				retval.Add(propertyInfo.DeclaringType);
			}

			return retval.ToArray();
		}
Exemplo n.º 2
0
        internal static Type[] GetReferencedTypes(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo, Type[] referencedTypes)
        {
            var retval = new List <Type>();

            if (configuration.ReferencedTypes != null)
            {
                retval.AddRange(configuration.ReferencedTypes);
            }

            if (referencedTypes != null)
            {
                retval.AddRange(referencedTypes);
            }

            if (propertyInfo?.PropertyType != null)
            {
                retval.Add(propertyInfo.PropertyType);
            }

            if (propertyInfo?.DeclaringType != null)
            {
                retval.Add(propertyInfo.DeclaringType);
            }

            return(retval.ToArray());
        }
Exemplo n.º 3
0
        private Type[] GetReferencedTypes(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
        {
            var referencedTypes = new List <Type>();

            if (configuration.ReferencedTypes != null)
            {
                referencedTypes.AddRange(configuration.ReferencedTypes);
            }

            if (this.ReferencedTypes != null)
            {
                referencedTypes.AddRange(this.ReferencedTypes);
            }

            if (this.ReferencedType != null)
            {
                referencedTypes.Add(this.ReferencedType);
            }

            if (propertyInfo?.PropertyType != null)
            {
                referencedTypes.Add(propertyInfo.PropertyType);
            }

            if (propertyInfo?.DeclaringType != null)
            {
                referencedTypes.Add(propertyInfo.DeclaringType);
            }

            return(referencedTypes.ToArray());
        }
Exemplo n.º 4
0
		private Type[] GetReferencedTypes(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
		{
			var referencedTypes = new List<Type>();

			if (configuration.ReferencedTypes != null)
			{
				referencedTypes.AddRange(configuration.ReferencedTypes);
			}

			if (this.ReferencedTypes != null)
			{
				referencedTypes.AddRange(this.ReferencedTypes);
			}

			if (this.ReferencedType != null)
			{
				referencedTypes.Add(this.ReferencedType);
			}

			if (propertyInfo?.PropertyType != null)
			{
				referencedTypes.Add(propertyInfo.PropertyType);
			}

			if (propertyInfo?.DeclaringType != null)
			{
				referencedTypes.Add(propertyInfo.DeclaringType);
			}

			return referencedTypes.ToArray();
		}
Exemplo n.º 5
0
        public static DataAccessModel BuildDataAccessModel(Type dataAccessModelType, DataAccessModelConfiguration configuration)
        {
            if (!dataAccessModelType.IsSubclassOf(typeof(DataAccessModel)))
            {
                throw new ArgumentException("Data access model type must derive from DataAccessModel", nameof(dataAccessModelType));
            }

            configuration = configuration ?? GetDefaultConfiguration(dataAccessModelType);

            if (configuration == null)
            {
                throw new InvalidOperationException("No configuration specified or declaredd");
            }

            var buildInfo = CachingDataAccessModelAssemblyProvider.Default.GetDataAccessModelAssembly(dataAccessModelType, configuration);
            var retval    = buildInfo.NewDataAccessModel();

            retval.SetConfiguration(configuration);
            retval.SetAssemblyBuildInfo(buildInfo);
            retval.hasAnyAutoIncrementValidators = retval.TypeDescriptorProvider.GetTypeDescriptors().Any(c => c.PersistedProperties.Any(d => d.IsAutoIncrement && d.AutoIncrementAttribute.ValidateExpression != null));

            retval.Initialise();

            return(retval);
        }
Exemplo n.º 6
0
        public static DataAccessModel BuildDataAccessModel(Type dataAccessModelType, DataAccessModelConfiguration configuration)
        {
            if (!dataAccessModelType.IsSubclassOf(typeof(DataAccessModel)))
            {
                throw new ArgumentException("Data access model type must derive from DataAccessModel", nameof(dataAccessModelType));
            }

            configuration = configuration ?? GetDefaultConfiguration(dataAccessModelType);

            if (configuration == null)
            {
                throw new InvalidOperationException("No configuration specified or declaredd");
            }

            var buildInfo = CachingDataAccessModelAssemblyProvider.Default.GetDataAccessModelAssembly(dataAccessModelType, configuration);
            var retval    = buildInfo.NewDataAccessModel();

            retval.SetConfiguration(configuration);
            retval.SetAssemblyBuildInfo(buildInfo);

            retval.Initialise();

            return(retval);
        }
Exemplo n.º 7
0
 public LambdaExpression GetSetLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
 {
     return(this.SetExpression == null ? null : ComputedExpressionParser.Parse(this.SetExpression, propertyInfo, GetReferencedTypes(configuration, propertyInfo, this.ReferencedTypes?.ConcatUnlessNull(this.ReferencedType).ToArray()), propertyInfo.PropertyType));
 }
Exemplo n.º 8
0
 public LambdaExpression GetSetLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
 {
     return(this.SetExpression == null ? null : ComputedExpressionParser.Parse(this.SetExpression, propertyInfo, GetReferencedTypes(configuration, propertyInfo)));
 }
 public LambdaExpression GetValidateLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
 {
     return(this.ValidateExpression == null ? null : ComputedExpressionParser.Parse(this.ValidateExpression, propertyInfo, ComputedMemberAttribute.GetReferencedTypes(configuration, propertyInfo, this.ReferencedTypes?.ConcatUnlessNull(this.ReferencedType).ToArray()), typeof(bool)));
 }
Exemplo n.º 10
0
		public LambdaExpression GetSetLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
		{
			return this.SetExpression == null ? null : ComputedExpressionParser.Parse(this.SetExpression, propertyInfo, GetReferencedTypes(configuration, propertyInfo, this.ReferencedTypes?.ConcatUnlessNull(this.ReferencedType).ToArray()), propertyInfo.PropertyType);
		}
Exemplo n.º 11
0
		public LambdaExpression GetSetLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
		{
			return this.SetExpression == null ? null : ComputedExpressionParser.Parse(this.SetExpression, propertyInfo, GetReferencedTypes(configuration, propertyInfo));
		}
Exemplo n.º 12
0
 internal void SetConfiguration(DataAccessModelConfiguration configuration)
 {
     this.Configuration = configuration;
 }
Exemplo n.º 13
0
 public static T BuildDataAccessModel <T>(DataAccessModelConfiguration configuration)
     where T : DataAccessModel
 {
     return((T)BuildDataAccessModel(typeof(T), configuration));
 }
Exemplo n.º 14
0
		public LambdaExpression GetValidateLambdaExpression(DataAccessModelConfiguration configuration, PropertyInfo propertyInfo)
		{
			return this.ValidateExpression == null ? null : ComputedExpressionParser.Parse(this.ValidateExpression, propertyInfo, ComputedMemberAttribute.GetReferencedTypes(configuration, propertyInfo, this.ReferencedTypes?.ConcatUnlessNull(this.ReferencedType).ToArray()), typeof(bool));
		}