Esempio n. 1
0
        public override IObjRef CreateObjRef(AbstractCacheValue cacheValue, int idIndex)
        {
            IPreparedObjRefFactory objRefConstructorDelegate = constructorDelegateMap.Get(cacheValue.EntityType, idIndex);

            if (objRefConstructorDelegate == null)
            {
                objRefConstructorDelegate = BuildDelegate(cacheValue.EntityType, idIndex);
            }
            return(objRefConstructorDelegate.CreateObjRef(cacheValue.Id, cacheValue.Version));
        }
Esempio n. 2
0
        public IObjRef EntityToObjRef(Object entity, int idIndex, IEntityMetaData metaData, bool forceOri)
        {
            Object id;
            Object version;
            Member versionMember = metaData.VersionMember;

            if (entity is AbstractCacheValue)
            {
                AbstractCacheValue cacheValue = (AbstractCacheValue)entity;
                if (idIndex == ObjRef.PRIMARY_KEY_INDEX)
                {
                    id = cacheValue.Id;
                }
                else
                {
                    id = CompositeIdFactory.CreateIdFromPrimitives(metaData, idIndex, cacheValue);
                }
                version = cacheValue.Version;
            }
            else if (entity is ILoadContainer)
            {
                ILoadContainer lc = (ILoadContainer)entity;
                if (idIndex == ObjRef.PRIMARY_KEY_INDEX)
                {
                    id = lc.Reference.Id;
                }
                else
                {
                    id = CompositeIdFactory.CreateIdFromPrimitives(metaData, idIndex, lc.Primitives);
                }
                version = lc.Reference.Version;
            }
            else
            {
                id      = metaData.GetIdMemberByIdIndex(idIndex).GetValue(entity, false);
                version = versionMember != null?versionMember.GetValue(entity, false) : null;
            }
            IObjRef ori;

            if (id != null || forceOri)
            {
                ori = ObjRefFactory.CreateObjRef(metaData.EntityType, idIndex, id, version);
            }
            else
            {
                ori = new DirectObjRef(metaData.EntityType, entity);
            }

            return(ori);
        }
Esempio n. 3
0
        public Object CreateIdFromPrimitives(IEntityMetaData metaData, int idIndex, AbstractCacheValue cacheValue)
        {
            int[][] alternateIdMemberIndicesInPrimitives = metaData.AlternateIdMemberIndicesInPrimitives;
            int[]   compositeIndex = alternateIdMemberIndicesInPrimitives[idIndex];

            if (compositeIndex.Length == 1)
            {
                return(cacheValue.GetPrimitive(compositeIndex[0]));
            }
            PrimitiveMember compositeIdMember = metaData.AlternateIdMembers[idIndex];

            Object[] ids = new Object[compositeIndex.Length];
            for (int a = compositeIndex.Length; a-- > 0;)
            {
                ids[a] = cacheValue.GetPrimitive(compositeIndex[a]);
            }
            return(CreateCompositeId(metaData, compositeIdMember, ids));
        }
Esempio n. 4
0
 public abstract IObjRef CreateObjRef(AbstractCacheValue cacheValue, int idIndex);
Esempio n. 5
0
 public abstract IObjRef CreateObjRef(AbstractCacheValue cacheValue);
