コード例 #1
0
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            // Copy all the items we need to swap from slot A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            // Clear slot A
            from.MyItems.Clear();
            from.rarityFrame.enabled = false;

            // Take all items from Slot B and copy them into slot A
            from.AddItems(MyItems);

            // Clear slot B
            MyItems.Clear();

            // Move the items from Copy A to B
            AddItems(tmpFrom);

            return(true);
        }

        return(false);
    }
コード例 #2
0
ファイル: SlotScript.cs プロジェクト: YoannKersulec/ProjetX
    /// <summary>
    /// Swaps two items in the inventory
    /// </summary>
    /// <param name="from"></param>
    /// <returns></returns>
    private bool SwapItems(SlotScript from)
    {
        from.MyCover.enabled = false;
        if (IsEmpty)
        {
            return(false);
        }
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            //Copy all the items we need to swap from A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            //Clear Slot a
            from.MyItems.Clear();
            //All items from slot b and copy them into A
            from.AddItems(MyItems);

            //Clear B
            MyItems.Clear();
            //Move the items from ACopy to B
            AddItems(tmpFrom);

            return(true);
        }

        return(false);
    }
コード例 #3
0
    /// <summary>
    /// Responsible for trying to add the items to the slot.
    /// </summary>
    /// <param name="newItems">the stack of new items</param>
    /// <returns></returns>

    public bool AddItems(ObservableStack <Item> newItems)
    {
        if (newItems.Peek().GetInventoryType() != slotType && slotType != InventoryType.None)
        {
            return(false);
        }

        if (IsEmpty || newItems.Peek().GetName() == item.GetName())
        {
            int count = newItems.Count;

            for (int i = 0; i < count; i++)
            {
                if (IsFull)
                {
                    return(false);
                }

                AddItem(newItems.Pop());
            }

            return(true);
        }

        return(false);
    }
コード例 #4
0
        public async Task PushPopAndPushAgain()
        {
            var stack = new ObservableStack <int>();

            // Push one element
            stack.Push(1);
            Assert.AreEqual(1, stack.Value);
            Assert.AreEqual(Optional.Some(1), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());

            // Pop it back to empty
            var pop1 = stack.Pop();

            Assert.AreEqual(1, pop1);
            Assert.Throws <InvalidOperationException>(() => { var a = stack.Value; });
            Assert.AreEqual(Optional.None <int>(), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());

            // Push two elements
            stack.Push(1);
            stack.Push(2);
            Assert.AreEqual(2, stack.Value);
            Assert.AreEqual(Optional.Some(2), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.Some(1), await stack.PeekUnder.FirstAsync());
        }
コード例 #5
0
ファイル: CommandProcess.cs プロジェクト: ArunPrakashG/Luna
        internal CommandProcess(OSPlatform platform, bool enableIOLogging = false, bool logToInternalTrace = false, bool asAdmin = false)
        {
            if (platform != Helpers.GetPlatform())
            {
                throw new PlatformNotSupportedException();
            }

            InternalTraceLogging = logToInternalTrace;
            EnableIOLogging      = enableIOLogging;
            Logger             = new InternalLogger(ShellName);
            IsElevationCapable = IsElevated();

            DefaultProcessStartInfo = new ProcessStartInfo()
            {
                CreateNoWindow         = false,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                StandardErrorEncoding  = Encoding.ASCII,
                StandardOutputEncoding = Encoding.ASCII,
                StandardInputEncoding  = Encoding.ASCII,
                WindowStyle            = ProcessWindowStyle.Hidden,
                WorkingDirectory       = Directory.GetCurrentDirectory(),
                FileName = ShellName
            };

            GenerateProcessInstance();
            OutputContainer = new ObservableStack <string>();
            ErrorContainer  = new ObservableStack <string>();
            InputContainer  = new ObservableStack <string>();
            OutputContainer.CollectionChanged += ProcessStandardOutput;
            ErrorContainer.CollectionChanged  += ProcessStandardError;
            InputContainer.CollectionChanged  += ProcessStandardInput;
        }
コード例 #6
0
    /// <summary>
    /// Returns whether or not it was possible to swap the two item stacks.
    /// </summary>
    /// <param name="from">the first clicked slot</param>

    bool SwapItems(InventorySlot from)
    {
        if (from.slotType != slotType && slotType != InventoryType.None)
        {
            return(false);
        }

        if (IsEmpty)
        {
            return(false);
        }

        if (from.item.GetName() != item.GetName() ||
            from.items.Count + items.Count > item.GetStackSize())
        {
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.items);

            from.items.Clear();
            from.AddItems(items);

            items.Clear();
            AddItems(tmpFrom);

            Debug.Log("Item Swap");
            return(true);
        }

        Debug.Log("Swap failed");

        return(false);
    }
コード例 #7
0
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            //kopija itema iz slota A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            //ocisti slot A
            from.MyItems.Clear();
            //uzmemo sve iteme iz slota B i kopira ih u slot A
            from.AddItems(MyItems);

            //ocisti slot B
            MyItems.Clear();
            //premjesti iteme iz Atmp u B
            AddItems(tmpFrom);

            return(true);
        }

        return(false);
    }
コード例 #8
0
ファイル: SlotScript.cs プロジェクト: spartann123/TCCRPG
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }

        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            //cópia de todos os itens
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.items);

            //limpa slot A
            from.items.Clear();
            //Todos os itens do slot B, copia para o slot A
            from.AddItems(items);

            //limpa slot B
            items.Clear();
            //Move os itens cópia do slot A para o slot B
            AddItems(tmpFrom);

            return(true);
        }

        return(false);
    }
コード例 #9
0
        public async Task Replace()
        {
            var stack = new ObservableStack <int>();

            // Initialize stack to be replaced
            stack.Push(13);
            stack.Push(37);

            // Replace all elements
            stack.Replace(1, 2, 3);
            Assert.AreEqual(Optional.Some(3), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.Some(2), await stack.PeekUnder.FirstAsync());

            // Pop them off again
            stack.Pop();
            Assert.AreEqual(Optional.Some(2), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.Some(1), await stack.PeekUnder.FirstAsync());
            stack.Pop();
            Assert.AreEqual(Optional.Some(1), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());
            stack.Pop();
            Assert.AreEqual(Optional.None <int>(), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());

            // Push after it was cleared
            stack.Push(1);
            Assert.AreEqual(1, stack.Value);
            Assert.AreEqual(Optional.Some(1), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());
        }
コード例 #10
0
    /// <summary>
    /// Places a stack of items in a new slot of the bags or tries to stack them if they are of the same type
    /// </summary>
    /// <param name="newItems"></param>
    /// <returns></returns>
    public bool AddItems(ObservableStack <Item> newItems)
    {
        // if the slot is empty or if the slot has items of the same type
        if (IsEmpty || newItems.Peek().GetType() == MyItem.GetType())
        {
            // how many items do I have in my hand?
            int count = newItems.Count;

            // for each of the items I have in my hand
            for (int i = 0; i < count; i++)
            {
                // if the stack is full
                if (IsFull)
                {
                    // then stop trying to add items to it
                    return(false);
                }

                // if its not full then add the current iteration of the items in my hand
                AddItem(newItems.Pop());
            }

            // we managed to get through all the items and we have no more items in our hand
            return(true);
        }

        // this slot is not empty or the things there are not of the same type so the function cannot do anything
        return(false);
    }
コード例 #11
0
    private bool SwapItems(InventorySlots from)
    {
        if (IsEmpty)
        {
            return(false);
        }
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.StackSize)
        {
            //Copy all items from A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.itemStack);
            Debug.Log("SLOT A COPIED TO B");
            //Clear slot A
            from.itemStack.Clear();
            Debug.Log("SLOT A CLEARED");

            //Copy from B and put in A
            from.AddItems(itemStack);

            //Clear B
            itemStack.Clear();

            //Move from the copy of A to B
            AddItems(tmpFrom);
            return(true);
        }
        return(false);
    }
コード例 #12
0
ファイル: SlotScript.cs プロジェクト: obrown6652/Capstone
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            //copy all the items we need to swap from A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.items);

            //clear slot A
            from.items.Clear();
            //all items from slot B and copy them into A
            from.AddItems(items);

            //clear B
            items.Clear();
            //move the items from A copy to B
            AddItems(tmpFrom);

            return(true);
        }
        return(false);
    }
