IsNullOrEmpty generic method for Array to avoid Re-Sharper warning

I’ve used the following extension method in many places.

public static bool IsNullOrEmpty(this Object[] myArr)
{
return (myArr == null || myArr.Length == 0);
}

Recently I’ve noticed that Resharper shows warning covariant array conversion to object[] may cause an exception for the following code

ObjectsOfMyClass.IsNullOrEmpty()


I’ve resolved the issue by creating generic extension method

public static bool IsNullOrEmpty<T>(this T[] myArr)
{
return (myArr == null || myArr.Length == 0);
}

Related links

http://connect.microsoft.com/VisualStudio/feedback/details/94089/add-isnullorempty-to-array-class
   public static bool IsNullOrEmpty(this System.Collections.IEnumerable source)
       {
           if (source == null)
               return true;
           else
           {
               return !source.GetEnumerator().MoveNext();
           }
       }

http://stackoverflow.com/questions/8560106/isnullorempty-equivalent-for-array-c-sharp

“Read It Later Pro” has been ruined into Pocket, but RIL Free is still usable.

I loved RIL Pro for iPad and used it every day, but about a month ago I was forced to upgrade to new version, named Pocket.
The new version has so many problems, that it’s almost unusable.
The main issue is that iPad app doesn’t show many of the saved links. 
I’ve posted my opinion that it would be better to have  Pocket as a new separate application and recommend users to install it side by side with RIL Pro and try before replace at Pocket forum  APR 20, 2012 
I found that there a many other threads that report different issues with a new version and I’ve posted a few comments, supporting suggestions to fix the issues, that were broken by the Pocket.(e.g. here)
 Pocket agents answered only a  small number of questions, and many of their answers were unreasonable- like “We removed this feature because it is not convenient for our future plans”
Example of this is still stored in Google cache

