/// <summary> Finds the mapping for the specified <paramref name="typeName"/>. </summary>
        /// <param name="typeName"> The name of the <see cref="Type"/> to look-up. </param>
        /// <returns>
        ///   A <see cref="string"/> or <see langword="null"/> if the <paramref name="typeName"/> is not mapped
        ///   to a path.
        /// </returns>
        public string FindResource(string typeName)
        {
            if (string.IsNullOrEmpty(typeName))
            {
                return(null);
            }
            Type type = WebTypeUtility.GetType(typeName, true);

            return(FindResource(type));
        }
예제 #2
0
        /// <summary>
        ///   Returns an instance the class specified by the <see cref="EditModeControlType"/> property, which will then be used for editing this
        ///   column during edit mode.
        /// </summary>
        public IBusinessObjectBoundEditableWebControl CreateEditModeControl()
        {
            if (string.IsNullOrEmpty(_editModeControlType))
            {
                return(null);
            }

            Type type = WebTypeUtility.GetType(_editModeControlType, true);

            return((IBusinessObjectBoundEditableWebControl)ObjectFactory.Create(type, ParamList.Empty));
        }
예제 #3
0
 /// <summary> Gets the <see cref="Type"/> for the specified <paramref name="typeName"/>. </summary>
 /// <include file='..\doc\include\ExecutionEngine\WxeHandler.xml' path='WxeHandler/GetTypeByTypeName/*' />
 protected Type GetTypeByTypeName(string typeName)
 {
     ArgumentUtility.CheckNotNullOrEmpty("typeName", typeName);
     try
     {
         var type = WebTypeUtility.GetType(typeName, true, ignoreCase: true);
         if (!typeof(WxeFunction).IsAssignableFrom(type))
         {
             throw new WxeException(
                       string.Format("The function type '{0}' is invalid. Wxe functions must be derived from '{1}'.", typeName, typeof(WxeFunction).FullName));
         }
         return(type);
     }
     catch (TypeLoadException e)
     {
         throw new WxeException(string.Format("The function type '{0}' is invalid.", typeName), e);
     }
     catch (FileNotFoundException e)
     {
         throw new WxeException(string.Format("The function type '{0}' is invalid.", typeName), e);
     }
 }
예제 #4
0
            public virtual Type ResolveFunctionType()
            {
                UrlMappingEntry mapping = UrlMappingConfiguration.Current.Mappings.FindByID(_mappingID);

                bool hasMapping  = mapping != null;
                bool hasTypeName = !string.IsNullOrEmpty(_typeName);

                Type functionType = null;

                if (hasTypeName)
                {
                    functionType = WebTypeUtility.GetType(_typeName, true);
                }

                if (hasMapping)
                {
                    if (functionType == null)
                    {
                        functionType = mapping.FunctionType;
                    }
                    else if (mapping.FunctionType != functionType)
                    {
                        throw new InvalidOperationException(
                                  string.Format(
                                      "The WxeFunctionCommand in has both a MappingID ('{0}') and a TypeName ('{1}') defined, but they resolve to different WxeFunctions.",
                                      _mappingID,
                                      _typeName));
                    }
                }
                else if (!hasTypeName)
                {
                    throw new InvalidOperationException("The WxeFunctionCommand has no valid MappingID or FunctionTypeName specified.");
                }

                return(functionType);
            }
예제 #5
0
        /// <summary>
        ///   Gets the permanent URL for the <see cref="WxeFunction"/> of the specified <paramref name="functionType"/>
        ///   and using the <paramref name="urlParameters"/>.
        /// </summary>
        /// <include file='..\doc\include\ExecutionEngine\WxeContext.xml' path='WxeContext/GetPermanentUrl/param[@name="httpContext" or @name="functionType" or @name="urlParameters" or @name="fallbackOnCurrentUrl"]' />
        protected static string GetPermanentUrl(HttpContextBase httpContext, Type functionType, NameValueCollection urlParameters, bool fallbackOnCurrentUrl)
        {
            ArgumentUtility.CheckNotNull("httpContext", httpContext);
            ArgumentUtility.CheckNotNull("functionType", functionType);
            if (!typeof(WxeFunction).IsAssignableFrom(functionType))
            {
                throw new ArgumentException(string.Format("The functionType '{0}' must be derived from WxeFunction.", functionType), "functionType");
            }
            ArgumentUtility.CheckNotNull("urlParameters", urlParameters);

            NameValueCollection internalUrlParameters = NameValueCollectionUtility.Clone(urlParameters);

            UrlMapping.UrlMappingEntry mappingEntry = UrlMapping.UrlMappingConfiguration.Current.Mappings[functionType];
            if (mappingEntry == null)
            {
                string functionTypeName = WebTypeUtility.GetQualifiedName(functionType);
                internalUrlParameters.Set(WxeHandler.Parameters.WxeFunctionType, functionTypeName);
            }

            string path;

            if (mappingEntry == null)
            {
                string defaultWxeHandler = Configuration.WebConfiguration.Current.ExecutionEngine.DefaultWxeHandler;
                if (string.IsNullOrEmpty(defaultWxeHandler))
                {
                    if (fallbackOnCurrentUrl)
                    {
                        path = httpContext.Request.Url.AbsolutePath;
                    }
                    else
                    {
                        throw new WxeException(
                                  string.Format(
                                      "No URL mapping has been defined for WXE Function '{0}', nor has a default WxeHandler URL been specified in the application configuration (web.config).",
                                      functionType.FullName));
                    }
                }
                else
                {
                    path = defaultWxeHandler;
                }
            }
            else
            {
                path = mappingEntry.Resource;
            }

            string permanentUrl = UrlUtility.GetAbsoluteUrl(httpContext, path)
                                  + UrlUtility.FormatQueryString(internalUrlParameters, httpContext.Response.ContentEncoding);

            int maxLength = Configuration.WebConfiguration.Current.ExecutionEngine.MaximumUrlLength;

            if (permanentUrl.Length > maxLength)
            {
                throw new WxePermanentUrlTooLongException(
                          string.Format(
                              "Error while creating the permanent URL for WXE function '{0}'. "
                              + "The URL exceeds the maximum length of {1} bytes. Generated URL: {2}",
                              functionType.Name,
                              maxLength,
                              permanentUrl));
            }

            return(permanentUrl);
        }