public DotNetOpenAuth.Messaging.Bindings.CryptoKey GetKey(string bucket, string handle)
        {
            DotNetOpenAuth.Messaging.Bindings.CryptoKey key = null;

            using (IEntityContext context = DependencyInjection.Get<IEntityContext>())
            {
                using (IOAuth2CryptoKeyRepository repository = DependencyInjection.Get<IOAuth2CryptoKeyRepository>(InjectionParameter.Create("context", context)))
                {
                    IQueryOver<Entity.OAuth2CryptoKey, Entity.OAuth2CryptoKey> query =
                        repository
                            .Query()
                            .Where(x => x.Bucket == bucket)
                            .Where(x => x.Handle == handle);

                    Entity.OAuth2CryptoKey _key = query.List().SingleOrDefault();
                    if (_key != null)
                    {
                        key = new DotNetOpenAuth.Messaging.Bindings.CryptoKey(Encoding.Unicode.GetBytes(_key.Secret), new DateTime(_key.ExpiresUtc.Ticks, DateTimeKind.Utc));
                    }
                }

                context.Commit();
            }

            return key;
        }
		public DotNetOpenAuth.Messaging.Bindings.CryptoKey GetKey(string bucket, string handle)
		{
			DotNetOpenAuth.Messaging.Bindings.CryptoKey key = null;

			using (IEntityContext context = DependencyInjection.Get<IEntityContext>())
			{
				using (IOAuth2CryptoKeyRepository repository = DependencyInjection.Get<IOAuth2CryptoKeyRepository>(InjectionParameter.Create("context", context)))
				{
					IQueryOver<Entity.OAuth2CryptoKey, Entity.OAuth2CryptoKey> query =
						repository
							.Query()
							.Where(x => x.Bucket == bucket)
							.Where(x => x.Handle == handle);

					Entity.OAuth2CryptoKey _key = query.List().SingleOrDefault();
					if (_key != null)
					{
						key = new DotNetOpenAuth.Messaging.Bindings.CryptoKey(Encoding.Unicode.GetBytes(_key.Secret), new DateTime(_key.ExpiresUtc.Ticks, DateTimeKind.Utc));
					}
				}

				context.Commit();
			}

			return key;
		}
		public void StoreKey(string bucket, string handle, DotNetOpenAuth.Messaging.Bindings.CryptoKey key)
		{
			using (IEntityContext context = DependencyInjection.Get<IEntityContext>())
			{
				using (IOAuth2CryptoKeyRepository repository = DependencyInjection.Get<IOAuth2CryptoKeyRepository>(InjectionParameter.Create("context", context)))
				{
					Entity.OAuth2CryptoKey _key = new Entity.OAuth2CryptoKey();
					_key.ID = Guid.NewGuid();
					_key.Bucket = bucket;
					_key.Handle = handle;
					_key.Secret = Encoding.Unicode.GetString(key.Key);
					_key.ExpiresUtc = key.ExpiresUtc;

					repository.AddOrUpdate(_key);
				}

				context.Commit();
			}
		}