Exemple #1
0
        public void Invalidate(ObjectId[] objectsToInvalidate)
        {
            foreach (var roleByAssociationEntry in this.cachedCompositeRoleByAssociationByRoleType)
            {
                var roleByAssociation = roleByAssociationEntry.Value;
                foreach (var objectToInvalidate in objectsToInvalidate)
                {
                    roleByAssociation.Remove(objectToInvalidate);
                }
            }

            foreach (var roleByAssociationEntry in this.cachedCompositeRoleByAssociationByRoleType)
            {
                var roleByAssociation = roleByAssociationEntry.Value;
                foreach (var objectToInvalidate in objectsToInvalidate)
                {
                    roleByAssociation.Remove(objectToInvalidate);
                }
            }

            foreach (var roleByAssociationEntry in this.cachedCompositesRoleByAssociationByRoleType)
            {
                var roleByAssociation = roleByAssociationEntry.Value;
                foreach (var objectToInvalidate in objectsToInvalidate)
                {
                    roleByAssociation.Remove(objectToInvalidate);
                }
            }
        }
Exemple #2
0
 internal Reference(Session session, IClass @class, ObjectId objectId, long cacheId)
     : this(session, @class, objectId, false)
 {
     this.cacheId = cacheId;
     this.flags[MaskExistsKnown] = true;
     this.flags[MaskExists] = true;
 }
Exemple #3
0
 internal override void AdjustCurrentId(ObjectId id)
 {
     var idLong = (ObjectIdLong)id;
     if (idLong.ValueLong > this.currentId)
     {
         this.currentId = idLong.ValueLong;
     }
 }
Exemple #4
0
 internal override void AdjustCurrentId(ObjectId id)
 {
     ObjectIdInteger idInteger = (ObjectIdInteger) id;
     if (idInteger.ValueInteger > currentId)
     {
         currentId = idInteger.ValueInteger;
     }
 }
Exemple #5
0
        internal Reference(Session session, IClass @class, ObjectId objectId, bool isNew)
        {
            this.session = session;
            this.@class = @class;
            this.objectId = objectId;

            this.flags[MaskIsNew] = isNew;
            if (isNew)
            {
                this.flags[MaskExistsKnown] = true;
                this.flags[MaskExists] = true;
            }
        }
Exemple #6
0
        public ICachedObject GetOrCreateCachedObject(IClass concreteClass, ObjectId objectId, long localCacheId)
        {
            if (this.transientConcreteClasses != null && this.transientConcreteClasses.Contains(concreteClass))
            {
                return new CachedObject(localCacheId);
            }

            CachedObject cachedObject;
            if (this.cachedObjectByObjectId.TryGetValue(objectId, out cachedObject))
            {
                if (!cachedObject.LocalCacheVersion.Equals(localCacheId))
                {
                    cachedObject = new CachedObject(localCacheId);
                    this.cachedObjectByObjectId[objectId] = cachedObject;
                }
            }
            else
            {
                cachedObject = new CachedObject(localCacheId);
                this.cachedObjectByObjectId[objectId] = cachedObject;
            }

            return cachedObject;
        }
Exemple #7
0
 internal void OnCreated(ObjectId objectId)
 {
     this.created.Add(objectId);
 }
Exemple #8
0
 public void SetObjectType(ObjectId objectId, IClass objectType)
 {
     this.objectTypeByObjectId[objectId] = objectType;
 }
Exemple #9
0
 public IClass GetObjectType(ObjectId objectId)
 {
     IClass objectType;
     this.objectTypeByObjectId.TryGetValue(objectId, out objectType);
     return objectType;
 }
Exemple #10
0
        public void OnChangingCompositesRole(ObjectId association, IRoleType roleType, ObjectId changedRole)
        {
            this.associations.Add(association);

            if (changedRole != null)
            {
                this.roles.Add(changedRole);
            }

            this.RoleTypes(association).Add(roleType);
        }
Exemple #11
0
 public bool IsForced(ObjectId objectId)
 {
     return this.ForcedDerivations.Contains(objectId);
 }
Exemple #12
0
            internal bool Contains(ObjectId objectId)
            {
                if (this.removed != null && this.removed.Contains(objectId))
                {
                    return false;
                }

                return this.baseline.Contains(objectId) || (this.added != null && this.added.Contains(objectId));
            }
Exemple #13
0
 internal UnitRelation(ObjectId association, object role)
 {
     this.Association = association;
     this.Role = role;
 }
Exemple #14
0
        public void OnChangingUnitRole(ObjectId association, IRoleType roleType)
        {
            this.associations.Add(association);

            this.RoleTypes(association).Add(roleType);
        }
