Beispiel #1
0
        private DreamCookie(string name, string value, XUri uri, DateTime expires, int version, bool secure, bool discard, string comment, XUri commentUri, bool httpOnly, bool skipContextDiscovery)
        {
            if(string.IsNullOrEmpty(name)) {
                throw new ArgumentException("Name cannot be empty");
            }
            _name = name;
            _value = value;
            if(uri != null) {
                _uri = uri.WithoutQuery().WithoutCredentials().WithoutFragment().AsLocalUri();
                if(!skipContextDiscovery) {
                    DreamContext dc = DreamContext.CurrentOrNull;
                    if(dc != null) {
                        _publicUri = dc.PublicUri;
                        _localMachineUri = dc.Env.LocalMachineUri;
                    }
                }
            }

            // auto-convert very old expiration dates to max since they are most likely bogus
            if(expires.Year < 2000) {
                expires = DateTime.MaxValue;
            }
            if(expires != DateTime.MaxValue) {
                expires = expires.ToUniversalTime();

                // need to trim milliseconds of the passed in date
                expires = new DateTime(expires.Year, expires.Month, expires.Day, expires.Hour, expires.Minute, expires.Second, 0, DateTimeKind.Utc).ToUniversalTime();
            }

            // initialize cookie
            _expires = expires;
            _version = version;
            _secure = secure;
            _discard = discard;
            _comment = comment;
            _commentUri = commentUri;
            _httpOnly = httpOnly;
        }
        private void Queue(DateTime eventTime, XUri channel, XUri resource, string[] origin, XDoc doc) {
            doc.Attr("wikiid", _wikiid).Attr("event-time", eventTime);
            var data = new ChangeData();
            data.Channel = channel;
            data.Resource = resource == null ? null : resource.WithoutQuery().WithoutFragment();
            data.Origin = origin;
            data.Doc = doc;

            if(!_changeQueue.TryEnqueue(data)) {
                _log.WarnFormat("unable to enqueue change data into processing queue");
            }
        }