Hyves.Service.Core.HyvesSession.InitializeToken C# (CSharp) Method

InitializeToken() public method

Initializes the session information once a session has been created.
public InitializeToken ( string token, string tokenSecret, System.DateTime expireDate ) : void
token string The unique identifier of the session.
tokenSecret string The secret of the session.
expireDate System.DateTime
return void
		public void InitializeToken(string token, string tokenSecret, DateTime expireDate)
		{
			if (string.IsNullOrEmpty(token))
			{
				throw new ArgumentException("token");
			}

			if (string.IsNullOrEmpty(tokenSecret))
			{
				throw new ArgumentException("tokenSecret");
			}

      this.token = token;
      this.tokenSecret = tokenSecret;
      this.expireDate = expireDate;
		}

Usage Example

        private static HttpWebRequest CreateRequest(string requestToken, string requestTokenSecret, HyvesExpirationType expirationType, HyvesSession session)
        {
            HyvesRequestParameterList parameters = new HyvesRequestParameterList();
            HyvesMethod method;

            if (string.IsNullOrEmpty(requestToken))
            {
                method = HyvesMethod.AuthRequesttoken;

                StringBuilder methodsStringBuilder = new StringBuilder();

                if (session.Methods.Contains(HyvesMethod.All))
                {
                    Array hyvesMethodValues = Enum.GetValues(typeof(HyvesMethod));
                    foreach (HyvesMethod hyvesMethod in hyvesMethodValues)
                    {
                        if (hyvesMethod != HyvesMethod.Unknown)
                        {
                            methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
                        }
                    }

                    methodsStringBuilder = methodsStringBuilder.Replace(
                        string.Format("{0},", EnumHelper.GetDescription(HyvesMethod.All)),
                        string.Empty);
                }
                else
                {
                    foreach (HyvesMethod hyvesMethod in session.Methods)
                    {
                        methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
                    }
                }

                string methods = methodsStringBuilder.ToString();
                parameters["methods"] = methods.Substring(0, methods.Length - 1);

                parameters["expirationtype"] = EnumHelper.GetDescription(expirationType);
            }
            else
            {
                session.InitializeToken(requestToken, requestTokenSecret, DateTime.MinValue);
                method = HyvesMethod.AuthAccesstoken;
            }

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HyvesHttpUri);

            parameters.InitializeRequest(request, method, session);

            return(request);
        }
All Usage Examples Of Hyves.Service.Core.HyvesSession::InitializeToken