public override string ToString()
    {
        var  sb      = new StringBuilder("FriendChannelMatricesResponse(");
        bool __first = true;

        if (__isset.expires)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Expires: ");
            Expires.ToString(sb);
        }
        if (Matrices != null && __isset.matrices)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Matrices: ");
            Matrices.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
 internal string ToJson()
 {
     return(JsonMapper.ToJson(new Dictionary <string, string>
     {
         {
             "AccessKey",
             base.AccessKey
         },
         {
             "SecretKey",
             base.SecretKey
         },
         {
             "Token",
             base.Token
         },
         {
             "Expires",
             Expires.ToString("u", CultureInfo.InvariantCulture)
         },
         {
             "Subject",
             Subject
         }
     }));
 }
Пример #3
0
 internal string SerializeUnencrypted()
 {
     return("Domain: " + Domain.Replace('\n', ' ') + "\n" +
            "OwnerName: " + OwnerName.Replace('\n', ' ') + "\n" +
            "Issued: " + Issued.ToString() + "\n" +
            "Expires: " + Expires.ToString() + "\n" +
            "Features: " + Join(Features) + "\n");
 }
Пример #4
0
            public void should_create_string_with_full_date_in_utc()
            {
                Expires expires = Expires.At(new DateTimeOffset(new DateTime(2014, 5, 6, 7, 8, 9)));

                expires.ToString().
                Should().
                Be("at 2014-05-06T03:08:09");
            }
Пример #5
0
            public void should_create_string_with_seconds()
            {
                Expires expires = Expires.In(5.Seconds());

                expires.ToString().
                Should().
                Be("in 5");
            }
Пример #6
0
            public void should_create_string_with_full_date_in_utc()
            {
                var     dateTime = new DateTime(2014, 5, 6, 7, 8, 9);
                var     offset   = new TimeSpan(4, 0, 0);
                Expires expires  = Expires.At(new DateTimeOffset(dateTime, offset));

                expires.ToString().
                Should().
                Be("at 2014-05-06T03:08:09");
            }
Пример #7
0
        /// <summary>
        /// Отправляет ответное сообщение, используя переданный в исходном
        /// сообщении обратный адрес и идентификатор сообщения.
        /// </summary>
        /// <typeparam name="TResponse">.NET тип отправляемого сообщения.</typeparam>
        /// <param name="response">Отправляемое сообщение.</param>
        /// <param name="expires">Настройки, которые определяют время пока ответ актуален.</param>
        public void Reply <TResponse>(TResponse response, Expires expires = null) where TResponse : class
        {
            var headers = new Dictionary <string, object>();

            if (expires != null)
            {
                headers[Headers.Expires] = expires.ToString();
            }

            this.Delivery.ReplyWith(new Message <TResponse>(MessageLabel.Empty, headers, response));
        }
Пример #8
0
        /// <summary>
        /// Serializes the instance to a json-format string for external storage
        /// </summary>
        /// <returns>The serialized object in json</returns>
        internal string ToJson()
        {
            // don't need all data, and we want to be explicit on the datetime format
            var props = new Dictionary <string, string>();

            props.Add(AccessKeyProperty, AccessKey);
            props.Add(SecretKeyProperty, SecretKey);
            props.Add(TokenProperty, Token);

            props.Add(ExpiresProperty, Expires.ToString("u", CultureInfo.InvariantCulture));

            props.Add(SubjectProperty, Subject);

            return(JsonMapper.ToJson(props));
        }
