当前位置: 首页>>代码示例>>C#>>正文


C# TagList.Add方法代码示例

本文整理汇总了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;
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:34,代码来源:Rules.cs

示例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);
     }
 }
开发者ID:jaquadro,项目名称:NNBT,代码行数:11,代码来源:NbtMerge.cs

示例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;
        }
开发者ID:einsteinsci,项目名称:nbt-io,代码行数:18,代码来源:Program.cs

示例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
//.........这里部分代码省略.........
开发者ID:judek,项目名称:RiverValley2,代码行数:101,代码来源:Multimedia.aspx.cs

示例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());
                }
            }

//.........这里部分代码省略.........
开发者ID:einsteinsci,项目名称:nbt-io,代码行数:101,代码来源:NbtJsonReader.cs

示例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");
        }
开发者ID:utunga,项目名称:Tradeify,代码行数:13,代码来源:TestSerialization.cs

示例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.

//.........这里部分代码省略.........
开发者ID:judek,项目名称:judek,代码行数:101,代码来源:Multimedia.aspx.cs

示例8: Apply

 public override void Apply(TagList tag, int key)
 {
     while (key >= tag.Count)
         tag.Add(null);
     tag[key] = _value;
 }
开发者ID:jaquadro,项目名称:NNBT,代码行数:6,代码来源:NbtMerge.cs


注:本文中的TagList.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。