Esempio n. 6
0
        protected void ToStringIntern(StringBuilder sb, IPrintable preSpace, bool?entityDescriptionAtRoot)
        {
            Object[] cacheValues = this.cacheValues;

            if (entityDescriptionAtRoot == null)
            {
                IObjRef[] objRefs = this.objRefs;
                for (int a = 0, size = objRefs.Length; a < size; a++)
                {
                    IObjRef objRef = objRefs[a];
                    sb.Append(pipe).Append(' ').Append(a + 1);
                    sb.Append(". Type=").Append(objRef.RealType.Name);
                    sb.Append(" Id(");
                    if (objRef.IdNameIndex == ObjRef.PRIMARY_KEY_INDEX)
                    {
                        sb.Append("PK");
                    }
                    else
                    {
                        sb.Append("AK-").Append(objRef.IdNameIndex);
                    }
                    sb.Append(")=").Append(objRef.Id);
                    entityDescriptionAtRoot = true;
                    preSpace.ToString(sb);
                }
            }
            sb.Append(pipe).Append(" Cache");
            bool firstSuffix = true;

            if (!privileged)
            {
                firstSuffix = AppendSuffix("SEC", firstSuffix, sb);
            }
            if (transactional)
            {
                firstSuffix = AppendSuffix("TX", firstSuffix, sb);
            }
            if (threadLocal)
            {
                firstSuffix = AppendSuffix("L", firstSuffix, sb);
            }
            if (parentEntry == null)
            {
                firstSuffix = AppendSuffix("G", firstSuffix, sb);
            }
            sb.Append("--#0x").Append(ToHexString(cache));

            IPrintable oldPreSpace = preSpace;

            preSpace = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
            {
                oldPreSpace.ToString(sb2);
                sb2.Append('\t');
            }));
            IPrintable preSpaceForCacheValue;

            if (childEntries == null)
            {
                preSpaceForCacheValue = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                {
                    preSpace.ToString(sb2);
                    sb2.Append("   ");
                }));
            }
            else
            {
                preSpaceForCacheValue = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                {
                    preSpace.ToString(sb2);
                    sb2.Append("|  ");
                }));
            }
            for (int a = 0, size = cacheValues.Length; a < size; a++)
            {
                preSpaceForCacheValue.ToString(sb);
                sb.Append(a + 1).Append('.');
                Object cacheValue = cacheValues[a];
                if (cacheValue == null)
                {
                    sb.Append(" n/a");
                    continue;
                }
                IEntityMetaData metaData = ((IEntityMetaDataHolder)cacheValue).Get__EntityMetaData();
                Object          id, version = null;
                bool            hasVersion        = metaData.VersionMember != null;
                bool            hasPendingChanges = false;
                if (cacheValue is AbstractCacheValue)
                {
                    AbstractCacheValue cacheValueCasted = (AbstractCacheValue)cacheValue;
                    id = cacheValueCasted.Id;
                    if (hasVersion)
                    {
                        version = cacheValueCasted.Version;
                    }
                }
                else
                {
                    id = metaData.IdMember.GetValue(cacheValue);
                    if (hasVersion)
                    {
                        version = metaData.VersionMember.GetValue(cacheValue);
                    }
                    hasPendingChanges = this.pendingChanges != null && this.pendingChanges[a];
                }
                if (!entityDescriptionAtRoot.HasValue || !entityDescriptionAtRoot.Value)
                {
                    sb.Append(" Type=").Append(metaData.EntityType.Name);
                    sb.Append(" Id=").Append(id);
                }
                if (hasVersion)
                {
                    sb.Append(" Version=").Append(version);
                }
                if (hasPendingChanges)
                {
                    sb.Append(" (m)");
                }
            }
            if (this.childEntries is CacheWalkerResult[])
            {
                CacheWalkerResult[] childEntries2 = (CacheWalkerResult[])this.childEntries;
                for (int a = 0, size = childEntries2.Length; a < size; a++)
                {
                    bool hasSuccessor       = a < size - 1;
                    CacheWalkerResult entry = childEntries2[a];

                    IPrintable preSpaceForChildEntry = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                    {
                        preSpace.ToString(sb2);
                        if (hasSuccessor)
                        {
                            sb2.Append("|");
                        }
                    }));
                    preSpace.ToString(sb);
                    entry.ToStringIntern(sb, preSpaceForChildEntry, entityDescriptionAtRoot);
                }
            }
            else if (this.childEntries != null)
            {
                CacheWalkerResult entry = (CacheWalkerResult)this.childEntries;
                preSpace.ToString(sb);
                entry.ToStringIntern(sb, preSpace, entityDescriptionAtRoot);
            }
        }