Пример #9
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Via.ToString());
            sb.Append(From.ToString());
            sb.Append($"To: <sip:{To.ToString()}>").AppendLine();
            sb.Append(CallId.ToString());
            sb.Append(CSeq.ToString());
            if (!string.IsNullOrEmpty(UserAgent))
            {
                sb.Append($"User-Agent: {UserAgent}").AppendLine();
            }
            if (Expires > 0)
            {
                sb.Append($"Expires: {Expires.ToString()}").AppendLine();
            }
            if (!string.IsNullOrEmpty(Accept))
            {
                sb.Append($"Accept: {Accept}").AppendLine();
            }
            if (!string.IsNullOrEmpty(ContentType))
            {
                sb.Append($"Content-Type: {ContentType}").AppendLine();
            }
            if (ContentLength > 0)
            {
                sb.Append($"Content-Length: {ContentLength.ToString()}").AppendLine();
            }
            sb.Append($"Max-Forwards: {MaxForwards}").AppendLine();
            if (Allow != null && Allow.Count > 0)
            {
                sb.Append($"Allow: {string.Join(",",Allow)}").AppendLine();
            }
            if (CustomHeaders.Count() > 0)
            {
                foreach (KeyValuePair <string, string> Header in CustomHeaders)
                {
                    sb.Append($"X-{Header.Key}: {Header.Value}").AppendLine();
                }
            }

            return(sb.ToString());
        }
Пример #10
0
        internal string GetHeaderValue()
        {
            var sb = new StringBuilder();

            sb.Append(Name);
            sb.Append('=');
            sb.Append(Value);

            if (!String.IsNullOrEmpty(Domain))
            {
                sb.Append("; domain=");
                sb.Append(Domain);
            }

            if (Expires != DateTime.MinValue)
            {
                sb.Append("; expires=");
                sb.Append(Expires.ToString(DateFormat, DateCulture));
            }

            if (!String.IsNullOrEmpty(Path))
            {
                sb.Append("; path=");
                sb.Append(Path);
            }

            if (Secure)
            {
                sb.Append("; secure");
            }

            if (HttpOnly)
            {
                sb.Append("; HttpOnly");
            }

            return(sb.ToString());
        }
Пример #11
0
            /// <summary>
            /// Returns a human readable, single-line description of the license
            /// </summary>
            /// <returns></returns>
            internal string GetShortDescription()
            {
                StringBuilder sb = new StringBuilder(OwnerName + " - " + Domain + " - " + Issued.ToString() + " - " + Expires.ToString() + " - ");

                foreach (var id in Features)
                {
                    sb.Append(GetFriendlyName(id) + " ");
                }
                return(sb.ToString().TrimEnd());
            }
Пример #12
0
        private static void LoginNavigationStarted(Uri url, object state)
        {
            FacebookOAuthResult result;

            // Check if we're waiting for user input or if login is complete
            if (_client.TryParseOAuthCallbackUrl(url, out result))
            {
                // Login complete
                if (result.IsSuccess)
                {
                    AccessToken         = result.AccessToken;
                    Expires             = result.Expires;
                    _client.AccessToken = AccessToken;
                    // TODO: Replace this code with appropriate Facebook.Client calls
                    //Settings.Set(TOKEN_KEY, EncryptionProvider.Encrypt(AccessToken, AppId));
                    //Settings.Set(EXPIRY_DATE_BIN, Expires.ToBinary());
                }
                _web.Finish();
                if (_onHideUnity != null)
                {
                    _onHideUnity(false);
                }

                API("/me?fields=id,name", HttpMethod.GET, fbResult =>
                {
                    if (IsLoggedIn)
                    {
                        UserId   = fbResult.Json["id"] as string;
                        UserName = fbResult.Json["name"] as string;
                        // TODO: Replace this code with appropriate Facebook.Client calls
                        //Settings.Set(FBID_KEY, UserId);
                        //Settings.Set(FBNAME_KEY, UserName);
                    }

                    if (state is FacebookDelegate)
                    {
                        JsonObject jResult = new JsonObject();
                        jResult.Add(new KeyValuePair <string, object>("authToken", AccessToken));
                        jResult.Add(new KeyValuePair <string, object>("authTokenExpiry", Expires.ToString()));

                        ((FacebookDelegate)state)(new FBResult()
                        {
                            Json = jResult,
                            Text = jResult.ToString()
                        });
                    }
                });
            }
        }
Пример #13
0
        public string GetShortDescription()
        {
            var sb = new StringBuilder(OwnerName + " - " + Domain + " - " + Issued.ToString() + " - " + Expires.ToString() + " - ");

            foreach (var id in Features)
            {
                sb.Append(id + " ");
            }
            return(sb.ToString().TrimEnd());
        }