protected internal virtual void OnClientInit(bool reinit)
{
if ((this.init && !reinit) || this.DeferInitScriptGeneration)
{
return;
}
this.EnsureChildControls();
if (!this.DesignMode && !(this is Layout))
{
if(!this.init)
{
this.ResourceManager.RegisterInitID(this);
}
if (this is Observable)
{
if (this.IsLazy)
{
if (this is LazyObservable)
{
Plugin p = this as Plugin;
if (p != null && p.Singleton)
{
this.clientInitScript = this.InstanceOf;
}
else if (!(this is ICustomConfigSerialization))
{
string template = "this.{0}=new {1}({2})";
this.clientInitScript = string.Format(template, this.ClientID, this.InstanceOf, this.InitialConfig);
}
else
{
this.clientInitScript = ((ICustomConfigSerialization) this).ToScript(this);
}
}
else
{
this.clientInitScript = this.LazyMode == LazyMode.Instance ? "new {0}({1})".FormatWith(this.InstanceOf, this.InitialConfig) : this.InitialConfig;
}
}
else
{
this.clientInitScript = this.GetClientConstructor();
}
}
}
this.init = true;
}