Пример #1
0
        private void ClonePartition(PartitionDescriptor newPartitionDescriptor, Partition oldPartition)
        {
            var hashPartition = oldPartition as HashPartition;

            if (hashPartition != null)
            {
                var newPartition = newPartitionDescriptor.CreateHashPartition(hashPartition.Filegroup);
                CopyDbName(oldPartition, newPartition);
                return;
            }
            var listPartition = oldPartition as ListPartition;

            if (listPartition != null)
            {
                var newPartition = newPartitionDescriptor.CreateListPartition(listPartition.Filegroup, (string[])listPartition.Values.Clone());
                CopyDbName(oldPartition, newPartition);
                return;
            }
            var rangePartition = oldPartition as RangePartition;

            if (rangePartition != null)
            {
                var newPartition = newPartitionDescriptor.CreateRangePartition(rangePartition.Filegroup, rangePartition.Boundary);
                CopyDbName(oldPartition, newPartition);
                return;
            }
            throw new ArgumentOutOfRangeException("oldPartition", Strings.ExUnexpectedTypeOfParameter);
        }
Пример #2
0
 public PhysicalPartition(PartitionDescriptor descriptor, IBuffer buffer, uint sectorSize)
 {
     _partitionNumber = descriptor.PartitionNumber;
     _parentBuffer    = buffer;
     _contentBuffer   = new SubBuffer(_parentBuffer, descriptor.PartitionStartingLocation * (long)sectorSize, descriptor.PartitionLength * (long)sectorSize);
     _descriptor      = descriptor;
 }
Пример #3
0
 public PhysicalPartition(PartitionDescriptor descriptor, IBuffer buffer, uint sectorSize)
 {
     _partitionNumber = descriptor.PartitionNumber;
     _parentBuffer = buffer;
     _contentBuffer = new SubBuffer(_parentBuffer, descriptor.PartitionStartingLocation * (long)sectorSize, descriptor.PartitionLength * (long)sectorSize);
     _descriptor = descriptor;
 }
Пример #4
0
        private void ClonePartitionDescriptor(IPartitionable newObject, IPartitionable oldObject)
        {
            var oldPartitionDescriptor = oldObject.PartitionDescriptor;

            if (oldPartitionDescriptor == null)
            {
                return;
            }

            var column = GetPartitionColumn(newObject, oldPartitionDescriptor);
            var partitionDescriptor = new PartitionDescriptor(newObject, column, oldPartitionDescriptor.PartitionMethod);

            CopyDbName(partitionDescriptor, oldPartitionDescriptor);
            foreach (var oldPartition in oldPartitionDescriptor.Partitions)
            {
                ClonePartition(partitionDescriptor, oldPartition);
            }

            newObject.PartitionDescriptor = partitionDescriptor;
        }
Пример #5
0
        private TableColumn GetPartitionColumn(IPartitionable newObject, PartitionDescriptor oldPartitionDescriptor)
        {
            var table = newObject as Table;

            if (table != null)
            {
                return(table.TableColumns[oldPartitionDescriptor.Column.Name]);
            }

            var index = newObject as Index;

            if (index != null)
            {
                var tableColumn = index.Columns[oldPartitionDescriptor.Column.Name].Column as TableColumn;
                if (tableColumn != null)
                {
                    return(tableColumn);
                }
                throw new InvalidOperationException(Strings.ExUnableToGetTableColumnInstanceFromIndex);
            }
            throw new ArgumentOutOfRangeException("newObject", Strings.ExUnexpectedTypeOfParameter);
        }
 /// <inheritdoc/>
 /// <exception cref="NotSupportedException">Method is not supported.</exception>
 protected override IPathNode VisitPartitionDescriptor(PartitionDescriptor partitionDescriptor)
 {
     throw new NotSupportedException();
 }