Beispiel #1
0
 public UpdateToken(string setToken, object value, ValueEnum valueType)
     : this()
 {
     SetToken = setToken;
     Value = value;
     ValueType = valueType;
 }
    public Deck()
    {
        Random rand = new Random();

        Cards = new List <Card>();
        List <int> listNumberSuite = new List <int>();
        List <int> listNumberDeck  = new List <int>();
        int        number;

        for (int i = 0; i < 4; i++)
        {
            do
            {
                number = rand.Next(1, 4);
            } while (listNumberSuite.Contains(number));
            SuitEnum suit = (SuitEnum)number;
            int      deckNumber;
            for (int j = 0; j < 13; j++)
            {
                do
                {
                    deckNumber = rand.Next(1, 13);
                } while (listNumberDeck.Contains(deckNumber));
                ValueEnum deck = (ValueEnum)deckNumber;
                Cards.Add(new Card(suit, deck));
            }
        }
        foreach (Card c in Cards)
        {
            Console.WriteLine(c.Display());
        }
    }
    public Deck()
    {
        Random rand = new Random();

        Cards = new List <Card>();
        List <int> possibleSuit    = Enumerable.Range(1, 4).ToList();
        List <int> listNumberSuite = new List <int>();

        for (int i = 0; i < 4; i++)
        {
            int index = rand.Next(0, possibleSuit.Count);
            listNumberSuite.Add(possibleSuit[index]);
            SuitEnum suit = (SuitEnum)possibleSuit[index];
            possibleSuit.RemoveAt(index);
            List <int> possibleDeck   = Enumerable.Range(1, 13).ToList();
            List <int> listNumberDeck = new List <int>();
            for (int j = 0; j < 13; j++)
            {
                int indexDeck = rand.Next(0, possibleDeck.Count);
                listNumberDeck.Add(possibleDeck[indexDeck]);
                ValueEnum deck = (ValueEnum)possibleDeck[indexDeck];
                Cards.Add(new Card(suit, deck));
                possibleDeck.RemoveAt(indexDeck);
            }
        }
        foreach (Card c in Cards)
        {
            Console.WriteLine(c.Display());
        }
    }
 /// <summary>
 /// Property change listener for observable collection.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="args"></param>
 private void HandlePropertyChange(object source, PropertyChangedEventArgs args)
 {
     if (args.PropertyName.Equals(nameof(SelectedValue)))
     {
         if (m_valueValuesCollection.IndexOf(SelectedValue) == ValueNumValues.IndexOf(100))
         {
             m_SelectedValueEnum = ValueEnum.First;
         }
         if (m_valueValuesCollection.IndexOf(SelectedValue) == ValueNumValues.IndexOf(200))
         {
             m_SelectedValueEnum = ValueEnum.Second;
         }
         if (m_valueValuesCollection.IndexOf(SelectedValue) == ValueNumValues.IndexOf(300))
         {
             m_SelectedValueEnum = ValueEnum.Third;
         }
         if (m_valueValuesCollection.IndexOf(SelectedValue) == ValueNumValues.IndexOf(400))
         {
             m_SelectedValueEnum = ValueEnum.Fourth;
         }
     }
     else
     {
         // Do something when we don't get an expected value...
     }
 }
Beispiel #5
0
 public DecoratedDoubleValue(double value, string beforeText = null, string afterText                    = null,
                             ValueEnum decimalCount          = ValueEnum.Int, ValueEnum zeroDecimalCount = ValueEnum.Triple,
                             bool displayThousandSeparator   = false, bool alwaysDisplayDecimals         = false)
     : base(value, decimalCount, zeroDecimalCount, displayThousandSeparator, alwaysDisplayDecimals)
 {
     BeforeText = beforeText;
     AfterText  = afterText;
 }
Beispiel #6
0
 public CompareToken(string selectToken, CompareEnum compareType, object value, ValueEnum valueType)
     : this()
 {
     SelectToken = selectToken;
     CompareType = compareType;
     Value = value;
     ValueType = valueType;
 }
    public void Update(ValueEnum someValue, int?someOtherValue = null)
    {
        if ((someOtherValue.HasValue && someValue != ValueEnum.HasOtherValue) ||
            (!someOtherValue.HasValue && someValue == ValueEnum.HasOtherValue))
        {
            throw new ArgumentException("Invalid value combination.");
        }

        SomeValue      = someValue;
        SomeOtherValue = someOtherValue;
    }
Beispiel #8
0
 //constructor of agenda
 public Agenda()
 {
     _title            = String.Empty;
     _content          = String.Empty;
     _place            = String.Empty;
     _startDateTime    = null;
     _endDateTime      = null;
     _reminderDateTime = null;
     _isRemind         = false;
     _value            = ValueEnum.Common;
 }
