keith-hall / extensions Goto Github PK
View Code? Open in Web Editor NEWUseful static or extension methods for working in C# or LINQPad
License: Apache License 2.0
Useful static or extension methods for working in C# or LINQPad
License: Apache License 2.0
Add tests for StringExtensions to show how they work, example uses etc.
Could base on the following LINQPad dumps:
"hello world".IndexOfEnd("hello").Dump("IndexOfEnd hello");
"hello world".AllSortedIndexesOf(new [] { "o", "e", "l"}).Dump("AllSortedIndexes");
"hello world".CountOccurrences(Enumerable.Repeat("l", 1)).Dump("l Occurrences");
"hello world".TextAfter(" ").Dump("2nd word");
"hello world".TextBefore(" ").Dump("1st word");
"test".TextBefore("nope").Dump();
"test".TextAfter("nope").Dump();
"i.e. <ul><li>test 1</li><!-- comment --><li>text 2</li><li>testing</li></ul> - get li texts".AllTextBetween("<li>", "</li>").Dump("simple");
"i.e. <ul><li>test 1</li><!-- comment --><li>text 2</li><li>testing</li></ul> - get <li> texts".AllTextBetween("<li>", "</li>").Dump("no end 1");
"<li>test<li>blah</li>text</li>".AllTextBetween("<li>", "</li>").Dump("2 starts");
"hello;world;testing;text;test".AllTextBetween(";", ";").Dump(";");
to allow converting date formats into something more valid etc.
use when converting from string, check data type from projection matches that of column and throw an exception if not
Often, Count is used to check if the number of elements in a sequence exceeds a certain amount. But this will enumerate through all elements in a sequence in order to do so, which is unnecessary and affects performance. Therefore an extension method to solve this would be useful.
add a TimeSpan paramater to ObservableExtensions ReSubscribeOnError and DelaySubscription by that amount after an error occurs
the DataTable to SQL Insert method currently only deals with Strings. If a DataTable contains a column with a DateTime value, it should output it in the correct, unambiguous format. Same goes for Booleans, these are represented as bits in SQL.
show example of why it is useful to convert an xml file to a data table - i.e. webservice returns array of objects, useful to visualise
update readme with description of String extension methods - most of the time when doing an IndexOf, you want to get the TextBefore, TextAfter or TextBetween another IndexOf
and create extension method to convert from local timezone to UTC and vise versa
Reading an XML to DataTable can include unexpected data if there are elements between rows
The CSV methods were built for querying directly using deferred-loading, but when populating a DataTable, they are very inefficient.
some string all indexes of methods can be made parallel for better performance
Close method is not part of a finally block, meaning there are circumstances where it won't get executed when it should...
Add tests to EnumerableExtensions.CountExceeds, to prove that it does not iterate over more elements than necessary.
Example using divide by zero exception if it iterated over all elements:
var src = Enumerable.Range(1, 4).Concat(new [] { 0 });
src.Select (s => 1 / s).CountExceeds(3).Dump();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.