Beispiel #1
0
 private void Proxy_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         Expires.Focus();
     }
 }
 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
         }
     }));
 }
    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());
    }
            public void should_create_expires_object_with_date()
            {
                Expires expires = Expires.Parse("at 2014-05-06T03:08:09");

                expires.Date.Should().
                Be(new DateTimeOffset(new DateTime(2014, 5, 6, 3, 8, 9), new TimeSpan(0, 0, 0)).ToLocalTime());
            }
Beispiel #5
0
 protected bool Equals(LiaraCookie cookie)
 {
     return(string.Equals(Name, cookie.Name) && string.Equals(Value, cookie.Value) &&
            string.Equals(Domain, cookie.Domain) && string.Equals(Path, cookie.Path) &&
            Expires.Equals(cookie.Expires) && SecureOnly.Equals(cookie.SecureOnly) &&
            HttpOnly.Equals(cookie.HttpOnly));
 }
Beispiel #6
0
        public void unfinished_messages_will_be_dead_lettered_even_if_they_have_been_started_up_in_the_past()
        {
            var queueName     = "Test_Destination_TTL_500";
            var deadQueueName = MessagingBaseConfiguration.DeadLetterPrefix + queueName;

            messaging.CreateDestination <IMsg>(queueName, Expires.AfterMilliseconds(500)); // Very short TTL. Real-world is more likely to be hours or days.
            MessagingBaseConfiguration.LastConfiguration.Get <IMessageRouter>().Purge(queueName);
            MessagingBaseConfiguration.LastConfiguration.Get <IMessageRouter>().Purge(deadQueueName);
            messaging.SendMessage(testMessage);

            var message = messaging.TryStartMessage <IMsg>(queueName);

            message.Cancel(); // equivalent of the process crashing etc.


            Thread.Sleep(1000); // 'huge' delay


            message = messaging.TryStartMessage <IMsg>(queueName);
            Assert.That(message, Is.Null, "Message should NOT be in the original queue, but it was");

            message = messaging.TryStartMessage <IMsg>(deadQueueName);
            Assert.That(message, Is.Not.Null, "Message should be in the DLQ, but I didn't find it");
            message.Finish();
        }
Beispiel #7
0
        public void if_a_time_restriction_has_been_set__an_expired_message_will_be_written_to_a_dead_letter_queue()
        {
            var queueName     = "Test_Destination_TTL_500";
            var deadQueueName = MessagingBaseConfiguration.DeadLetterPrefix + queueName;

            messaging.CreateDestination <IMsg>(queueName, Expires.AfterMilliseconds(500)); // Very short TTL. Real-world is more likely to be hours or days.
            MessagingBaseConfiguration.LastConfiguration.Get <IMessageRouter>().Purge(queueName);
            MessagingBaseConfiguration.LastConfiguration.Get <IMessageRouter>().Purge(deadQueueName);
            messaging.SendMessage(testMessage);


            Thread.Sleep(1000); // 'huge' delay


            var message = messaging.TryStartMessage <IMsg>(queueName);

            Assert.That(message, Is.Null, "Message should NOT be in the original queue, but it was");

            message = messaging.TryStartMessage <IMsg>(deadQueueName);
            Assert.That(message, Is.Not.Null, "Message should be in the DLQ, but I didn't find it");

            message.Finish(); // Should be able to complete the message to take it out of the DLQ
            message = messaging.TryStartMessage <IMsg>(deadQueueName);
            Assert.That(message, Is.Null, "Message should have been removed from DLQ, but it stayed");
        }
Beispiel #8
0
        public SubscribeResponse Subscribe(string resourceUri, IEnumerable <Selector> selectors, SubscribeRequest request)
        {
            EndpointAddressBuilder susbcriptionManagerEndpointAddress = new EndpointAddressBuilder();

            Expires expiration = request.Expires ?? Expires.FromTimeSpan(DefaultExpirationTime);

            Subsciption subsciption = GetManager(resourceUri, request.Filter).Subscribe(
                request.Filter,
                selectors,
                expiration,
                susbcriptionManagerEndpointAddress);

            lock (_activeSubscriptions)
            {
                _activeSubscriptions[subsciption.Identifier] = subsciption;
            }
            //R7.2.4-1
            return(new SubscribeResponse
            {
                SubscriptionManager = new SubscriptionManager(susbcriptionManagerEndpointAddress, subsciption.Identifier, OperationContextProxy.Current.LocalAddress, subsciption.DeliveryResourceUri),
                EnumerationContext = request.Delivery.Mode == Delivery.DeliveryModePull
                         ? new EnumerationContextKey(subsciption.Identifier)
                         : null,
                Expires = expiration
            });
        }
