Exemplo n.º 1
0
        private long RouteToChildCell(string fieldName)
        {
            //string np = CellGroupUtil.Normalize(fieldName);
            ushort ct = CellGroupUtil.GetTypeCode(fieldName);

            return(CellGroupUtil.GetCellID(CellId, ct));
        }
Exemplo n.º 2
0
 private IEnumerable <long> ChildrenIDs()
 {
     using (var cell = Global.LocalStorage.Usetype_object(CellId))
     {
         foreach (var type in cell.types)
         {
             yield return(CellGroupUtil.GetCellID(CellId, type));
         }
     }
 }
Exemplo n.º 3
0
        public bool isOfType(string cell_type_name)
        {
            ushort cell_type = (ushort)StorageSchema.GetCellType(cell_type_name);
            long   cid       = CellGroupUtil.GetCellID(cell_id, cell_type);

            var generic_child = Global.LocalStorage.UseGenericCell(cid, CellAccessOptions.ReturnNullOnCellNotFound);

            if (generic_child == null)
            {
                return(false);
            }

            generic_child.Dispose();
            return(true);
        }
Exemplo n.º 4
0
        public T Cast <T>() where T : ICellAccessor
        {
            ushort cell_type;
            string cell_type_name = typeof(T).Name;

            cell_type_name = cell_type_name.Substring(0, cell_type_name.Length - 9);
            cell_type      = (ushort)StorageSchema.GetCellType(cell_type_name);

            long cid = CellGroupUtil.GetCellID(cell_id, cell_type);

            var generic_child = Global.LocalStorage.UseGenericCell(cid, CellAccessOptions.ReturnNullOnCellNotFound);

            if (generic_child == null)
            {
                return(default(T));
            }

            return((T)generic_child);
        }
Exemplo n.º 5
0
        public T GetField <T>(string fieldName)
        {
            if (fieldName.Equals("entity_ids"))
            {
                using (var cell = Global.LocalStorage.UseGenericCell(category_cell_id, CellAccessOptions.ReturnNullOnCellNotFound))
                {
                    if (cell == null)
                    {
                        return(default(T));
                    }
                    return(cell.GetField <T>(fieldName));
                }
            }

            if (fieldName.Equals("type_object_type"))
            {
                using (var cell = Global.LocalStorage.UseGenericCell(CellId, CellAccessOptions.ReturnNullOnCellNotFound))
                {
                    if (cell == null)
                    {
                        throw new ArgumentException("Undefined field.");
                    }

                    var type_names = cell.GetField <List <ushort> >("types").Select(tcode => CellGroupUtil.GetTypeName(tcode));
                    return(_convert <T>(type_names));
                }
            }

            long child_id = RouteToChildCell(fieldName);

            using (var cell = Global.LocalStorage.UseGenericCell(child_id, CellAccessOptions.ReturnNullOnCellNotFound))
            {
                if (cell == null)
                {
                    return(default(T));
                }
                return(cell.GetField <T>(fieldName));
            }
        }