Beispiel #9
0
 //constructor of agenda
 public Agenda()
 {
     _title = String.Empty;
     _content = String.Empty;
     _place = String.Empty;
     _startDateTime = null;
     _endDateTime = null;
     _reminderDateTime = null;
     _isRemind = false;
     _value = ValueEnum.Common;
 }
Beispiel #10
0
 /// <summary>
 /// Class Constructor
 /// </summary>
 /// <param name="value">Value as a string</param>
 /// <param name="suit">Suit as a string</param>
 public PokerCard(string value, string suit)
 {
     if (value.All(char.IsNumber))
     {
         Value = (ValueEnum)int.Parse(value);
     }
     else
     {
         Enum.TryParse(value, true, out Value);
     }
     Enum.TryParse(suit, true, out Suit);
 }
Beispiel #11
0
        protected virtual void ShowRequestForBackMessage(EventArgs args)
        {
            MessageBoxResult messageResult = MessageBox.Show("В текущую запись учебного заведения" +
                                                             Environment.NewLine +
                                                             "были внесены изменения." +
                                                             Environment.NewLine + Environment.NewLine +
                                                             "Сохранить внесенные изменения?",
                                                             "Сохранение текущей записи",
                                                             MessageBoxButton.YesNoCancel,
                                                             MessageBoxImage.Question,
                                                             MessageBoxResult.Yes);

            if (DomainContext != null && DomainContext.ViewModel != null)
            {
                ValueEnum result = ConvertToValueEnum(messageResult);
                DomainContext.ViewModel.SetResponseForBack(result);
            }
        }
Beispiel #12
0
        protected virtual void ShowRequestForDeleteMessage(EventArgs args)
        {
            MessageBoxResult messageResult = MessageBox.Show("Текущая запись учебного заведения" +
                                                             Environment.NewLine +
                                                             "будет удалена без возможности" +
                                                             Environment.NewLine +
                                                             "восстановления!" +
                                                             Environment.NewLine + Environment.NewLine +
                                                             "Вы уверены, что ходите сделать" +
                                                             Environment.NewLine + "данную операцию?",
                                                             "Удаление текущей записи",
                                                             MessageBoxButton.YesNo,
                                                             MessageBoxImage.Stop,
                                                             MessageBoxResult.Yes);

            if (DomainContext != null && DomainContext.ViewModel != null)
            {
                ValueEnum result = ConvertToValueEnum(messageResult);
                DomainContext.ViewModel.SetResponseForDelete(result);
            }
        }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Objective" /> class.
 /// </summary>
 /// <param name="type">Type of objective function, i.e. &#x60;min&#x60; or &#x60;min-max&#x60;.   * &#x60;min&#x60;: Minimizes the objective value.  * &#x60;min-max&#x60;: Minimizes the maximum objective value.  For instance, &#x60;min&#x60; -&gt; &#x60;vehicles&#x60; minimizes the number of employed vehicles. &#x60;min&#x60; -&gt; &#x60;completion_time&#x60; minimizes the sum of your vehicle routes&#x27; completion time.  If you use, for example, &#x60;min-max&#x60; -&gt; &#x60;completion_time&#x60;, it minimizes the maximum of your vehicle routes&#x27; completion time, i.e. it minimizes the overall makespan. This only makes sense if you have more than one vehicle. In case of one vehicle, switching from &#x60;min&#x60; to &#x60;min-max&#x60; should not have any impact. If you have more than one vehicle, then the algorithm tries to constantly move stops from one vehicle to another such that the completion time of longest vehicle route can be further reduced. For example, if you have one vehicle that takes 8 hours to serve all customers, adding another vehicle (and using &#x60;min-max&#x60;) might halve the time to serve all customers to 4 hours. However, this usually comes with higher transport costs.  If you want to minimize &#x60;vehicles&#x60; first and, second, &#x60;completion_time&#x60;, you can also combine different objectives like this:  &#x60;&#x60;&#x60;json \&quot;objectives\&quot; : [    {       \&quot;type\&quot;: \&quot;min\&quot;,       \&quot;value\&quot;: \&quot;vehicles\&quot;    },    {       \&quot;type\&quot;: \&quot;min\&quot;,       \&quot;value\&quot;: \&quot;completion_time\&quot;    } ] &#x60;&#x60;&#x60;  If you want to balance activities or the number of stops among all employed drivers, you need to specify it as follows:  &#x60;&#x60;&#x60;json \&quot;objectives\&quot; : [    {       \&quot;type\&quot;: \&quot;min-max\&quot;,       \&quot;value\&quot;: \&quot;completion_time\&quot;    },    {       \&quot;type\&quot;: \&quot;min-max\&quot;,       \&quot;value\&quot;: \&quot;activities\&quot;    } ] &#x60;&#x60;&#x60;  (required) (default to TypeEnum.Min).</param>
 /// <param name="value">The value of the objective function. The objective value &#x60;transport_time&#x60; solely considers the time your drivers spend on the road, i.e. transport time. In contrary to &#x60;transport_time&#x60;, &#x60;completion_time&#x60; also takes waiting times at customer sites into account. The &#x60;completion_time&#x60; of a route is defined as the time from starting to ending the route, i.e. the route&#x27;s transport time, the sum of waiting times plus the sum of activity durations. Note that choosing &#x60;transport_time&#x60; or &#x60;completion_time&#x60; only makes a difference if you specified time windows for your services/shipments since only in scenarios with time windows waiting times can occur. The objective value &#x60;vehicles&#x60; can only be used along with &#x60;min&#x60; and minimizes vehicles.  (required) (default to ValueEnum.Transporttime).</param>
 public Objective(TypeEnum type = TypeEnum.Min, ValueEnum value = ValueEnum.Transporttime)
 {
     // to ensure "type" is required (not null)
     if (type == null)
     {
         throw new InvalidDataException("type is a required property for Objective and cannot be null");
     }
     else
     {
         this.Type = type;
     }
     // to ensure "value" is required (not null)
     if (value == null)
     {
         throw new InvalidDataException("value is a required property for Objective and cannot be null");
     }
     else
     {
         this.Value = value;
     }
 }