コード例 #13
0
 public DoAction(
     ObservableStack <IUndoable> undoableActions, ObservableStack <IUndoable> redoableActions, IUndoable action)
 {
     _undoableActions = undoableActions;
     _redoableActions = redoableActions;
     _action          = action;
 }
コード例 #14
0
    }//end of PutItemBack function

    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }

        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            //copy all items need to be swap from slot A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.items);

            //Clear the slot A
            from.items.Clear();

            //Take everything from slot B and copy it into A
            from.AddItems(items);

            //Clear B
            items.Clear();

            //Move from A to B
            AddItems(tmpFrom);
            return(true);
        }
        return(false);
    }// end of SwapItems function
コード例 #15
0
        public async Task EmptyStack()
        {
            var stack = new ObservableStack <int>();

            Assert.Throws <InvalidOperationException>(() => { var a = stack.Value; });
            Assert.AreEqual(Optional.None <int>(), await stack.Peek.FirstAsync());
            Assert.AreEqual(Optional.None <int>(), await stack.PeekUnder.FirstAsync());
        }
コード例 #16
0
        internal SessionizedProcess(OSPlatform platform, string command, bool enableIOLogging = false, bool asAdmin = false)
        {
            if (string.IsNullOrEmpty(command))
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (Helpers.GetPlatform() != platform)
            {
                throw new PlatformNotSupportedException();
            }

            EnableIOLogging = enableIOLogging;
            string shellName = Helpers.GetPlatform() == OSPlatform.Linux || Helpers.GetPlatform() == OSPlatform.FreeBSD ? UNIX_SHELL : WINDOWS_SHELL;

            Logger             = new InternalLogger(shellName);
            IsElevationCapable = IsElevated();
            bool isUnixEnv = Helpers.GetPlatform() == OSPlatform.Linux || Helpers.GetPlatform() == OSPlatform.FreeBSD;

            command = $"{(isUnixEnv ? "-c" : "/C")} {(isUnixEnv && IsElevationCapable ? "sudo" : "")} \"{EscapeArguments(command)}\"";

            Process           = new Process();
            Process.StartInfo = new ProcessStartInfo()
            {
                CreateNoWindow         = false,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                StandardErrorEncoding  = Encoding.ASCII,
                StandardOutputEncoding = Encoding.ASCII,
                StandardInputEncoding  = Encoding.ASCII,
                WindowStyle            = ProcessWindowStyle.Hidden,
                WorkingDirectory       = Directory.GetCurrentDirectory(),
                FileName  = shellName,
                Arguments = command
            };

            Process.EnableRaisingEvents = true;
            Process.Disposed           += OnDisposed;
            Process.ErrorDataReceived  += OnErrorReceived;
            Process.Exited             += OnExit;
            Process.OutputDataReceived += OnOutputReceived;
            Process.Start();
            Process.BeginOutputReadLine();
            Process.BeginErrorReadLine();

            OutputContainer = new ObservableStack <string>();
            ErrorContainer  = new ObservableStack <string>();
            InputContainer  = new ObservableStack <string>();
            OutputContainer.CollectionChanged += ProcessStandardOutput;
            ErrorContainer.CollectionChanged  += ProcessStandardError;
            InputContainer.CollectionChanged  += ProcessStandardInput;
            InputSessionVariable = null;
            Helpers.InBackgroundThread(() => InitInputSession(ref InputSessionVariable, CommandInputSessionToken.Token));
        }
コード例 #17
0
        public void ShouldNotPopItemWhenEmpty()
        {
            // arrange
            var target = new ObservableStack<string>();

            // act
            Assert.Throws<InvalidOperationException>( () => target.Pop() );

            // assert
        }
コード例 #18
0
        private GlobalManagement()
        {
            TerrainBrushSize = 10;
            Terrain          = FloorMaterial.Grass;

            Clipboard      = new ObservableCollection <IVisualElement>();
            UndoStack      = new ObservableStack <IEditorAction>();
            RedoStack      = new ObservableStack <IEditorAction>();
            TerrainStrokes = new StrokeCollection();
            TerrainStrokes.StrokesChanged += TerrainStrokes_StrokesChanged;
        }
