/// <summary> /// Initializes a new instance of the <see cref="EntityCollectionScanTarget" /> class. /// </summary> /// <param name="entityType"> /// The entity type. /// </param> /// <param name="entitySpec"> /// The entity specification. /// </param> /// <param name="inspectedEnumerable"> /// The inspected enumerable. /// </param> /// <param name="collection"> /// The target collection. /// </param> /// <exception cref="PersistenceException"> /// If the <paramref name="inspectedEnumerable" /> does not have an add method. /// </exception> internal EntityCollectionScanTarget(Type entityType, EntitySpec entitySpec, InspectedEnumerable inspectedEnumerable, object collection) : base(entityType, entitySpec) { if (!inspectedEnumerable.HasAdd) { throw new PersistenceException( string.Format(CultureInfo.InvariantCulture, @"Enumerable {0} has no void Add({1}) method.", inspectedEnumerable.InspectedType, inspectedEnumerable.ElementType)); } this.setter = this.Add; this.add = inspectedEnumerable.Add; this.collection = collection; }
/// <summary> /// Initializes a new instance of the <see cref="EntityIndexerScanTarget" /> class. /// </summary> /// <param name="entityType"> /// The entity type. /// </param> /// <param name="entitySpec"> /// The entity spec. /// </param> /// <param name="inspectedEnumerable"> /// The inspected enumerable. /// </param> /// <param name="collection"> /// The collection. /// </param> /// <param name="pos"> /// The position in the indexed collection. /// </param> /// <exception cref="PersistenceException"> /// If the <paramref name="inspectedEnumerable" /> does not have an indexer. /// </exception> internal EntityIndexerScanTarget(Type entityType, EntitySpec entitySpec, InspectedEnumerable inspectedEnumerable, object collection, int pos) : base(entityType, entitySpec) { if (!inspectedEnumerable.HasIndexer) { throw new PersistenceException( string.Format(CultureInfo.InvariantCulture, @"Enumerable {0} has no index for type {1}.", inspectedEnumerable.InspectedType, inspectedEnumerable.ElementType)); } this.setter = this.Set; this.inspectedEnumerable = inspectedEnumerable; this.collection = collection; this.pos = pos; }