Exemple #15
0
        internal bool ExtentContains(IRoleType roleType, ObjectId objectId)
        {
            CompositesRole compositesRole;
            if (this.ModifiedRolesByRoleType != null && this.ModifiedRolesByRoleType.TryGetValue(roleType, out compositesRole))
            {
                return compositesRole.Contains(objectId);
            }

            return Array.IndexOf(this.GetNonModifiedCompositeRoles(roleType), objectId) >= 0;
        }
Exemple #16
0
        public bool TryGetUnit(ObjectId association, object cacheId, IRoleType roleType, out object role)
        {
            Dictionary<ObjectId, CachedUnitRole> entryByAssociation;
            if (this.cachedUnitRoleByAssociationByRoleType.TryGetValue(roleType, out entryByAssociation))
            {
                CachedUnitRole cachedUnitRole;
                if (entryByAssociation.TryGetValue(association, out cachedUnitRole))
                {
                    if (cachedUnitRole.CacheId.Equals(cacheId))
                    {
                        role = cachedUnitRole.Role;
                        return true;
                    }
                }
            }

            role = null;
            return false;
        }
Exemple #17
0
        internal void OnChangingCompositeRole(Roles association, IRoleType roleType, ObjectId previousRole, ObjectId newRole)
        {
            this.associations.Add(association.Reference.ObjectId);

            if (previousRole != null)
            {
                this.roles.Add(previousRole);
            }

            if (newRole != null)
            {
                this.roles.Add(newRole);
            }

            this.RoleTypes(association.Reference.ObjectId).Add(roleType);
        }
Exemple #18
0
        public ISet<IRoleType> GetRoleTypes(ObjectId association)
        {
            ISet<IRoleType> roleTypes;
            if (this.RoleTypesByAssociation.TryGetValue(association, out roleTypes))
            {
                return roleTypes;
            }

            return this.emptySet;
        }
Exemple #19
0
 public void OnDeleted(ObjectId objectId)
 {
     this.deleted.Add(objectId);
 }
Exemple #20
0
 public void OnCreated(ObjectId objectId)
 {
     this.created.Add(objectId);
 }
Exemple #21
0
 internal CachedCompositesRole(object cacheId, ObjectId[] role)
 {
     this.cacheId = cacheId;
     this.role = role;
 }
Exemple #22
0
 internal void OnDeleted(ObjectId objectId)
 {
     this.deleted.Add(objectId);
 }
Exemple #23
0
        public void SetComposite(ObjectId association, object cacheId, IRoleType roleType, ObjectId role)
        {
            Dictionary<ObjectId, CachedCompositeRole> entryByAssociation;
            if (!this.cachedCompositeRoleByAssociationByRoleType.TryGetValue(roleType, out entryByAssociation))
            {
                entryByAssociation = new Dictionary<ObjectId, CachedCompositeRole>();
                this.cachedCompositeRoleByAssociationByRoleType[roleType] = entryByAssociation;
            }

            entryByAssociation[association] = new CachedCompositeRole(cacheId, role);
        }
Exemple #24
0
        private ISet<IRoleType> RoleTypes(ObjectId associationId)
        {
            ISet<IRoleType> roleTypes;
            if (!this.RoleTypesByAssociation.TryGetValue(associationId, out roleTypes))
            {
                roleTypes = new HashSet<IRoleType>();
                this.RoleTypesByAssociation[associationId] = roleTypes;
            }

            return roleTypes;
        }
Exemple #25
0
        internal bool TryGetCompositeRole(IRoleType roleType, out ObjectId roleId)
        {
            roleId = null;

            object role = null;
            if (this.modifiedRoleByRoleType == null || !this.modifiedRoleByRoleType.TryGetValue(roleType, out role))
            {
                if (this.CachedObject == null || !this.CachedObject.TryGetValue(roleType, out role))
                {
                    if (!this.Reference.IsNew)
                    {
                        return false;
                    }
                }
            }

            roleId = (ObjectId)role;
            return true;
        }
Exemple #26
0
 public static C1 Instantiate(ISession session, ObjectId id)
 {
     return (C1)session.Instantiate(id);
 }
Exemple #27
0
            internal void Remove(ObjectId objectId)
            {
                if (this.original == null)
                {
                    this.original = new HashSet<ObjectId>(this.baseline);
                }

                if (this.added != null && this.added.Contains(objectId))
                {
                    this.added.Remove(objectId);
                    return;
                }

                if (this.baseline.Contains(objectId))
                {
                    if (this.removed == null)
                    {
                        this.removed = new HashSet<ObjectId>();
                    }

                    this.removed.Add(objectId);
                }
            }
Exemple #28
0
 private IObject GetObject(ObjectId objectId)
 {
     return new Strategy(this.Session, objectId).GetObject();
 }
Exemple #29
0
 internal Strategy(Session session, ObjectId objectId)
 {
     this.session = session;
     this.objectId = objectId;
 }
Exemple #30
0
 internal abstract void AdjustCurrentId(ObjectId id);