/// <summary> /// Sorts the Entries by field name (case sensitive) as prescribed by an order list. /// </summary> /// <param name="sortOrder">The list defining the order in which the table entries should be displayed.</param> public void Sort(IList <string> sortOrder) { if (Entries.Any()) { (Entries as List <Entry>).Sort(new EntryComparer(sortOrder)); } }
private void AddOrUpdateSteamApp(SteamApp newSteamApp, int?missingIndex = null) { lock (entriesLock) { // check if id and name is already in cache if (Entries.Any(e => e.Key == Int32.Parse(newSteamApp.Id) && e.Value.NormalizedTitle == newSteamApp.NormalizedTitle)) { return; } Log.WriteLine($"{ CurrentClassName }.{ Utils.GetCurrentMethodName() }({ newSteamApp.ToString() })"); if (Entries.Any(e => e.Key == Int32.Parse(newSteamApp.Id))) { Entries.Remove(Int32.Parse(newSteamApp.Id)); } Entries.Add(Int32.Parse(newSteamApp.Id), newSteamApp); Save(); if (missingIndex.HasValue) { Missing.RemoveAt(missingIndex.Value); SaveMissing(); } } }
public override void ToStream(Stream icoStream) { if (Entries == null || Entries.Any(e => e == null)) { throw new InvalidOperationException("Entries are null"); } if (Count != Entries.Length) { throw new InvalidOperationException("Count does not equal to Entries count"); } if (Entries.Length == 0) { base.ToStream(icoStream); return; } Validate(); base.ToStream(icoStream); foreach (var e in Entries) { e.ToStream(icoStream); } }
private void NewTheme() { ErrorText = ""; try { if (!GenericInputDialog.ShowInputDialog(Owner, "Filename for new theme", "New Theme (filename)", "MyTheme.xml", out var filename)) { throw new Exception("Aborted by user"); } if (!filename.ToLower().EndsWith(".xml")) { throw new Exception("Filename must end with xml"); } if (Entries.Any(e => e.SourceFilename.ToLower() == filename.ToLower())) { throw new Exception("Filename already exists"); } var newEntry = new ThemeEditorEntry() { OriginalSource = "", SourceFilename = filename, Name = "New Theme", Source = "", }; Entries.Add(newEntry); SelectedEntry = newEntry; } catch (Exception e) { ErrorText = e.ToString(); } }
private bool FindNewSteamApp() { for (var i = random.Next(0, Missing.Count - 1); i < Missing.Count && !stopScrapping; ++i) { var missingParts = Missing[i].Split(';'); var missingSteamAppId = missingParts[0]; // if steam app is no longer missing, remove it from missing list if (Entries.Any(e => e.Key == Int32.Parse(missingSteamAppId))) { Missing.RemoveAt(i); return(false); } // if steam app was recently checked if (missingParts.Length > 1 && DateTime.Parse(missingParts[1]).AddDays(7) > DateTime.Now) { continue; } var newSteamApp = GetSteamApp(missingSteamAppId); if (newSteamApp != null) { // woohoo new steam app found AddOrUpdateSteamApp(newSteamApp, i); return(true); } else { Missing[i] = $"{ missingSteamAppId };{ DateTime.Now.ToShortDateString() }"; } } return(false); }
private void SetLastEntryDuration() { if (Entries.Any()) { IUIEntry lastEntry = Entries.Last(); lastEntry.Duration = DateTime.Now - lastEntry.Time; } }
private void RemoveDirectory() { Entries.Remove(SelectedDirectory); if (Entries.Any()) { SelectedDirectory = Entries.Keys.First(); } }
protected override GZipArchiveEntry CreateEntry(string filePath, Stream source, long size, DateTime?modified, bool closeStream) { if (Entries.Any()) { throw new InvalidOperationException("Only one entry is allowed in a GZip Archive"); } return(new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream)); }
public void SetCurrentSelectedEntry(int index) { if (!Entries.Any()) { return; } CurrentSelectedEntry = Entries.ElementAt(index); }
public bool Validate() { if (Entries.Any(x => string.IsNullOrWhiteSpace(x.Artist))) { Errors.Add("Each entry must specify an Artist"); } return(!Errors.Any()); }
protected float CalculateFooterHeight(SKRect[] valueLabelSizes) { var result = Margin; if (Entries.Any(e => !string.IsNullOrEmpty(e.Label))) { result += LabelTextSize - Margin; } return(result); }
private void Add() { if (Entries != null && !Entries.Any(e => e.Entry == NewEntry)) { Entries.Add(new DictionaryEntryAndState { Entry = NewEntry, Added = true }); } NewEntry = null; }
public Stream OpenRead() { if (Entries != null && Entries.Any()) { Stream.Position = 0; return(Stream); } else { return(null); } }
protected float[] CalculateAxisXScalars() { var hasXValues = Entries.Any(e => e.X != 0); if (hasXValues) { return(CalculateAxisScalars(e => e.X)); } return(Enumerable.Range(1, Entries.Length + 1) .Select(e => e * 1f) .ToArray()); }
public override void UnExecute() { if (!Entries.Any()) { return; } var lastEntry = Entries.Last(); Sb.Remove(Sb.Length - lastEntry.Length, lastEntry.Length); Entries.Remove(lastEntry); }
public virtual void SetEntry(string key, object value) { lock (assignmentLocker) { if (Entries.Any(x => x.Name == key)) { this[key].SetValue(value); } else { AddEntry(key, value); } } }
public virtual void AddEntry(string key, object value) { lock (assignmentLocker) { if (Entries.Any(x => x.Name == key)) { throw new InvalidOperationException(key + " is already exist"); } Entries.Add(new SettingsEntryEntity(key, value) { Settings = this }); } }
/// <summary> /// Gets the DML output of the DSX Table. /// </summary> /// <returns>The string output of the DSX Table in DML format.</returns> public override string ToString() { if (Entries.Any()) { OpenTable(Name); foreach (var entry in Entries) { AddField(entry.Name, entry.Value); } CloseTableWithWrite(); } return(Output.ToString()); }
protected override async Task SaveItem() { if (string.IsNullOrEmpty(Current.Name)) { return; } if (Entries.Any(x => x.Name == Current.Name && x != Current)) { return; } await Key.GetDatabase().HashSet(Key, Current.Name, Current.CurrentValue); Current.OriginalValue = Current.CurrentValue; }
public void AddEntry(Entry e) { if (!Entries.Any(p => p.Title == e.Title)) { Entries.Add(e); isUnsavedChanges = true; } else { throw new ArgumentException( "An entry with the title, '" + e.Title + "' already exists. Titles must be unique"); } }
public virtual ModCategory this[string category] { get { Entries.TryGetValue(category, out var cat); if (cat == null) { cat = new ModCategory(Entries.Any() ? Entries.Max(entry => entry.Value.Index) + 1 : 0); Entries.Add(category, cat); } return(cat); } }
protected float CalculateHeaderHeight(SKRect[] valueLabelSizes) { var result = Margin; if (Entries.Any()) { var maxValueWidth = valueLabelSizes.Max(x => x.Width); if (maxValueWidth > 0) { result += maxValueWidth + Margin; } } return(result); }
protected override async Task SaveItem() { if (Entries.Any(x => x.OriginalValue == Current.CurrentValue && x != Current)) { return; } if (Current.IsNew) { await Key.GetDatabase().SortedSetAdd(Key, Current.CurrentValue, Current.CurrentScore); } else { await Key.GetDatabase().SortedSetUpdate(Key, Current.OriginalValue, Current.CurrentValue, Current.CurrentScore); } Current.OriginalValue = Current.CurrentValue; Current.OriginalScore = Current.CurrentScore; }
private void CreateEntry(string key) { createEntry.Text = "Add..."; if (string.IsNullOrWhiteSpace(key)) { return; } var selectedTable = tabs[activeTabIndex].userData as LocalizationTable; if (selectedTable !.Entries.Any(entry => string.Equals(entry.Key, key, StringComparison.InvariantCulture))) { return; } CreateEntryImpl(selectedTable, key); }
public void AddForeignId(object foreignId) { if (foreignId == null) { throw new ArgumentNullException(nameof(foreignId)); } //Check the EntityId matches the known type for TEntity if (!ForeignProperty.PropertyType.Equals(foreignId.GetType())) { throw new InvalidOperationException($"Type mismatch for foreign key. {foreignId.GetType()} specified however expected type {ForeignProperty.PropertyType}"); } //Check the entity isn't already loaded if (!Entries.Any(e => Equals(foreignId, ForeignProperty.GetValue(e.Entity)))) { UnloadedIds.Add(foreignId); } }
public static void UpdateLists() { while (true) { try { var Files = Directory.GetFiles("Data"); foreach (var File in Files) { if (File.EndsWith(".json")) { try { var _List = System.IO.File.ReadAllText(File); var newList = JsonConvert.DeserializeObject <List <Entry> >(_List); List <Entry> NewEntries = new List <Entry>(); foreach (var en in newList) { if (!Entries.Any(x => x.Link == en.Link)) { NewEntries.Add(en); } } if (NewEntries.Any()) { Entries.AddRange(NewEntries); Zorro.MongoDB.PushBatch(NewEntries); } } catch { } } } #if DEBUG Thread.Sleep(5000); #else Thread.Sleep(60000); #endif } catch { } } }
private async void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e) { if (Entries == null || !Entries.Any()) { return; } if (this.Entries.Count() > _currentPoint) { ((ChartView)sender).Chart = this.CreateChart(); } else { ((ChartView)sender).PaintSurface -= OnPaintCanvas; } await Task.Delay(TimeSpan.FromSeconds(1.0 / 30)); ((ChartView)sender).InvalidateSurface(); }
/// <summary>添加文件。 /// 必须指定文件路径<paramref name="fileName"/>,如果不指定实体名<paramref name="entryName"/>,则使用文件名,并加到顶级目录。</summary> /// <param name="fileName">文件路径</param> /// <param name="entryName">实体名</param> /// <param name="level">压缩等级</param> /// <returns></returns> public ZipEntry CreateEntryFromFile(String fileName, String entryName = null, CompressionLevel level = CompressionLevel.Optimal) { if (String.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } if (String.IsNullOrEmpty(entryName)) { entryName = Path.GetFileName(fileName); } entryName = entryName.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); // 判断并添加目录 var dir = Path.GetDirectoryName(entryName); if (!String.IsNullOrEmpty(dir)) { if (!dir.EndsWith(DirSeparator)) { dir += DirSeparator; } if (!Entries.Any(x => x.FileName.EqualIgnoreCase(dir))) { var zde = new ZipEntry { FileName = dir }; Entries.Add(zde); } } var entry = ZipEntry.Create(fileName, entryName, level == CompressionLevel.NoCompression); Entries.Add(entry); return(entry); }
/// <summary>添加文件。 /// 必须指定文件路径<paramref name="fileName"/>,如果不指定实体名<paramref name="entryName"/>,则使用文件名,并加到顶级目录。</summary> /// <param name="fileName">文件路径</param> /// <param name="entryName">实体名</param> /// <param name="stored">是否仅存储,不压缩</param> /// <returns></returns> public ZipEntry AddFile(String fileName, String entryName = null, Boolean?stored = false) { if (String.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } if (String.IsNullOrEmpty(entryName)) { entryName = Path.GetFileName(fileName); } entryName = entryName.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); // 判断并添加目录 var dir = Path.GetDirectoryName(entryName); if (!String.IsNullOrEmpty(dir)) { if (!dir.EndsWith(DirSeparator)) { dir += DirSeparator; } if (!Entries.Any(x => x.FileName.EqualIgnoreCase(dir))) { var zde = new ZipEntry { FileName = dir }; Entries.Add(zde); } } var entry = ZipEntry.Create(fileName, entryName, stored); Entries.Add(entry); return(entry); }
public bool HasEntry(DBHeader counterpart) => Entries.Any(x => (x.Locale == counterpart.Locale || x.Locale == 0) && x.TableHash == counterpart.TableHash && x.IsValid == 1);