Example #1
0
    public static MetaCell CreateMetaCell(Cell cell)
    {
        MetaCell metaCell = new MetaCell();

        metaCell._x      = cell.X;
        metaCell._y      = cell.Y;
        metaCell._isWall = cell.Contains != null;
        return(metaCell);
    }
Example #2
0
    public static MetaField CreateMetaField(int cols, int rows, List <Cell> cells)
    {
        MetaField field = new MetaField();

        field._columns = cols;
        field._rows    = rows;
        for (int i = 0; i < cells.Count; i++)
        {
            field._field.Add(MetaCell.CreateMetaCell(cells[i]));
        }
        return(field);
    }
Example #3
0
        public void Scan(List <string> entity)
        {
            var type_groups = entity.Select(ParseTriple).Where(_ => _.Subject != null).GroupBy(_ => GetTypeName(_.Predicate)).ToList();

            if (type_groups.Count == 0)
            {
                return;
            }
            var cellId = MID2CellId(type_groups[0].First().Subject);

            var metacell = new MetaCell(cellId, Fields: new List <MetaField>());

            metacell.TypeId = -1;//mark type id to -1, indicating that this a multi-typed cell TODO constant
            foreach (var type_group in type_groups)
            {
                string type   = type_group.Key;
                int    typeId = TSLGenerator.GetTypeId(type);

                foreach (var property_instances in type_group.GroupBy(_ => GetTslName(_.Predicate)))
                {
                    string    property  = property_instances.Key;
                    int       fieldId   = TSLGenerator.GetFieldId(property);
                    bool      isList    = property_instances.Count() > 1;
                    FieldType fieldType = property_instances.Aggregate(FieldType.ft_byte, (v, current) =>
                    {
                        var current_ft = GetFieldType(ref current);
                        return(TSLGenerator.UpdateFieldType(v, current_ft));
                    });
                    MetaField field = new MetaField {
                        fieldId = fieldId, fieldType = fieldType, isList = isList, typeId = typeId
                    };
                    metacell.Fields.Add(field);
                }
            }

            Global.LocalStorage.SaveMetaCell(metacell);
        }
Example #4
0
 public void Add(MetaCell cell)
 {
     metaCells.Add(cell);
 }