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


C# ktString.Trim方法代码示例

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


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

示例2: ParseInfoString

        public static Dictionary<ktString, ktString> ParseInfoString( ktString InfoStr )
        {
            int p = 0, p2 = 0;
            ktString property;
            ktString prop_name, prop_value;

            Dictionary<ktString, ktString> InfoMap = new Dictionary<ktString, ktString>();

            while (!InfoStr.IsEmpty())
            {
                p = InfoStr.IndexOf(';');
                if (p < 0)
                {
                    property = InfoStr;
                    p = InfoStr.Length() - 1;
                }
                else
                {
                    property = InfoStr.SubString(0, p).Trim();
                }
                p2 = property.IndexOf('=');
                prop_name = property.SubString(0, p2).AsUpper();
                prop_value = property.SubString(p2 + 1);

                InfoMap.Add(prop_name, prop_value);

                InfoStr.Remove(0, p + 1);
                InfoStr = InfoStr.Trim();
            }

            return InfoMap;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:32,代码来源:ktTalker.cs

示例3: Scan

        /// <summary>
        /// Scan/Parse the script into tokens
        /// </summary>
        public bool Scan(ktString Script, ktString Name)
        {
            bool Ret = true;

            Script.Replace("\r\n", "\n",true);

            // Initiate the lineno.
            m_CurLine = 1;
            m_CharPos = 1;
              // .. and name
            m_Name = Name;

            if (m_Tokens != null)
            {
                m_Tokens.Clear();
                m_Tokens = null;
            }

            // Init...
            ktString Line = new ktString();
            int Pos = 0;
            Script.Trim();
            ktRegEx RE = new ktRegEx(ktToken.Separators);

            // ... the block-stack
            if (m_BlockStack != null)
            {
                m_BlockStack.Clear();
                m_BlockStack = null;
            }
            m_BlockStack = new ktList();
            // ... the token-list
            if (m_Tokens != null)
            {
                m_Tokens.Clear();
                m_Tokens = null;
            }
            m_Tokens = new ktList();
            m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", 0, 0));
            // ... the token-stack
            if (m_TokenStack != null)
            {
                m_TokenStack.Clear();
                m_TokenStack = null;
            }
            m_TokenStack = new ktList();
            // ... the lines (??)
            if (m_Lines != null)
            {
                m_Lines.Clear();
                m_Lines = null;
            }
            m_Lines = new ktList();
            m_Lines.Node = new ktNode(Name, m_CurToken = new ktToken(ktTokenType.Program, Name, 0, 0));
            // ... the line-stack
            if (m_LineStack != null)
            {
                m_LineStack.Clear();
                m_LineStack = null;
            }
            m_LineStack = new ktList();

            if (m_MainBlock == null)
            {
                m_MainBlock = new ktBlock(new ktList());
            }
            else
            {
                if (m_MainBlock.Lines != null)
                {
                    m_MainBlock.Lines.Clear();
                }
                m_MainBlock.ClearKTSymbols();
            }
            m_MainBlock.SetMain(this);

            m_BlockStack.Add("ktTBlock", m_MainBlock);

            /* In the "original scanner" (C++), we took one line (terminated by \n)
             * 	at a time and worked on, now we just go through the line.
             * And We hope that it will be much "leaner"!
             */
            // Go on until the there's nothing left...
            while (!Script.IsEmpty())
            {
                // Get the position for the next separator
                Pos = RE.Find(Script);

                // If there was none...
                if (Pos < 0)
                {
                    // Take it to the end...
                    Pos = Script.Len();
                }
                else if (Pos == 0)
                {
                    Pos++;
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:kt.cs


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