예제 #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Consumer" /> class.
		/// </summary>
		/// <param name="consumerKey">The consumer key.</param>
		/// <param name="consumerSecret">The consumer secret.</param>
		/// <param name="serviceProvider">The service provider.</param>
		/// <param name="temporaryCredentialStorage">The temporary credential storage.</param>
		/// <param name="hostFactories">The host factories.</param>
		public Consumer(
			string consumerKey,
			string consumerSecret,
			ServiceProviderDescription serviceProvider,
			ITemporaryCredentialStorage temporaryCredentialStorage,
			IHostFactories hostFactories = null) {
			this.ConsumerKey = consumerKey;
			this.ConsumerSecret = consumerSecret;
			this.ServiceProvider = serviceProvider;
			this.TemporaryCredentialStorage = temporaryCredentialStorage;
			this.HostFactories = hostFactories ?? new DefaultOAuthHostFactories();
		}
예제 #2
0
파일: Consumer.cs 프로젝트: terry2012/DSV
 /// <summary>
 /// Initializes a new instance of the <see cref="Consumer" /> class.
 /// </summary>
 /// <param name="consumerKey">The consumer key.</param>
 /// <param name="consumerSecret">The consumer secret.</param>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="temporaryCredentialStorage">The temporary credential storage.</param>
 /// <param name="hostFactories">The host factories.</param>
 public Consumer(
     string consumerKey,
     string consumerSecret,
     ServiceProviderDescription serviceProvider,
     ITemporaryCredentialStorage temporaryCredentialStorage,
     IHostFactories hostFactories = null)
 {
     this.ConsumerKey                = consumerKey;
     this.ConsumerSecret             = consumerSecret;
     this.ServiceProvider            = serviceProvider;
     this.TemporaryCredentialStorage = temporaryCredentialStorage;
     this.HostFactories              = hostFactories ?? new DefaultOAuthHostFactories();
 }
예제 #3
0
        public static Consumer CreateConsumer(bool forWeb = true)
        {
            string consumerKey    = ConfigurationManager.AppSettings["twitterConsumerKey"];
            string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];

            if (IsTwitterConsumerConfigured)
            {
                ITemporaryCredentialStorage storage = forWeb ? (ITemporaryCredentialStorage) new CookieTemporaryCredentialStorage() : new MemoryTemporaryCredentialStorage();
                return(new Consumer(consumerKey, consumerSecret, ServiceDescription, storage)
                {
                    HostFactories = new TwitterHostFactories(),
                });
            }
            else
            {
                throw new InvalidOperationException("No Twitter OAuth consumer key and secret could be found in web.config AppSettings.");
            }
        }