Beispiel #14
0
        public void GetValueFromCustomAttribute_PassCustomAttribute_ValueIsReturned(double searchString, ValueEnum expectedEnum)
        {
            //Act
            var actualResult = Enums.GetValueFromCustomAttribute <ValueEnum, ValueAttribute, double>(searchString, a => a.Value);

            Assert.That(actualResult, Is.EqualTo(expectedEnum));
        }
Beispiel #15
0
        public void ParseEnum_EnumValueHasDescriptionAttribute_ActualDescriptionMatchesExpected(ValueEnum enumValue, double expectedResult)
        {
            //Act
            ValueAttribute actualResult = Enums.GetCustomAttribute <ValueAttribute>(enumValue);

            //Assert
            Assert.AreEqual(expectedResult, actualResult.Value);
        }
Beispiel #16
0
        public static IEnumerable <CWMArticle> ScrapeIssueArticles(
            CWMIssue cwmIssue)
        {
            var context = BrowsingContext.New(
                Configuration.Default.WithDefaultLoader());

            var downloadPageUrl = cwmIssue.IssuePageAbsoluteUrl;

            using (var document = context
                                  .OpenAsync(downloadPageUrl)
                                  .GetAwaiter()
                                  .GetResult())
            {
                var canvasWrapper = document
                                    .GetElementById("canvas-wrapper");

                var contentDiv = canvasWrapper
                                 .QuerySelector(
                    "div#canvas > " +
                    "div#page-body-wrapper > " +
                    "div#page-body > " +
                    "div#content-wrapper > " +
                    "div#content");

                var mainContentDiv = contentDiv.Children[2];

                var productBlockContentElement = mainContentDiv
                                                 .QuerySelector(
                    "div#productWrapper > " +
                    "div.product-description > " +
                    "div.sqs-layout > " +
                    "div.row.sqs-row > " +
                    "div.col > " +
                    "div.sqs-block.html-block > " +
                    "div.sqs-block-content");

                var currentArticleCategory = "Unknown";

                var magazineSections = ValueEnum
                                       .EnumerateValues <MagazineSection, string>()
                                       .ToArray();

                foreach (var productBlockElement in productBlockContentElement.Children)
                {
                    var articeInfoStr = productBlockElement
                                        .TextContent
                                        .Replace("&nbsp;", "")
                                        .Trim();

                    var isMagazineSection = magazineSections
                                            .Contains(
                        articeInfoStr,
                        new FuzzyStringMatchingComparer(2));

                    if (isMagazineSection)
                    {
                        currentArticleCategory = articeInfoStr;
                        continue;
                    }

                    var splitTerms = articeInfoStr.Split('-');

                    if (splitTerms.Length == 2)
                    {
                        var articleName   = splitTerms[0].Trim();
                        var articleAuthor = splitTerms[1].Trim();

                        yield return(new CWMArticle(
                                         currentArticleCategory,
                                         articleName,
                                         articleAuthor,
                                         cwmIssue));
                    }
                    else
                    {
                        var articleName = articeInfoStr.Trim();

                        yield return(new CWMArticle(
                                         currentArticleCategory,
                                         articleName,
                                         "unknown",
                                         cwmIssue));
                    }
                }
            }
        }
 public Card(SuitEnum cardSuit, ValueEnum cardValue)
 {
     Suit  = cardSuit;
     Value = cardValue;
 }
