📄 microsoftajax.debug.js
字号:
/// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
/// <param name="message" type="String" optional="true" mayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "paramName", type: String, mayBeNull: true, optional: true},
{name: "message", type: String, mayBeNull: true, optional: true}
]);
if (e) throw e;
var displayMessage = "Sys.ArgumentUndefinedException: " + (message ? message : Sys.Res.argumentUndefined);
if (paramName) {
displayMessage += "\n" + String.format(Sys.Res.paramName, paramName);
}
var e = Error.create(displayMessage, { name: "Sys.ArgumentUndefinedException", paramName: paramName });
e.popStackFrame();
return e;
}
Error.format = function Error$format(message) {
/// <param name="message" type="String" optional="true" mayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "message", type: String, mayBeNull: true, optional: true}
]);
if (e) throw e;
var displayMessage = "Sys.FormatException: " + (message ? message : Sys.Res.format);
var e = Error.create(displayMessage, {name: 'Sys.FormatException'});
e.popStackFrame();
return e;
}
Error.invalidOperation = function Error$invalidOperation(message) {
/// <param name="message" type="String" optional="true" mayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "message", type: String, mayBeNull: true, optional: true}
]);
if (e) throw e;
var displayMessage = "Sys.InvalidOperationException: " + (message ? message : Sys.Res.invalidOperation);
var e = Error.create(displayMessage, {name: 'Sys.InvalidOperationException'});
e.popStackFrame();
return e;
}
Error.notImplemented = function Error$notImplemented(message) {
/// <param name="message" type="String" optional="true" mayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "message", type: String, mayBeNull: true, optional: true}
]);
if (e) throw e;
var displayMessage = "Sys.NotImplementedException: " + (message ? message : Sys.Res.notImplemented);
var e = Error.create(displayMessage, {name: 'Sys.NotImplementedException'});
e.popStackFrame();
return e;
}
Error.parameterCount = function Error$parameterCount(message) {
/// <param name="message" type="String" optional="true" mayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "message", type: String, mayBeNull: true, optional: true}
]);
if (e) throw e;
var displayMessage = "Sys.ParameterCountException: " + (message ? message : Sys.Res.parameterCount);
var e = Error.create(displayMessage, {name: 'Sys.ParameterCountException'});
e.popStackFrame();
return e;
}
Error.prototype.popStackFrame = function Error$popStackFrame() {
if (arguments.length !== 0) throw Error.parameterCount();
if (typeof(this.stack) === "undefined" || this.stack === null ||
typeof(this.fileName) === "undefined" || this.fileName === null ||
typeof(this.lineNumber) === "undefined" || this.lineNumber === null) {
return;
}
var stackFrames = this.stack.split("\n");
var currentFrame = stackFrames[0];
var pattern = this.fileName + ":" + this.lineNumber;
while(typeof(currentFrame) !== "undefined" &&
currentFrame !== null &&
currentFrame.indexOf(pattern) === -1) {
stackFrames.shift();
currentFrame = stackFrames[0];
}
var nextFrame = stackFrames[1];
if (typeof(nextFrame) === "undefined" || nextFrame === null) {
return;
}
var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/);
if (typeof(nextFrameParts) === "undefined" || nextFrameParts === null) {
return;
}
this.fileName = nextFrameParts[1];
this.lineNumber = parseInt(nextFrameParts[2]);
stackFrames.shift();
this.stack = stackFrames.join("\n");
}
if (!window) this.window = this;
window.Type = Function;
window.__rootNamespaces = [];
window.__registeredTypes = {};
Type.__fullyQualifiedIdentifierRegExp = new RegExp("^[^.0-9 \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]([^ \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]*[^. \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\])?$", "i");
Type.__identifierRegExp = new RegExp("^[^.0-9 \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\][^. \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]*$", "i");
Type.prototype.callBaseMethod = function Type$callBaseMethod(instance, name, baseArguments) {
/// <param name="instance"></param>
/// <param name="name" type="String"></param>
/// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "instance"},
{name: "name", type: String},
{name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true}
]);
if (e) throw e;
var baseMethod = this.getBaseMethod(instance, name);
if (!baseMethod) throw Error.invalidOperation(String.format(Sys.Res.methodNotFound, name));
if (!baseArguments) {
return baseMethod.apply(instance);
}
else {
return baseMethod.apply(instance, baseArguments);
}
}
Type.prototype.getBaseMethod = function Type$getBaseMethod(instance, name) {
/// <param name="instance"></param>
/// <param name="name" type="String"></param>
/// <returns type="Function" mayBeNull="true"></returns>
var e = Function._validateParams(arguments, [
{name: "instance"},
{name: "name", type: String}
]);
if (e) throw e;
if (!this.isInstanceOfType(instance)) throw Error.argumentType('instance', Object.getType(instance), this);
var baseType = this.getBaseType();
if (baseType) {
var baseMethod = baseType.prototype[name];
return (baseMethod instanceof Function) ? baseMethod : null;
}
return null;
}
Type.prototype.getBaseType = function Type$getBaseType() {
/// <returns type="Type" mayBeNull="true"></returns>
if (arguments.length !== 0) throw Error.parameterCount();
return (typeof(this.__baseType) === "undefined") ? null : this.__baseType;
}
Type.prototype.getInterfaces = function Type$getInterfaces() {
/// <returns type="Array" elementType="Type" mayBeNull="false" elementMayBeNull="false"></returns>
if (arguments.length !== 0) throw Error.parameterCount();
var result = [];
var type = this;
while(type) {
var interfaces = type.__interfaces;
if (interfaces) {
for (var i = 0, l = interfaces.length; i < l; i++) {
var interfaceType = interfaces[i];
if (!Array.contains(result, interfaceType)) {
result[result.length] = interfaceType;
}
}
}
type = type.__baseType;
}
return result;
}
Type.prototype.getName = function Type$getName() {
/// <returns type="String"></returns>
if (arguments.length !== 0) throw Error.parameterCount();
return (typeof(this.__typeName) === "undefined") ? "" : this.__typeName;
}
Type.prototype.implementsInterface = function Type$implementsInterface(interfaceType) {
/// <param name="interfaceType" type="Type"></param>
/// <returns type="Boolean"></returns>
var e = Function._validateParams(arguments, [
{name: "interfaceType", type: Type}
]);
if (e) throw e;
this.resolveInheritance();
var interfaceName = interfaceType.getName();
var cache = this.__interfaceCache;
if (cache) {
var cacheEntry = cache[interfaceName];
if (typeof(cacheEntry) !== 'undefined') return cacheEntry;
}
else {
cache = this.__interfaceCache = {};
}
var baseType = this;
while (baseType) {
var interfaces = baseType.__interfaces;
if (interfaces) {
if (Array.indexOf(interfaces, interfaceType) !== -1) {
return cache[interfaceName] = true;
}
}
baseType = baseType.__baseType;
}
return cache[interfaceName] = false;
}
Type.prototype.inheritsFrom = function Type$inheritsFrom(parentType) {
/// <param name="parentType" type="Type"></param>
/// <returns type="Boolean"></returns>
var e = Function._validateParams(arguments, [
{name: "parentType", type: Type}
]);
if (e) throw e;
this.resolveInheritance();
var baseType = this.__baseType;
while (baseType) {
if (baseType === parentType) {
return true;
}
baseType = baseType.__baseType;
}
return false;
}
Type.prototype.initializeBase = function Type$initializeBase(instance, baseArguments) {
/// <param name="instance"></param>
/// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true"></param>
/// <returns></returns>
var e = Function._validateParams(arguments, [
{name: "instance"},
{name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true}
]);
if (e) throw e;
if (!this.isInstanceOfType(instance)) throw Error.argumentType('instance', Object.getType(instance), this);
this.resolveInheritance();
if (this.__baseType) {
if (!baseArguments) {
this.__baseType.apply(instance);
}
else {
this.__baseType.apply(instance, baseArguments);
}
}
return instance;
}
Type.prototype.isImplementedBy = function Type$isImplementedBy(instance) {
/// <param name="instance" mayBeNull="true"></param>
/// <returns type="Boolean"></returns>
var e = Function._validateParams(arguments, [
{name: "instance", mayBeNull: true}
]);
if (e) throw e;
if (typeof(instance) === "undefined" || instance === null) return false;
var instanceType = Object.getType(instance);
return !!(instanceType.implementsInterface && instanceType.implementsInterface(this));
}
Type.prototype.isInstanceOfType = function Type$isInstanceOfType(instance) {
/// <param name="instance" mayBeNull="true"></param>
/// <returns type="Boolean"></returns>
var e = Function._validateParams(arguments, [
{name: "instance", mayBeNull: true}
]);
if (e) throw e;
if (typeof(instance) === "undefined" || instance === null) return false;
if (instance instanceof this) return true;
var instanceType = Object.getType(instance);
return !!(instanceType === this) ||
(instanceType.inheritsFrom && instanceType.inheritsFrom(this)) ||
(instanceType.implementsInterface && instanceType.implementsInterface(this));
}
Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) {
/// <param name="typeName" type="String"></param>
/// <param name="baseType" type="Type" optional="true" mayBeNull="true"></param>
/// <param name="interfaceTypes" parameterArray="true" type="Type"></param>
/// <returns type="Type"></returns>
var e = Function._validateParams(arguments, [
{name: "typeName", type: String},
{name: "baseType", type: Type, mayBeNull: true, optional: true},
{name: "interfaceTypes", type: Type, parameterArray: true}
]);
if (e) throw e;
if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName);
var parsedName;
try {
parsedName = eval(typeName);
}
catch(e) {
throw Error.argument('typeName', Sys.Res.argumentTypeName);
}
if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName);
if (window.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName));
if ((arguments.length > 1) && (typeof(baseType) === 'undefined')) throw Error.argumentUndefined('baseType');
if (baseType && !baseType.__class) throw Error.argument('baseType', Sys.Res.baseNotAClass);
this.prototype.constructor = this;
this.__typeName = typeName;
this.__class = true;
if (baseType) {
this.__baseType = baseType;
this.__basePrototypePending = true;
}
if (!window.__classes) window.__classes = {};
window.__classes[typeName.toUpperCase()] = this;
if (interfaceTypes) {
this.__interfaces = [];
for (var i = 2; i < arguments.length; i++) {
var interfaceType = arguments[i];
if (!interfaceType.__interface) throw Error.argument('interfaceTypes[' + (i - 2) + ']', Sys.Res.notAnInterface);
this.resolveInheritance();
for (var methodName in interfaceType.prototype) {
var method = interfaceType.prototype[methodName];
if (!this.prototype[methodName]) {
this.prototype[methodName] = method;
}
}
this.__interfaces.push(interfaceType);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -