Exemplo n.º 1
0
        private void RemapEntityReference(RemapContext context, ReferenceFieldChangeInfo info)
        {
            var entity = Session.Query.SingleOrDefault(info.FieldOwner);

            if (entity == null)
            {
                return;
            }
            var referencedEntity = (Entity)entity.GetFieldValue(info.Field);

            if (referencedEntity == null)
            {
                return;
            }
            var referencedKey = referencedEntity.Key;
            var realKey       = context.TryRemapKey(referencedKey);

            entity.SetReferenceKey(info.Field, realKey);
        }
Exemplo n.º 2
0
        private void RemapEntitySetReference(RemapContext context, ReferenceFieldChangeInfo info)
        {
            var fieldAssociation = info.Field.GetAssociation(info.FieldValue.TypeInfo);

            if (!fieldAssociation.IsMaster && fieldAssociation.IsPaired)
            {
                return;
            }

            var oldCombinedKey = info.AuxiliaryEntity;

            var fieldOwnerKey = context.TryRemapKey(info.FieldOwner);
            var fieldValueKey = context.TryRemapKey(info.FieldValue);

            var transformer   = new CombineTransform(false, fieldOwnerKey.Value.Descriptor, fieldValueKey.Value.Descriptor);
            var combinedTuple = transformer.Apply(TupleTransformType.Tuple, fieldOwnerKey.Value, fieldValueKey.Value);

            var newCombinedKey = Key.Create(Session.Domain, Session.StorageNodeId, fieldAssociation.AuxiliaryType, TypeReferenceAccuracy.ExactType, combinedTuple);

            context.RegisterKeyMap(oldCombinedKey, newCombinedKey);
        }
 private void Register(ReferenceFieldChangeInfo fieldChangeInfo)
 {
     changes.Add(fieldChangeInfo);
 }