Пример #1
0
        /// <summary>
        /// Clone a ContextEntity object.
        /// </summary>
        /// <returns></returns>
        public ContextEntity Clone()
        {
            ContextEntity cloned = new ContextEntity();

            cloned.ClientIP = this.ClientIP;
            cloned.RequestUri = this.RequestUri;
            cloned.RequestUriTemplate = this.RequestUriTemplate;
            cloned.HttpMethod = this.HttpMethod;
            cloned.HttpHeader = this.HttpHeader;
            cloned.ContentType = this.ContentType;
            cloned.ContentLength = this.ContentLength;
            cloned.IsAuthed = this.IsAuthed;
            cloned.Language = this.Language;
            cloned.Token = this.Token;
            cloned.LoginName = this.LoginName;

            // just support simple type for items
            foreach ( KeyValuePair<string, object> kvp in this.Items )
            {
                cloned.Items.Add(kvp.Key,kvp.Value);
            }

            return cloned;
        }
Пример #2
0
        /// <summary>
        /// Set context in a new thread.
        /// </summary>
        /// <param name="contextEntity">ContextEntity object.</param>
        public static void SetContext(ContextEntity contextEntity)
        {
            if (contextEntity == null) return;

            Index = contextEntity.Index - 1;

            ClientIP = contextEntity.ClientIP;
            HttpMethod = contextEntity.HttpMethod;
            HttpHeader = contextEntity.HttpHeader;
            RequestUri = contextEntity.RequestUri;
            RequestUriTemplate = contextEntity.RequestUriTemplate;
            IsAuthed = contextEntity.IsAuthed;
            Language = contextEntity.Language;
            Token = contextEntity.Token;
            LoginName = contextEntity.LoginName;

            Items = contextEntity.Items;
        }