public override void UpdateOneToMany(Object iterator, ISerializableObject owner, Type storedType, Serializer serializer)
        {
            IVirtualKey vKey = AttributeWorker.GetInstance(serializer.Target).CreateVirtualKey(serializer, owner.GetType(), storedType);

            vKey.InitVirtualKeyBySource(owner);

            ((IDirectAccessIteratorConfiguration)iterator).Restriction = Restrictions.RestrictionFactory.SqlRestriction(storedType, vKey.ToSqlStringForward(serializer.Target));
        }
Example #2
0
        internal void AdjustKeyDownward(ISerializableObject iso)
        {
            AttributeWorker w    = AttributeWorker.GetInstance(_sinkSerializer.Target);
            IVirtualKey     vKey = w.CreateVirtualKey(_sinkSerializer, _synchronizedType, iso.GetType());

            vKey.InitVirtualKeyBySource(FetchObject(_sinkSerializer, _sinkGuid));
            vKey.ApplyVirtualKeyToTarget(iso);
        }
        public override Object LoadOneToMany(ISerializableObject owner, Type storedType, Serializer serializer)
        {
            Type genType = typeof(DirectAccesIteratorImpl <>).MakeGenericType(new Type[] { storedType });
            IDirectAccessIteratorConfiguration conf = (IDirectAccessIteratorConfiguration)Activator.CreateInstance(genType);

            IVirtualKey vKey = AttributeWorker.GetInstance(serializer.Target).CreateVirtualKey(serializer, owner.GetType(), storedType);

            vKey.InitVirtualKeyBySource(owner);

            conf.Restriction = Restrictions.RestrictionFactory.SqlRestriction(storedType, vKey.ToSqlStringForward(serializer.Target));
            conf.Serializer  = serializer;

            return(conf);
        }
Example #4
0
        public void ConnectOneToOne(ISerializableObject source, ISerializableObject target)
        {
            IVirtualKey vKey = AttributeWorker.GetInstance(Target).CreateVirtualKey(this, source.GetType(), target.GetType());

            vKey.InitVirtualKeyBySource(source);
            vKey.ApplyVirtualKeyToTarget(target);

            try
            {
                vKey.TargetField.SetValue(target, source);
            }
            catch (Exception)
            {
            }
        }
Example #5
0
        public void HandleOneToOneReflexive(ISerializableObject handledItem, OneToOneDefAttribute attr, FieldInfo field)
        {
            Type        type = field.FieldType;
            IVirtualKey vKey = AttributeWorker.GetInstance(_serializer.Target).CreateVirtualKey(_serializer, type, handledItem.GetType());

            try
            {
                vKey.InitVirtualKeyBySource(handledItem);
            }
            catch (InvalidOperationException)
            {
                field.SetValue(handledItem, null);
                return;
            }
            IRestriction        r   = Restrictions.RestrictionFactory.SqlRestriction(type, vKey.ToSqlStringForward(_serializer.Target));
            ISerializableObject tmp = _serializer.Connector.Load(type, r);

            field.SetValue(handledItem, tmp);
        }