protected virtual ITypeHandler4 TypeHandlerForClass(ObjectContainerBase container
                                                     , IReflectClass fieldType)
 {
     container.ShowInternalClasses(true);
     try
     {
         return(container.TypeHandlerForClass(Handlers4.BaseType(fieldType)));
     }
     finally
     {
         container.ShowInternalClasses(false);
     }
 }
Example #2
0
 private void WriteObject(IWriteContext context, ITypeHandler4 typeHandler, object
                          obj)
 {
     if (IsPlainObject(obj))
     {
         context.WriteObject(new PlainObjectHandler(), obj);
         return;
     }
     if (Handlers4.UseDedicatedSlot(context, typeHandler))
     {
         context.WriteObject(obj);
     }
     else
     {
         typeHandler.Write(context, obj);
     }
 }
        public void Defragment(ITypeHandler4 handler)
        {
            ITypeHandler4 typeHandler = HandlerRegistry.CorrectHandlerVersion(this, handler);

            if (Handlers4.UseDedicatedSlot(this, typeHandler))
            {
                if (Handlers4.HasClassIndex(typeHandler))
                {
                    CopyID();
                }
                else
                {
                    CopyUnindexedID();
                }
                return;
            }
            typeHandler.Defragment(this);
        }
        private ClassMetadata DetectFieldType()
        {
            IReflectClass claxx = _containingClass.ClassReflector();

            if (claxx == null)
            {
                return(null);
            }
            _reflectField = claxx.GetDeclaredField(_name);
            if (_reflectField == null)
            {
                return(null);
            }
            IReflectClass fieldType = _reflectField.GetFieldType();

            if (fieldType == null)
            {
                return(null);
            }
            return(Handlers4.ErasedFieldType(Container(), fieldType));
        }
        public ITypeHandler4 ConfiguredTypeHandler(IReflectClass claxx)
        {
            object cachedHandler = _mapReflectorToTypeHandler.Get(claxx);

            if (null != cachedHandler)
            {
                return((ITypeHandler4)cachedHandler);
            }
            ITypeHandler4 typeHandler = Container().ConfigImpl.TypeHandlerForClass(claxx, HandlerVersion
                                                                                   );

            if (typeHandler is IBuiltinTypeHandler)
            {
                ((IBuiltinTypeHandler)typeHandler).RegisterReflector(Reflector());
            }
            if (Handlers4.IsValueType(typeHandler))
            {
                MapClassToTypeHandler(claxx, typeHandler);
            }
            return(typeHandler);
        }
Example #6
0
        /// <summary>return false if class not completely initialized, otherwise true</summary>
        internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth
                                          updateDepth)
        {
            if (!BitIsTrue(Const4.Continue))
            {
                return(true);
            }
            if (!_class.StateOK())
            {
                return(false);
            }
            if (!_class.AspectsAreInitialized())
            {
                return(false);
            }
            if (DTrace.enabled)
            {
                DTrace.Continueset.Log(GetID());
            }
            BitFalse(Const4.Continue);
            MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true
                                                                );

            Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
            Pointer4            pointer   = context.AllocateSlot();
            ByteArrayBuffer     buffer    = context.ToWriteBuffer(pointer);
            ObjectContainerBase container = trans.Container();

            container.WriteNew(trans, pointer, _class, buffer);
            object obj = _object;

            ObjectOnNew(trans, obj);
            if (_class.HasIdentity())
            {
                _object = container.NewWeakReference(this, obj);
            }
            SetStateClean();
            EndProcessing();
            return(true);
        }
        public sealed override void CascadeActivation(IActivationContext context)
        {
            if (!Alive())
            {
                return;
            }
            object cascadeTo = CascadingTarget(context);

            if (cascadeTo == null)
            {
                return;
            }
            IActivationContext cascadeContext = context.ForObject(cascadeTo);
            ClassMetadata      classMetadata  = cascadeContext.ClassMetadata();

            if (classMetadata == null)
            {
                return;
            }
            EnsureObjectIsActive(cascadeContext);
            Handlers4.CascadeActivation(cascadeContext, classMetadata.TypeHandler());
        }
        private void EnsureObjectIsActive(IActivationContext context)
        {
            if (!context.Depth().Mode().IsActivate())
            {
                return;
            }
            if (Handlers4.IsValueType(GetHandler()))
            {
                return;
            }
            ObjectContainerBase container     = context.Container();
            ClassMetadata       classMetadata = container.ClassMetadataForObject(context.TargetObject
                                                                                     ());

            if (classMetadata == null || !classMetadata.HasIdentity())
            {
                return;
            }
            if (container.IsActive(context.TargetObject()))
            {
                return;
            }
            container.StillToActivate(context.Descend());
        }
Example #9
0
        private void InitializeFieldType()
        {
            ObjectContainerBase stream      = ContainingClass().Container();
            IReflectClass       storedClass = stream.Reflector().ForClass(TranslatorStoredClass(_translator
                                                                                                ));

            Configure(storedClass, false);
            IReflectClass baseType = Handlers4.BaseType(storedClass);

            stream.ShowInternalClasses(true);
            try
            {
                _fieldType = stream.ProduceClassMetadata(baseType);
            }
            finally
            {
                stream.ShowInternalClasses(false);
            }
            if (null == _fieldType)
            {
                throw new InvalidOperationException("Cannot produce class metadata for " + baseType
                                                    + "!");
            }
        }
 public override IPreparedComparison PrepareComparison(IContext context, object source
                                                       )
 {
     return(Handlers4.PrepareComparisonFor(TypeHandler(), context, source));
 }
 public override object InstantiateTransient(UnmarshallingContext context)
 {
     return(Handlers4.ReadValueType(context, CorrectHandlerVersion(context)));
 }
Example #12
0
 private int CalculateLinkLength(IHandlerVersionContext context)
 {
     return(Handlers4.CalculateLinkLength(HandlerRegistry.CorrectHandlerVersion(context
                                                                                , GetHandler())));
 }
Example #13
0
 public bool CanLoadByIndex()
 {
     return(Handlers4.CanLoadFieldByIndex(GetHandler()));
 }
Example #14
0
 internal virtual bool SupportsIndex()
 {
     return(Alive() && (GetHandler() is IIndexable4) && (!Handlers4.IsUntyped(GetHandler
                                                                                  ())));
 }
 public object Run()
 {
     Handlers4.Activate(context, this._enclosing._typeHandler);
     return(null);
 }
Example #16
0
 private int CalculateLinkLength()
 {
     return(Handlers4.CalculateLinkLength(GetHandler()));
 }