Beispiel #18
0
 public Card(ValueEnum value, SuitEnum suit)
 {
     Value = value.ToString();
     Suit  = suit.ToString();
 }
Beispiel #19
0
        public DoubleValue(double value, ValueEnum decimalCount = ValueEnum.Int, ValueEnum zeroDecimalCount = ValueEnum.Triple,
                           bool displayThousandSeparator        = false, bool alwaysDisplayDecimals = false) : base(Math.Round(value, (int)decimalCount))
        {
            _cultureInfo = new CultureInfo("tr-TR", false);

            _originalValue = value;

            NumberFormat = "0";

            var integerPart = (int)Math.Truncate(_originalValue);
            var decimalPart = (float)(_originalValue - integerPart);

            int tmpValue;

            if (integerPart == 0 || alwaysDisplayDecimals)
            {
                switch (zeroDecimalCount)
                {
                case ValueEnum.Triple:
                    tmpValue = (int)(decimalPart * 1000);
                    if ((tmpValue <= -1 && tmpValue >= -9) || (tmpValue >= 1 && tmpValue <= 9) || alwaysDisplayDecimals)
                    {
                        _cultureInfo.NumberFormat.NumberDecimalDigits = 3;
                        NumberFormat = "0.000";
                        break;
                    }
                    goto case ValueEnum.Double;

                case ValueEnum.Double:
                    tmpValue = (int)(decimalPart * 100);
                    if ((tmpValue <= -1 && tmpValue >= -9) || (tmpValue >= 1 && tmpValue <= 9) || alwaysDisplayDecimals)
                    {
                        _cultureInfo.NumberFormat.NumberDecimalDigits = 2;
                        NumberFormat = "0.00";
                        break;
                    }
                    goto case ValueEnum.Single;

                case ValueEnum.Single:
                    tmpValue = (int)(decimalPart * 10);
                    if ((tmpValue <= -1 && tmpValue >= -9) || (tmpValue >= 1 && tmpValue <= 9) || alwaysDisplayDecimals)
                    {
                        _cultureInfo.NumberFormat.NumberDecimalDigits = 1;
                        NumberFormat = "0.0";
                        break;
                    }
                    goto default;

                default:
                    _cultureInfo.NumberFormat.NumberDecimalDigits = 0;
                    NumberFormat = "0";
                    break;
                }
            }
            else
            {
                switch (decimalCount)
                {
                case ValueEnum.Triple:
                    NumberFormat = "0.000";
                    break;

                case ValueEnum.Double:
                    NumberFormat = "0.00";
                    break;

                case ValueEnum.Single:
                    NumberFormat = "0.0";
                    break;

                case ValueEnum.Int:
                    NumberFormat = "0";
                    break;
                }
                _cultureInfo.NumberFormat.NumberDecimalDigits = (int)decimalCount;
            }

            _cultureInfo.NumberFormat.NumberGroupSeparator = "";
            if (displayThousandSeparator)
            {
                _cultureInfo.NumberFormat.NumberGroupSeparator = ".";
                NumberFormat = "#,##" + NumberFormat;
            }

            Value = Math.Round(value, _cultureInfo.NumberFormat.NumberDecimalDigits);
        }
 public Card(SuitEnum suit, ValueEnum val)
 {
     this.Suit = suit;
     this.Value = val;
 }
Beispiel #21
0
 protected bool Equals(
     ValueEnum <TValue> other)
 {
     return(GetType() == other.GetType() &&
            Value.Equals(other.Value));
 }
Beispiel #22
0
 public int CompareTo(
     ValueEnum <TValue> obj)
 {
     return(LineNumber.CompareTo(obj.LineNumber));
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResetSections" /> class.
 /// </summary>
 /// <param name="value">value (required).</param>
 /// <param name="after">after date-time criteria for history reset.</param>
 /// <param name="before">before date-time criteria for history reset.</param>
 public ResetSections(ValueEnum value = default(ValueEnum), DateTime after = default(DateTime), DateTime before = default(DateTime))
 {
     this.Value  = value;
     this.After  = after;
     this.Before = before;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConditionOption" /> class.
 /// </summary>
 /// <param name="condition">Condition of an email object that can be used to filter results (required).</param>
 /// <param name="value">Expected condition value (required).</param>
 public ConditionOption(ConditionEnum condition = default(ConditionEnum), ValueEnum value = default(ValueEnum))
 {
     this.Condition = condition;
     this.Value     = value;
 }
Beispiel #25
0
 public Card(SuitsEnum nwSuit, ValueEnum nwValue)
 {
     Suits  = nwSuit;
     Values = nwValue;
 }