Ejemplo n.º 1
0
        public Object getValue(DustDataEntity key, Object defVal, object hint)
        {
            Object            ret = defVal;
            DustDataReference er  = null;

            if (content.TryGetValue(key, out ret))
            {
                er  = ret as DustDataReference;
                ret = (null == er) ? ret : er.getAt(hint);
            }

            if ((null == ret) && (DustValType.LinkDefMap == key.optValType))
            {
                Object refPT;
                if (content.TryGetValue(DustSystem.getEntity(MetaLinks.LinkDefItemTypePrimary), out refPT))
                {
                    DustDataEntity ePT = ((DustDataReference)refPT).eTarget;

                    var eNew = new DustDataEntity();

                    eNew.setValue(DustSystem.getEntity(DataLinks.EntityPrimaryType), ePT, null);
                    ret = eNew;
                }
            }

            return(ret ?? defVal);
        }
Ejemplo n.º 2
0
        public void accessImpl(DustAccessCommand op, DustInfoTray tray)
        {
            var session = getCurrentSession();

            DustDataEntity ei = (tray.entity is DustContext)
                                ? session.ctx[((DustContext)tray.entity)]
                                : (DustDataEntity)tray.entity;

            var eKey = tray.key as DustDataEntity;

            if (null == eKey)
            {
                var key = tray.key as DustKey;
                if (null != key)
                {
                    eKey = modules[key.module][key.key];
                }
            }

            switch (op)
            {
            case DustAccessCommand.read:
                tray.value = ei.getValue(eKey, tray.value, tray.dustHint);

                if ((null == tray.value) && DustUtils.isEnumRef(eKey.optValType))
                {
                    foreach (DustProcCursor drc in rootSession.cursors)
                    {
                        if ((drc.owner == ei) && (drc.key == eKey))
                        {
                            tray.value = drc.Current.eTarget;
                            return;
                        }
                    }
                }

                break;

            case DustAccessCommand.write:
                tray.value = ei.setValue(eKey, tray.value, tray.dustHint);
                break;

            case DustAccessCommand.visit:
                var vp = new DustProcVisitProcess(session, tray);
                var vt = tray as DustVisitTray;

                if (null == vt)
                {
                    vp.visitRef(ei, eKey, null, true);
                }
                else
                {
                    vp.visitEntity(null);
                }
                break;
            }
        }