コード例 #19
0
        public void ConstructorShouldInitializeFromSequence()
        {
            // arrange
            var expected = new[] { "1", "2", "3" };

            // act
            var target = new ObservableStack<string>( expected );

            // assert
            Assert.Equal( 3, target.Count );
            Assert.True( target.SequenceEqual( expected.Reverse() ) );
        }
コード例 #20
0
        public void ShouldPushItemWithEvents()
        {
            // arrange
            var expected = "1";
            var target = new ObservableStack<string>();

            // act
            Assert.PropertyChanged( target, "Count", () => target.Push( expected ) );

            // assert
            Assert.Equal( 1, target.Count );
            Assert.Equal( expected, target.Peek() );
        }
コード例 #21
0
		public HelpWindow () {
			this.Documents = new HelpDocument [] {
				//new CautionDocument (),
				new OverviewDocument (),
				new ShortcutsDocument (),
			};
			
			this.BackCommands = new ObservableStack <Action> ();
			this.ForwardCommands = new ObservableStack <Action> ();

			InitializeComponent ();

			this.DocumentListBox.SelectedItem = this.Documents [0];
		}
コード例 #22
0
        public HelpWindow()
        {
            this.Documents = new HelpDocument [] {
                //new CautionDocument (),
                new OverviewDocument(),
                new ShortcutsDocument(),
            };

            this.BackCommands    = new ObservableStack <Action> ();
            this.ForwardCommands = new ObservableStack <Action> ();

            InitializeComponent();

            this.DocumentListBox.SelectedItem = this.Documents [0];
        }
コード例 #23
0
        public void ShouldPeekItem()
        {
            // arrange
            var target = new ObservableStack<string>();

            target.Push( "2" );
            target.Push( "1" );
            target.Push( "3" );

            // act
            var actual = target.Peek();

            // assert
            Assert.Equal( "3", actual );
        }
コード例 #24
0
        public void ShouldPopItemWithEvents()
        {
            // arrange
            var expected = "1";
            string actual = null;
            var target = new ObservableStack<string>();

            target.Push( expected );

            // act
            Assert.PropertyChanged( target, "Count", () => actual = target.Pop() );

            // assert
            Assert.Equal( 0, target.Count );
            Assert.Equal( expected, actual );
        }
コード例 #25
0
ファイル: SlotScript.cs プロジェクト: NZBane/kus
    public bool AddItems(ObservableStack <Item> newItems)
    {
        if (IsEmpty || newItems.Peek().GetType() == MyItem.GetType())
        {
            int count = newItems.Count;

            for (int i = 0; i < count; i++)
            {
                if (IsFull)
                {
                    return(false);
                }
                AddItem(newItems.Pop());
            }
            return(true);
        }
        return(false);
    }
コード例 #26
0
ファイル: SlotScript.cs プロジェクト: bondingreality/Trurealm
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }

        if (from.MyItem.GetType() != MyItem.GetType() || from.IsFull || IsFull)
        {
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);
            from.MyItems.Clear();
            from.AddItems(MyItems);
            MyItems.Clear();
            AddItems(tmpFrom);
            return(true);
        }
        return(false);
    }
コード例 #27
0
    public bool AddItems(ObservableStack <Item> newItems)
    {
        if (IsEmpty || newItems.Peek().GetType() == MyItem.GetType())
        {
            int count = newItems.Count;

            for (int i = 0; i < count; i++)
            {
                if (IsFull)
                {
                    Debug.Log("The slot is full");
                    return(false);
                }
                AddItem(newItems.Pop()); //puts all items in the slot if its not full
            }
            return(true);
        }
        return(false);
    }
コード例 #28
0
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }
        if ((from.MyItem.GetType() != MyItem.GetType()) || (from.MyCount + MyCount > MyItem.MyStackSize))
        {
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.items);

            from.items.Clear();
            from.AddItems(items);

            items.Clear();
            AddItems(tmpFrom);

            return(true);
        }
        return(false);
    }