Beispiel #9
0
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expiresIn"></param>
        /// <returns></returns>
        public bool SetCache(string key, object value, Expires expires = Expires.一小时)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new Exception("key is null");
            }
            DateTime expiresIn;

            switch (expires)
            {
            case Expires.一小时:
                expiresIn = DateTime.Now.AddHours(1);
                break;

            case Expires.一天:
                expiresIn = DateTime.Now.AddDays(1);
                break;

            case Expires.七天:
                expiresIn = DateTime.Now.AddDays(7);
                break;

            case Expires.一个月:
                expiresIn = DateTime.Now.AddMonths(1);
                break;

            default:
                expiresIn = DateTime.Now.AddDays(1);
                break;
            }
            return(SetCache(key, value, expiresIn));
        }
Beispiel #10
0
            public void should_create_expires_object_with_date()
            {
                Expires expires = Expires.Parse("at 2014-05-06T03:08:09");

                expires.Date.Should().
                Be(new DateTimeOffset(new DateTime(2014, 5, 6, 7, 8, 9)));
            }
Beispiel #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Network.Length != 0)
            {
                hash ^= Network.GetHashCode();
            }
            hash ^= outputs_.GetHashCode();
            if (Time != 0UL)
            {
                hash ^= Time.GetHashCode();
            }
            if (Expires != 0UL)
            {
                hash ^= Expires.GetHashCode();
            }
            if (Memo.Length != 0)
            {
                hash ^= Memo.GetHashCode();
            }
            if (PaymentUrl.Length != 0)
            {
                hash ^= PaymentUrl.GetHashCode();
            }
            if (MerchantData.Length != 0)
            {
                hash ^= MerchantData.GetHashCode();
            }
            return(hash);
        }
Beispiel #12
0
            public void should_create_expires_object_with_period()
            {
                Expires expires = Expires.Parse("in 15");

                expires.Period.Should().
                Be(15.Seconds());
            }
Beispiel #13
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");
 }
Beispiel #14
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     Date.ToStream(output);
     Expires.ToStream(output);
     DCId.ToStream(output);
     IpPortList.ToStream(output);
 }
Beispiel #15
0
            public void should_create_string_with_seconds()
            {
                Expires expires = Expires.In(5.Seconds());

                expires.ToString().
                Should().
                Be("in 5");
            }
Beispiel #16
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");
            }
Beispiel #17
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Expires.ToBytes(),
                Peer.ToBytes(),
                Chats.ToBytes(),
                Users.ToBytes()));
 }
        public void Deserialize()
        {
            var serializer = new XmlSerializer(typeof(Expires));

            var     xml     = XElement.Parse("<wse:Expires xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'>2010-08-23T00:00:00Z</wse:Expires>");
            Expires expires = (Expires)serializer.Deserialize(xml.CreateReader());

            Assert.That(expires.Value, Is.EqualTo(new DateTime(2010, 8, 23)));
        }
Beispiel #19
0
 /// <summary>
 /// Checks if the current WebCookie is equal to the provided one.
 /// </summary>
 /// <param name="other">The instance to compare to.</param>
 /// <returns>True if both are value-wise equal, otherwise false.</returns>
 public Boolean Equals(WebCookie other) =>
 Domain.Equals(other.Domain) &&
 Expires.Equals(other.Expires) &&
 IsHostOnly.Equals(other.IsHostOnly) &&
 IsHttpOnly.Equals(other.IsHttpOnly) &&
 IsSecure.Equals(other.IsSecure) &&
 Key.Equals(other.Key) &&
 Value.Equals(other.Value) &&
 Path.Equals(other.Path) &&
 MaxAge.Equals(other.MaxAge);
