Skip to content

Instantly share code, notes, and snippets.

/a.cs

Created May 25, 2017 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/92c5336cc555ae83b4467e401413bb2c to your computer and use it in GitHub Desktop.
Save anonymous/92c5336cc555ae83b4467e401413bb2c to your computer and use it in GitHub Desktop.
private bool IsItemsSourceEmpty()
{
if (DataSource == null)
return true;
var collection = DataSource as ICollection;
if (collection != null)
return collection.Count > 0;
var enumerator = DataSource.GetEnumerator();
var hasElement = enumerator.MoveNext();
(enumerator as IDisposable)?.Dispose();
return !hasElement;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment