コード例 #1
0
        private void createListPosition_Click(object sender, RoutedEventArgs e)
        {
            ListPosition listPosition = new ListPosition();

            listPosition.Show();
            this.Close();
        }
コード例 #2
0
        private async Task <string> ListPopAsync(string key, ListPosition position)
        {
            using (var tx = _stateManager.CreateTransaction())
            {
                var list = await _dictionary.TryGetValueAsync(tx, key);

                if (list.HasValue &&
                    list.Value.Count > 0)
                {
                    try
                    {
                        string retVal = null;
                        await _dictionary.AddOrUpdateAsync(tx, key,
                                                           (k) =>
                        {
                            throw new AddValueRestrictedException();
                        },
                                                           (k, ov) =>
                        {
                            switch (position)
                            {
                            case ListPosition.First:
                                retVal = ov.First.Value;
                                ov.RemoveFirst();
                                break;

                            case ListPosition.Last:
                                retVal = ov.Last.Value;
                                ov.RemoveLast();
                                break;

                            default:
                                throw new NotImplementedException($"{nameof(position)} value {position} is not implemented.");
                            }

                            return(ov);
                        });

                        await tx.CommitAsync();

                        return(retVal);
                    }
                    catch (AddValueRestrictedException)
                    {
                        // There should be no value added / created during this operation.
                        // If the list contains no elements, return null instead.
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var position = value.ToListPosition();

            if (position.HasValue)
            {
                _position = position.Value;
                return(true);
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Inserts a wait block into the waiters list.
        /// </summary>
        /// <param name="waitBlock">The wait block to insert.</param>
        /// <param name="position">Specifies where to insert the wait block.</param>
        private void InsertWaitBlock(WaitBlock *waitBlock, ListPosition position)
        {
            switch (position)
            {
            case ListPosition.First:
                InsertHeadList(_waitersListHead, waitBlock);
                break;

            case ListPosition.LastExclusive:
                InsertTailList(_firstSharedWaiter, waitBlock);
                break;

            case ListPosition.Last:
                InsertTailList(_waitersListHead, waitBlock);
                break;
            }
        }
コード例 #5
0
        protected override Boolean IsValid(CSSValue value)
        {
            if (value.Is("inside"))
            {
                _position = ListPosition.Inside;
            }
            else if (value.Is("outside"))
            {
                _position = ListPosition.Outside;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        protected virtual Label OnCreateLabelForItem(object item, ListPosition listPosition)
        {
            var text = (item != null) ? item.ToString () : String.Empty;
            var label = new Label { Text = text };
            if (Orientation == StackOrientation.Horizontal) {
                label.HorizontalOptions = listPosition.GetLayoutOption ();
                label.VerticalOptions = LayoutOptions.Center;
            } else {
                label.HorizontalOptions = LayoutOptions.Center;
                label.VerticalOptions = listPosition.GetLayoutOption ();
            }

            if (LabelStyle != null) {
                label.Style = LabelStyle;
            }

            return label;
        }
コード例 #7
0
        private async Task ListAddAsync(string key, IEnumerable <string> values, ListPosition position)
        {
            using (var tx = _stateManager.CreateTransaction())
            {
                await _dictionary.AddOrUpdateAsync(tx, key,
                                                   (k) =>
                {
                    return(new LinkedList <string>(values));
                },
                                                   (k, ov) =>
                {
                    switch (position)
                    {
                    case ListPosition.First:
                        foreach (var value in values)
                        {
                            ov.AddFirst(value);
                        }
                        break;

                    case ListPosition.Last:
                        foreach (var value in values)
                        {
                            ov.AddLast(value);
                        }
                        break;

                    default:
                        throw new NotImplementedException($"{nameof(position)} value {position} is not implemented.");
                    }

                    return(ov);
                });

                await tx.CommitAsync();
            }
        }
コード例 #8
0
 internal override void Reset()
 {
     _position = Default;
 }
コード例 #9
0
 public void SetPosition(ListPosition position)
 {
     _position = position;
 }
コード例 #10
0
ファイル: RobotK79.cs プロジェクト: UsachevSergey/Olimp
 public Robot()
 {
     ListPosition.Add(new position(0, 0));
 }
コード例 #11
0
 internal override void Reset()
 {
     _position = ListPosition.Outside;
 }
コード例 #12
0
 /// <summary>
 /// Inserts a wait block into the waiters list.
 /// </summary>
 /// <param name="waitBlock">The wait block to insert.</param>
 /// <param name="position">Specifies where to insert the wait block.</param>
 private void InsertWaitBlock(WaitBlock* waitBlock, ListPosition position)
 {
     switch (position)
     {
         case ListPosition.First:
             InsertHeadList(_waitersListHead, waitBlock);
             break;
         case ListPosition.LastExclusive:
             InsertTailList(_firstSharedWaiter, waitBlock);
             break;
         case ListPosition.Last:
             InsertTailList(_waitersListHead, waitBlock);
             break;
     }
 }
コード例 #13
0
 internal CSSListStylePositionProperty()
     : base(PropertyNames.ListStylePosition)
 {
     _inherited = true;
     _position  = ListPosition.Outside;
 }