24Apr I’ve posted a request to restore RIL Pro in AppStore until they will fix the problems in pocket.
From 27 April they introduced moderation on the public forum and stopped show new posts.
Actually “moderation” is not a correct work, it’s converted the forum into Q&A site, where they show only posts with answers that they like.
Furthermore they removed many discussion threads that existed on the forum before the “moderation”.
When I pointed to this in email, the answer was un-reasonable-that their forum is actually not a forum, but “a helpful support site where users can get their questions answered”
In fact users post public questions and do not see them posted for a week or forever.
For couple of my questions I received email starting with the words
    “An agent has responded to your question (Link to Question<http://readitlater.assistly.com/customer/portal/questions/306173-sync-in-ril-free-stopped-working>).”
But the link is not working, because they deleted the discussion from the forum.
At the beginning of May Pocket support answered that the  “known issue with a partial list sync” is addressed and will be in the next upgrade.
Despite the statement in upgrade notes, next upgrade didn’t help with the problem(at least for me).
Support  replied to me, that  “it seems as though a small handful of users are still experiencing this sync discrepancy.”
27Apr I’ve reported that “Sync in RIL Free stopped working” and it was on forum at least until 6 May(according Google cache)
10 May I received a reply via email(but post has been removed from the forum)
“The fix is to log out of Read It Later Free, and then log back in. Although your local cache will be cleared, the app will go through your list and re-download your items.”
 It was the first useful advice after introducing Pocket. Now I am able to use RIL Free. With all it’s limitation RIL Free is in much more workable conditions, than Pocket. It shows all articles that I’ve saved and it allowed to rename titles. The only feature from RIL Pro, that I really missing, is the ability to filter only untagged articles.
So now I can read all my saved articles in RIL Free and wait until they will fix the Pocket.
The conclusion I’ve had is that the Pocket company doesn’t respect their customers, and I should not rely on their products too much. However the application is quite convenient, and I am familiar with it, so I will continue to use it. 
The company’s  behaviour reminds me how Google changed layout of iGoogle tabs and ignored hundreds of complains. Note that recently (4 years later) Google returned to layout similar to original.


Links about SQL PIVOT

One of my colleagues asked how to create SQL query to show results as columns of a row, that actually stored in multiple rows in the table. Other co-worker suggested to use cursor to manually generate required rows.
I’ve found a few links about SQL PIVOT.  
It is easy to start with
http://www.kodyaz.com/articles/t-sql-pivot-tables-in-sql-server-tutorial-with-examples.aspx
or http://programmingsolution.net/post/SQL-Server-Pivot-Converting-Rows-to-Columns-with-Dynamic-Query.aspx

More detailed are articles written by Itzik Ben-Ganhttp://www.sqlmag.com/article/tsql3/pivot-or-unpivot-your-data
and
http://www.sqlmag.com/content1/topic/pivot-or-unpivot-your-data/catpath/tsql3/page/2compaslightly  

How to use Pivoting Without Aggregation is described inhttp://www.sqlmag.com/article/tsql3/pivoting-without-aggregation

My ListOfStringsHelper class

I am using a few helper classes. This post describes my ListOfStringsHelper class.

  1. #region  Namespace Imports
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Diagnostics;
  8. #endregion  //Namespace Imports
  9.  
  10. namespace Common
  11. {
  12. //    using System.Collections;
  13.     //See also StringArrayHelper.cs, CollectionsHelper.cs
  14.     public static class ListOfStringsHelper
  15.     {
  16.         public static bool StringContainsAnyFromList(List<string> patternsList, string sMsg)
  17.         {
  18.             bool bFound = patternsList.Exists(
  19.                 sMsg.Contains
  20.                 );
  21.             return bFound;
  22.         }
  23.         public static string FindFirstPatternContainedInString(List<string> patternsList, string sMsg)
  24.         {
  25.             string sFound = patternsList.Find(
  26.                 sMsg.Contains
  27.                );
  28.             return sFound;
  29.         }
  30.         /// <summary>
  31.         /// If no patters match the string, return empty
  32.         /// </summary>
  33.         /// <param name=”patternsList”></param>
  34.         /// <param name=”sMsg”></param>
  35.         /// <returns></returns>
  36.         public static string FindFirstPatternContainedInString(string[] patternsList, string sMsg)
  37.         {
  38.             foreach (string pattern in patternsList)
  39.             {
  40.                 if (sMsg.Contains(pattern))
  41.                 {
  42.                    // Debug.Assert(false, “Investigate why not?.”);
  43.                     // bValid = false;
  44.                     return pattern;
  45.                 }
  46.  
  47.                 break;
  48.             }
  49.             return “”;
  50.         }
  51.                 public static bool ContainsString(this IEnumerable<string> collection, string toFind, boolignoreCase = true)
  52.                 {
  53.                         return collection.Contains(toFind, StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase));
  54.                 }
  55.  
  56.  
  57.         /// <summary>
  58.         /// Returns true, if any string in list contains the substring(case insensitive)
  59.         /// </summary>
  60.         /// <param name=”list”></param>
  61.         /// <param name=”substringToFind”></param>
  62.         /// <returns></returns>
  63.         /// <remarks><seealso cref=”FindFirstContainingSubstring” /></remarks>
  64.         public static bool IsListContainsSubstring(this IEnumerable<String> list, string substringToFind)
  65.         {
  66.                 //TODO: create overloads with exact match  or case sencitive
  67.                 list = list.ToList();
  68.                 if (list.IsNullOrEmptySequence())
  69.                 { return false; }
  70.                 else
  71.                 {
  72.                         substringToFind = substringToFind.ToUpper();
  73.                         return list.Any(remark => remark.ToUpper().Contains(substringToFind));
  74.                 }
  75.         }
  76.  
  77.         /// <summary>
  78.         /// Returns first string in list,that contains the substring(case insensitive)
  79.         /// </summary>
  80.         /// <param name=”list”></param>
  81.         /// <param name=”substringToFind”></param>
  82.         /// <returns>NullOrEmpty if not found</returns>
  83.         public static string FindFirstContainingSubstring(this List<String> list, string substringToFind)
  84.         {
  85.                 //TODO: create overloads with exact match  or case sencitive
  86.                 if (list.IsNullOrEmpty())
  87.                 { return “”; }
  88.                 else
  89.                 {
  90.                         substringToFind = substringToFind.ToUpper();
  91.                         return list.FirstOrDefault(remark => remark.ToUpper().Contains(substringToFind));
  92.                 }
  93.         }
  94.  
  95.         /// <summary>
  96.         /// Returns first string in list,that StartsWith the substring(case insensitive)
  97.         /// </summary>
  98.         /// <param name=”list”></param>
  99.         /// <param name=”substringToFind”></param>
  100.         /// <returns>NullOrEmpty if not found</returns>
  101.         public static string FindFirstStartingWithSubstring(this List<String> list, string substringToFind)
  102.         {
  103.                 //TODO: create overloads with exact match  or case sencitive
  104.                 if (list.IsNullOrEmpty())
  105.                 { return “”; }
  106.                 else
  107.                 {
  108.                         substringToFind = substringToFind.ToUpper();
  109.                         return list.FirstOrDefault(remark => remark.ToUpper().StartsWith(substringToFind));
  110.                 }
  111.         }
  112.         public static string ToCSVString(this List<String> inputList)
  113.         {
  114.                 return inputList.ToString<string>(“,”, “”);
  115.                 //string [] arrStrs=inputList.ToArray();
  116.                 //return string.Join(“,”, arrStrs);
  117.         }
  118.  
  119.     }//end of class
  120. }
    1. #region  Namespace Imports
    2. using System;
    3. using System.Collections.Generic;
    4. using System.Globalization;
    5. using System.Linq;
    6. using System.Text;
    7. using System.Diagnostics;
    8. #endregion  //Namespace Imports
    9.  
    10. namespace Common
    11. {
    12. //    using System.Collections;
    13.     //See also StringArrayHelper.cs, CollectionsHelper.cs
    14.     public static class ListOfStringsHelper
    15.     {
    16.         public static bool StringContainsAnyFromList(List<string> patternsList, string sMsg)
    17.         {
    18.             bool bFound = patternsList.Exists(
    19.                 sMsg.Contains
    20.                 );
    21.             return bFound;
    22.         }
    23.         public static string FindFirstPatternContainedInString(List<string> patternsList, string sMsg)
    24.         {
    25.             string sFound = patternsList.Find(
    26.                 sMsg.Contains
    27.                );
    28.             return sFound;
    29.         }
    30.         /// <summary>
    31.         /// If no patters match the string, return empty
    32.         /// </summary>
    33.         /// <param name=”patternsList”></param>
    34.         /// <param name=”sMsg”></param>
    35.         /// <returns></returns>
    36.         public static string FindFirstPatternContainedInString(string[] patternsList, string sMsg)
    37.         {
    38.             foreach (string pattern in patternsList)
    39.             {
    40.                 if (sMsg.Contains(pattern))
    41.                 {
    42.                    // Debug.Assert(false, “Investigate why not?.”);
    43.                     // bValid = false;
    44.                     return pattern;
    45.                 }
    46.  
    47.                 break;
    48.             }
    49.             return “”;
    50.         }
    51.                 public static bool ContainsString(this IEnumerable<string> collection, string toFind, boolignoreCase = true)
    52.                 {
    53.                         return collection.Contains(toFind, StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase));
    54.                 }
    55.  
    56.  
    57.         /// <summary>
    58.         /// Returns true, if any string in list contains the substring(case insensitive)
    59.         /// </summary>
    60.         /// <param name=”list”></param>
    61.         /// <param name=”substringToFind”></param>
    62.         /// <returns></returns>
    63.         /// <remarks><seealso cref=”FindFirstContainingSubstring” /></remarks>
    64.         public static bool IsListContainsSubstring(this IEnumerable<String> list, string substringToFind)
    65.         {
    66.                 //TODO: create overloads with exact match  or case sencitive
    67.                 list = list.ToList();
    68.                 if (list.IsNullOrEmptySequence())
    69.                 { return false; }
    70.                 else
    71.                 {
    72.                         substringToFind = substringToFind.ToUpper();
    73.                         return list.Any(remark => remark.ToUpper().Contains(substringToFind));
    74.                 }
    75.         }
    76.  
    77.         /// <summary>
    78.         /// Returns first string in list,that contains the substring(case insensitive)
    79.         /// </summary>
    80.         /// <param name=”list”></param>
    81.         /// <param name=”substringToFind”></param>
    82.         /// <returns>NullOrEmpty if not found</returns>
    83.         public static string FindFirstContainingSubstring(this List<String> list, string substringToFind)
    84.         {
    85.                 //TODO: create overloads with exact match  or case sencitive
    86.                 if (list.IsNullOrEmpty())
    87.                 { return “”; }
    88.                 else
    89.                 {
    90.                         substringToFind = substringToFind.ToUpper();
    91.                         return list.FirstOrDefault(remark => remark.ToUpper().Contains(substringToFind));
    92.                 }
    93.         }
    94.  
    95.         /// <summary>
    96.         /// Returns first string in list,that StartsWith the substring(case insensitive)
    97.         /// </summary>
    98.         /// <param name=”list”></param>
    99.         /// <param name=”substringToFind”></param>
    100.         /// <returns>NullOrEmpty if not found</returns>
    101.         public static string FindFirstStartingWithSubstring(this List<String> list, string substringToFind)
    102.         {
    103.                 //TODO: create overloads with exact match  or case sencitive
    104.                 if (list.IsNullOrEmpty())
    105.                 { return “”; }
    106.                 else
    107.                 {
    108.                         substringToFind = substringToFind.ToUpper();
    109.                         return list.FirstOrDefault(remark => remark.ToUpper().StartsWith(substringToFind));
    110.                 }
    111.         }
    112.         public static string ToCSVString(this List<String> inputList)
    113.         {
    114.                 return inputList.ToString<string>(“,”, “”);
    115.                 //string [] arrStrs=inputList.ToArray();
    116.                 //return string.Join(“,”, arrStrs);
    117.         }
    118.  
    119.     }//end of class
    120. }