Asp.net 检查iClientScriptInCluster注销的好处有多大?

Asp.net 检查iClientScriptInCluster注销的好处有多大?,asp.net,.net,Asp.net,.net,在RegisterClientScriptInclude之前检查isclientScriptinclude的好处有多大 从: 其中指出: 请注意,如果要检查现有客户端脚本的逻辑包括 如果已删除,则中仍不会有重复的客户端脚本 已呈现页面,因为RegisterClientScriptInclude方法检查 复制品检查的好处是减少不必要的 计算。 我想知道突出显示的句子。什么是不必要的计算 对我来说,情况似乎正好相反。在RegisterClientScriptInclude之前使用isclientSc

RegisterClientScriptInclude
之前检查
isclientScriptinclude
的好处有多大

从:

其中指出:

请注意,如果要检查现有客户端脚本的逻辑包括 如果已删除,则中仍不会有重复的客户端脚本 已呈现页面,因为RegisterClientScriptInclude方法检查 复制品检查的好处是减少不必要的 计算。

我想知道突出显示的句子。什么是不必要的计算

对我来说,情况似乎正好相反。在
RegisterClientScriptInclude
之前使用
isclientScriptinclude
应该/将检查已注册的脚本两次(因此增加了不必要的计算,而不是减少)


我在这里遗漏了什么?

IsClientScriptIncludeRegistered是一个简单的签入字典,如果脚本全部就绪,那么它是一个非常快速的检查,没有很多代码

public bool IsClientScriptIncludeRegistered(Type type, string key)
{
    if (type == null)
    {
        throw new ArgumentNullException("type");
    }
    return ((this._registeredClientScriptBlocks != null) && 
     this._registeredClientScriptBlocks.Contains(
        CreateScriptIncludeKey(type, key, false)));
}
另一方面,
注册表客户端criptinclude
包含更多的代码,直到达到对现有数据库的检查

internal void RegisterClientScriptInclude(Control control, Type type, string key, string url)
{
    IScriptManager scriptManager = this._owner.ScriptManager;
    if ((scriptManager != null) && scriptManager.SupportsPartialRendering)
    {
        scriptManager.RegisterClientScriptInclude(control, type, key, url);
    }
    else
    {
        this.RegisterClientScriptInclude(type, key, url);
    }
}

internal void RegisterClientScriptInclude(Type type, string key, string url, bool isResource)
{
    if (type == null)
    {
        throw new ArgumentNullException("type");
    }
    if (string.IsNullOrEmpty(url))
    {
        throw ExceptionUtil.ParameterNullOrEmpty("url");
    }
    string script = "\r\n<script src=\"" + HttpUtility.HtmlAttributeEncode(url) + "\" type=\"text/javascript\"></script>";
    this.RegisterScriptBlock(CreateScriptIncludeKey(type, key, isResource), script, ClientAPIRegisterType.ClientScriptBlocks);
}

internal void RegisterScriptBlock(ScriptKey key, string script, ClientAPIRegisterType type)
{
    switch (type)
    {
        case ClientAPIRegisterType.ClientScriptBlocks:
            this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, false);
            break;

        case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
            this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, true);
            break;

        case ClientAPIRegisterType.ClientStartupScripts:
            this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, false);
            break;

        case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
            this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, true);
            break;
    }
    if (this._owner.PartialCachingControlStack != null)
    {
        foreach (BasePartialCachingControl control in this._owner.PartialCachingControlStack)
        {
            control.RegisterScriptBlock(type, key, script);
        }
    }
}


private void RegisterScriptBlock(ScriptKey key, string script, ref ListDictionary scriptBlocks, ref ArrayList scriptList, bool needsScriptTags)
{
    if (scriptBlocks == null)
    {
        scriptBlocks = new ListDictionary();
        scriptList = new ArrayList();
    }
    if (!scriptBlocks.Contains(key))
    {
        Tuple<ScriptKey, string, bool> tuple = new Tuple<ScriptKey, string, bool>(key, script, needsScriptTags);
        scriptBlocks.Add(key, null);
        scriptList.Add(tuple);
    }
}
内部无效注册表ClientScriptInclude(控件、类型、字符串键、字符串url)
{
IScriptManager scriptManager=this.\u owner.scriptManager;
if((scriptManager!=null)&&scriptManager.SupportsPartialRendering)
{
RegisterClientScriptInclude(控件、类型、键、url);
}
其他的
{
RegisterClientScriptInclude(类型、键、url);
}
}
内部无效注册表ClientScriptInclude(类型、字符串键、字符串url、bool isResource)
{
if(type==null)
{
抛出新的ArgumentNullException(“类型”);
}
if(string.IsNullOrEmpty(url))
{
抛出异常直到参数完全或空(“url”);
}
字符串脚本=“\r\n”;
RegisterScriptBlock(CreateScriptIncludeKey(类型、键、isResource)、script、ClientApireRegisterType.ClientScriptBlocks);
}
内部无效RegisterScriptBlock(ScriptKey键、字符串脚本、ClientApireRegisterType类型)
{
开关(类型)
{
案例ClientAPIRegisterType.ClientScriptBlocks:
this.RegisterScriptBlock(key,script,ref this.\u registeredClientScriptBlocks,ref this.\u clientScriptBlocks,false);
打破
案例客户端PiregisterType.ClientScriptBlocksWithoutTags:
this.RegisterScriptBlock(key,script,ref this.\u registeredClientScriptBlocks,ref this.\u clientScriptBlocks,true);
打破
案例ClientAPIRegisterType.ClientStartupScript:
this.RegisterScriptBlock(键,脚本,引用this.\u RegisteredClientStartupScript,引用this.\u ClientStartupScript,false);
打破
案例客户端PiRegisterType.ClientStartupScriptsWithoutTags:
this.RegisterScriptBlock(键,脚本,引用this.\u registeredclientstartupscript,引用this.\u clientstartupscript,true);
打破
}
if(this.\u owner.PartialCachingControlStack!=null)
{
foreach(此中的BasePartialCachgControl控件。\u所有者.PartialCachgControl堆栈)
{
RegisterScriptBlock(类型、键、脚本);
}
}
}
私有无效注册表ScriptBlock(ScriptKey键、字符串脚本、ref ListDictionary scriptBlocks、ref ArrayList scriptList、bool needsScriptTags)
{
if(scriptBlocks==null)
{
scriptBlocks=新建ListDictionary();
scriptList=新建ArrayList();
}
如果(!scriptBlocks.Contains(键))
{
Tuple Tuple=新的Tuple(键、脚本、需求描述);
scriptBlocks.Add(key,null);
scriptList.Add(元组);
}
}

