.Net Framework
I want to post a few recently created collection extensions to write in one line, what otherwise takes 2 or more public static void AddIfNotNull<T>( this IList<T> coll, T newItem) where T : class { if (newItem != null) { coll.Add(newItem); } } public static void AddRangeIfNotNullOrEmpty<... this List<T> coll, IEnumerable<T> newItems) where T : class { if (!newItems.IsNullOrEmptySeq... { coll.AddRange(newItems); } } public static void AddIfNotContains<TKey, TValue>( ......
I've tried to use Microsoft Enterprise Library(EntLIb) editor, as it was suggested in http://weblogs.asp.net/suku... but after changes all comments in config files were removed. Always consider to move any Enterprise Library configurations to a separate file before editing ......
To optimize performance of visual studio build I've found multiple recommendations to change CopyLocal property for dependent dlls to false,e.g. From http://stackoverflow.com/qu... CopyLocal? For sure turn this offhttp://stackoverflow.com... set the Copy Local property to false and enforce this via a custom msbuild stephttp://codebetter.com/p... ......
I am using a few helper classes. This post describes my ListOfStringsHelper class. #region Namespace Importsusing System;using System.Collections.Generic;... System.Globalization;using System.Linq;using System.Text;using System.Diagnostics;#endregion //Namespace Imports namespace Common{// using System.Collections; //See also StringArrayHelper.cs, CollectionsHelper.cs public static class ListOfStringsHelper { public static bool StringContainsAnyFromList(L... patternsList, string sMsg) ......
The class below is used to create adjustable messages using System; /// Summary description for EnglishGrammerHelper. /// </summary> public class EnglishGrammerHelper { public EnglishGrammerHelper() { // // TODO: Add constructor logic here // } /// <summary> /// Compiles sentence with person,verb and rest of the sentence /// </summary> /// <param name="person"></param... /// <param name="verb"></param> /// <param name="restSentence"><... /// ......
Previously I've posted a few Helper Classes . This post describes DataSetHelper class, that mostly based on series of MSDN articles. However I did some modifications(e.g see posts DataSetHelper.SelectDistinct method for multiple columns and “Handling missing source columns in DataSetHelper.InsertInto method” ) using System; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Collections; using Microsoft.ApplicationBlocks... using System.Collections.Generic; namespace ......
Previously I've posted a few Helper Classes . This post describes my StringArrayHelper class: using Iesi.Collections; using Microsoft.VisualBasic; using Microsoft.VisualBasic.Compi... using System; using System.Collections; using System.Runtime.CompilerServ... using System.Xml; using System.Text; public static class StringArrayHelper { //created from CollectionsHelper.cs // Methods //'ignore new string, if already exist in the array // empty string considered as separate entry // function ......
Previously I've posted a few Helper Classes . This post describes my DateTimeHelper class. using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualBasic.Compi... using Microsoft.VisualBasic; using System.Diagnostics; public static class DateTimeHelper { public static DateTime DateAndTime(DateTime dateValue, DateTime timeValue) { DateTime time2; time2 = new DateTime(dateValue.Year, dateValue.Month, dateValue.Day, timeValue.Hour, timeValue.Minute, timeValue.Second); ......
Previously I've posted a few Helper Classes . This post describes my CollectionsHelper class. ///<summary> /// //from http://diditwith.net/PermaL... ///</summary> ///<example> ///<code> ///</code> ///</example> public static class CollectionsHelper { /*When C# extensions will be available( promised in C# 3, add this keyword to parameter * public static bool IsNullOrEmpty(this ICollection c) //from http://diditwith.net/PermaL... ......
Previously I've posted a few Helper Classes . This post describes my RegexMatchsHelper class I also added a few related links: Use Regular Expressions to Constrain Input in ASP.NET using System; using System.Diagnostics; using System.Text.RegularExpressi... ///<summary> /// Summary description for RegexMatchs. ///</summary> public class RegexMatchsHelper { public RegexMatchsHelper() { // // TODO: Add constructor logic here // } // public static void RetrieveMatchedStringTest() // { // ......
Previously I've posted a few Helper Classes . This post describes my StreamHelper class using Microsoft.VisualBasic; using System; using System.IO; using System.Reflection; using System.Text; using System.Diagnostics; public class StreamHelper { // 'See also FxLib Author: Kamal Patel, Rick Hodder // 'Find the first entry of sToFing and returns the string after it // 'See also FxLib StringExtract (and StuffString) // Methods public StreamHelper() { } #region "Stream and Resources Functions" //C# version ......
Previously I've posted a few Helper Classes . This post describes my HttpWebRequestHelper class: using System; using System.Text.RegularExpressi... using System.IO; using System.Diagnostics ; using System.Net; namespace FSHelperLib { using System; using System.Text; // clarification from http://www.dotnetsmart.com/... // System.Web.HttpRequest is a class used on the server and inside an ASP.NET application. It represents the *incoming* request from a client. // System.Net.HttpWebRequest ......
Previously I've posted a few Helper Classes . This post describes my EnumHelper class. The class uses other helper classes, in particular CollectionsHelper Related links: Overriding ToString on enum, Mapping Text to Enum entries . Enum Helper Class Using Generics , My new little friend, Enum<T>, Making C# enums more usable - the Parse() method https://connect.microsoft.c... using System; using System.Collections.Generic; using System.Text; ......
I've used MS Installer class to provide custom actions during setup in a few projects(e.g.see Using VS 2005 Web Setup Project with custom actions). However if you have some complex logic to do as a part of setup, it is possible that some exception will occur. I don't like to hide exceptions, and they are shown to the user,causing installation to rollback. It is not good, becuse sometimes user wants to ignore exception and use installation even if some custom action failed. I found that moving code ......
I've posted a few code snippets and some people noticed that there are references to unresolved methods.I am using a few helper classes. This post describes my FileHelper class: System.IO; /// <summary> /// Summary description for FileHelper. using /// See also StreamHelper class methods, e.g. SaveStringToFile,SaveToFile /// </summary> public static class FileHelper { public static string GetFileExtensionWithoutDot(... fileName) { string sExt=Path.GetExtension(file... if ((null==sExt) ......
Some time ago I had to create the utility to rename files with special characters to allow them to be inclyuded in Visual SourceSafeI've used VBeXpress generator, that had templates with ‘%’ in file names. Unfortunately the names with ‘%’ like %%Project.Name%%.sln are not acceptable by VSS due to invalid VSS syntax. This utility copies changed templates to files with encoded names,acceptable by VSS. It's allowed to check-in/check out individual files(with encoded names) and view thier changes/history. ......
I have an Indexing catalog on the FileServer with several directories specified with local path and UNC aliases(e.g. physical path C:\DataSamples\Indexing\Tes... with \\vKnowledge\IndexingTestFo... alias) I also have .Net application that queries this indexing catalog using IXSSO Control Library -Indexing services((See my post how to use Fill Dataset with rows in a specified range http://thespoke.net/blogs/m... returned include Path column which is expected ......
I was asked to find utility to test OLEDB conection paramenters.I desided to use EXCEL with the following procedure: 1.Create UDL file as described http://msdn.microsoft.com/l... 2. Open MS Excel (I've tested it with Excel 2003) , hope that previous versions are similar. 3. On the Data menu, point to Import External Data, and then click Import Data. 4. In the "Files of Type" select "Microsoft Data Links( ......
About a year ago I played with Enterprise Library Logging application block and created TextBoxSink based on the provided DebugTraceSink. It wasn't fully complete, but now I decided to check can I use it for my current task. Because of .Net 2.0 changes I renamed the class to TextBoxListener, derived it from CustomTraceListener and had to overide TraceData,Write and WriteLine instead of previously overridable SendMessageCore. It also requred to add in App.config listener in categorySources/listeners ......
I've posted a few code snippets and some people noticed that there are references to unresolved methods.I am using a few helper classes. This post describes my SystemHelper class: namespace FSHelperLib { using Iesi.Collections; using Microsoft.VisualBasic; using Microsoft.VisualBasic.Compi... using Microsoft.Win32; using System; using System.IO; using System.Collections; using System.Diagnostics ; using System.Reflection; using System.Runtime.CompilerServ... using System.Web; public class ......
Full .Net Framework Archive