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


C# ktString.AfterFirst方法代码示例

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


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

示例1: Get

        /// <summary>
        /// This function will get the list/child corresponding the keys
        ///  (Keys can basically be a path [similar to a filesystem or XPath]
        ///    ex: "/root/child/subchild" or just an "element"/key)
        /// </summary>
        /// <param name="Keys">The path to the node/child</param>
        /// <param name="ReturnAll">Should we return all that matches?</param>
        public ktList Get(ktString Keys, bool ReturnAll)
        {
            // Init...
            ktString Key;
            ktString TmpKeys = Keys; // Temporary to save the given value

            //  Remove leading slashs (/)..
            Keys.Trim(ktStripType.leading, "/");

            if (Keys.Contains("/"))
            {
                // Get the first key
                Key = Keys.BeforeFirst('/');
                // Remove the first key
                Keys = Keys.AfterFirst('/');
            }
            else
            {
                Key = Keys;
            }

            // If the given key matches the key of "this node" (or we didn't get a key)
            if ((m_Node != null) && (m_Node.Check(Key)) || (Key == ""))
            {
                // Return "this"
                return this;
            }

            // No elements??
            if (m_Head == null)
            {
                // there's nothing to get
                throw new ktError("The list is empty (in ktList::Get( " + TmpKeys + ", bool ))", ktERR.EMPTY);
            }

            // Init...
            ktList TmpList = null;
            ktList AllMatches = null;
            bool GoOn = true;
            Reset();

            // Should we return all matches?
            if (ReturnAll)
            {
                AllMatches = new ktList();
            }

            // Go thru the list..
            while (MoveNext() && GoOn)
            {
                // Try it...
                try
                {
                    // Get the "sublist(s)"
                    TmpList = CurrentNode.Get(Keys, ReturnAll); // Key or Keys??

                    // If we should return all
                    if (ReturnAll)
                    {
                        // Add the found list... (and then go on)
                        AllMatches.Add(TmpList);
                    }
                    else
                    {
                        // Stop looking...
                        GoOn = false;
                    }
                    // Catch an error...
                }
                catch (ktError E)
                {
                    // If it was an error other than "Not found" or empty...
                    if ((E.ErrorNumber != ktERR._404) && (E.ErrorNumber != ktERR.EMPTY))
                    {
                        // Re-throw it
                        throw E;
                    } // If
                } // Catch
            } // While

            // If we should return all matches and
            //  we found something (The list isn't empty)
            if (ReturnAll && (!AllMatches.IsEmpty()))
            {
                // Set GoOn to false (as it marks a found node/list)
                GoOn = false;
            }

            // If we should get all matches but only found one
            if (ReturnAll && (AllMatches.GetCount() == 1))
            {
                // Get the first (and only) child
                TmpList = AllMatches.First;
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktList.cs


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