Beispiel #20
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            Expires.ToStream(output);
            Peer.ToStream(output);
            Chats.ToStream(output);
            Users.ToStream(output);

            CustomFlags.NullableToStream(output);
        }
Beispiel #21
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");
            }
        /// <summary>
        /// Append string representation of this <see cref="SetCookieHeaderValue"/> to given
        /// <paramref name="builder"/>.
        /// </summary>
        /// <param name="builder">
        /// The <see cref="StringBuilder"/> to receive the string representation of this
        /// <see cref="SetCookieHeaderValue"/>.
        /// </param>
        public void AppendToStringBuilder(StringBuilder builder)
        {
            builder.Append(_name.AsSpan());
            builder.Append("=");
            builder.Append(_value.AsSpan());

            if (Expires.HasValue)
            {
                AppendSegment(builder, ExpiresToken, HeaderUtilities.FormatDate(Expires.GetValueOrDefault()));
            }

            if (MaxAge.HasValue)
            {
                AppendSegment(builder, MaxAgeToken, HeaderUtilities.FormatNonNegativeInt64((long)MaxAge.GetValueOrDefault().TotalSeconds));
            }

            if (Domain != null)
            {
                AppendSegment(builder, DomainToken, Domain);
            }

            if (Path != null)
            {
                AppendSegment(builder, PathToken, Path);
            }

            if (Secure)
            {
                AppendSegment(builder, SecureToken, null);
            }

            // Allow for Unspecified (-1) to skip SameSite
            if (SameSite == SameSiteMode.None)
            {
                AppendSegment(builder, SameSiteToken, SameSiteNoneToken);
            }
            else if (SameSite == SameSiteMode.Lax)
            {
                AppendSegment(builder, SameSiteToken, SameSiteLaxToken);
            }
            else if (SameSite == SameSiteMode.Strict)
            {
                AppendSegment(builder, SameSiteToken, SameSiteStrictToken);
            }

            if (HttpOnly)
            {
                AppendSegment(builder, HttpOnlyToken, null);
            }

            foreach (var extension in Extensions)
            {
                AppendSegment(builder, extension, null);
            }
        }
Beispiel #23
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = NotBefore.GetHashCode();
         hashCode = (hashCode * 397) ^ Expires.GetHashCode();
         hashCode = (hashCode * 397) ^ Admin.GetHashCode();
         hashCode = (hashCode * 397) ^ Debug.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #24
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));
        }
Beispiel #25
0
 public override int GetHashCode()
 {
     return(StringComparer.OrdinalIgnoreCase.GetHashCode(_name)
            ^ StringComparer.OrdinalIgnoreCase.GetHashCode(_value)
            ^ (Expires.HasValue ? Expires.GetHashCode() : 0)
            ^ (MaxAge.HasValue ? MaxAge.GetHashCode() : 0)
            ^ (Domain != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Domain) : 0)
            ^ (Path != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Path) : 0)
            ^ Secure.GetHashCode()
            ^ HttpOnly.GetHashCode());
 }
        /// <summary>
        /// Sets the absolute time when the cached value expires.
        /// </summary>
        /// <param name="absoluteExpiration">The date/time when the item expires.</param>
        /// <returns>The CachedLifetime instance (allows chaining).</returns>
        public CachedLifetime ExpiresOn(DateTime absoluteExpiration)
        {
            if (absoluteExpiration != Cache.NoAbsoluteExpiration)
            {
                _duration       = Cache.NoSlidingExpiration;
                _expirationKind = Expires.OnDateTime;
            }

            _expiresOn = absoluteExpiration;
            return(this);
        }
