Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
//
// AsyncPostBackErrorEventArgs.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Web.UI
{
public class AsyncPostBackErrorEventArgs : EventArgs
{
Exception _exception;
public AsyncPostBackErrorEventArgs (Exception exception)
{
_exception = exception;
}
public Exception Exception {
get {
return _exception;
}
}
}
}

View File

@@ -0,0 +1,130 @@
//
// AsyncPostBackTrigger.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Reflection;
namespace System.Web.UI
{
public class AsyncPostBackTrigger : UpdatePanelControlTrigger
{
static readonly MethodInfo _eventHandler = typeof (AsyncPostBackTrigger).GetMethod ("OnEvent");
static readonly char[] _controlIdSeparators = {'_', '$'};
string _eventName;
public new string ControlID {
get {
return base.ControlID;
}
set {
base.ControlID = value;
}
}
[DefaultValue ("")]
[Category ("Behavior")]
public string EventName {
get {
if (_eventName == null)
return String.Empty;
return _eventName;
}
set {
_eventName = value;
}
}
protected internal override bool HasTriggered ()
{
Control ctrl = FindTargetControl (true);
string ctrlUniqueID = ctrl != null ? ctrl.UniqueID : null;
if (ctrlUniqueID == null)
return false;
string asyncPostBackElementID = Owner.ScriptManager.AsyncPostBackSourceElementID;
if (String.Compare (asyncPostBackElementID, ctrlUniqueID, StringComparison.Ordinal) == 0)
return true;
else {
int sep = asyncPostBackElementID.IndexOfAny (_controlIdSeparators);
if (sep > -1 && String.Compare (asyncPostBackElementID, 0, ctrlUniqueID, 0, ctrlUniqueID.Length, StringComparison.Ordinal) == 0)
return true;
}
return false;
}
protected internal override void Initialize ()
{
Control c = FindTargetControl (true);
ScriptManager sm = Owner.ScriptManager;
string eventName = EventName;
if (String.IsNullOrEmpty (eventName)) {
object[] attrs = c.GetType ().GetCustomAttributes (typeof (DefaultEventAttribute), true);
if (attrs != null && attrs.Length > 0) {
var dea = attrs [0] as DefaultEventAttribute;
if (dea != null)
eventName = dea.Name;
}
}
if (!String.IsNullOrEmpty (eventName)) {
EventInfo evi = c.GetType ().GetEvent (eventName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
if (evi == null)
throw new InvalidOperationException (String.Format ("Could not find an event named '{0}' on associated control '{1}' for the trigger in UpdatePanel '{2}'.", eventName, c.ID, Owner.ID));
Delegate d = null;
try {
d = Delegate.CreateDelegate (evi.EventHandlerType, this, _eventHandler);
}
catch (ArgumentException) {
throw new InvalidOperationException (String.Format ("The event '{0}' in '{1}' for the control '{2}' does not match a standard event handler signature.", eventName, c.GetType (), c.ID));
}
evi.AddEventHandler (c, d);
}
sm.RegisterAsyncPostBackControl (c);
}
public void OnEvent (object sender, EventArgs e)
{
UpdatePanel owner = Owner;
if (owner != null && owner.UpdateMode != UpdatePanelUpdateMode.Always)
owner.Update ();
}
public override string ToString () {
return String.Format ("AsyncPostBackTrigger: {0}.{1}", ControlID, EventName);
}
}
}

View File

@@ -0,0 +1,56 @@
//
// AuthenticationServiceManager.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace System.Web.UI
{
[DefaultProperty ("Path")]
public class AuthenticationServiceManager
{
string _path;
[Category ("Behavior")]
[NotifyParentProperty (true)]
[DefaultValue ("")]
public string Path {
get {
if (_path == null)
return String.Empty;
return _path;
}
set {
_path = value;
}
}
}
}

View File

@@ -0,0 +1,162 @@
2010-02-02 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: adjusted script rendering to match .NET
formatting.
* ScriptComponentDescriptor.cs: GetScript adds ID value (if
present) to the set of properties.
GetScript rewritten to use StringBuilder.
* ScriptBehaviorDescriptor.cs: GetScript adds Name, if present and
set by the user, to the descriptor's set of properties. The name
must be rendered to the client.
2009-09-28 Marek Habersack <mhabersack@novell.com>
* UpdatePanel.cs: RenderChildren stores the alternative writer in
a private property, for the benefit of nested child panels. Fixes
bug #542441
* ScriptManager.cs: don't render invisible panel IDs during async
request. Fixes bug #542533
2009-05-26 Marek Habersack <mhabersack@novell.com>
* ScriptReferenceBase.cs: implemented (3.5 SP1)
* ScriptReference.cs: now inherits from the ScriptReferenceBase
class. Implemented all the required methods, removed some
properties which now live in the base class.
* ScriptManager.cs: code refactoring - moved parts of script
registration code to ScriptReference
2009-04-23 Marek Habersack <mhabersack@novell.com>
* AsyncPostBackTrigger.cs: HasTriggered () must look up the
UniqueID of the control specified in the ControlID property or
otherwise it may miss certain triggers.
2009-04-11 Marek Habersack <mhabersack@novell.com>
* UpdatePanel.cs: implemented SingleChildControlCollection to be
used in CreateControlCollection ().
RequiresUpdate not only checks the update mode and explicit update
requests, but also looks if any triggers fired.
Initialize () initializes triggers only if partial rendering is
supported by the ScriptManager.
IsInPartialRendering property no longer returns the value of
ScriptManager.IsInPartialRendering. Instead, it relies on the
value of instance field which can be set using new internal
SetInPartialRendering () method (called from
ScriptManager.RenderPageCallback ())
Simplified the logic in RenderChildren ().
* ScriptManager.cs: no need to register panels for refresh in
OnPreRenderComplete, this is now done in RenderPageCallback.
Modified HasBeenRendered () so that it doesn't query whether the
panel has been explicitly updated by the user, but checks whether
panel is in the list of panels to refresh.
RaisePostDataChangedEvent () doesn't update the panel whose id is
named in the POST request for refresh. This is handled in
RenderPageCallback.
Reverted the changes to WriteCallbackPanel and RenderFormCallback
committed in r129774.
RenderPageCallback now correctly detects panels to be refreshed
(and thus included in the async response).
* AsyncPostBackTrigger.cs, PostBackTrigger.cs: implemented
HasTriggered ().
2009-04-08 Marek Habersack <mhabersack@novell.com>
* ScriptComponentDescriptor.cs: properties/events/references must
be serialized in alphabetical order. This matches what .NET
does. Some 3rd party controls depend upon this fact.
2009-04-07 Marek Habersack <mhabersack@novell.com>
* ScriptComponentDescriptor.cs: new values replace old in
AddEntry.
2009-03-19 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: WriteCallbackPanel is called from
UpdatePanel.RenderChildren and should not output anything for
panels registered as the ones to refresh. If such a panel calls
this method, its output is stored in a dictionary to be used later
in RenderFormCallback.
RenderFormCallback first renders all the form controls. In that
process UpdatePanel instances, if any, may call
WriteCallbackPanel. After that, if there are panels registered for
refresh, another loop over the list is made this time checking
whether any panels left their output in WriteCallbackPanel. If a
panel hasn't done it it is rendered. And last, another check is
done to see if the loop described above caused any panels to leave
output in WriteCallbackPanel. If yes, the output is written to the
text writer.
2009-01-26 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: before registering script service reference
check if the service type is decorated with the [ScriptService]
custom attribute. Only such service types can be called from
client JavaScript.
2008-10-02 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: reverting revision 114552 since the real bug
was somewhere else. The correct fix is to make sure UpdatePanels
which output something _or_ have been named in the POST request as
requiring a refresh are marked as such. Only in that situation
HasBeenRendered returns true (as it should for those panels)
Cosmetical output change - the hidden fields are output after the
update panels contents is sent in an async request. It makes the
async response look similar to the MS.NET's one but, more
importantly, makes debugging easier.
2008-09-23 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: CultureInfoSerializer no longer derives from
the obsolete LazyDictionary.
2008-09-01 Marek Habersack <mhabersack@novell.com>
* UpdatePanel.cs: if the writer passed to RenderChildren is not
derived from ScriptManager.AlternativeHtmlTextWriter, check
whether its InnerWriter derives from that type and, if yes, use
it from that point onwards.
2008-08-13 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: always request the webform.js script to be
present. It may happen that a control during a dynamic update will
need to call one of the WebForm_* functions and the call will fail
as the script will be absent.
If debugging is enabled, send the full exception backtrace in
WriteCallbackException - helps debugging AJAX errors.
2008-08-08 Marek Habersack <mhabersack@novell.com>
* UpdatePanel.cs: do not check whether a panel whose children are
to be rendered has been marked for update in the async postback
mode. It prevents complex scenarios where there is one superior
update panel which owns an inferior one, and only the superior one
has Update called on it.
2008-06-05 Marek Habersack <mhabersack@novell.com>
* ScriptManager.cs: do not throw NREX when there are no profile or
authentication service sections in the config files.
2008-05-15 Marek Habersack <mhabersack@novell.com>
* AsyncPostBackTrigger.cs: don't thrown an exception if EventName
is null or empty and there is no DefaultEventAttribute attached to
the control.
2008-05-14 Marek Habersack <mhabersack@novell.com>
* ScriptComponentDescriptor.cs: do not add the same
entry twice to a dictionary.

View File

@@ -0,0 +1,73 @@
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2011 Novell, Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Reflection;
using System.Web.Hosting;
namespace System.Web.UI
{
sealed class CompositeEntry
{
public Assembly Assembly;
public string NameOrPath;
public WebResourceAttribute Attribute;
string GetFilePath ()
{
if (Assembly != null)
return Assembly.Location;
else if (!String.IsNullOrEmpty (NameOrPath))
return HostingEnvironment.MapPath (NameOrPath);
else
return String.Empty;
}
public bool IsModifiedSince (DateTime since)
{
return File.GetLastWriteTimeUtc (GetFilePath ()) > since;
}
public bool IsModifiedSince (long atime)
{
return File.GetLastWriteTimeUtc (GetFilePath ()).Ticks > atime;
}
public override int GetHashCode ()
{
int ret = 0;
if (Assembly != null)
ret ^= Assembly.GetHashCode ();
if (NameOrPath != null)
ret ^= NameOrPath.GetHashCode ();
return ret;
}
}
}

View File

@@ -0,0 +1,178 @@
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2011 Novell, Inc (http://novell.com/)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_3_5
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Handlers;
using System.Web.Hosting;
namespace System.Web.UI
{
[DefaultProperty ("Path")]
public class CompositeScriptReference : ScriptReferenceBase
{
public const string COMPOSITE_SCRIPT_REFERENCE_PREFIX = "CSR:";
static SplitOrderedList <string, List <CompositeEntry>> entriesCache;
ScriptReferenceCollection scripts;
[PersistenceMode (PersistenceMode.InnerProperty)]
[Editor ("System.Web.UI.Design.CollectionEditorBase, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Design)]
[MergableProperty (false)]
[Category ("Behavior")]
[DefaultValue (null)]
[NotifyParentProperty (true)]
public ScriptReferenceCollection Scripts {
get {
if (scripts == null)
scripts = new ScriptReferenceCollection ();
return scripts;
}
}
static CompositeScriptReference ()
{
entriesCache = new SplitOrderedList <string, List <CompositeEntry>> (StringComparer.Ordinal);
}
internal static List <CompositeEntry> GetCompositeScriptEntries (string url)
{
if (String.IsNullOrEmpty (url) || entriesCache.Count == 0)
return null;
List <CompositeEntry> ret;
if (!entriesCache.Find ((uint)url.GetHashCode (), url, out ret))
return null;
return ret;
}
protected internal override string GetUrl (ScriptManager scriptManager, bool zip)
{
if (scriptManager == null)
// .NET emulation...
throw new NullReferenceException (".NET emulation");
var url = new StringBuilder (COMPOSITE_SCRIPT_REFERENCE_PREFIX);
string path;
string name;
CompositeEntry entry;
List <CompositeEntry> entries = null;
WebResourceAttribute wra;
foreach (ScriptReference sr in Scripts) {
if (sr == null)
continue;
name = sr.Name;
if (!String.IsNullOrEmpty (name)) {
Assembly assembly = sr.ResolvedAssembly;
name = GetScriptName (name, sr.IsDebugMode (scriptManager), null, assembly, out wra);
path = scriptManager.ScriptPath;
if (sr.IgnoreScriptPath || String.IsNullOrEmpty (path)) {
entry = new CompositeEntry {
Assembly = assembly,
NameOrPath = name,
Attribute = wra
};
} else {
AssemblyName an = assembly.GetName ();
entry = new CompositeEntry {
NameOrPath = String.Concat (VirtualPathUtility.AppendTrailingSlash (path), an.Name, '/', an.Version, '/', name),
Attribute = wra
};
}
} else if (!String.IsNullOrEmpty ((path = sr.Path))) {
bool notFound = false;
name = GetScriptName (path, sr.IsDebugMode (scriptManager), scriptManager.EnableScriptLocalization ? ResourceUICultures : null, null, out wra);
if (!HostingEnvironment.HaveCustomVPP)
notFound = !File.Exists (HostingEnvironment.MapPath (name));
else
notFound = !HostingEnvironment.VirtualPathProvider.FileExists (name);
if (notFound)
throw new HttpException ("Web resource '" + name + "' was not found.");
entry = new CompositeEntry {
NameOrPath = name
};
} else
entry = null;
if (entry != null) {
if (entries == null)
entries = new List <CompositeEntry> ();
entries.Add (entry);
url.Append (entry.GetHashCode ().ToString ("x"));
entry = null;
}
}
if (entries == null || entries.Count == 0)
return String.Empty;
string ret = ScriptResourceHandler.GetResourceUrl (ThisAssembly, url.ToString (), NotifyScriptLoaded);
entriesCache.InsertOrUpdate ((uint)ret.GetHashCode (), ret, entries, entries);
return ret;
}
#if NET_4_0
protected internal override bool IsAjaxFrameworkScript (ScriptManager scriptManager)
{
return false;
}
[Obsolete ("Use IsAjaxFrameworkScript(ScriptManager)")]
#endif
protected internal override bool IsFromSystemWebExtensions ()
{
if (scripts == null || scripts.Count == 0)
return false;
Assembly myAssembly = ThisAssembly;
foreach (ScriptReference sr in scripts)
if (sr.ResolvedAssembly == myAssembly)
return true;
return false;
}
internal bool HaveScripts ()
{
return (scripts != null && scripts.Count > 0);
}
}
}
#endif

View File

@@ -0,0 +1,53 @@
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2010 Novell, Inc (http://novell.com/)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_3_5
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
namespace System.Web.UI
{
public class CompositeScriptReferenceEventArgs : EventArgs
{
public CompositeScriptReference CompositeScript {
get; private set;
}
public CompositeScriptReferenceEventArgs (CompositeScriptReference compositeScript)
{
this.CompositeScript = compositeScript;
}
}
}
#endif

View File

@@ -0,0 +1,116 @@
//
// ExtenderControl.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace System.Web.UI
{
[DefaultProperty ("TargetControlID")]
[ParseChildren (true)]
[NonVisualControl]
[PersistChildren (false)]
public abstract class ExtenderControl : Control, IExtenderControl
{
ScriptManager _scriptManager;
string _targetControlID;
protected ExtenderControl () { }
[DefaultValue ("")]
[IDReferenceProperty]
[Category ("Behavior")]
public string TargetControlID {
get {
if (_targetControlID == null)
return String.Empty;
return _targetControlID;
}
set { _targetControlID = value; }
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[EditorBrowsable (EditorBrowsableState.Never)]
public override bool Visible {
get {
return base.Visible;
}
set {
throw new NotImplementedException ();
}
}
ScriptManager ScriptManager {
get {
if (_scriptManager == null) {
_scriptManager = ScriptManager.GetCurrent (Page);
if (_scriptManager == null)
throw new InvalidOperationException (String.Format ("The control with ID '{0}' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.", ID));
}
return _scriptManager;
}
}
protected abstract IEnumerable<ScriptDescriptor> GetScriptDescriptors (Control targetControl);
protected abstract IEnumerable<ScriptReference> GetScriptReferences ();
protected internal override void OnPreRender (EventArgs e) {
base.OnPreRender (e);
if (String.IsNullOrEmpty (TargetControlID))
throw new InvalidOperationException (String.Format ("The TargetControlID of '{0}' is not valid. The value cannot be null or empty.", ID));
Control c = FindControl (TargetControlID);
if (c == null)
throw new InvalidOperationException (String.Format ("The TargetControlID of '{0}' is not valid. A control with ID '{1}' could not be found.", ID, TargetControlID));
ScriptManager.RegisterExtenderControl (this, c);
}
protected internal override void Render (HtmlTextWriter writer) {
ScriptManager.RegisterScriptDescriptors (this);
base.Render (writer);
}
#region IExtenderControl Members
IEnumerable<ScriptDescriptor> IExtenderControl.GetScriptDescriptors (Control targetControl) {
return GetScriptDescriptors (targetControl);
}
IEnumerable<ScriptReference> IExtenderControl.GetScriptReferences () {
return GetScriptReferences ();
}
#endregion
}
}

View File

@@ -0,0 +1,41 @@
//
// IExtenderControl.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Web.UI
{
public interface IExtenderControl
{
IEnumerable<ScriptDescriptor> GetScriptDescriptors (Control targetControl);
IEnumerable<ScriptReference> GetScriptReferences ();
}
}

View File

@@ -0,0 +1,41 @@
//
// IScriptControl.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Web.UI
{
public interface IScriptControl
{
IEnumerable<ScriptDescriptor> GetScriptDescriptors ();
IEnumerable<ScriptReference> GetScriptReferences ();
}
}

View File

@@ -0,0 +1,64 @@
//
// PostBackTrigger.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Web.UI
{
public class PostBackTrigger : UpdatePanelControlTrigger
{
public new string ControlID {
get {
return base.ControlID;
}
set {
base.ControlID = value;
}
}
protected internal override bool HasTriggered ()
{
// Since this kind of trigger causes a normal postback, we never get
// triggered
return false;
}
protected internal override void Initialize () {
Control c = FindTargetControl (false);
ScriptManager sm = Owner.ScriptManager;
sm.RegisterPostBackControl (c);
}
public override string ToString () {
return String.Format ("PostBack: {0}", ControlID);
}
}
}

View File

@@ -0,0 +1,72 @@
//
// ProfileServiceManager.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
namespace System.Web.UI
{
[DefaultProperty ("Path")]
public class ProfileServiceManager
{
string _path;
[DefaultValue ("")]
[NotifyParentProperty (true)]
[Category ("Behavior")]
[TypeConverter (typeof (StringArrayConverter))]
public string [] LoadProperties {
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
[NotifyParentProperty (true)]
[Category ("Behavior")]
[DefaultValue ("")]
public string Path {
get {
if (_path == null)
return String.Empty;
return _path;
}
set {
_path = value;
}
}
}
}

View File

@@ -0,0 +1,58 @@
//
// RegisteredArrayDeclaration.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public sealed class RegisteredArrayDeclaration
{
readonly Control _control;
readonly string _name;
readonly string _value;
internal RegisteredArrayDeclaration (Control control, string name, string value) {
_control = control;
_name = name;
_value = value;
}
public Control Control {
get { return _control; }
}
public string Name {
get { return _name; }
}
public string Value {
get { return _value; }
}
}
}

View File

@@ -0,0 +1,58 @@
//
// RegisteredDisposeScript.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public sealed class RegisteredDisposeScript
{
readonly Control _control;
readonly UpdatePanel _updatePanel;
readonly string _script;
internal RegisteredDisposeScript (Control control, string script, UpdatePanel updatePanel) {
_control = control;
_script = script;
_updatePanel = updatePanel;
}
public Control Control {
get { return _control; }
}
public string Script {
get { return _script; }
}
internal UpdatePanel UpdatePanel {
get { return _updatePanel; }
}
}
}

View File

@@ -0,0 +1,70 @@
//
// RegisteredArrayDeclaration.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public sealed class RegisteredExpandoAttribute
{
readonly Control _control;
readonly string _controlId;
readonly bool _encode;
readonly string _name;
readonly string _value;
internal RegisteredExpandoAttribute (Control control, string controlId, string name, string value, bool encode) {
_control = control;
_name = name;
_value = value;
_controlId = controlId;
_encode = encode;
}
public Control Control {
get { return _control; }
}
public string Name {
get { return _name; }
}
public string Value {
get { return _value; }
}
public string ControlId {
get { return _controlId; }
}
public bool Encode {
get { return _encode; }
}
}
}

View File

@@ -0,0 +1,58 @@
//
// RegisteredHiddenField.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public sealed class RegisteredHiddenField
{
readonly Control _control;
readonly string _name;
readonly string _initialValue;
internal RegisteredHiddenField (Control control, string name, string initialValue) {
_control = control;
_name = name;
_initialValue = initialValue;
}
public Control Control {
get { return _control; }
}
public string Name {
get { return _name; }
}
public string InitialValue {
get { return _initialValue; }
}
}
}

View File

@@ -0,0 +1,82 @@
//
// RegisteredScript.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public sealed class RegisteredScript
{
readonly Control _control;
readonly bool _addScriptTags;
readonly string _key;
readonly string _script;
readonly RegisteredScriptType _scriptType;
readonly Type _type;
readonly string _url;
internal RegisteredScript (Control control, Type type, string key, string script, string url, bool addScriptTag, RegisteredScriptType scriptType) {
_control = control;
_type = type;
_script = script;
_url = url;
_addScriptTags = addScriptTag;
_scriptType = scriptType;
_key = key;
}
public bool AddScriptTags {
get { return _addScriptTags; }
}
public Control Control {
get { return _control; }
}
public string Key {
get { return _key; }
}
public string Script {
get { return _script; }
}
public RegisteredScriptType ScriptType {
get { return _scriptType; }
}
public Type Type {
get { return _type; }
}
public string Url {
get { return _url; }
}
}
}

View File

@@ -0,0 +1,41 @@
//
// RegisteredScriptType.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI
{
public enum RegisteredScriptType
{
ClientScriptInclude = 0,
ClientScriptBlock = 1,
ClientStartupScript = 2,
OnSubmitStatement = 3,
}
}

View File

@@ -0,0 +1,91 @@
//
// ScriptBehaviorDescriptor.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Web.UI
{
public class ScriptBehaviorDescriptor : ScriptComponentDescriptor
{
string _name;
bool _nameSet;
public ScriptBehaviorDescriptor (string type, string elementID)
: base (type) {
if (String.IsNullOrEmpty (elementID))
throw new ArgumentException ("Value cannot be null or empty.", "elementID");
ElementIDInternal = elementID;
}
public override string ClientID {
get {
string clientId = base.ClientID;
if (String.IsNullOrEmpty (clientId))
return String.Format ("{0}${1}", ElementID, Name);
return clientId;
}
}
public string ElementID {
get {
return ElementIDInternal;
}
}
public string Name {
get {
if (String.IsNullOrEmpty (_name))
_name = GetNameFromType (Type);
return _name;
}
set {
_name = value;
_nameSet = true;
}
}
static string GetNameFromType (string Type) {
int lastIndex = Type.LastIndexOf ('.') + 1;
if (lastIndex > 0 && lastIndex < Type.Length)
return Type.Substring (lastIndex);
return Type;
}
protected internal override string GetScript ()
{
if (_nameSet && !String.IsNullOrEmpty (_name))
AddProperty ("name", _name);
return base.GetScript ();
}
}
}

View File

@@ -0,0 +1,205 @@
//
// ScriptComponentDescriptor.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Script.Serialization;
namespace System.Web.UI
{
public class ScriptComponentDescriptor : ScriptDescriptor
{
string _elementID;
string _type;
string _id;
IDictionary<string, string> _properties;
IDictionary<string, string> _events;
IDictionary<string, string> _references;
public ScriptComponentDescriptor (string type) {
if (String.IsNullOrEmpty (type))
throw new ArgumentException ("Value cannot be null or empty.", "type");
_type = type;
}
public virtual string ClientID {
get {
return ID;
}
}
internal string ElementIDInternal {
get {
return _elementID;
}
set {
_elementID = value;
}
}
public virtual string ID {
get {
if (_id == null)
return String.Empty;
return _id;
}
set {
_id = value;
}
}
public string Type {
get {
return _type;
}
set {
if (String.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", "value");
_type = value;
}
}
public void AddComponentProperty (string name, string componentID) {
if (name == null)
throw new ArgumentException ("Value cannot be null or empty.", "name");
if (componentID == null)
throw new ArgumentException ("Value cannot be null or empty.", "componentID");
AddEntry (ref _references, String.Format ("\"{0}\"", name), String.Format ("\"{0}\"", componentID));
}
public void AddElementProperty (string name, string elementID) {
if (name == null)
throw new ArgumentException ("Value cannot be null or empty.", "name");
if (elementID == null)
throw new ArgumentException ("Value cannot be null or empty.", "elementID");
AddEntry (ref _properties, String.Format ("\"{0}\"", name), String.Format ("$get(\"{0}\")", elementID));
}
public void AddEvent (string name, string handler) {
if (name == null)
throw new ArgumentException ("Value cannot be null or empty.", "name");
if (handler == null)
throw new ArgumentException ("Value cannot be null or empty.", "handler");
AddEntry (ref _events, String.Format ("\"{0}\"", name), handler);
}
public void AddProperty (string name, object value) {
if (name == null)
throw new ArgumentException ("Value cannot be null or empty.", "name");
string valueString;
if (value == null)
valueString = "null";
else
valueString = JavaScriptSerializer.DefaultSerializer.Serialize (value);
AddEntry (ref _properties, String.Format ("\"{0}\"", name), valueString);
}
public void AddScriptProperty (string name, string script) {
if (name == null)
throw new ArgumentException ("Value cannot be null or empty.", "name");
if (script == null)
throw new ArgumentException ("Value cannot be null or empty.", "script");
AddEntry (ref _properties, String.Format ("\"{0}\"", name), script);
}
void AddEntry (ref IDictionary<string, string> dictionary, string key, string value) {
if (dictionary == null)
dictionary = new SortedDictionary<string, string> ();
if (!dictionary.ContainsKey (key))
dictionary.Add (key, value);
else
dictionary [key] = value;
}
protected internal override string GetScript ()
{
string id = ID;
if (id != String.Empty)
AddProperty ("id", id);
bool haveFormID = String.IsNullOrEmpty (FormID) == false;
bool haveElementID = String.IsNullOrEmpty (ElementIDInternal) == false;
var sb = new StringBuilder ("$create(");
if (haveFormID)
sb.Append ("$get(\"");
sb.Append (Type);
if (haveFormID)
sb.Append ("\")");
WriteSerializedProperties (sb);
WriteSerializedEvents (sb);
WriteSerializedReferences (sb);
if (haveElementID)
sb.AppendFormat (", $get(\"{0}\")", ElementIDInternal);
sb.Append (");");
return sb.ToString ();
}
internal static string SerializeDictionary (IDictionary<string, string> dictionary)
{
if (dictionary == null || dictionary.Count == 0)
return "null";
StringBuilder sb = new StringBuilder ("{");
foreach (string key in dictionary.Keys)
sb.AppendFormat ("{0}:{1},", key, dictionary [key]);
sb.Length--;
sb.Append ("}");
return sb.ToString ();
}
void WriteSerializedProperties (StringBuilder sb)
{
sb.Append (", ");
sb.Append (SerializeDictionary (_properties));
}
void WriteSerializedEvents (StringBuilder sb)
{
sb.Append (", ");
sb.Append (SerializeDictionary (_events));
}
void WriteSerializedReferences (StringBuilder sb)
{
sb.Append (", ");
sb.Append (SerializeDictionary (_references));
}
}
}

Some files were not shown because too many files have changed in this diff Show More