本文整理汇总了C#中TagList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TagList.Add方法的具体用法?C# TagList.Add怎么用?C# TagList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagList
的用法示例。
在下文中一共展示了TagList.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static void Load(string path)
{
var l = new TagList<TagString>();
if (File.Exists(path))
{
var t = File.ReadAllLines(path);
var p = "";
foreach (string s in t)
{
//New page
if (s == "\t----")
{
l.Add(new TagString(p));
p = "";
continue;
}
if (p == "")
p = s;
else
p = p + "\n" + s;
}
l.Add(new TagString(p));
} else
{
l.Add(new TagString("Rules not found"));
}
var c = new TagCompound();
c ["pages"] = l;
c ["title"] = new TagString("Rules");
Debug.WriteLine("Rules: " + c);
Content = c;
}
示例2: ApplyId
public void ApplyId(TagList tag)
{
foreach (var kv in Operations) {
int index = Id.FindIndexWithId(tag, kv.Key);
if (index == -1) {
tag.Add(null);
index = tag.Count - 1;
}
kv.Value.Apply(tag, index);
}
}
示例3: MakeRootTag
private static TagCompound MakeRootTag()
{
TagList list = new TagList("ZZZZ", ETagType.Compound);
TagCompound tag = list.AddCompound();
tag.SetShort("EF", 4095);
TagCompound tag2 = list.AddCompound();
tag2.SetFloat("JK", 0.5f);
tag2.SetString("TXT", "Hello World!");
list.Add(tag);
list.Add(tag2);
dynamic root = new TagCompound("ROOT");
root.Set(list);
root.DYN = new int[] { 5, -6 };
root.ZZZZ[1].TEST = 0.1;
return root;
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//LabelMain.Text = GetContent("Body");
LiteralPageTitle.Text = FormatPageTitle("Sermon Archive");
LabelRightSideBarArea.Text = "<span class=\"title\">Archives</span><br />";
TagList pageTagList = null;
List<Document> SideBarList = null;
List<Document> DocumentList = null;
if (null == Session["EditRiverValleyMedia"])
{
DocumentList = Cache.Get("cache.RiverValley.MultimediaFiles") as List<Document>;
SideBarList = Cache.Get("cache.RiverValley.MultimediaSideBar") as List<Document>;
pageTagList = Cache.Get("cache.RiverValley.MultimediaTagList") as TagList;
}
if ((null == DocumentList) ||
(null == SideBarList) ||
(null == pageTagList))
{//Means that there is no cache read everything from disk
#region ReadLoop
DocumentList = new List<Document>();
SideBarList = new List<Document>();
pageTagList = new TagList();
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));
List<FileInfo> multimediaFileList = new List<FileInfo>();
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));
Document doc;
System.Collections.Hashtable ht2 = new System.Collections.Hashtable();
foreach (FileInfo file in multimediaFileList)
{
try
{
if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
doc = new VideoFile(this, file.Name);
else
doc = new AudioFile(this, file.Name);
foreach (Tag t in doc.Tags)
{
pageTagList.Add(t);
}
//doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
doc.Link = doc.Name;
}
catch { continue; }
DocumentList.Add(doc);
#region Fill RightSideBar
if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
{
SideBarList.Add(doc);
}
#endregion
}
#endregion
#region Sort
//Sort by date - sort should always be done after all filters for performance
DocumentList.Sort(delegate(Document f1, Document f2)
{
return DateTime.Compare(f2.Dated, f1.Dated);
});
//Do the same for right side bar
SideBarList.Sort(delegate(Document f1, Document f2)
{
return DateTime.Compare(f2.Dated, f1.Dated);
});
//And left
pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
{
return t1.Name.CompareTo(t2.Name);
});
#endregion
#region Insert Cache
//.........这里部分代码省略.........
示例5: ParseList
public static TagList ParseList(JsonReader reader, string rootName)
{
TagList list = new TagList(rootName);
bool foundGeneric = false;
while (reader.Read())
{
if (reader.TokenType == JsonToken.Boolean)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.Byte;
}
bool b = (bool)reader.Value;
TagByte tag = new TagByte(null, b);
list.Add(tag);
}
else if (reader.TokenType == JsonToken.Integer)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.Long;
}
long l = (long)reader.Value;
TagLong tag = new TagLong(null, l);
list.Add(tag);
}
else if (reader.TokenType == JsonToken.Float)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.Float;
}
else if (list.GenericType == ETagType.Long)
{
List<TagDouble> buf = new List<TagDouble>();
foreach (TagLong tl in list)
{
buf.Add(new TagDouble(tl.Name, tl.Value));
}
list.Clear();
list.GenericType = ETagType.Double;
foreach (TagDouble td in buf)
{
list.Add(td);
}
}
double d = (double)reader.Value;
TagDouble tag = new TagDouble(null, d);
list.Add(tag);
}
else if (reader.TokenType == JsonToken.String)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.String;
}
string s = reader.Value as string;
TagString tag = new TagString(null, s);
list.Add(tag);
}
else if (reader.TokenType == JsonToken.StartObject)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.Compound;
}
TagCompound tag = ParseCompound(reader, null);
list.Add(tag);
}
else if (reader.TokenType == JsonToken.StartArray)
{
if (!foundGeneric)
{
foundGeneric = true;
list.GenericType = ETagType.List;
}
TagList inner = ParseList(reader, null);
list.Add(inner);
}
else if (reader.TokenType == JsonToken.EndArray)
{
return list;
}
else
{
throw new NotImplementedException("Currently no handling for this type of JSON token: " + reader.TokenType.ToString());
}
}
//.........这里部分代码省略.........
示例6: TestTagListRoundTrip
public void TestTagListRoundTrip()
{
TagList orig = new TagList();
ITagRepository tagProvider = Global.GetTagRepository();
orig.Add(tagProvider.GetAndAddTagIfAbsent("foo", TagType.tag));
orig.Add(tagProvider.GetAndAddTagIfAbsent("freecycle", TagType.tag));
orig.Add(tagProvider.GetAndAddTagIfAbsent("barter", TagType.tag));
string serialized = JSON.Serialize(orig);
TagList deserialized = JSON.Deserialize<TagList>(serialized);
Assert.AreEqual(orig, deserialized, "Round trip serialization for TagList failed");
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
LabelMain.Text = GetContent("Body");
LabelRightSideBarArea.Text = "<span class=\"subtitle\">By Month</span><br />";
TagList pageTagList = null;
List<Document> SideBarList = null;
List<Document> DocumentList = null;
if (null == Session["EditjudekGallery"])
{
DocumentList = Cache.Get("cache.judek.MultimediaFiles") as List<Document>;
SideBarList = Cache.Get("cache.judek.MultimediaSideBar") as List<Document>;
pageTagList = Cache.Get("cache.judek.MultimediaTagList") as TagList;
}
if ((null == DocumentList) ||
(null == SideBarList) ||
(null == pageTagList))
{//Means that there is no cache read everything from disk
#region ReadLoop
DocumentList = new List<Document>();
SideBarList = new List<Document>();
pageTagList = new TagList();
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));
List<FileInfo> multimediaFileList = new List<FileInfo>();
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));
Document doc;
System.Collections.Hashtable ht2 = new System.Collections.Hashtable();
foreach (FileInfo file in multimediaFileList)
{
try
{
if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
doc = new VideoFile(this, file.Name);
else
doc = new AudioFile(this, file.Name);
foreach (Tag t in doc.Tags)
{
pageTagList.Add(t);
}
//doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
doc.Link = doc.Name;
}
catch { continue; }
DocumentList.Add(doc);
#region Fill RightSideBar
if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
{
SideBarList.Add(doc);
}
#endregion
}
#endregion
#region Sort
//Sort by date - sort should always be done after all filters for performance
DocumentList.Sort(delegate(Document f1, Document f2)
{
return DateTime.Compare(f2.Dated, f1.Dated);
});
//Do the same for right side bar
SideBarList.Sort(delegate(Document f1, Document f2)
{
return DateTime.Compare(f2.Dated, f1.Dated);
});
//And left
pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
{
return t1.Name.CompareTo(t2.Name);
});
#endregion
#region Insert Cache
//Fill the cache with newly read info.
//.........这里部分代码省略.........
示例8: Apply
public override void Apply(TagList tag, int key)
{
while (key >= tag.Count)
tag.Add(null);
tag[key] = _value;
}