/// <summary> /// Recursively ensures: /// * Arbitrary ISassType implementation. /// * Circular reference on each "listy" item stored in the values. /// </summary> /// <param name="lists">List containing instances of SassList</param> private void WalkAndEnsureDependencies(List <SassList> lists) { // Prevent from re-entrance. if (_ensured) { return; } // FIXME: Should we instead loop through the array and // report the exact index which violates this rule? if (!Values.All(v => v is ISassExportableType)) { throw new SassTypeException(SassTypeException.ArbitraryInterfaceImplmentationMessage); } // Detect the circular-referencing values. lists.Add(this); var filteredValues = Values.OfType <SassList>().ToList(); if (filteredValues.Any(lists.Contains)) { throw new SassTypeException(SassTypeException.CircularReferenceMessage); } filteredValues.ForEach(v => v.WalkAndEnsureDependencies(lists)); _ensured = true; }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } var multipleStringFieldValue = obj as MultipleStringFieldValue; if (multipleStringFieldValue != null && (Values == null || Values.Count == 0 || multipleStringFieldValue.Values == null || multipleStringFieldValue.Values.Count == 0)) { return((Values == null || Values.Count == 0) && (multipleStringFieldValue.Values == null || multipleStringFieldValue.Values.Count == 0)); } if (multipleStringFieldValue != null && Values.Count != multipleStringFieldValue.Values.Count) { return(false); } return(Values.All(v => multipleStringFieldValue != null && multipleStringFieldValue.HasValue(v))); }
public LocalizedText Trim() { if (Values.All(x => x.Trim() == x)) { return(this); } var result = new LocalizedText(); foreach (var(key, value) in this) { result[key] = value.Trim(); } return(result); }
public static int Score(int[] dice, YachtCategory category) { var occurences = dice.GroupBy(d => d).ToDictionary(group => group.Key, group => group.Count()); switch (category) { case YachtCategory.Ones: case YachtCategory.Twos: case YachtCategory.Threes: case YachtCategory.Fours: case YachtCategory.Fives: case YachtCategory.Sixes: return(dice.Where(d => d == (int)category).Sum()); case YachtCategory.FullHouse when occurences.Keys.Count == 2 && occurences.Values.All(o => o == 2 || o == 3): return(dice.Sum()); case YachtCategory.FourOfAKind when occurences.Values.Any(o => o >= 4): return(occurences.Single(kvp => kvp.Value >= 4).Key * 4); case YachtCategory.LittleStraight when occurences.Values.All(o => o == 1) && occurences.ContainsKey(1) && occurences.ContainsKey(5): return(30); case YachtCategory.BigStraight when occurences.Values.All(o => o == 1) && occurences.ContainsKey(2) && occurences.ContainsKey(6): return(30); case YachtCategory.Choice: return(dice.Sum()); case YachtCategory.Yacht when dice.All(o => o == dice[0]): return(50); default: return(0); } }
internal bool AllSolutionsUse(sbyte s) { if (Values == null) { return(true); } if (IndexPos == 0 && Values.ContainsKey(s)) { return(Values.All(x => x.Key == s || x.Value.AllSolutionsUse(s))); } else if (IndexPos > 0) { //I did not start w/ the s value, but maybe one of my children has it. return(Values.ContainsKey(s) || Values.Any(x => x.Value.AllSolutionsUse(s))); } return(false); }
public override bool Equals(object obj) { if (obj != null && obj is EntityPackage) { var other = (EntityPackage)obj; //Warn: there is a CHANCE... that this will give false positives. For instance: //if we have two relations that are exactly the same but the "other" has //two different relations, one of which is the same. The chances of that are //extremely slim (especially considering the ids must be the same)... but still possible. return(Entity.Equals(other.Entity) && Values.Count == other.Values.Count && Relations.Count == other.Relations.Count && Values.All(x => other.Values.Contains(x)) && Relations.All(x => other.Relations.Contains(x))); } else { return(false); } }
//================================================= public Map(Dictionary <string, string> dictionary) : base() { IEnumerable <PropertyInfo> props = getProperties(); foreach (PropertyInfo prop in props) { try { XlFieldAttribute attr = getAttribute <XlFieldAttribute>(prop); KeyValuePair <string, string> tmp = dictionary.SingleOrDefault(x => x.Value.Equals(prop.Name, StringComparison.CurrentCultureIgnoreCase) || attr.Captions.Any(y => x.Value.Equals(y, StringComparison.CurrentCultureIgnoreCase))); if (!isDefault(tmp)) { this[tmp.Key.rMatch(@"^[A-Z]+")] = new MapItem { Attribute = attr, Property = prop } } ; } catch (InvalidOperationException ex) { Exceptioins.Add(new InvalidOperationException($"Дублирование заголовков, {prop.Name}", ex)); } } string[][] captions = getClassCaptions(true); MissingFields = captions.Where(x => Values.All(y => !y.Contains(x))).Select(x => x.First()); }
public void ChangeStatus(Status status, string item) { if (status == Status.UnChecked) { SelectedValues.Remove(item); } else { SelectedValues.Add(item); } if (Values.All(SelectedValues.Contains)) { Status = Status.Checked; } else if (SelectedValues.Any()) { Status = Status.Indeterminate; } else { Status = Status.UnChecked; } }
public bool IsEmpty() => Values.All(s => s == "");
/// <summary> /// Determines whether all the elements inside this <see cref="HoconValue"/> /// are a string. /// </summary> /// <returns> /// <c>true</c>if all elements inside this <see cref="HoconValue"/> are a string; otherwise <c>false</c>. /// </returns> public bool IsString() { return(Values.Any() && Values.All(v => v.IsString())); }
public bool GenDict() => Values.All(GenerateEpisodeDict);
public bool HandleEvent(CommandBase command, UserInfo user, List <string> args) { return(Values.All(mode => mode.HandleEvent(command, user, args))); }
public bool IsNull() { return(Values.All(x => x.Value == null)); }
/// <summary> /// Determines whether all the elements inside this <see cref="HoconValue"/> /// are a string. /// </summary> /// <returns> /// <c>true</c>if all elements inside this <see cref="HoconValue"/> are a string; otherwise <c>false</c>. /// </returns> public bool IsString() { return(Values.Count > 0 && Values.All(v => v.IsString())); }
public bool IsInteger() { int myInt; return(Values.All(v => int.TryParse(v.NewValue, out myInt))); }
public bool IsNumeric() { double myDouble; return(Values.All(v => double.TryParse(v.NewValue, out myDouble))); }