Beispiel #1
0
        /// <summary>
        /// Get an entity from its id
        /// </summary>
        /// <param name="id">Id of the entity</param>
        /// <returns>The entity corresponding to the id</returns>
        public EntityFactory.Entity GetEntity(UInt32 id)
        {
            CorePackage.Global.IDefinition def = entity_factory.Find(id);

            return(new EntityFactory.Entity
            {
                Id = id,
                Name = def.Name,
                Type = GetEntityType(id),
                Visibility = (EntityFactory.VISIBILITY)def.Parent.GetVisibilityOf(def.Name)
            });
        }
Beispiel #2
0
        /// <summary>
        /// Get a list of entities corresponding to the given ids.
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public List <EntityFactory.Entity> GetEntities(List <UInt32> ids)
        {
            if (ids == null)
            {
                return(null);
            }
            var ret = new List <EntityFactory.Entity>();

            foreach (var id in ids)
            {
                CorePackage.Global.IDefinition def = entity_factory.Find(id);
                ret.Add(new EntityFactory.Entity {
                    Id = id, Name = def.Name, Type = GetEntityType(id)
                });
            }
            return(ret);
        }
Beispiel #3
0
        public UInt32 FindEntity(string path)
        {
            String[] names = path.Substring(1).Split('/');
            CorePackage.Global.IDefinition cwe = entity_factory.Find(EntityFactory.BASE_ID.GLOBAL_CTX);

            foreach (string name in names)
            {
                if (cwe is CorePackage.Global.IDeclarator decl)
                {
                    cwe = decl.Find(name);
                }
                else
                {
                    throw new KeyNotFoundException($"Cannot access to entity {name} from {cwe.Name}: Not a declarator");
                }
            }
            return(entity_factory.GetEntityID(cwe));
        }