public static void Apply() { Game game = ServiceHelper.Game; int width = SettingsManager.Settings.Width; int height = SettingsManager.Settings.Height; if (SettingsManager.Settings.UseCurrentMode) { DisplayMode currentDisplayMode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; SettingsManager.Settings.Height = height = currentDisplayMode.Height; SettingsManager.Settings.Width = width = (int)Math.Round((double)height * (double)currentDisplayMode.AspectRatio); } if (SettingsManager.Settings.ScreenMode == ScreenMode.Fullscreen && !Enumerable.Any <DisplayMode>((IEnumerable <DisplayMode>)GraphicsAdapter.DefaultAdapter.SupportedDisplayModes, (Func <DisplayMode, bool>)(x => { if (x.Width == width) { return(x.Height == height); } else { return(false); } }))) { width = SettingsManager.Settings.Width = SettingsManager.NativeResolution.Width; height = SettingsManager.Settings.Height = SettingsManager.NativeResolution.Height; } SettingsManager.DeviceManager.IsFullScreen = SettingsManager.Settings.ScreenMode == ScreenMode.Fullscreen; SettingsManager.DeviceManager.PreferredBackBufferWidth = width; SettingsManager.DeviceManager.PreferredBackBufferHeight = height; SettingsManager.DeviceManager.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; game.IsMouseVisible = !SettingsManager.DeviceManager.IsFullScreen; try { SettingsManager.DeviceManager.ApplyChanges(); } catch (GraphicsModeException ex) { Logger.Log("SettingsManager", string.Format("Could not set screen to desired resolution ({0}x{1}; falling back to native", (object)SettingsManager.Settings.Width, (object)SettingsManager.Settings.Height)); DisplayMode currentDisplayMode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; SettingsManager.DeviceManager.PreferredBackBufferWidth = SettingsManager.Settings.Width = currentDisplayMode.Width; SettingsManager.DeviceManager.PreferredBackBufferHeight = SettingsManager.Settings.Height = currentDisplayMode.Height; SettingsManager.DeviceManager.ApplyChanges(); } Logger.Log("SettingsManager", "Screen set to " + (object)GraphicsAdapter.DefaultAdapter.CurrentDisplayMode); Logger.Log("SettingsManager", string.Format("Backbuffer is {0}x{1}", (object)SettingsManager.DeviceManager.GraphicsDevice.PresentationParameters.BackBufferWidth, (object)SettingsManager.DeviceManager.GraphicsDevice.PresentationParameters.BackBufferHeight)); SettingsManager.SetupViewport(SettingsManager.DeviceManager.GraphicsDevice, false); SettingsManager.DeviceManager.OnDeviceReset(EventArgs.Empty); game.IsMouseVisible = false; }
public double GetCWeight() { var rows = table.Select("Sum(" + nameof(weightTableTermCompiled.cw) + ")"); if (!Enumerable.Any <DataRow>(rows)) { return(0); } DataRow dr = Enumerable.First <DataRow>(rows); var vl = dr[nameof(weightTableTermCompiled.cw)]; return(vl.imbConvertValueSafeTyped <Double>()); }
private void WriteParameters(XmlTextWriter xmlWriter) { if (!Enumerable.Any(myParameters)) { return; } xmlWriter.WriteStartElement("parameters"); foreach (var parameter in myParameters) { parameter.ExportTo(xmlWriter); } xmlWriter.WriteEndElement(); }
public void Any_Predicate_With_ValidData_Must_Succeed(int[] source, Func <int, bool> predicate) { // Arrange var expected = Enumerable .Any(source, predicate); // Act var result = source.AsValueEnumerable() .Any(predicate); // Assert _ = result.Must() .BeEqualTo(expected); }
public override string ToString() { if (IsSucceeded) { return($"Check was successful"); } if (Enumerable.Any(InnerResults)) { return(ErrorMessage + "\n\t" + string.Join("\n\t", Enumerable.Select(InnerResults, ir => ir.ToString().Replace("\n", "\n\t")))); } return(ErrorMessage); }
private static bool CanEverKill(Hediff hediff) { if (hediff.def.stages == null) { return(hediff.def.lethalSeverity >= 0f); } if (Enumerable.Any(hediff.def.stages, t => t.lifeThreatening)) { return(true); } return(hediff.def.lethalSeverity >= 0f); }
public void Any_With_ValidData_Must_Succeed(int[] source) { // Arrange var expected = Enumerable .Any(source); // Act var result = source.AsValueEnumerable() .Any(); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Any_Predicate_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate) { // Arrange var expected = Enumerable .Any(source, predicate.AsFunc()); // Act var result = ArrayExtensions .Any(source, predicate); // Assert _ = result.Must() .BeEqualTo(expected); }
//public void CollectAll(IEnumerable items) // where T:class,IContentToken, new() //{ // if (items != null) // { // foreach (Object en in items) // { // if (en is IContentSubSentence) // { // IContentSubSentence icss = en as IContentSubSentence; // Add(icss.items); // } else // { // Add(en as IContentToken); // } // } // } //} public List <IContentToken> this[contentTokenFlag flag] { get { if (Enumerable.Any(this, x => x.flags.HasFlag(flag))) { return(Enumerable.Where(this, x => x.flags.HasFlag(flag)).ToList()); } else { return(new List <IContentToken>()); } } }
/// <summary> /// Remove the specified number of prefixed spaces from each line of the comment. /// Fails if any non-blank lines don't start with at least the specified number of spaces. /// </summary> public bool RemoveSpaces(int spaces) { string[] lines = _text.Split('\n'); if (Enumerable.Any(lines, delegate(string line) { return(StringUtil.CharCount(line, ' ', 0) < spaces && line.Length > 0); })) { return(false); } _text = null; foreach (string line in lines) { _text += (_text == null ? "" : "\n") + (string.IsNullOrEmpty(line) ? "" : line.Remove(0, spaces)); } return(true); }
public (bool, object) Convert(string strValue, Type desiredTargetType, ConvertContext context) { var results = (from c in converters let r = c.Convert(strValue, desiredTargetType, context) where r.Item1 select new { r.Item1, r.Item2 }).ToList(); if (Enumerable.Any(results)) { return(true, Enumerable.First(results).Item2); } return(false, null); }
public static bool IsMethodOverridden(Type currentType, Type methodDeclaringType, string method) { return(Enumerable.Any <MethodInfo>((IEnumerable <MethodInfo>)currentType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), (Func <MethodInfo, bool>)(info => { if (info.Name == method && info.DeclaringType != methodDeclaringType) { return info.GetBaseDefinition().DeclaringType == methodDeclaringType; } else { return false; } }))); }
public void Execute(object parameter) { var layer = (Data.Layer)parameter; var useSelection = Enumerable.Any(layer.Selection, item => item is Data.Point); var usePaths = new List <Data.Path>(); var retainPaths = new List <Data.Path>(); Data.Path refPath = null; foreach (var path in layer.Paths) { if (path.IsOpen) { retainPaths.Add(path); } //else //{ if (refPath == null && Enumerable.Any(path.Points, point => point.IsSelected)) { refPath = path; } else { usePaths.Add(path); } //} } // TODO: consider dropping this behavior, more confusing than useful if (refPath == null) { refPath = usePaths.Last(); usePaths.RemoveAt(usePaths.Count - 1); } var refPathArray = new Data.Path[] { refPath }; if (BooleanOps.HasOverlaps(usePaths, refPathArray)) { var resultPaths = BooleanFunc(usePaths, refPathArray); using (var group = layer.CreateUndoGroup()) { layer.Paths.Clear(); layer.Paths.AddRange(resultPaths); layer.Paths.AddRange(retainPaths); ((App)Application.Current).InvalidateData(); } } }
void ValidateAppliesTo(EndpointReference appliesTo) { if (_addressExpected == null || _addressExpected.Length == 0) { return; } var validAppliesTo = Enumerable.Any(_addressExpected, x => appliesTo.Uri.Equals(x)); if (!validAppliesTo) { throw new InvalidRequestException(String.Format("The relying party address is not valid. Expected value is {0}, the actual value is {1}.", _addressExpected, appliesTo.Uri.AbsoluteUri)); } }
public async ValueTask Range_AnyAsync_With_ValidData_Must_Succeed(int start, int count) { // Arrange var expected = Enumerable.Any(Enumerable.Range(start, count)); // Act var result = await AsyncValueEnumerable.Range(start, count) .AnyAsync() .ConfigureAwait(false); // Assert _ = result.Must() .BeEqualTo(expected); }
public static void ThrowExceptionWhenNotInEnum(string paramName, object value, Type enumType) { Validators.EnsureValidParamName(paramName); Validators.ThrowExceptionWhenIsNull("enumType", (object)enumType); Type enumType1 = enumType; bool flag = false; if (enumType.IsGenericType) { if (!enumType.Assembly.FullName.Equals(typeof(Nullable <>).Assembly.FullName) || !enumType.Namespace.Equals(typeof(Nullable <>).Namespace) || !enumType.Name.Equals(typeof(Nullable <>).Name)) { throw new ArgumentException("enumType debe ser una enumeración", "enumType"); } flag = true; enumType1 = Nullable.GetUnderlyingType(enumType); } if (!enumType1.IsEnum) { throw new ArgumentException("enumType debe ser una enumeración", "enumType"); } if (!flag && value == null) { throw new ArgumentException("El valor de '{0}' no puedo ser nulo si el tipo no es nulable", paramName); } if (!Enumerable.Any <FlagsAttribute>(Enumerable.OfType <FlagsAttribute>((IEnumerable)enumType1.GetCustomAttributes(false)))) { if (value != null && !Enum.IsDefined(enumType1, value)) { throw new ArgumentException("El valor de '{0}' no es un valor posible", paramName); } } else { IEnumerable <long> enumerable = Enumerable.Select <object, long>(Enumerable.Cast <object>((IEnumerable)Enum.GetValues(enumType1)), (Func <object, long>)(x => (long)Convert.ChangeType(x, typeof(long)))); long num1 = 0; long num2 = (long)Convert.ChangeType(value, typeof(long)); foreach (long num3 in enumerable) { if ((num3 & num2) == num3) { num1 += num3; } } if (num1 != num2) { throw new ArgumentException("El valor de '{0}' no es un valor posible", paramName); } } }
private void ProcessData(BalanceData balanceData, Action callback = null) { BalanceRefillViewModel.LoadUnfulfilledConsumables((Action <List <InAppUnfulfilledProduct> >)(unfulfilledProducts => { BalanceData balanceData1 = balanceData; this.Balance = balanceData1 != null ? balanceData1.Balance : 0; this.VotesPacks = new List <VotesPackViewModel>(); BalanceData balanceData2 = balanceData; List <VotesPack> m0List; if (balanceData2 == null) { m0List = null; } else { List <VotesPack> votesPacks = balanceData2.VotesPacks; m0List = votesPacks != null ? Enumerable.ToList <VotesPack>(Enumerable.OrderBy <VotesPack, int>(votesPacks, (Func <VotesPack, int>)(votesPack => votesPack.VotesCount))) : null; } List <VotesPack> votesPackList = m0List; if (votesPackList != null) { for (int index = 0; index < votesPackList.Count; ++index) { VotesPack votesPack = votesPackList[index]; bool flag = Enumerable.Any <InAppUnfulfilledProduct>(unfulfilledProducts, (Func <InAppUnfulfilledProduct, bool>)(product => product.ProductId == votesPack.MerchantProductId)); VotesPackViewModel votesPackViewModel = new VotesPackViewModel(votesPack); votesPackViewModel.IconCoinId = index + 1; int num = !flag ? 1 : 0; votesPackViewModel.CanPurchase = num != 0; this.VotesPacks.Add(votesPackViewModel); } } Execute.ExecuteOnUIThread((Action)(() => { // ISSUE: type reference // ISSUE: method reference this.NotifyPropertyChanged <int>(() => this.Balance); // ISSUE: type reference // ISSUE: method reference this.NotifyPropertyChanged <List <VotesPackViewModel> >(() => this.VotesPacks); })); Action action = callback; if (action == null) { return; } action(); })); }
public override void Filter(List <int> inputList) { base.Filter(inputList); if (!IsFilterActive) { return; } if (Enumerable.Any(PrepareLanding.Instance.GameData.WorldData.WorldCharacteristics, worldCharacteristicData => worldCharacteristicData.Characteristic == UserData.MostLeastItem.Characteristic)) { FilterCharacteristic(UserData.MostLeastItem); } }
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { JsonProperty property = base.CreateProperty(member, memberSerialization); object[] customAttributes = member.GetCustomAttributes(typeof(JsonPropertyAttribute), true); if (Enumerable.Any <object>(customAttributes)) { string propertyName = Enumerable.Single(Enumerable.Cast <JsonPropertyAttribute>((IEnumerable)customAttributes)).PropertyName; if (!string.IsNullOrEmpty(propertyName)) { property.PropertyName = propertyName; } } return(property); }
private HttpParser Bytes(byte value) { if (!this.Success) { return(this); } IEnumerable <byte> range = this.Range; if (!Enumerable.Any <byte>(range) || (int)Enumerable.First <byte>(range) != (int)value) { return(this.Fail()); } ++this._offset; return(this); }
public override void Execute() { if (Enumerable.Any <ViewElement>(this.HideableViews)) { this.HidePalettes(); } else { if (!Enumerable.Any <ViewElement>(this.AutoHiddenViews)) { return; } this.RestorePalettes(); } }
/// <summary> /// remove null item(s) in collection /// </summary> /// <typeparam name="T"><![CDATA[T in IEnumerable]]></typeparam> /// <param name="source"></param> /// <param name="dest"></param> static public void IEnumerableRemoveEmpty <T>(IEnumerable <T> source, out IEnumerable <T> dest) { dest = null; try { if (Enumerable.Any(source)) { dest = source.Where(item => null != item); } } catch (Exception ex) { MyLog.Instance.Warning(ex, "Exception in CWmsDataUtility.IEnumerableRemoveEmpty<{0}>({1})", typeof(T), source); } }
/// <summary> /// Parse a <see cref="PropertyDecl"/> or <see cref="EventDecl"/>. /// </summary> public static PropertyDeclBase Parse(Parser parser, CodeObject parent, ParseFlags flags) { // If our parent is a TypeDecl, verify that we have an unused Expression (it can be either an // identifier or a Dot operator for explicit interface implementations). Otherwise, require a // possible type in addition to the Expression. // If it doesn't seem to match the proper pattern, abort so that other types can try parsing it. if ((parent is TypeDecl && parser.HasUnusedExpression) || parser.HasUnusedTypeRefAndExpression) { // If we have an unused 'event' modifier, it's an event, otherwise treat it as a property string eventModifier = ModifiersHelpers.AsString(Modifiers.Event).Trim(); bool isEvent = (Enumerable.Any(parser.Unused, delegate(ParsedObject parsedObject) { return(parsedObject is Token && ((Token)parsedObject).Text == eventModifier); })); return(isEvent ? (PropertyDeclBase) new EventDecl(parser, parent) : new PropertyDecl(parser, parent)); } return(null); }
public bool?InDesignMode() { string[] strArray = new string[] { "BLEND.EXE", "XDESPROC.EXE" }; Assembly entryAssembly = Assembly.GetEntryAssembly(); if (entryAssembly != null) { string exeName = new FileInfo(entryAssembly.Location).Name.ToUpperInvariant(); if (Enumerable.Any <string>(strArray, x => x.Contains(exeName))) { return(true); } } return(false); }
public static void RegisterPrefetchUrls() { try { if (Enumerable.Any <Uri>((IEnumerable <Uri>)ContentPrefetcher.get_ContentUris(), (Func <Uri, bool>)(u => u.AbsoluteUri == "http://berlox.com/finance/data.bin"))) { return; } ContentPrefetcher.get_ContentUris().Clear(); ContentPrefetcher.get_ContentUris().Add(new Uri("http://berlox.com/finance/data.bin")); } catch { } }
public void Any_Predicate_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate) { // Arrange var list = source.ToList(); var expected = Enumerable .Any(source, predicate.AsFunc()); // Act var result = ListBindings .Any(list, predicate); // Assert _ = result.Must() .BeEqualTo(expected); }
public static bool Any <T>(this IEnumerable <T> list, Func <T, bool> selector) { #if UNITY_IOS || UNITY_ANDROID foreach (var e in list) { if (selector(e)) { return(true); } } return(false); #else return(Enumerable.Any(list, selector)); #endif }
/// <summary> /// Updates the picker. /// </summary> private void UpdatePicker() { if (Control == null) { return; } Control.Placeholder = Element.Title; Control.Text = (Element.SelectedIndex <= -1 || Element.Items == null) ? string.Empty : Element.Items[Element.SelectedIndex]; _picker.ReloadAllComponents(); if (Element.SelectedIndex > -1 && Element.Items != null && Enumerable.Any(Element.Items)) { _picker.Select(Element.SelectedIndex, 0, true); } }
/// <summary> /// 产品销量 /// </summary> /// <param name="shopBranchId"></param> /// <param name="productId"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public static long GetProductSaleCount(long shopBranchId, long productId, DateTime startDate, DateTime endDate) { IEnumerable <OrderItem> source = Enumerable.Where <OrderItem>((IEnumerable <OrderItem>)OrderApplication.GetOrderItemsByOrderId(Enumerable.Select <Order, long>((IEnumerable <Order>)OrderApplication.GetOrdersNoPage(new OrderQuery() { ShopBranchId = new long?(shopBranchId), StartDate = new DateTime?(startDate), EndDate = new DateTime?(endDate.AddDays(-1.0)) }), (Func <Order, long>)(e => e.Id))), (Func <OrderItem, bool>)(e => e.ProductId == productId)); if (Enumerable.Any <OrderItem>(source)) { return(Enumerable.Sum <OrderItem>(source, (Func <OrderItem, long>)(x => x.Quantity))); } return(0); }
public bool Equals(TClass x, TClass y) { if (!Enumerable.Any <Expression <Func <TClass, object> > >((IEnumerable <Expression <Func <TClass, object> > >) this._expressions)) { return(object.Equals((object)x, (object)y)); } foreach (Expression <Func <TClass, object> > exp in this._expressions) { if (!object.Equals(ExpressionHelper.GetValue <TClass, object>(exp, x), ExpressionHelper.GetValue <TClass, object>(exp, y))) { return(false); } } return(true); }