本文整理汇总了C#中Categories.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Categories.Add方法的具体用法?C# Categories.Add怎么用?C# Categories.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Categories
的用法示例。
在下文中一共展示了Categories.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Excluded
private bool Excluded(ITestMethodInfo testMethod) {
if(_excludedCategories.IsEmpty) {
return false;
}
var local = new Categories();
local.Add(testMethod.Categories);
local.Add(testMethod.InheritedCategories);
return local.Intersect(_excludedCategories).Count > 0;
}
示例2: GetCategory
public Categories GetCategory(string[] ids, int ipage)
{
if (ids == null || ids.Length == 0)
return new Categories();
if (IdCateDic.Count == 0)
{
TryToLoadCategoriesDicFromFile();
}
if (IdCateDic.ContainsKey(ids[0]))
{
Categories categories = new Categories();
foreach (var id in ids)
{
categories.Add(IdCateDic[id]);
}
return categories;
}
else
{
return GetCategoryFromNetwork(ids, ipage);
}
}
示例3: ExcludedSurvivesRefresh
public void ExcludedSurvivesRefresh() {
RecipeFactory.Type = typeof(ASpecialRecipe);
RecipeFactory.NewRecipe(string.Empty);
_fc.ResetAllCategories();
_fc.ExcludeCategory("Blue");
_fc.RefreshCategoriesList();
var expected = new Categories();
expected.Add("Blue");
Assert.Equals(expected, _fc.ExcludedCategories);
}
示例4: IsIncluded
private bool IsIncluded(ITestFixture testFixture) {
if( _includedCategories.IsEmpty
|| (testFixture.Categories.IsEmpty
&& testFixture.InheritedCategories.IsEmpty) ) {
return true;
}
var local = new Categories();
local.Add(testFixture.Categories);
local.Add(testFixture.InheritedCategories);
return local.Intersect(_includedCategories).Count > 0;
}
示例5: DeserializeCategories
private static void DeserializeCategories(XmlNode doc, string categoriesGroupName,
Categories categoriesCollection) {
var includedCatNodes = doc.SelectNodes("categorySelector/" + categoriesGroupName + "/category");
foreach(XmlElement elem in includedCatNodes) {
categoriesCollection.Add(elem.InnerText);
}
}
示例6: StringsTrimmedWhenArrayAdded
public void StringsTrimmedWhenArrayAdded() {
var strings = new[] { " blue ", " green " };
var cats = new Categories();
cats.Add(strings);
Assert.Equals(2, cats.Count);
Assert.Contains("blue", cats.ToArray());
Assert.DoesNotContain(" blue ", cats.ToArray());
Assert.Contains("green", cats.ToArray());
Assert.DoesNotContain(" green ", cats.ToArray());
}
示例7: Main
static void Main(string[] args) {
var osInfo = System.Environment.OSVersion;
Settings.Load(Toolkit.CurrentDirectory.FindPrecedingFile("settings.json").FullPath);
var pwd = Settings.Passcode;
var dbcfg = Settings.Databases["default"];
var cats = new Categories().Select();
var parents = new Categories().Where(new { ParentID = DBNull.Value });
var productData = Util.IO.File.ReadText("C:\\Work\\products.json");
var products = AOI.Util.Codecs.JSON.Decode<List<Dictionary<string, dynamic>>>(productData);
foreach (var product in products) {
var productCategory = ((string)product["category"]).ToUpper();
var parts = productCategory.Split('/');
var parentCategory = parts[0];
var pc = parents.Where(c => c.Label.ToUpper() == parentCategory).FirstOrDefault();
if (pc == null) {
pc = new Categories().Single(new { Label = productCategory });
if (pc == null) {
pc = new Categories().Add(new {
Label = parentCategory
});
parents.Add(pc);
}
}
if (parts.Length > 1) {
var childCategory = parts[1];
var child = pc.Child(childCategory, true);
product["category_id"] = child.ID;
} else {
product["category_id"] = pc.ID;
}
var description = product["description"];
description = Util.Toolkit.UrlDecode(description);
var url = product["picture"];
//var data = Util.Http.GET(url);
//Util.IO.File.WriteBinary("C:\\Work\\product.jpg", data);
//product["picture_snapshot"] = data;
}
Log.Trace("...");
//new Categories().Fetch(
// new {
// ParentID = 1
// }
//);
//var filtered = new Categories().Where(new {
// ParentID = 2
//});
//var categories = new Categories().Select();
//var category = categories[0];
//var childrens = category.Children;
////category.Update(new {
//// Description = "This is a category."
//// });
//var child = category.Create("MIRRORS");
//var children = category.Children;
var db = AOI.Data.Database.Open("DefaultConnection");
//db.Insert(new Query("INSERT INTO categories (label, ParentID) VALUES (@label, @ParentID);").Set("Label", "ACCESSORIES").Set("ParentID", 2));
//var people = db.SelectRecords<Person>("SELECT applicant_transaction_number as ID, first_name as FirstName, last_name as LastName FROM \"Applicants\" LIMIT 10;");
//var records = db.SelectRecords("SELECT first_name as FirstName, last_name as LastName FROM \"Applicants\" LIMIT 10;");
//var records = db.SelectRecords("SELECT * FROM \"Applicants\";");
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "ACCESSORIES"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "ARCHITECTURAL"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "FURNISHINGS"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "TEXTILES"));
var records = db.SelectRecords<Category>("SELECT * FROM Categories;");
Console.WriteLine("...");
}
示例8: RemoveFiresOnlyWhenCatRemoved
public void RemoveFiresOnlyWhenCatRemoved() {
var eventListener = new ModifiedListener();
var cats = new Categories();
cats.Modified += eventListener.OnModified;
cats.Add("blue");
cats.Remove("red");
Assert.Equals(1, eventListener.EventCount, "Modified event wasn't fired.");
}
示例9: AddedStringIsTrimmed
public void AddedStringIsTrimmed() {
var cats = new Categories();
cats.Add(" blue ");
Assert.Equals(1, cats.Count);
Assert.Contains("blue", cats.ToArray());
Assert.DoesNotContain(" blue ", cats.ToArray());
}
示例10: ClearOnNonEmptyFiresModifiedEvent
public void ClearOnNonEmptyFiresModifiedEvent() {
var eventListener = new ModifiedListener();
var cats = new Categories();
cats.Modified += eventListener.OnModified;
cats.Add("bla");
cats.Clear();
Assert.Equals(2, eventListener.EventCount, "Modified event wasn't fired.");
}
示例11: AddCategoriesFiresModifiedEvent
public void AddCategoriesFiresModifiedEvent() {
var eventListener = new ModifiedListener();
var cats = new Categories();
cats.Modified += eventListener.OnModified;
var otherCats = new Categories();
otherCats.Add(new[] { "red", "green", "blue" });
cats.Add(otherCats);
Assert.Equals(1, eventListener.EventCount, "Modified event wasn't fired.");
}
示例12: AddStringArrayFiresOnceOnly
public void AddStringArrayFiresOnceOnly() {
var eventListener = new ModifiedListener();
var cats = new Categories();
cats.Modified += eventListener.OnModified;
cats.Add(new[] { "red", "green", "blue" });
Assert.Equals(1, eventListener.EventCount, "Modified event wasn't fired.");
}
示例13: AddFiresModifiedEventOnlyIfSomethingHasBeenAdded
public void AddFiresModifiedEventOnlyIfSomethingHasBeenAdded() {
var eventListener = new ModifiedListener();
var cats = new Categories();
cats.Add("bla");
cats.Modified += eventListener.OnModified;
cats.Add("bla"); // adding the same shouldn't fire
Assert.Equals(0, eventListener.EventCount,
"Modified event was fired unnecessarily.");
}
示例14: EmptyStringIsIgnoredAsCategory
public void EmptyStringIsIgnoredAsCategory() {
var cats = new Categories();
cats.Add(string.Empty);
Assert.Equals(0, cats.Count);
}