public void AddingTagTest() { TagCollection myCollection = new TagCollection(); bool firstAddingResult = true; foreach (var item in testTags.Values) { firstAddingResult = firstAddingResult && myCollection.AddTag(item); } bool secondtAddingResult = true; foreach (var item in testTags.Values) { secondtAddingResult = secondtAddingResult && myCollection.AddTag(item); } Assert.AreEqual(true, firstAddingResult); Assert.AreEqual(false, secondtAddingResult); }
public InfoGroup <BaseInfoType> ToInfoGroup() { InfoGroup <BaseInfoType> g = new InfoGroup <BaseInfoType>("RJOutline"); foreach (KeyValuePair <String, String> kv in this.data) { if (LocaleTexts.IsEqual("文件容量", kv.Key)) { g.InfoList.Add(kv.Key, new LiteralText(kv.Key, kv.Value)); continue; } TagCollection tc = new TagCollection(kv.Key); if (LocaleTexts.IsEqual("分类", kv.Key)) { String[] s = kv.Value.Split(' '); foreach (String ss in s) { tc.AddTag(new Tag(ss)); } } else if (LocaleTexts.IsEqual("作者", kv.Key) || LocaleTexts.IsEqual("剧情", kv.Key) || LocaleTexts.IsEqual("插画", kv.Key) || LocaleTexts.IsEqual("声优", kv.Key)) { String[] s = kv.Value.Split(new String[] { " / " }, StringSplitOptions.RemoveEmptyEntries); foreach (String ss in s) { tc.AddTag(new Tag(ss)); } } else { tc.AddTag(new Tag(kv.Value)); } g.InfoList.Add(tc.Name, tc); } return(g); }
protected override void ApplyEffectsCore(AttackState state, TagCollection target) { foreach (var tag in state.GetTags(TagScope)) { if (MatchKindUtility.IsMatch(tag.Key, TagKey, TagKeyMatchKind, false)) { var newTag = tag.CloneWithKey(NewTagKey); target.AddTag(newTag, ConflictResolution); } } }
public InfoGroup <BaseInfoType> GetAllInfos() { InfoGroup <BaseInfoType> info = new InfoGroup <BaseInfoType>(RJNum); RJOutline outline = new RJOutline(html); Locale l = outline.GetLocale(); String cache = LocaleTexts.InLang("作品名", l); info.InfoList.Add(cache, new LiteralText(cache, GetWorkName())); cache = LocaleTexts.InLang("封面图", l); InfoGroup <Picture> pics = new InfoGroup <Picture>(cache); int i = 0; foreach (Image pic in GetImages()) { pics.InfoList.Add((i).ToString(), new Picture(i.ToString(), pic)); i++; } info.InfoList.Add(cache, pics); cache = LocaleTexts.InLang("社团名", l); TagCollection tc = new TagCollection(cache); tc.AddTag(new Tag(GetCircleName())); info.InfoList.Add(cache, tc); foreach (BaseInfoType inf in outline.ToInfoGroup()) { info.InfoList.Add(inf.Name, inf); } cache = LocaleTexts.InLang("作品内容", l); info.InfoList.Add(cache, new LiteralText(cache, GetSummary())); cache = LocaleTexts.InLang("评价", l); info.InfoList.Add(cache, new LiteralText(cache, GetRating())); return(info); }
public void TestInitialize() { int totalcount = 30600; int boolcoilcount = 0; int boolinputcount = 0; int ushortholdingcount = 0; int ushortinputcount = 0; int floatholdingcount = 0; int floatinputcount = 0; for (int i = 0; i < totalcount; i++) { string name = ""; Tag newTag; if (i < (totalcount / 6)) { //bool tag - coil status boolcoilcount++; name = "boolcoil"; newTag = new Tag(name + boolcoilcount.ToString()); newTag.DefineBoolTag(StatusFunction.CoilStatus); } else if (i >= (totalcount / 6) && i < (totalcount * 2 / 6)) { //bool tag - input status boolinputcount++; name = "boolinput"; newTag = new Tag(name + boolinputcount.ToString()); newTag.DefineBoolTag(StatusFunction.InputStatus); } else if (i >= (totalcount * 2 / 6) && i < (totalcount * 3 / 6)) { //ushort tag - holding register ushortholdingcount++; name = "ushortholding"; newTag = new Tag(name + ushortholdingcount.ToString()); newTag.DefineUshortTag(RegisterFunction.HoldingRegister); } else if (i >= (totalcount * 3 / 6) && i < (totalcount * 4 / 6)) { //ushort tag - input register ushortinputcount++; name = "ushortinput"; newTag = new Tag(name + ushortinputcount.ToString()); newTag.DefineUshortTag(RegisterFunction.InputRegister); } else if (i >= (totalcount * 4 / 6) && i < (totalcount * 5 / 6)) { //float tag - holding register floatholdingcount++; name = "floatholding"; newTag = new Tag(name + floatholdingcount.ToString()); newTag.DefineFloatTag(RegisterFunction.HoldingRegister, new Converters.LSRFFloatConverter()); } else { //float tag - input register floatinputcount++; name = "floatinput"; newTag = new Tag(name + floatinputcount.ToString()); newTag.DefineFloatTag(RegisterFunction.InputRegister, new Converters.LSRFFloatConverter()); } newTag.InnerTag.AddAddress((ushort)i); myCollection.AddTag(newTag); } myCollection.CalculateParseAddresses(); }
protected override void ApplyEffectsCore(AttackState state, TagCollection target) { target.AddTag(Tag, ConflictResolution); }
public void GetTagWithNameTest() { TagCollection myCollection = new TagCollection(); foreach (var item in testTags.Values) { myCollection.AddTag(item); } int boolcount = 0; foreach (var item in testTags.Keys) { if (item.StartsWith("bool")) { if (myCollection.GetBoolTagWithName(item) != null) { boolcount++; } } } int ushortcount = 0; foreach (var item in testTags.Keys) { if (item.StartsWith("ushort")) { if (myCollection.GetUshortTagWithName(item) != null) { ushortcount++; } } } int floatcount = 0; foreach (var item in testTags.Keys) { if (item.StartsWith("float")) { if (myCollection.GetFloatTagWithName(item) != null) { floatcount++; } } } int totalcount = 0; foreach (var item in testTags.Keys) { if (myCollection.GetTagWithName(item) != null) { totalcount++; } } Assert.AreEqual(20, boolcount); Assert.AreEqual(20, ushortcount); Assert.AreEqual(20, floatcount); Assert.AreEqual(60, totalcount); }