public void Remove(UrlMappingEntry entry) { if (entry != null) { List.Remove(entry); } }
/// <summary> Finds the mapping for the specified <paramref name="type"/>. </summary> /// <param name="type"> The name of the <see cref="Type"/> to look-up. </param> /// <returns> /// A <see cref="string"/> or <see langword="null"/> if the <paramref name="type"/> is not mapped to a path. /// </returns> public string FindResource(Type type) { UrlMappingEntry entry = Find(type); if (entry == null) { return(null); } return(entry.Resource); }
/// <summary> Finds the mapping for the specified <paramref name="path"/>. </summary> /// <param name="path"> The path to look-up. </param> /// <returns> /// A <see cref="Type"/> or <see langword="null"/> if the <paramref name="path"/> does not map to a /// <see cref="WxeFunction"/>. /// </returns> public Type FindType(string path) { UrlMappingEntry entry = Find(path); if (entry == null) { return(null); } return(entry.FunctionType); }
protected virtual void ValidateNewValue(object value) { UrlMappingEntry entry = ArgumentUtility.CheckNotNullAndType <UrlMappingEntry> ("value", value); base.OnValidate(value); if (Find(entry.Resource) != null) { throw new ArgumentException(string.Format("The mapping already contains an entry for the following resource: '{0}'.", entry.Resource), "value"); } if (FindByID(entry.ID) != null) { throw new ArgumentException(string.Format("The mapping already contains an entry for the following ID: '{0}'.", entry.ID), "value"); } }
/// <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); }
public int Add(UrlMappingEntry entry) { return(List.Add(entry)); }