/// <summary> /// Initializes a new instance of the <see cref="MultiCrossReferenceFieldMapping"/> class. /// </summary> /// <param name="property"> /// The property. /// </param> /// <param name="valueExpression"> /// The value expression. /// </param> /// <param name="childMappings"> /// The child mappings. /// </param> /// <param name="dynamicTypeManager"> /// The dynamic type manager. /// </param> /// <param name="runtimeDatabase"> /// The runtime database. /// </param> public MultiCrossReferenceFieldMapping( PropertyInfo property, MappingExpression valueExpression, IEnumerable<IProcessFieldMapping> childMappings, IDynamicTypeManager dynamicTypeManager, IRuntimeDatabase runtimeDatabase) { if (property == null) throw new ArgumentNullException("property"); var crAttribute = property.GetCustomAttribute<CrossRefFieldAttribute>(); if (crAttribute == null || !crAttribute.AllowMultiple) throw new ArgumentException("The specified property is not a multi cross reference field."); if (childMappings == null) throw new ArgumentNullException("childMappings"); var childMappingsArray = childMappings.ToArray(); if (childMappingsArray.All(m => !m.IsKey)) throw new ArgumentException("At least one key field should be specified."); if (dynamicTypeManager == null) throw new ArgumentNullException("dynamicTypeManager"); if (runtimeDatabase == null) throw new ArgumentNullException("runtimeDatabase"); _property = property; _valueExpression = valueExpression; _childMappings = childMappingsArray; _dynamicTypeManager = dynamicTypeManager; _runtimeDatabase = runtimeDatabase; _referencedProcessName = crAttribute.ReferenceTableName; }
/// <summary> /// Initializes a new instance of the <see cref="SingleCrossReferenceFieldMapping"/> class. /// </summary> /// <param name="property"> /// The property. /// </param> /// <param name="valueExpression"> /// The value expression. /// </param> /// <param name="isKey"> /// Specifies whether this is a key mapping. /// </param> /// <param name="typeConverter"> /// The type converter. /// </param> /// <param name="dynamicTypeManager"> /// The dynamic type manager. /// </param> /// <param name="runtimeDatabase"> /// The runtime database. /// </param> /// <param name="childMappings"> /// The child mappings. /// </param> public SingleCrossReferenceFieldMapping( PropertyInfo property, MappingExpression valueExpression, bool isKey, ITypeConverter typeConverter, IDynamicTypeManager dynamicTypeManager, IRuntimeDatabase runtimeDatabase, IEnumerable<IProcessFieldMapping> childMappings) { if (property == null) throw new ArgumentNullException("property"); var crAttribute = property.GetCustomAttribute<CrossRefFieldAttribute>(); if (crAttribute == null || crAttribute.AllowMultiple || !typeof(int?).IsAssignableFrom(property.PropertyType)) throw new ArgumentException("The specified property is not a single cross reference field."); if (typeConverter == null) throw new ArgumentNullException("typeConverter"); if (dynamicTypeManager == null) throw new ArgumentNullException("dynamicTypeManager"); if (runtimeDatabase == null) throw new ArgumentNullException("runtimeDatabase"); _property = property; _valueExpression = valueExpression; _isKey = isKey; _typeConverter = typeConverter; _dynamicTypeManager = dynamicTypeManager; _runtimeDatabase = runtimeDatabase; _childMappings = (childMappings ?? Enumerable.Empty<IProcessFieldMapping>()).ToArray(); _referencedProcessName = crAttribute.ReferenceTableName; }
/// <summary> /// Initializes a new instance of the <see cref="IntegrationServiceMethod"/> class. /// </summary> /// <param name="processName"> /// The process name. /// </param> /// <param name="fieldMappings"> /// The field mappings. /// </param> /// <param name="resultCalculator"> /// The result calculator. /// </param> /// <param name="dynamicTypeManager"> /// The dynamic type manager. /// </param> /// <param name="applicationContext"> /// The application context. /// </param> /// <param name="runtimeDatabase"> /// The runtime database. /// </param> /// <param name="editableRootDataContextFactory"> /// The editable root data context factory. /// </param> /// <param name="logger"> /// The logger. /// </param> public IntegrationServiceMethod( string processName, IEnumerable<IProcessFieldMapping> fieldMappings, IValueCalculator resultCalculator, IDynamicTypeManager dynamicTypeManager, IApplicationContext applicationContext, IRuntimeDatabase runtimeDatabase, IEditableRootDataContextFactory editableRootDataContextFactory, ILogger logger) { if (string.IsNullOrEmpty(processName)) throw new ArgumentException(@"The process name cannot be null or empty.", "processName"); if (fieldMappings == null) throw new ArgumentNullException("fieldMappings"); if (dynamicTypeManager == null) throw new ArgumentNullException("dynamicTypeManager"); if (applicationContext == null) throw new ArgumentNullException("applicationContext"); if (runtimeDatabase == null) throw new ArgumentNullException("runtimeDatabase"); if (editableRootDataContextFactory == null) throw new ArgumentNullException("editableRootDataContextFactory"); if (logger == null) throw new ArgumentNullException("logger"); ProcessName = processName; DynamicTypeManager = dynamicTypeManager; ApplicationContext = applicationContext; RuntimeDatabase = runtimeDatabase; EditableRootDataContextFactory = editableRootDataContextFactory; Logger = logger; foreach (var fieldMapping in fieldMappings) { FieldMappings.Add(fieldMapping); if (fieldMapping.IsKey) KeyMappings.Add(fieldMapping); } ResultCalculator = resultCalculator; }