Beispiel #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityArrayScanTarget" /> class.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity spec.
 /// </param>
 /// <param name="array">
 ///     The array.
 /// </param>
 /// <param name="indexes">
 ///     The indexes.
 /// </param>
 internal EntityArrayScanTarget(Type entityType, EntitySpec entitySpec, Array array, int[] indexes)
     : base(entityType, entitySpec)
 {
     this.array   = array;
     this.indexes = new int[indexes.Length];
     Array.Copy(indexes, this.indexes, indexes.Length);
     this.setter = this.Set;
 }
        /// <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;
        }
Beispiel #3
0
        /// <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;
        }
Beispiel #4
0
        /// <summary>
        ///     Adds an entity specification to the scan.
        /// </summary>
        /// <param name="entitySpec">
        ///     The entity specification to add.
        /// </param>
        /// <param name="scanSpec">
        ///     The scan specification.
        /// </param>
        internal void Add(EntitySpec entitySpec, ScanSpec scanSpec)
        {
            lock (this.syncRoot)
            {
                if (this.tables == null)
                {
                    this.tables = new Map <Pair <string>, ITableScan>();
                }

                this.tables = new Map <Pair <string>, ITableScan>();

                var tableScanSpec = this.tables.GetOrAdd(new Pair <string>(entitySpec.Namespace, entitySpec.TableName),
                                                         kvp => this.CreateTableScan(scanSpec));
                tableScanSpec.Add(entitySpec);
            }
        }
Beispiel #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityScanTarget" /> class.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity specification.
 /// </param>
 /// <param name="key">
 ///     The entity key.
 /// </param>
 protected EntityScanTarget(Type entityType, EntitySpec entitySpec, Key key)
     : base(entityType, entitySpec, key)
 {
 }
Beispiel #6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityScanTarget" /> class.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity specification.
 /// </param>
 protected EntityScanTarget(Type entityType, EntitySpec entitySpec)
     : base(entityType, entitySpec)
 {
 }
Beispiel #7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityScanTarget" /> class.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity spec.
 /// </param>
 /// <param name="setter">
 ///     The scan target setter action.
 /// </param>
 internal EntityScanTarget(Type entityType, EntitySpec entitySpec, Action <object, object> setter)
     : base(entityType, entitySpec)
 {
     this.setter = setter;
 }
Beispiel #8
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityScanTarget" /> class.
 /// </summary>
 /// <param name="property">
 ///     The inspected property.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity specification.
 /// </param>
 /// <param name="target">
 ///     The scan target.
 /// </param>
 internal EntityScanTarget(InspectedProperty property, EntitySpec entitySpec, object target)
     : base(property.PropertyType, entitySpec)
 {
     this.target = target;
     this.setter = property.Setter;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityQueryScanTarget" /> class.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="entitySpec">
 ///     The entity spec.
 /// </param>
 /// <param name="key">
 ///     The entity key.
 /// </param>
 /// <param name="valueSink">
 ///     The value sink.
 /// </param>
 internal EntityQueryScanTarget(Type entityType, EntitySpec entitySpec, Key key, Action <object> valueSink)
     : base(entityType, entitySpec, key)
 {
     this.setter    = this.Add;
     this.valueSink = valueSink;
 }