本文整理汇总了C#中System.Web.Routing.RequestContext.GetPluginSymbolicName方法的典型用法代码示例。如果您正苦于以下问题:C# RequestContext.GetPluginSymbolicName方法的具体用法?C# RequestContext.GetPluginSymbolicName怎么用?C# RequestContext.GetPluginSymbolicName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Routing.RequestContext
的用法示例。
在下文中一共展示了RequestContext.GetPluginSymbolicName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetControllerType
protected override Type GetControllerType(RequestContext requestContext, string controllerName)
{
var symbolicName = requestContext.GetPluginSymbolicName();
if (symbolicName != null)
{
var controllerType = ControllerTypeCache.GetControllerType(symbolicName, controllerName);
if (controllerType != null)
{
return controllerType;
}
var controllerTypeName = controllerName + "Controller";
var plugin = LEnvironment.GetAllPlugins().FirstOrDefault(p => p.Assembly.GetName().Name == symbolicName);
if (plugin != null)
{
foreach (var type in plugin.Assembly.GetTypes())
{
if (type.Name.Contains(controllerTypeName) && typeof(IController).IsAssignableFrom(type))
{
controllerType = type;
ControllerTypeCache.AddControllerType(symbolicName.ToString(), controllerName, controllerType);
Logger.LogInfo(string.Format("Loaded controller '{0}' from bundle '{1}' and then added to cache.", controllerName, symbolicName));
return controllerType;
}
}
}
Logger.LogInfo(string.Format("Failed to load controller '{0}' from bundle '{1}'.", controllerName, symbolicName));
}
try
{
//if exists duplicated controller type, below will throw an exception.
return base.GetControllerType(requestContext, controllerName);
}
catch (Exception ex)
{
Logger.LogError("PluginControllerFactory GetControllerType : ", ex);
}
requestContext.RouteData.DataTokens["pluginName"] = symbolicName;
requestContext.RouteData.DataTokens["Namespaces"] = ControllerTypeCache.DefaultNamespaces;
var result = base.GetControllerType(requestContext, controllerName);
if (result != null)
{
return result;
}
Logger.LogWarn(string.Format("no is controller '{0}' from bundle '{1}' and then added to cache.", controllerName, symbolicName));
return null;
}