IsClientScriptIncludeRegistered是一个简单的签入字典,如果脚本全部就绪,那么它是一个非常快速的检查,没有很多代码

public bool IsClientScriptIncludeRegistered(Type type, string key)
{
    if (type == null)
    {
        throw new ArgumentNullException("type");
    }
    return ((this._registeredClientScriptBlocks != null) && 
     this._registeredClientScriptBlocks.Contains(
        CreateScriptIncludeKey(type, key, false)));
}
另一方面,
注册表客户端criptinclude
包含更多的代码,直到达到对现有数据库的检查

internal void RegisterClientScriptInclude(Control control, Type type, string key, string url)
{
    IScriptManager scriptManager = this._owner.ScriptManager;
    if ((scriptManager != null) && scriptManager.SupportsPartialRendering)
    {
        scriptManager.RegisterClientScriptInclude(control, type, key, url);
    }
    else
    {
        this.RegisterClientScriptInclude(type, key, url);
    }
}

internal void RegisterClientScriptInclude(Type type, string key, string url, bool isResource)
{
    if (type == null)
    {
        throw new ArgumentNullException("type");
    }
    if (string.IsNullOrEmpty(url))
    {
        throw ExceptionUtil.ParameterNullOrEmpty("url");
    }
    string script = "\r\n<script src=\"" + HttpUtility.HtmlAttributeEncode(url) + "\" type=\"text/javascript\"></script>";
    this.RegisterScriptBlock(CreateScriptIncludeKey(type, key, isResource), script, ClientAPIRegisterType.ClientScriptBlocks);
}

internal void RegisterScriptBlock(ScriptKey key, string script, ClientAPIRegisterType type)
{
    switch (type)
    {
        case ClientAPIRegisterType.ClientScriptBlocks:
            this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, false);
            break;

        case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
            this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, true);
            break;

        case ClientAPIRegisterType.ClientStartupScripts:
            this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, false);
            break;

        case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
            this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, true);
            break;
    }
    if (this._owner.PartialCachingControlStack != null)
    {
        foreach (BasePartialCachingControl control in this._owner.PartialCachingControlStack)
        {
            control.RegisterScriptBlock(type, key, script);
        }
    }
}


private void RegisterScriptBlock(ScriptKey key, string script, ref ListDictionary scriptBlocks, ref ArrayList scriptList, bool needsScriptTags)
{
    if (scriptBlocks == null)
    {
        scriptBlocks = new ListDictionary();
        scriptList = new ArrayList();
    }
    if (!scriptBlocks.Contains(key))
    {
        Tuple<ScriptKey, string, bool> tuple = new Tuple<ScriptKey, string, bool>(key, script, needsScriptTags);
        scriptBlocks.Add(key, null);
        scriptList.Add(tuple);
    }
}
内部无效注册表ClientScriptInclude(控件、类型、字符串键、字符串url)
{
IScriptManager scriptManager=this.\u owner.scriptManager;
if((scriptManager!=null)&&scriptManager.SupportsPartialRendering)
{
RegisterClientScriptInclude(控件、类型、键、url);
}
其他的
{
RegisterClientScriptInclude(类型、键、url);
}
}
内部无效注册表ClientScriptInclude(类型、字符串键、字符串url、bool isResource)
{
if(type==null)
{
抛出新的ArgumentNullException(“类型”);
}
if(string.IsNullOrEmpty(url))
{
抛出异常直到参数完全或空(“url”);
}
字符串脚本=“\r\n”;
RegisterScriptBlock(CreateScriptIncludeKey(类型、键、isResource)、script、ClientApireRegisterType.ClientScriptBlocks);
}
内部无效RegisterScriptBlock(ScriptKey键、字符串脚本、ClientApireRegisterType类型)
{
开关(类型)
{
案例ClientAPIRegisterType.ClientScriptBlocks:
this.RegisterScriptBlock(key,script,ref this.\u registeredClientScriptBlocks,ref this.\u clientScriptBlocks,false);
打破
案例客户端PiregisterType.ClientScriptBlocksWithoutTags:
this.RegisterScriptBlock(key,script,ref this.\u registeredClientScriptBlocks,ref this.\u clientScriptBlocks,true);
打破
案例ClientAPIRegisterType.ClientStartupScript:
this.RegisterScriptBlock(键,脚本,引用this.\u RegisteredClientStartupScript,引用this.\u ClientStartupScript,false);
打破
案例客户端PiRegisterType.ClientStartupScriptsWithoutTags:
this.RegisterScriptBlock(键,脚本,引用this.\u registeredclientstartupscript,引用this.\u clientstartupscript,true);
打破
}
if(this.\u owner.PartialCachingControlStack!=null)
{
foreach(基本部分计算机控制i