Exception InvalidMerge(EntityOperation other)
        {
            var message = string.Format("Included '{0}' operation cannot be followed by '{1}' operation",
                GetType().Name, other.GetType().Name);

            return new InvalidOperationException(message);
        }
        Exception InvalidMerge(EntityOperation other)
        {
            var message = string.Format("Included '{0}' operation cannot be followed by '{1}' operation",
                                        GetType().Name, other.GetType().Name);

            return(new InvalidOperationException(message));
        }
            public override EntityOperation Merge(EntityOperation other)
            {
                if (other is Insert)
                {
                    throw InvalidMerge(other);
                }

                if (other is Replace)
                {
                    return(other);
                }

                if (other is Delete)
                {
                    return(other);
                }

                if (other is InsertOrMerge)
                {
                    throw InvalidMerge(other);
                }

                if (other is InsertOrReplace)
                {
                    throw InvalidMerge(other);
                }

                throw new InvalidOperationException("Unsupported operation type: " + other.GetType());
            }
            new static Exception InvalidMerge(EntityOperation other)
            {
                var message = string.Format("Included 'Delete' operation interdifused with " +
                                            "preceding 'Insert' operation. " +
                                            "'{0}' cannot be applied to NULL",
                                            other.GetType());

                return(new InvalidOperationException(message));
            }
            public override EntityOperation Merge(EntityOperation other)
            {
                if (other is Insert)
                    return new Replace(other.Entity);

                if (other is Replace)
                    throw InvalidMerge(other);

                if (other is Delete)
                    throw InvalidMerge(other);

                throw new InvalidOperationException("Unsupported operation type: " + other.GetType());
            }
            public void Merge(EntityOperation next)
            {
                if (current != EntityOperation.None &&
                    next.Entity != current.Entity)
                {
                    throw new InvalidOperationException(
                              "Mistaken identity. Different instance of entity " +
                              "has been already registered in this session under RowKey: " +
                              next.Entity.RowKey);
                }

                current = current.Merge(next);
            }
        void Record(EntityOperation operation)
        {
            var entityKey = operation.Entity.RowKey;

            EntityChangeRecord record;
            if (!records.TryGetValue(entityKey, out record))
            {
                record = new EntityChangeRecord(operation);
                records.Add(entityKey, record);
                return;
            }

            record.Merge(operation);
        }
        void Record(EntityOperation operation)
        {
            var entityKey = operation.Entity.RowKey;

            EntityChangeRecord record;

            if (!records.TryGetValue(entityKey, out record))
            {
                record = new EntityChangeRecord(operation);
                records.Add(entityKey, record);
                return;
            }

            record.Merge(operation);
        }
 internal EntityChangeRecord(EntityOperation first)
 {
     current = first;
 }
 public abstract EntityOperation Merge(EntityOperation other);
Exemple #11
0
 Include(IncludeType type, EntityOperation operation)
 {
     Type = type;
     Operation = operation;
 }
 internal EntityChangeRecord(EntityOperation first)
 {
     current = first;
 }
 public abstract EntityOperation Merge(EntityOperation other);
            static new Exception InvalidMerge(EntityOperation other)
            {
                var message = string.Format("Included 'Delete' operation interdifused with " +
                                            "preceding 'Insert' operation. " +
                                            "'{0}' cannot be applied to NULL",
                    other.GetType());

                return new InvalidOperationException(message);
            }
Exemple #15
0
 public override EntityOperation Merge(EntityOperation other) =>
 throw new InvalidOperationException("Internal-only stream header merge operation");
            public void Merge(EntityOperation next)
            {
                if (current != EntityOperation.None
                    && next.Entity != current.Entity)
                    throw new InvalidOperationException(
                        "Mistaken identity. Different instance of entity " +
                        "has been already registered in this session under RowKey: " +
                         next.Entity.RowKey);

                current = current.Merge(next);
            }
Exemple #17
0
        internal static IncludedOperationConflictException Create(Partition partition, EntityOperation include)
        {
            var dump = Dump(include.Entity);

            var message = string.Format(
                "Included '{3}' operation had conflicts in partition '{1}' which resides in '{0}' table located at {2}\n" +
                "Dump of conflicting [{5}] contents follows: \n\t{4}",
                partition.Table, partition, partition.Table.StorageUri,
                include.GetType().Name, dump, include.Entity.GetType());

            return(new IncludedOperationConflictException(partition, include.Entity, message));
        }
Exemple #18
0
 Include(IncludeType type, EntityOperation operation)
 {
     Type      = type;
     Operation = operation;
 }
Exemple #19
0
        internal static IncludedOperationConflictException Create(CloudTable table, Partition partition, EntityOperation include)
        {
            var dump = JsonConvert.SerializeObject(include.Entity, Formatting.Indented);

            var message = string.Format(
                "Included '{3}' operation had conflicts in partition '{1}' which resides in '{0}' table located at {2}\n" +
                "Dump of conflicting [{5}] contents follows: \n\t{4}",
                table, partition, table.StorageUri, include.GetType().Name, dump, include.Entity.GetType());

            return new IncludedOperationConflictException(table, partition, include.Entity, message);
        }