// Name: MicrosoftAjax.debug.js
// Assembly: System.Web.Extensions
// Version: 4.0.0.0
// FileVersion: 4.0.20526.0
//-----------------------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------
// MicrosoftAjax.js
// Microsoft AJAX Framework.
Function.__typeName = 'Function';
Function.__class = true;
Function.createCallback = function Function$createCallback(method, context) {
/// <summary locid="M:J#Function.createCallback" />
/// <param name="method" type="Function"></param>
/// <param name="context" mayBeNull="true"></param>
/// <returns type="Function"></returns>
var e = Function._validateParams(arguments, [
{name: "method", type: Function},
{name: "context", mayBeNull: true}
]);
if (e) throw e;
return function() {
var l = arguments.length;
if (l > 0) {
var args = [];
for (var i = 0; i < l; i++) {
args[i] = arguments[i];
}
args[l] = context;
return method.apply(this, args);
}
return method.call(this, context);
}
}
Function.createDelegate = function Function$createDelegate(instance, method) {
/// <summary locid="M:J#Function.createDelegate" />
/// <param name="instance" mayBeNull="true"></param>
/// <param name="method" type="Function"></param>
/// <returns type="Function"></returns>
var e = Function._validateParams(arguments, [
{name: "instance", mayBeNull: true},
{name: "method", type: Function}
]);
if (e) throw e;
return function() {
return method.apply(instance, arguments);
}
}
Function.emptyFunction = Function.emptyMethod = function Function$emptyMethod() {
/// <summary locid="M:J#Function.emptyMethod" />
}
Function.validateParameters = function Function$validateParameters(parameters, expectedParameters, validateParameterCount) {
/// <summary locid="M:J#Function.validateParameters" />
/// <param name="parameters"></param>
/// <param name="expectedParameters"></param>
/// <param name="validateParameterCount" type="Boolean" optional="true"></param>
/// <returns type="Error" mayBeNull="true"></returns>
var e = Function._validateParams(arguments, [
{name: "parameters"},
{name: "expectedParameters"},
{name: "validateParameterCount", type: Boolean, optional: true}
]);
if (e) throw e;
return Function._validateParams(parameters, expectedParameters, validateParameterCount);
}
Function._validateParams = function Function$_validateParams(params, expectedParams, validateParameterCount) {
var e, expectedLength = expectedParams.length;
validateParameterCount = validateParameterCount || (typeof(validateParameterCount) === "undefined");
e = Function._validateParameterCount(params, expectedParams, validateParameterCount);
if (e) {
e.popStackFrame();
return e;
}
for (var i = 0, l = params.length; i < l; i++) {
var expectedParam = expectedParams[Math.min(i, expectedLength - 1)],
paramName = expectedParam.name;
if (expectedParam.parameterArray) {
paramName += "[" + (i - expectedLength + 1) + "]";
}
else if (!validateParameterCount && (i >= expectedLength)) {
break;
}
e = Function._validateParameter(params[i], expectedParam, paramName);
if (e) {
e.popStackFrame();
return e;
}
}
return null;
}
Function._validateParameterCount = function Function$_validateParameterCount(params, expectedParams, validateParameterCount) {
var i, error,
expectedLen = expectedParams.length,
actualLen = params.length;
if (actualLen < expectedLen) {
var minParams = expectedLen;
for (i = 0; i < expectedLen; i++) {
var param = expectedParams[i];
if (param.optional || param.parameterArray) {
minParams--;
}
}
if (actualLen < minParams) {
error = true;
}
}
else if (validateParameterCount && (actualLen > expectedLen)) {
error = true;
for (i = 0; i < expectedLen; i++) {
if (expectedParams[i].parameterArray) {
error = false;
break;
}
}
}
if (error) {
var e = Error.parameterCount();
e.popStackFrame();
return e;
}
return null;
}
Function._validateParameter = function Function$_validateParameter(param, expectedParam, paramName) {
var e,
expectedType = expectedParam.type,
expectedInteger = !!expectedParam.integer,
expectedDomElement = !!expectedParam.domElement,
mayBeNull = !!expectedParam.mayBeNull;
e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName);
if (e) {
e.popStackFrame();
return e;
}
var expectedElementType = expectedParam.elementType,
elementMayBeNull = !!expectedParam.elementMayBeNull;
if (expectedType === Array && typeof(param) !== "undefined" && param !== null &&
(expectedElementType || !elementMayBeNull)) {
var expectedElementInteger = !!expectedParam.elementInteger,
expectedElementDomElement = !!expectedParam.elementDomElement;
for (var i=0; i < param.length; i++) {
var elem = param[i];
e = Function._validateParameterType(elem, expectedElementType,
expectedElementInteger, expectedElementDomElement, elementMayBeNull,
paramName + "[" + i + "]");
if (e) {
e.popStackFrame();
return e;
}
}
}
return null;
}
Function._validateParameterType = function Function$_validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName) {
var e, i;
if (typeof(param) === "undefined") {
if (mayBeNull) {
return null;
}
else {
e = Error.argumentUndefined(paramName);
e.popStackFrame();
return e;
}
}
if (param === null) {
if (mayBeNull) {
return null;
}
else {
e = Error.argumentNull(paramName);
e.popStackFrame();
return e;
}
}
if (expectedType && expectedType.__enum) {
if (typeof(param) !== 'number') {
e = Error.argumentType(paramName, Object.getType(param), expectedType);
e.popStackFrame();
return e;
}
if ((param % 1) === 0) {
var values = expectedType.prototype;
if (!expectedType.__flags || (param === 0)) {
for (i in values) {
if (values[i] === param) return null;
}
}
else {
var v = param;
for (i in values) {
var vali = values[i];
if (vali === 0) continue;
if ((vali & param) === vali) {
v -= vali;
}
if (v === 0) return null;
}
}
}
e = Error.argumentOutOfRange(paramName, param, String.format(Sys.Res.enumInvalidValue, param, expectedType.getName()));
e.popStackFrame();
return e;
}
if (expectedDomElement && (!Sys._isDomElement(param) || (param.nodeType === 3))) {
e = Error.argument(paramName, Sys.Res.argumentDomElement);
e.popStackFrame()