Beispiel #27
0
            public void should_create_expires_object_with_date()
            {
                Expires expires = Expires.At(new DateTimeOffset(new DateTime(2014, 5, 6, 7, 8, 9)));

                expires.Period.Should().
                NotHaveValue();
                expires.Date.HasValue.Should().
                BeTrue();
                expires.Date.Should().
                Be(new DateTimeOffset(new DateTime(2014, 5, 6, 7, 8, 9)));
            }
        /// <summary>
        /// Sets the duration the cached item will remain valid.  This is a fixed duration.
        /// </summary>
        /// <param name="duration">The duration. Use Cache.NoSlidingExpiration to disable.</param>
        /// <returns>The CachedLifetime instance (allows chaining).</returns>
        public CachedLifetime ExpiresAfter(TimeSpan duration)
        {
            if (duration != Cache.NoSlidingExpiration)
            {
                _expiresOn      = Cache.NoAbsoluteExpiration;
                _expirationKind = Expires.AfterFixedDuration;
            }

            _duration = duration;
            return(this);
        }
Beispiel #29
0
            public void should_create_expires_object_with_period()
            {
                Expires expires = Expires.In(5.Seconds());

                expires.Period.Should().
                HaveValue();
                expires.Period.Should().
                Be(5.Seconds());
                expires.Date.HasValue.Should().
                BeFalse();
            }
        public override void Process(Entity e)
        {
            Expires expires = expiresMapper.Get(e);

            expires.ReduceLifeTime(world.Delta);

            if (expires.IsExpired)
            {
                e.Delete();
            }
        }
		/// <summary>
		/// Gets the instance from cache, if available, otherwise creates a new
		/// instance and caches it.
		/// </summary>
		/// <param name="registration">The creator (registration) to create a new instance.</param>
		/// <returns>The instance.</returns>
		public object GetInstance(IRegistration registration)
		{
			Cache cache = HttpRuntime.Cache;

			string key = registration.Key;
			object instance = cache[key];
			if (instance == null)
			{
				lock (_lock)
				{
					instance = cache[key];
					if (instance == null)
					{
						instance = registration.CreateInstance();

						if (_expiresOn == Cache.NoAbsoluteExpiration &&
							_duration == Cache.NoSlidingExpiration)
							_expirationKind = Expires.None;

						switch (_expirationKind)
						{
							case Expires.None:
								cache.Insert(key, instance, _dependencies, Cache.NoAbsoluteExpiration,
										Cache.NoSlidingExpiration, _priority, _onRemoveCallback);
								break;

							case Expires.OnDateTime:
								cache.Insert(key, instance, _dependencies, _expiresOn,
										Cache.NoSlidingExpiration, _priority, _onRemoveCallback);
								break;

							case Expires.AfterFixedDuration:
								cache.Insert(key, instance, _dependencies, DateTime.Now.Add(_duration),
										Cache.NoSlidingExpiration, _priority, _onRemoveCallback);
								break;

							case Expires.AfterSlidingDuration:
								cache.Insert(key, instance, _dependencies, Cache.NoAbsoluteExpiration,
									_duration, _priority, _onRemoveCallback);
								break;
						}

					}
				}
			}

			return instance;
		}
Beispiel #32
0
 internal static Expires Create(float p)
 {
     Expires expires = new Expires();
     expires.totalTime = p;
     expires.timeLeft = p;
     return expires;
 }
Beispiel #33
0
        /// <summary>
        /// Sets the absolute time when the cached value expires.
        /// </summary>
        /// <param name="absoluteExpiration">The date/time when the item expires.</param>
        /// <returns>The CachedLifetime instance (allows chaining).</returns>
        public CachedLifetime ExpiresOn(DateTime absoluteExpiration)
        {
            if (absoluteExpiration != Cache.NoAbsoluteExpiration)
            {
                _duration       = Cache.NoSlidingExpiration;
                _expirationKind = Expires.OnDateTime;
            }

            _expiresOn = absoluteExpiration;
            return this;
        }
Beispiel #34
0
        /// <summary>
        /// Sets the duration the cached item will remain valid.  This is a fixed duration.
        /// </summary>
        /// <param name="duration">The duration. Use Cache.NoSlidingExpiration to disable.</param>
        /// <returns>The CachedLifetime instance (allows chaining).</returns>
        public CachedLifetime ExpiresAfter(TimeSpan duration)
        {
            if (duration != Cache.NoSlidingExpiration)
            {
                _expiresOn      = Cache.NoAbsoluteExpiration;
                _expirationKind = Expires.AfterFixedDuration;
            }

            _duration = duration;
            return this;
        }