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... } }
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; }
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; }
//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; }
/// <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); }
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); } }
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); } }
/// <summary> /// Initializes a new instance of the <see cref="Objective" /> class. /// </summary> /// <param name="type">Type of objective function, i.e. `min` or `min-max`. * `min`: Minimizes the objective value. * `min-max`: Minimizes the maximum objective value. For instance, `min` -> `vehicles` minimizes the number of employed vehicles. `min` -> `completion_time` minimizes the sum of your vehicle routes' completion time. If you use, for example, `min-max` -> `completion_time`, it minimizes the maximum of your vehicle routes' 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 `min` to `min-max` 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 `min-max`) might halve the time to serve all customers to 4 hours. However, this usually comes with higher transport costs. If you want to minimize `vehicles` first and, second, `completion_time`, you can also combine different objectives like this: ```json \"objectives\" : [ { \"type\": \"min\", \"value\": \"vehicles\" }, { \"type\": \"min\", \"value\": \"completion_time\" } ] ``` If you want to balance activities or the number of stops among all employed drivers, you need to specify it as follows: ```json \"objectives\" : [ { \"type\": \"min-max\", \"value\": \"completion_time\" }, { \"type\": \"min-max\", \"value\": \"activities\" } ] ``` (required) (default to TypeEnum.Min).</param> /// <param name="value">The value of the objective function. The objective value `transport_time` solely considers the time your drivers spend on the road, i.e. transport time. In contrary to `transport_time`, `completion_time` also takes waiting times at customer sites into account. The `completion_time` of a route is defined as the time from starting to ending the route, i.e. the route's transport time, the sum of waiting times plus the sum of activity durations. Note that choosing `transport_time` or `completion_time` 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 `vehicles` can only be used along with `min` 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; } }
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)); }
public void ParseEnum_EnumValueHasDescriptionAttribute_ActualDescriptionMatchesExpected(ValueEnum enumValue, double expectedResult) { //Act ValueAttribute actualResult = Enums.GetCustomAttribute <ValueAttribute>(enumValue); //Assert Assert.AreEqual(expectedResult, actualResult.Value); }
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(" ", "") .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; }
public Card(ValueEnum value, SuitEnum suit) { Value = value.ToString(); Suit = suit.ToString(); }
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; }
protected bool Equals( ValueEnum <TValue> other) { return(GetType() == other.GetType() && Value.Equals(other.Value)); }
public int CompareTo( ValueEnum <TValue> obj) { return(LineNumber.CompareTo(obj.LineNumber)); }
/// <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; }
public Card(SuitsEnum nwSuit, ValueEnum nwValue) { Suits = nwSuit; Values = nwValue; }