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


C# Event.Add方法代码示例

本文整理汇总了C#中Event.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Event.Add方法的具体用法?C# Event.Add怎么用?C# Event.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseResults

        public void ParseResults(byte[] response)
        {
            string responseFromServer = "";
            responseFromServer = Encoding.ASCII.GetString(response);

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(responseFromServer);
            HtmlNode node = doc.DocumentNode;

            events = new List<Event>();
            foreach (HtmlNode row in node.GetNodesByClass("tr"))
            {
                HtmlNode temp = row.FirstChildWithClass("td");
                if (temp != null)
                {
                    if (EventTypes.Contains(temp.InnerText))
                    {
                        Event e = new Event();
                        List<HtmlNode> descriptions = row.GetNodesByClass("td").ToList();
                        HtmlNode linker = descriptions[1].FirstChildWithClass("a");
                        string link = linker.Attributes["href"].Value;

                        e.Add("Type", descriptions[0].InnerText);
                        e.Add("Name", linker.InnerText);
                        e.Add("Link", link);
                        e.Add("Event Venue", descriptions[2].InnerText);
                        e.Add("Location", descriptions[3].InnerText);
                        e.Add("Date", descriptions[4].InnerText.Trim());
                        events.Add(e);
                    }
                }
            }
        }
开发者ID:ben-abraham,项目名称:FIRSTScraper,代码行数:34,代码来源:EventLoader.cs

示例2: GetEventsFromCurrentSet

        /// <summary>
        /// Returns an enumerator over a set of the events 
        /// in the event stream, and gets ready for the next set.
        /// </summary>
        /// <remarks>
        /// <para>
        /// When using 'search/jobs/export endpoint', search results
        /// will be streamed back as they become available. It is possible
        /// for one or more previews to be received before the final one.
        /// The enumerator returned will be over a single preview or 
        /// the final results. Each time this method is called, 
        /// the next preview or the final results are enumerated if they are
        /// available; otherwise, an exception is thrown.
        /// </para>
        /// <para>
        /// After all events in the set is enumerated, the metadata of the 
        /// next set (if available) is read, with 
        /// <see cref="ResultsReader.IsPreview"/> 
        /// and <see cref="ResultsReader.Fields"/> being set accordingly.
        /// </para>
        /// </remarks>
        /// <returns>A enumerator.</returns>
        internal override IEnumerable<Event> GetEventsFromCurrentSet()
        {
            while (true)
            {
                if (!this.XmlReader.ReadToNextSibling("result"))
                {
                    yield break;
                }

                var result = new Event();

                this.ReadEachDescendant(
                    "field", 
                    () => 
                    {
                        var key = this.XmlReader["k"];

                        if (key == null)
                        {
                            throw new XmlException(
                                "'field' attribute 'k' not found");
                        }

                        var values = new List<string>();

                        var xmlDepthField = this.XmlReader.Depth;

                        while (this.XmlReader.Read())
                        {
                            if (this.XmlReader.Depth == xmlDepthField)
                            {
                                break;
                            }

                            Debug.Assert(
                                XmlReader.Depth > xmlDepthField,
                                "The loop should have exited earlier.");

                            if (this.XmlReader.IsStartElement("value"))
                            {
                                if (this.XmlReader.ReadToDescendant("text"))
                                {
                                    values.Add(
                                        this.XmlReader.ReadElementContentAsString());
                                }
                            }
                            else if (this.XmlReader.IsStartElement("v"))
                            {
                                result.SegmentedRaw = this.XmlReader.ReadOuterXml();
                                var value = ReadTextContentFromXml(
                                    result.SegmentedRaw);                    
                                values.Add(value);
                            }
                        }

                        result.Add(key, new Event.FieldValue(values.ToArray()));
                    });

                yield return result;
            }
        }
开发者ID:yonglehou,项目名称:splunk-sdk-csharp,代码行数:83,代码来源:ResultsReaderXml.cs


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