Exemplo n.º 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);
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
        }
Exemplo n.º 4
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, 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);
        }
Exemplo n.º 5
0
 internal Response(WorkContext work, HttpListenerResponse netResponse)
 {
     Work          = work;
     m_NetResponse = netResponse;
     m_NetResponse.Headers[HttpResponseHeader.Server] = Work.Server.Name;
 }