public static string ReplaceDirectMethods(string script, Control seed) { if (TokenUtils.IsDirectMethodsToken(script)) { UserControl parent = seed as UserControl; if (parent == null) { parent = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.UserControl)) as UserControl; } ResourceManager sm = null; string ns = "Ext.net.DirectMethods"; if (parent != null && !(parent is MasterPage && seed.Parent is System.Web.UI.WebControls.ContentPlaceHolder)) { string id = ResourceManager.GetControlIdentification(parent); if (id.IsNotEmpty()) { id = ".".ConcatWith(id); } sm = ResourceManager.GetInstance(HttpContext.Current); if (sm != null) { ns = sm.DirectMethodNamespace; } return(script.Replace(TokenUtils.DIRECTMETHODS_PATTERN, ns.ConcatWith(id))); } else { Page parentPage = seed as Page; if (parentPage == null) { parentPage = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.Page)) as System.Web.UI.Page; } if (parentPage != null) { sm = ResourceManager.GetInstance(parentPage); if (sm != null) { ns = sm.DirectMethodNamespace; } return(script.Replace(TokenUtils.DIRECTMETHODS_PATTERN, ns)); } } } return(script); }
public static string ReplaceDirectMethods(string script, Control seed) { if (TokenUtils.IsDirectMethodsToken(script)) { string ns = ResourceManager.GlobalNormalizedDirectMethodNamespace; #if MVC if (Ext.Net.MVC.MvcResourceManager.IsMVC || (seed is BaseControl && ((BaseControl)seed).IsMVC)) { if (HttpContext.Current != null && HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"] != null) { return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns.ConcatWith(".", HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"].ToString()))); } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns)); } #endif UserControl parent = seed as UserControl; if (parent == null) { parent = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.UserControl)) as UserControl; } ResourceManager sm = null; if (parent != null && !(parent is MasterPage && seed.Parent is System.Web.UI.WebControls.ContentPlaceHolder)) { string id = ResourceManager.GetControlIdentification(parent, null); if (id.IsNotEmpty()) { id = ".".ConcatWith(id); } sm = ResourceManager.GetInstance(HttpContext.Current); if (sm != null) { ns = sm.NormalizedDirectMethodNamespace; } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns.ConcatWith(id))); } else { Page parentPage = seed as Page; if (parentPage == null) { parentPage = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.Page)) as System.Web.UI.Page; } sm = ResourceManager.GetInstance(); if (sm != null) { ns = sm.NormalizedDirectMethodNamespace; } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns)); } } return(script); }