From 6e787e6cda1dfb3c25df7d906ea577c4c436c37e Mon Sep 17 00:00:00 2001 From: Uwe Zimmermann Date: Mon, 28 May 2012 20:05:29 +0200 Subject: [PATCH 1/2] added class 'DataReaderMinimod' --- MiniMods/DataReader/DataReaderMinimod.cs | 7 +++++++ MiniMods/Minimod.csproj | 1 + 2 files changed, 8 insertions(+) create mode 100755 MiniMods/DataReader/DataReaderMinimod.cs diff --git a/MiniMods/DataReader/DataReaderMinimod.cs b/MiniMods/DataReader/DataReaderMinimod.cs new file mode 100755 index 0000000..10fb78c --- /dev/null +++ b/MiniMods/DataReader/DataReaderMinimod.cs @@ -0,0 +1,7 @@ +namespace Minimod.DataReader +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/MiniMods/Minimod.csproj b/MiniMods/Minimod.csproj index d34304d..19e6394 100644 --- a/MiniMods/Minimod.csproj +++ b/MiniMods/Minimod.csproj @@ -145,6 +145,7 @@ + From bc4421192646a3fe3004bdec84ebb41d2689188a Mon Sep 17 00:00:00 2001 From: Uwe Zimmermann Date: Mon, 28 May 2012 20:11:14 +0200 Subject: [PATCH 2/2] added file 'DataReaderMinimod.nuspec' --- MiniMods/DataReader/DataReaderMinimod.cs | 129 ++++++++++++++++++- MiniMods/DataReader/DataReaderMinimod.nuspec | 18 +++ MiniMods/Minimod.csproj | 4 +- 3 files changed, 147 insertions(+), 4 deletions(-) create mode 100755 MiniMods/DataReader/DataReaderMinimod.nuspec diff --git a/MiniMods/DataReader/DataReaderMinimod.cs b/MiniMods/DataReader/DataReaderMinimod.cs index 10fb78c..329033f 100755 --- a/MiniMods/DataReader/DataReaderMinimod.cs +++ b/MiniMods/DataReader/DataReaderMinimod.cs @@ -1,7 +1,130 @@ -namespace Minimod.DataReader +using System; +using System.Data; + +namespace Minimod.DataReader { - public class Class1 + /// + ///

Minimod.DataReader, Version 0.0.1, Copyright © Uwe Zimmermann, 2012

+ /// A minimod with some extension methods for . + ///
+ /// + /// Licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the License. + /// http://www.apache.org/licenses/LICENSE-2.0 + /// + public static class DataReaderMinimod { - + /// + /// Gets the string value of the specified field. If the value is it returns null. + /// + /// An . + /// The name of the field. + /// A string containing the value of the specified field or null if the value is . + /// When parameter is null. + public static string GetStringOrNull(this IDataReader self, string name) + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + var ordinal = self.GetOrdinal(name); + + return self.IsDBNull(ordinal) ? null : self.GetString(ordinal); + } + + /// + /// Gets the string value of the specified field. If the value is it returns null. + /// + /// An . + /// The index of the field. + /// A string containing the value of the specified field or null if the value is . + /// When parameter is null. + public static string GetStringOrNull(this IDataReader self, int fieldIndex) + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + return self.IsDBNull(fieldIndex) ? null : self.GetString(fieldIndex); + } + + /// + /// Gets the value of the specified field as Nullable of . If the value is + /// it returns null. + /// + /// The type to return. It have to be a struct. + /// An . + /// The name of the field. + /// The value of the specified field or null if the value is . + /// When parameter is null. + public static TResult? GetNullableValue(this IDataReader self, string fieldName) where TResult : struct + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + var ordinal = self.GetOrdinal(fieldName); + + return self.IsDBNull(ordinal) ? null : (TResult?)self.GetValue(ordinal); + } + + /// + /// Gets the value of the specified field as Nullable of . If the value is + /// it returns null. + /// + /// The type to return. It have to be a struct. + /// An . + /// The index of the field. + /// The value of the specified field or null if the value is . + /// When parameter is null. + public static TResult? GetNullableValue(this IDataReader self, int fieldIndex) where TResult : struct + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + return self.IsDBNull(fieldIndex) ? null : (TResult?)self.GetValue(fieldIndex); + } + + /// + /// Gets the value of the specified field as . + /// + /// The type to return. It have to be a struct. + /// An . + /// The name of the field. + /// The value of the specified field or null if the value is . + /// When parameter is null. + public static TResult GetValue(this IDataReader self, string fieldName) where TResult : struct + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + var ordinal = self.GetOrdinal(fieldName); + + return (TResult)self.GetValue(ordinal); + } + + /// + /// Gets the value of the specified field as . + /// + /// The type to return. It have to be a struct. + /// An . + /// The index of the field. + /// The value of the specified field or null if the value is . + /// When parameter is null. + public static TResult GetValue(this IDataReader self, int fieldIndex) where TResult : struct + { + if (self == null) + { + throw new ArgumentNullException("self"); + } + + return (TResult)self.GetValue(fieldIndex); + } } } \ No newline at end of file diff --git a/MiniMods/DataReader/DataReaderMinimod.nuspec b/MiniMods/DataReader/DataReaderMinimod.nuspec new file mode 100755 index 0000000..e08a464 --- /dev/null +++ b/MiniMods/DataReader/DataReaderMinimod.nuspec @@ -0,0 +1,18 @@ + + + + Minimod.DataReader + 0.0.1 + Uwe Zimmermann + false + http://www.apache.org/licenses/LICENSE-2.0 + minimod + + A minimod with some extension methods for . + + A minimod with some extension methods for . + + + + + diff --git a/MiniMods/Minimod.csproj b/MiniMods/Minimod.csproj index 19e6394..ee7e317 100644 --- a/MiniMods/Minimod.csproj +++ b/MiniMods/Minimod.csproj @@ -84,6 +84,7 @@ + ..\packages\Ix_Experimental-Main.1.1.10823\lib\Net4\System.Interactive.dll @@ -96,6 +97,7 @@ + @@ -145,7 +147,6 @@ - @@ -161,6 +162,7 @@ +