예제 #1
0
 /// <summary>
 /// Handles processing exception - this implementation uses server-wide behavior.
 /// All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
 /// </summary>
 public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
 {
     ComponentDirector.HandleException(work, filter, handler, error);
 }
예제 #2
0
 /// <summary>
 /// Finds the most appropriate work handler to do the work.
 /// The default implementation finds first handler with matching URI pattern or null
 /// </summary>
 public virtual WorkHandler GetWorkHandler(WorkContext work)
 {
     return(m_Handlers.OrderedValues.FirstOrDefault(handler => handler.MakeMatch(work)));
 }
예제 #3
0
        /// <summary>
        /// Translates the named content into desired language trying to infer language from work context/locality/session.
        /// The search is first done in this portal then in inherited portals.
        /// Returns an empty string if no translation is possible
        /// </summary>
        public virtual string TranslateContent(string contentKey, string isoLang = null, WorkContext work = null)
        {
            if (isoLang.IsNullOrWhiteSpace())
            {
                isoLang = GetLanguageISOCode(work);
            }

            string result;

            var portal = this;

            while (portal != null)
            {
                var content = portal.m_LocalizableContent;

                if (content.TryGetValue(contentKey + "_" + isoLang, out result))
                {
                    return(result);
                }
                if (!isoLang.EqualsOrdIgnoreCase(portal.DefaultLanguageISOCode))
                {
                    if (content.TryGetValue(contentKey + "_" + portal.DefaultLanguageISOCode, out result))
                    {
                        return(result);
                    }
                }
                if (content.TryGetValue(contentKey, out result))
                {
                    return(result);
                }

                portal = portal.Parent;
            }

            return(string.Empty);
        }
예제 #4
0
파일: Portal.cs 프로젝트: wangchengqun/azos
        /// <summary>
        /// Translates the named content into desired language trying to infer language from work context/locality/session.
        /// The search is first done in this portal then in inherited portals.
        /// Returns an empty string if no translation is possible
        /// </summary>
        public virtual string TranslateContent(string contentKey, Atom?isoLang = null, WorkContext work = null)
        {
            if (!isoLang.HasValue || isoLang.Value.IsZero)
            {
                isoLang = GetLanguageISOCode(work);
            }

            string result;

            var portal = this;

            while (portal != null)
            {
                var content = portal.m_LocalizableContent;

                if (content.TryGetValue(contentKey + "_" + isoLang, out result))
                {
                    return(result);
                }
                if (isoLang.Value != portal.DefaultLanguageISOCode)
                {
                    if (content.TryGetValue(contentKey + "_" + portal.DefaultLanguageISOCode, out result))
                    {
                        return(result);
                    }
                }
                if (content.TryGetValue(contentKey, out result))
                {
                    return(result);
                }

                portal = portal.Parent;
            }

            return(string.Empty);
        }
예제 #5
0
파일: Response.cs 프로젝트: lulzzz/azos
 internal Response(WorkContext work, HttpListenerResponse netResponse)
 {
     Work          = work;
     m_NetResponse = netResponse;
     m_NetResponse.Headers[HttpResponseHeader.Server] = Work.Server.Name;
 }