summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-10-29 14:15:38 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-10-29 14:15:38 -0700
commit31f1630014f48fc9ea9b3083b76d93bb631be036 (patch)
tree85ba02a99da9aedf05be088ac6f57fc0d36737cc
parent6ff502a725a0b87c7dd8b1e0ae56217e989b9c3b (diff)
downloadDotNetOpenAuth-31f1630014f48fc9ea9b3083b76d93bb631be036.zip
DotNetOpenAuth-31f1630014f48fc9ea9b3083b76d93bb631be036.tar.gz
DotNetOpenAuth-31f1630014f48fc9ea9b3083b76d93bb631be036.tar.bz2
Fixed bug in sample where the DateTime.Kind on an OAuth token was being lost by the database.
-rw-r--r--samples/OAuthServiceProvider/Code/OAuthToken.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/samples/OAuthServiceProvider/Code/OAuthToken.cs b/samples/OAuthServiceProvider/Code/OAuthToken.cs
index 182a3e3..9099237 100644
--- a/samples/OAuthServiceProvider/Code/OAuthToken.cs
+++ b/samples/OAuthServiceProvider/Code/OAuthToken.cs
@@ -62,5 +62,34 @@ namespace OAuthServiceProvider.Code {
}
#endregion
+
+ /// <summary>
+ /// Called by LinqToSql when the <see cref="IssueDate"/> property is about to change.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ partial void OnIssueDateChanging(DateTime value) {
+ if (value.Kind == DateTimeKind.Unspecified) {
+ throw new ArgumentException("The DateTime.Kind cannot be Unspecified to ensure accurate timestamp checks.");
+ }
+ }
+
+ /// <summary>
+ /// Called by LinqToSql when <see cref="IssueDate"/> has changed.
+ /// </summary>
+ partial void OnIssueDateChanged() {
+ if (this.IssueDate.Kind == DateTimeKind.Local) {
+ this._IssueDate = this.IssueDate.ToUniversalTime();
+ }
+ }
+
+ /// <summary>
+ /// Called by LinqToSql when a token instance is deserialized.
+ /// </summary>
+ partial void OnLoaded() {
+ if (this.IssueDate.Kind == DateTimeKind.Unspecified) {
+ // this detail gets lost in db storage, but must be reaffirmed so that expiratoin checks succeed.
+ this._IssueDate = DateTime.SpecifyKind(this.IssueDate, DateTimeKind.Utc);
+ }
+ }
}
} \ No newline at end of file