コード例 #29
0
    }//end of AddItem function

    public bool AddItems(ObservableStack <Item> newItems)
    {
        if (IsEmpty || newItems.Peek().GetType() == MyItem.GetType())   //check for empty slot or items are same type

        {
            int count = newItems.Count;     //if the above condition matches set the count of items

            for (int i = 0; i < count; i++) // take all the item one by one and put it in the new slot
            {
                if (IsFull)
                {
                    return(false);
                }//end of if inside for loop

                AddItem(newItems.Pop());
            } //end of for
            return(true);
        }     //end of if
        return(false);
    }         //end of the function Additems
コード例 #30
0
    private bool SwapItems(SlotScript from)
    {
        from.MyCover.enabled = false;
        if (IsEmpty)
        {
            return(false);
        }

        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            from.MyItems.Clear();
            from.AddItems(MyItems);

            MyItems.Clear();
            AddItems(tmpFrom);

            return(true);
        }
        return(false);
    }
コード例 #31
0
 public TowerViewModel()
 {
     firstTower = new ObservableStack<TowerPlate>();
     secondTower = new ObservableStack<TowerPlate>();
     thirdTower = new ObservableStack<TowerPlate>();
     winTower = new ObservableStack<TowerPlate>();
     placeFromFirstToSecondTowerCommand = new RelayCommand(
                                 OnPlaceFromFirstToSecondTowerCommand);
     placeFromSecondToFirstTowerCommand = new RelayCommand(
                                 OnPlaceFromSecondToFirstTowerCommand);
     placeFromFirstToThirdTowerCommand = new RelayCommand(
                                 OnPlaceFromFirstToThirdTowerCommand);
     placeFromSecondToThirdCommand = new RelayCommand(
                                 OnPlaceFromSecondToThirdCommand);
     placeFromThirdToFirstCommand = new RelayCommand(
                                 OnPlaceFromThirdToFirstCommand);
     placeFromThirdToSecondCommand = new RelayCommand(
                                 OnPlaceFromThirdToSecondCommand);
     showSolutionCommand = new RelayCommand(
                                 OnShowSolutionCommand); 
     PropertyChanged += OnAmountOfPlatesChanged;
     GameWin += OnGameWon;
 }
コード例 #32
0
    public bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }

        int x = from.MyCount + MyCount;

        if (from.MyItem.GetType() != MyItem.GetType() || x > MyItem.MyStackSize)
        {
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            from.MyItems.Clear();
            from.AddItems(MyItems);

            MyItems.Clear();
            AddItems(tmpFrom);

            return(true);
        }

        return(false);
    }
コード例 #33
0
    private bool SwapItems(SlotScript from)
    {
        if (IsEmpty)
        {
            return(false);
        }

        // if the item im moving is different from the item(s) in this slot
        // or if the count of items in my hand plus the items in this slot is larger than the total stacksize allowed
        if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
        {
            // copy all the items we need to swap from A
            ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);

            // clear slot A
            from.MyItems.Clear();
            // take all items from slot B and copy them into A
            from.AddItems(MyItems);

            // Clear slot B
            MyItems.Clear();
            // Adding the items we originally copied into this slot
            AddItems(tmpFrom);

            Debug.Log("from slotting");

            if (showingToolTip)
            {
                UiManager.instance.RefreshToolTip(MyItem);
            }

            return(true);
        }

        return(false);
    }
コード例 #34
0
        public void ShouldTrimExcess()
        {
            // arrange
            var target = new ObservableStack<string>( 10 );

            target.Push( "1" );
            target.Push( "2" );
            target.Push( "3" );

            // act
            target.TrimExcess();

            // assert
            // no exception
        }
コード例 #35
0
 public ObservableStack(ObservableStack <T> items) : base(items)
 {
 }
コード例 #36
0
            public Visitor(JsonWriter writer,
                           bool includeLineColumn, bool includeRange,
                           LocationMembersPlacement locationMembersPlacement)
            {
                _writer = writer ?? throw new ArgumentNullException(nameof(writer));
                _stack  = new ObservableStack <INode>();

                _stack.Pushed += node =>
                {
                    _writer.StartObject();

                    if ((includeLineColumn || includeRange) &&
                        locationMembersPlacement == LocationMembersPlacement.Start)
                    {
                        WriteLocationInfo(node);
                    }

                    Member("type", node.Type.ToString());
                };

                _stack.Popped += node =>
                {
                    if ((includeLineColumn || includeRange) &&
                        locationMembersPlacement == LocationMembersPlacement.End)
                    {
                        WriteLocationInfo(node);
                    }

                    _writer.EndObject();
                };

                void WriteLocationInfo(INode node)
                {
                    if (includeRange)
                    {
                        writer.Member("range");
                        writer.StartArray();
                        writer.Number(node.Range.Start);
                        writer.Number(node.Range.End);
                        writer.EndArray();
                    }

                    if (includeLineColumn)
                    {
                        writer.Member("loc");
                        writer.StartObject();
                        writer.Member("start");
                        Write(node.Location.Start);
                        writer.Member("end");
                        Write(node.Location.End);
                        writer.EndObject();
                    }

                    void Write(Position position)
                    {
                        writer.StartObject();
                        Member("line", position.Line);
                        Member("column", position.Column);
                        writer.EndObject();
                    }
                }
            }
コード例 #37
0
 public void ShouldGrowAutomatically()
 {
     var target = new ObservableStack<string>( 0 );
     target.Push( "1" );
     Assert.Equal( 1, target.Count );
 }
コード例 #38
0
 private bool IsValidPlacing(ObservableStack<TowerPlate> tower,
                             TowerPlate plate) =>
                         tower.Count != 0 ? tower.Peek() > plate : true;
コード例 #39
0
        public void ShouldConvertToArray()
        {
            // arrange
            var target = new ObservableStack<string>();
            var expected = new[] { "3", "2", "1" };

            target.Push( "1" );
            target.Push( "2" );
            target.Push( "3" );

            // act
            var actual = target.ToArray();

            // assert
            Assert.True( actual.SequenceEqual( expected ) );
        }
コード例 #40
0
        public void ShouldEnumerate()
        {
            var target = new ObservableStack<string>();
            target.Push( "1" );
            target.Push( "2" );
            target.Push( "3" );

            var items1 = (System.Collections.Generic.IEnumerable<string>) target;

            foreach ( var item in items1 )
                Console.WriteLine( item );

            var items2 = (IEnumerable) target;

            foreach ( var item in items2 )
                Console.WriteLine( item );
        }
コード例 #41
0
 internal NavigationService()
 {
     NavigationStack = new ObservableStack<Control>();
     _current = 0;
 }
コード例 #42
0
 public UndoAction(ObservableStack <IUndoable> redoableActions, IUndoable action)
 {
     _redoableActions = redoableActions;
     _action          = action;
 }
コード例 #43
0
        public void ShouldContainItem( string value, bool expected )
        {
            // arrange
            var target = new ObservableStack<string>();

            target.Push( "One" );
            target.Push( "Two" );
            target.Push( "Three" );

            // act
            var actual = target.Contains( value );

            // assert
            Assert.Equal( expected, actual );
        }
コード例 #44
0
        public void ShouldCopyToLargeArray()
        {
            // arrange
            var expected = new[] { "1", "2" };
            var target = new ObservableStack<string>( expected );
            var actual = new string[4];

            // act
            target.CopyTo( actual, 2 );

            // assert
            Assert.True( actual.Skip( 2 ).SequenceEqual( expected.Reverse() ) );
        }
コード例 #45
0
        public void ShouldCopyToWhenICollection()
        {
            // arrange
            var target = new ObservableStack<string>();
            var collection = (ICollection) target;
            var expected = new[] { "1", "2" };
            var actual = new string[2];

            target.Push( "1" );
            target.Push( "2" );

            // act
            collection.CopyTo( actual, 0 );

            // assert
            Assert.True( actual.SequenceEqual( expected.Reverse() ) );
        }
コード例 #46
0
 public UndoData()
 {
     UndoStack = new ObservableStack<UndoScope>();
     RedoStack = new ObservableStack<UndoScope>();
 }
コード例 #47
0
        public void ShouldClearWithEvents()
        {
            // arrange
            var target = new ObservableStack<string>();

            target.Push( "1" );

            // act
            Assert.PropertyChanged( target, "Count", () => target.Clear() );

            // assert
            Assert.Equal( 0, target.Count );
        }