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


C# ImmutableStack.Add方法代码示例

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


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

示例1: AppendAbbreviation

        /// <summary>
        /// Appends an abbreviation to the given zscii text.
        /// </summary>
        /// <param name="zcharacter">
        /// The zcharacter.
        /// </param>
        /// <param name="calledRecursively">
        /// A value which indicates whether the method was called recursively.
        /// </param>
        /// <param name="zcharacters">
        /// The zcharacters.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        protected void AppendAbbreviation(byte zcharacter, bool calledRecursively, ref ImmutableStack<byte> zcharacters, ref ImmutableStack<Zscii> zsciiText)
        {
            if (calledRecursively)
            {
                this.FrontEnd.ErrorNotification(ErrorCondition.NestedAbbreviation, "Nested abbreviation detected.");
                return;
            }

            if (zcharacters != null)
            {
                var abbreviationNumber = ((zcharacter - 1) * 32) + zcharacters.Top;
                zcharacters = zcharacters.Tail;
                var abbreviationsTableAddress = this.Memory.ReadWord(24);
                var abbreviationAddress = 2 * this.Memory.ReadWord(abbreviationsTableAddress + (2 * abbreviationNumber));
                var abbreviation = this.ZCharactersToZscii(true, this.EncodedTextToZCharacters(ref abbreviationAddress));
                foreach (var zsciiCharacter in abbreviation.Enumerable())
                {
                    zsciiText = zsciiText.Add(zsciiCharacter);
                }
            }
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:36,代码来源:ZmachineV2.cs

示例2: AddAlphabetShiftToZCharacters

 /// <summary>
 /// Adds an alphabet shift to z-characters.
 /// </summary>
 /// <param name="neededAlphabet">
 /// The needed alphabet.
 /// </param>
 /// <param name="zsciiText">
 /// The zscii text following the alphabet shift.
 /// </param>
 /// <param name="lockedAlphabet">
 /// The locked alphabet.
 /// </param>
 /// <param name="characters">
 /// The z-characters.
 /// </param>
 protected override void AddAlphabetShiftToZCharacters(byte neededAlphabet, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
 {
     characters = characters.Add((byte)(neededAlphabet + 3));
 }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:19,代码来源:ZmachineV3.cs

示例3: AddAlphabetShiftToZCharacters

        /// <summary>
        /// Adds an alphabet shift to z-characters.
        /// </summary>
        /// <param name="neededAlphabet">
        /// The needed alphabet.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text following the alphabet shift.
        /// </param>
        /// <param name="lockedAlphabet">
        /// The locked alphabet.
        /// </param>
        /// <param name="characters">
        /// The z-characters.
        /// </param>
        protected virtual void AddAlphabetShiftToZCharacters(byte neededAlphabet, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
        {
            // bug: if next character is newline, space, etc...
            var shiftCharacter = (byte)(((3 + neededAlphabet - lockedAlphabet) % 3) + 1);
            if (zsciiText != null)
            {
                var nextIndex = this.GetZsciiAlphabetIndex(zsciiText.Top);
                var nextNeededAlphabet = (byte)((nextIndex == -1) ? 2 : nextIndex / 26);
                if (nextNeededAlphabet == neededAlphabet)
                {
                    shiftCharacter += 2;
                    lockedAlphabet = neededAlphabet;
                }
            }

            characters = characters.Add(shiftCharacter);
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:32,代码来源:ZmachineV1.cs

示例4: ZsciiCharacterToZCharacters

 /// <summary>
 /// Converts a zscii character to z-characters.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The zscii character.
 /// </param>
 /// <param name="zsciiText">
 /// The zscii text following the zscii character.
 /// </param>
 /// <param name="lockedAlphabet">
 /// The locked alphabet.
 /// </param>
 /// <param name="characters">
 /// The z-characters to add the results to.
 /// </param>
 /// <remarks>
 /// Newline is now part of the zscii alphabet.
 /// </remarks>
 protected virtual void ZsciiCharacterToZCharacters(Zscii zsciiCharacter, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
 {
     switch (zsciiCharacter)
     {
         case Zscii.Null:
             break;
         case Zscii.Space:
             characters = characters.Add((byte)0);
             break;
         case Zscii.NewLine:
             characters = characters.Add((byte)1);
             break;
         default:
             this.ZsciiAlphabetCharacterToZCharacters(zsciiCharacter, zsciiText, ref lockedAlphabet, ref characters);
             break;
     }
 }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:35,代码来源:ZmachineV1.cs

示例5: ZsciiAlphabetCharacterToZCharacters

        /// <summary>
        /// Converts a zscii alphabet character to z-characters.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The zscii character.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        /// <param name="lockedAlphabet">
        /// The locked alphabet.
        /// </param>
        /// <param name="characters">
        /// The z-characters.
        /// </param>
        protected void ZsciiAlphabetCharacterToZCharacters(Zscii zsciiCharacter, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
        {
            var zsciiAlphabetIndex = this.GetZsciiAlphabetIndex(zsciiCharacter);
            var neededAlphabet = (byte)((zsciiAlphabetIndex == -1) ? 2 : zsciiAlphabetIndex / 26);
            if (neededAlphabet != lockedAlphabet)
            {
                this.AddAlphabetShiftToZCharacters(neededAlphabet, zsciiText, ref lockedAlphabet, ref characters);
            }

            if (zsciiAlphabetIndex > -1)
            {
                characters = characters.Add((byte)((zsciiAlphabetIndex % 26) + 6));
            }
            else
            {
                characters = characters.Add((byte)6);
                characters = characters.Add((byte)((ushort)zsciiCharacter / 32));
                characters = characters.Add((byte)((ushort)zsciiCharacter & 31));
            }
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:35,代码来源:ZmachineV1.cs

示例6: ZCharactersToZscii

        /// <summary>
        /// Converts z-characters to zscii text.
        /// </summary>
        /// <param name="calledRecursively">
        /// A value which indicates whether the method was called recursively.
        /// </param>
        /// <param name="zcharacter">
        /// The zcharacter.
        /// </param>
        /// <param name="currentAlphabet">
        /// The current alphabet.
        /// </param>
        /// <param name="nextAlphabet">
        /// The next alphabet.
        /// </param>
        /// <param name="lockedAlphabet">
        /// The locked alphabet.
        /// </param>
        /// <param name="zcharacters">
        /// The zcharacters.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        protected virtual void ZCharactersToZscii(bool calledRecursively, byte zcharacter, byte currentAlphabet, ref byte nextAlphabet, ref byte lockedAlphabet, ref ImmutableStack<byte> zcharacters, ref ImmutableStack<Zscii> zsciiText)
        {
            switch (zcharacter)
            {
                case 0:
                    zsciiText = zsciiText.Add(Zscii.Space);
                    break;
                case 1:
                    zsciiText = zsciiText.Add(Zscii.NewLine);
                    break;
                case 2:
                case 3:
                    nextAlphabet = (byte)((lockedAlphabet + zcharacter - 1) % 3);
                    break;
                case 4:
                case 5:
                    nextAlphabet = lockedAlphabet = (byte)((lockedAlphabet + zcharacter) % 3);
                    break;
                default:
                    if (zcharacter == 6 && currentAlphabet == 2)
                    {
                        if (zcharacters.Count() > 1)
                        {
                            zsciiText = zsciiText.Add((Zscii)((zcharacters.Top * 32) + zcharacters.Tail.Top));
                            zcharacters = zcharacters.Tail.Tail;
                        }
                        else
                        {
                            zcharacters = null;
                        }

                        break;
                    }

                    zsciiText = zsciiText.Add(this.GetZsciiAlphabetCharacter((byte)((currentAlphabet * 26) + zcharacter - 6)));
                    break;
            }
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:62,代码来源:ZmachineV1.cs


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