Beispiel #1
0
        public static AbstractItem GetItem(string type)
        {
            AbstractItem item = null;

            if (type.Equals("Campus"))
            {
                item = new Campus();
            }
            else if (type.Equals("Category"))
            {
                item = new Category();
            }
            else if (type.Equals("Comment"))
            {
                item = new Comment();
            }
            else if (type.Equals("LostItem"))
            {
                item = new LostAndFoundItem();
            }
            return(item);
        }
Beispiel #2
0
 public void Init()
 {
     #region 初始化
     Campuslist = new List <Campus>();
     Campus campus1 = (Campus)ItemFactory.GetItem("Campus");
     Campus campus2 = (Campus)ItemFactory.GetItem("Campus");
     Campus campus3 = (Campus)ItemFactory.GetItem("Campus");
     Campus campus4 = (Campus)ItemFactory.GetItem("Campus");
     campus1.Rename("文理学部");
     campus2.Rename("信息学部");
     campus3.Rename("工学部");
     campus4.Rename("医学部");
     Campuslist.Add(campus1);
     Campuslist.Add(campus2);
     Campuslist.Add(campus3);
     Campuslist.Add(campus4);
     Category category1_1 = (Category)ItemFactory.GetItem("Category");
     Category category1_2 = (Category)ItemFactory.GetItem("Category");
     Category category1_3 = (Category)ItemFactory.GetItem("Category");
     Category category1_4 = (Category)ItemFactory.GetItem("Category");
     Category category1_5 = (Category)ItemFactory.GetItem("Category");
     category1_1.Rename("书籍");
     category1_2.Rename("电子");
     category1_3.Rename("证件");
     category1_4.Rename("日用");
     category1_5.Rename("其他");
     campus1.Add(category1_1);
     campus1.Add(category1_2);
     campus1.Add(category1_3);
     campus1.Add(category1_4);
     campus1.Add(category1_5);
     Category category2_1 = (Category)ItemFactory.GetItem("Category");
     Category category2_2 = (Category)ItemFactory.GetItem("Category");
     Category category2_3 = (Category)ItemFactory.GetItem("Category");
     Category category2_4 = (Category)ItemFactory.GetItem("Category");
     Category category2_5 = (Category)ItemFactory.GetItem("Category");
     category2_1.Rename("书籍");
     category2_2.Rename("电子产品");
     category2_3.Rename("证件");
     category2_4.Rename("日用品");
     category2_5.Rename("其他");
     campus2.Add(category2_1);
     campus2.Add(category2_2);
     campus2.Add(category2_3);
     campus2.Add(category2_4);
     campus2.Add(category2_5);
     Category category3_1 = (Category)ItemFactory.GetItem("Category");
     Category category3_2 = (Category)ItemFactory.GetItem("Category");
     Category category3_3 = (Category)ItemFactory.GetItem("Category");
     Category category3_4 = (Category)ItemFactory.GetItem("Category");
     Category category3_5 = (Category)ItemFactory.GetItem("Category");
     category3_1.Rename("书籍");
     category3_2.Rename("电子产品");
     category3_3.Rename("证件");
     category3_4.Rename("日用品");
     category3_5.Rename("其他");
     campus3.Add(category3_1);
     campus3.Add(category3_2);
     campus3.Add(category3_3);
     campus3.Add(category3_4);
     campus3.Add(category3_5);
     Category category4_1 = (Category)ItemFactory.GetItem("Category");
     Category category4_2 = (Category)ItemFactory.GetItem("Category");
     Category category4_3 = (Category)ItemFactory.GetItem("Category");
     Category category4_4 = (Category)ItemFactory.GetItem("Category");
     Category category4_5 = (Category)ItemFactory.GetItem("Category");
     category4_1.Rename("书籍");
     category4_2.Rename("电子产品");
     category4_3.Rename("证件");
     category4_4.Rename("日用品");
     category4_5.Rename("其他");
     campus4.Add(category4_1);
     campus4.Add(category4_2);
     campus4.Add(category4_3);
     campus4.Add(category4_4);
     campus4.Add(category4_5);
     #endregion
     #region 加入一些项目
     LostAndFoundItem mybook1 = (LostAndFoundItem)ItemFactory.GetItem("LostItem");
     mybook1.Rename("软件架构理论与实践");
     mybook1.EditDescription("白色封皮,封面有名字,本人电话1234567890");
     Campuslist[0].GetChild(0).Add(mybook1);
     #endregion
 }