This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ListExt | |
| { | |
| public static IEnumerable<T[]> GetSubsets<T>(this List<T> set, int subsetLength) | |
| { | |
| int[] indices = Enumerable.Range(0, subsetLength).ToArray(); | |
| while (true) | |
| { | |
| yield return indices.Select(i => set[i]).ToArray(); | |
| indices = Increment(indices, set.Count - 1); | |
| if (indices == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class StopwatchExt | |
| { | |
| public static string GetTimeString(this Stopwatch stopwatch, int numberofDigits = 1) | |
| { | |
| double s = stopwatch.ElapsedTicks / (double)Stopwatch.Frequency; | |
| if (s > 1) | |
| return Math.Round(s, numberofDigits) + " s"; | |
| if (s > 1e-3) | |
| return Math.Round(1e3 * s, numberofDigits) + " ms"; | |
| if (s > 1e-6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ListEx | |
| { | |
| public static IEnumerable<T> WrappingEnumerator<T>(this List<T> list) | |
| { | |
| var i = 0; | |
| while (true) | |
| { | |
| yield return list[i]; | |
| i = (i < (list.Count - 1)) | |
| ? i + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using NUnit.Framework; | |
| class LinqExtTests | |
| { | |
| [TestCase(0, 0, 0, 0)] | |
| [TestCase(1, 0, 0, 0)] | |
| [TestCase(0, 1, 0, 1)] | |
| [TestCase(0, 0, 1, 2)] | |
| public void MaxByTest(int first, int second, int third, int expectedIndex) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PerformanceTests | |
| { | |
| [Test] | |
| public void ReadSpeedTest() | |
| { | |
| var excelApp = new Application(); | |
| var workbook = excelApp.Workbooks.Add(); | |
| var sheet = (Worksheet)workbook.Worksheets[1]; | |
| var ns = new[] { 10, 100, 1000, 10000 }; | |
| BatchWrite(sheet, ns.Max()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class InternetConnection | |
| { | |
| /// <summary> | |
| /// Check if internetconnection is available | |
| /// </summary> | |
| /// <param name="lpdwFlags">Returns info about connection</param> | |
| /// <param name="dwReserved">Reserved pass 0 (default)</param> | |
| /// <returns></returns> | |
| [DllImport("wininet.dll", CharSet = CharSet.Auto)] | |
| private extern static bool InternetGetConnectedState(ref InternetConnectionState_e lpdwFlags, int dwReserved = 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [TestCase(typeof(Stats), "StatsProp")] | |
| public void CreateListView(Type type, string bindingPopertyName) | |
| { | |
| PropertyInfo[] propertyInfos = type.GetProperties(); | |
| var listView = new XElement("ListView"); | |
| listView.Add(new XAttribute("ItemsSource", string.Format(@"{{Binding {0}}}", bindingPopertyName))); | |
| var view = new XElement("ListView.View"); | |
| var gridView = new XElement("GridView"); | |
| foreach (var propertyInfo in propertyInfos) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class AttachedProperties | |
| { | |
| public static readonly DependencyProperty IconProperty = DependencyProperty.RegisterAttached( | |
| "Icon", | |
| typeof (StreamGeometry), | |
| typeof (AttachedProperties), | |
| new PropertyMetadata(default(StreamGeometry)) | |
| ); | |
| public static void SetIcon(UIElement element, StreamGeometry value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <UserControl x:Class="Namespace.FileControl" | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
| mc:Ignorable="d"> | |
| <Grid Height="Auto"> | |
| <Grid.ColumnDefinitions> | |
| <ColumnDefinition Width="Auto"/> | |
| <ColumnDefinition/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Drawing; | |
| using System.Drawing.Imaging; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Net; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using System.Windows; | |
| using System.Windows.Input; |