/// <summary> /// Find list of Cloth object by shapes. /// NOTES: There are two rules for clothes to be selected: /// <list type="number"> /// <item>It should contains all shapes in <code>shapes</code>.</item> /// <item>It should not contains any shapes in <code>notShapes</code>.</item> /// </list> /// </summary> /// <param name="shapes">The shapes contained by clothes.</param> /// <param name="notShapes">The shapes NOT contained by clothes.</param> /// <returns>Cloth objects list; empty list if none found.</returns> public List <Cloth> FindAllByShapes(ShapeEnum shapes, ShapeEnum notShapes) { Storage storage = DaoHelper.Instance.DbStorage; ClothRoot root = (ClothRoot)storage.Root; List <Cloth> clothes = new List <Cloth>(); BitIndex shapeIndex = root.ShapeIndex; if (shapeIndex.Count > 0) { foreach (Cloth cloth in shapeIndex.Select((int)shapes, (int)notShapes)) { clothes.Add(cloth); } } return(clothes); }
/// <summary> /// Find list of Cloth object by colors. /// NOTES: There are two rules for clothes to be selected: /// <list type="number"> /// <item>It should contains all colors in <code>colors</code>.</item> /// <item>It should not contains any colors in <code>notColors</code>.</item> /// </list> /// </summary> /// <param name="colors">The colors contained by clothes.</param> /// <param name="notColors">The colors NOT contained by clothes.</param> /// <returns>Cloth objects list; empty list if none found.</returns> public List <Cloth> FindAllByColors(ColorEnum colors, ColorEnum notColors) { Storage storage = DaoHelper.Instance.DbStorage; ClothRoot root = (ClothRoot)storage.Root; List <Cloth> clothes = new List <Cloth>(); BitIndex colorIndex = root.ColorIndex; // Console.WriteLine(colorIndex.Count); if (colorIndex.Count > 0) { foreach (Cloth cloth in colorIndex.Select((int)colors, (int)notColors)) { clothes.Add(cloth); } } return(clothes); }