⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atlasruntime.js

📁 《圣殿祭司的ASP.NET 2.0开发详解——使用C#》光盘内容.包含了书籍所含的源代码.非常经典的一本asp.net2.0的书籍
💻 JS
📖 第 1 页 / 共 5 页
字号:
        if (traceElement) {
            var children = traceElement.childNodes;
            for(var i = children.length - 2; i > 0; i--) {
                traceElement.removeChild(children[i]);
            }
            document.getElementById('__atlas_trace').style.display = 'none';
        }
    }
    
    this.dump = function(object, name, recursive, indentationPadding, loopArray) {
        name = name ? name : '';
        indentationPadding = indentationPadding ? indentationPadding : '';
        if (object == null) {
            this.trace(indentationPadding + name + ': null');
            return;
        }
        switch(typeof(object)) {
            case 'undefined':
                this.trace(indentationPadding + name + ': Undefined');
                break;
            case 'number': case 'string': case 'boolean':
                this.trace(indentationPadding + name + ': ' + object);
                break;
            default:
                if (!loopArray) {
                    loopArray = [];
                }
                else if (loopArray.contains(object)) {
                    this.trace(indentationPadding + name + ': ...');
                    return;
                }
                loopArray.add(object);
                var type = Object.getType(object);
                if (type != null) {
                    var typeName = type.getName();
                    this.trace(indentationPadding + name + (typeof(typeName) == 'string' ? ' {' + typeName + '}' : ''));
                    if ((indentationPadding == '') || recursive) {
                        indentationPadding += '+';
                        var i, length, properties, p, v;
                        if (Web.IArray.isImplementedBy(object)) {
                            length = object.get_length();
                            for (i = 0; i < length; i++) {
                                this.dump(object.getItem(i), '[' + i + ']', recursive, indentationPadding, loopArray);
                            }
                        }
                        if (Web.ITypeDescriptorProvider.isImplementedBy(object)) {
                            var td = Web.TypeDescriptor.getTypeDescriptor(object);
                            properties = td._getProperties();
                            for (p in properties) {
                                var propertyInfo = properties[p];
                                if (propertyInfo.name) {
                                    v = Web.TypeDescriptor.getProperty(object, propertyInfo.name);
                                    this.dump(v, p, recursive, indentationPadding, loopArray);
                                }
                            }
                        }
                        else {
                            for (p in object) {
                                v = object[p];
                                if (!Function.isInstanceOfType(v) && !Web.Event.isInstanceOfType(v)) {
                                    this.dump(v, p, recursive, indentationPadding, loopArray);
                                }
                            }
                        }
                    }
                }
                else {
                    var tagName = object.tagName;
                    var attributes = object.attributes;
                    if (tagName && attributes) {
                        this.trace(indentationPadding + name + ' {' + tagName + '}');
                        indentationPadding += '+';
                        length = attributes.length;
                        for (var i = 0; i < length; i++) {
                            var val = attributes[i].nodeValue;
                            if (val) {
                                this.dump(val, attributes[i].nodeName, recursive, indentationPadding, loopArray);
                            }
                        }
                    }
                    else {
                        this.trace('Unknown object');
                    }
                }
                loopArray.remove(object);
        }
    }
    
    this.fail = function(message) {
        Debug.breakIntoDebugger(message);
    }

    this.trace = function(text) {
        Debug.writeln(text);

        var traceElement = document.getElementById('__atlas_trace');
        if (!traceElement) {
            traceElement = document.createElement('FIELDSET');
            traceElement.id = '__atlas_trace';
            traceElement.style.backgroundColor = 'white';
            traceElement.style.color = 'black';
            traceElement.style.textAlign = 'left';
            traceElement.style.font = 'normal normal normal 1em/1.1em verdana,sans-serif';
            var legend = document.createElement('LEGEND');
            var legendText = document.createTextNode('Debugging Trace');
            legend.appendChild(legendText);
            traceElement.appendChild(legend);
            var clearButton = document.createElement('INPUT');
            clearButton.type = 'button';
            clearButton.value = 'Clear Trace';
            clearButton.onclick = debug.clearTrace;
            traceElement.appendChild(clearButton);
            document.body.appendChild(traceElement);
        }
        var traceLine = document.createElement('DIV');
        traceLine.innerHTML = text;
        traceElement.insertBefore(traceLine, traceElement.childNodes[traceElement.childNodes.length - 1]);
        traceElement.style.display = 'block';
    }
}

window.debug = new Web._Debug();

Web.Enum = new function() {

    function getValues() {
        if (!this._values) {
            var values = { };
            
            for (var f in this) {
                if (typeof(this[f]) != 'function') {
                    values[f] = this[f];
                }
            }
            this._values = values;
        }
        return this._values;
    }

    function valueFromString(s) {
        for (var f in this) {
            if (f == s) {
                return this[f];
            }
        }
        throw 'Invalid Enumeration Value';
    }

    function valueToString(value) {
        for (var i in this) {
            if (this[i] == value) {
                return i;
            }
        }
        throw 'Invalid Enumeration Value';
    }
    
    this.create = function() {
        var enumeration = { };
        enumeration.getValues = getValues;
        enumeration.parse = valueFromString;
        enumeration.toString = valueToString;
        
        for (var i = 0; i < arguments.length; i++) {
            enumeration[arguments[i]] = i;
        }
        
        return enumeration;
    }
}

Web.Flags = new function() {

    function valueFromString(s) {
        var parts = s.split('|');
        var value = 0;
        
        for (var i = parts.length - 1; i >= 0; i--) {
            var part = parts[i].trim();
            var found = false;
            
            for (var f in this) {
                if (f == part) {
                    value |= this[f];
                    found = true;
                    break;
                }
            }
            if (found == false) {
                throw 'Invalid Enumeration Value';
            }
        }
        
        return value;
    }

    function valueToString(value) {
        var sb = new Web.StringBuilder();
        for (var i in this) {
            if ((this[i] & value) != 0) {
                if (sb.isEmpty() == false) {
                    sb.append(' | ');
                }
                sb.append(i);
            }
        }
        return sb.toString();
    }

    this.create = function() {
        var flags = new Object();
        flags.parse = valueFromString;
        flags.toString = valueToString;
        
        for (var i = 0; i < arguments.length; i += 2) {
            var name = arguments[i];
            var value = arguments[i + 1];
            
            flags[name] = value;
        }
        
        return flags;
    }
}

Web.IArray = function() {
    this.get_length = Function.abstractMethod;
    this.getItem = Function.abstractMethod;
}
Type.registerInterface("Web.IArray");

Array.prototype.get_length = function() {
    return this.length;
}

Array.prototype.getItem = function(index) {
    return this[index];
}

Array._interfaces = [];
Array._interfaces.add(Web.IArray);


Web.IDisposable = function() {
    this.dispose = Function.abstractMethod;
}
Type.registerInterface('Web.IDisposable');

Web.StringBuilder = function(initialText) {
    var _parts = new Array();
    
    if ((typeof(initialText) == 'string') &&
        (initialText.length != 0)) {
        _parts.add(initialText);
    }

    this.append = function(text) {
        if ((text == null) || (typeof(text) == 'undefined')) {
            return;
        }
        if ((typeof(text) == 'string') && (text.length == 0)) {
            return;
        }
        
        _parts.add(text);
    }

    this.appendLine = function(text) {
        this.append(text);
        _parts.add('\r\n');
    }

    this.clear = function() {
        _parts.clear();
    }

    this.isEmpty = function() {
        return (_parts.length == 0);
    }

    this.toString = function(delimiter) {
        delimiter = delimiter || '';
        return _parts.join(delimiter);
    }
}
Type.registerSealedClass('Web.StringBuilder');
Web.ActionSequence = Web.Enum.create('BeforeEventHandler', 'AfterEventHandler');

Web.IAction = function() {
    this.get_sequence = Function.abstractMethod;
    this.execute = Function.abstractMethod;
    this.setOwner = Function.abstractMethod;
}
Type.registerInterface('Web.IAction');

Web.Event = function(owner, autoInvoke) {
    var _owner = owner;
    var _handlers = null;
    var _actions = null;
    var _autoInvoke = autoInvoke;
    var _invoked = false;
    
    this.get_autoInvoke = function() {
        return _autoInvoke;
    }
    
    this._getActions = function() {
        if (_actions == null) {
                                    _actions = Web.Component.createCollection(_owner);
        }
        return _actions;
    }
    this._getHandlers = function() {
        if (_handlers == null) {
            _handlers = [];
        }
        return _handlers;
    }
    this._getOwner = function() {
        return _owner;
    }
    
    this.isActive = function() {
        return ((_handlers != null) && (_handlers.length != 0)) ||
               ((_actions != null) && (_actions.length != 0));
    }
    
    this.get_isInvoked = function() {
        return _isInvoked;
    }
    
    this.dispose = function() {
        if (_handlers) {
            for (var h = _handlers.length - 1; h >= 0; h--) {
                _handlers[h] = null;
            }
            _handlers = null;
        }
        if (_actions) {
            _actions.dispose();
            _actions = null;
        }
        
        _owner = null;
    }
    
    this._setInvoked = function(value) {
        _invoked = true;
    }
}
Type.registerSealedClass('Web.Event', null, Web.IDisposable);

Web.Event.prototype.add = function(handler) {
    this._getHandlers().add(handler);
    if (this.get_autoInvoke() && this.get_isInvoked()) {
        handler(this._getOwner(), Web.EventArgs.Empty);
    }
}
Web.Event.prototype.addAction = function(action) {
    this._getActions().add(action);
    if (this.get_autoInvoke() && this.get_isInvoked()) {
        action.execute(this._getOwner(), Web.EventArgs.Empty);
    }
}
Web.Event.prototype.remove = function(handler) {
    this._getHandlers().remove(handler);
}
Web.Event.prototype.removeAction = function(action) {
    this._getActions().remove(action);
}
Web.Event.prototype.invoke = function(sender, eventArgs) {
    if (this.isActive()) {
        var actions = this._getActions();
        var handlers = this._getHandlers();
        var hasPostActions = false;
        var i;
        
        for (i = 0; i < actions.length; i++) {
            if (actions[i].get_sequence() == Web.ActionSequence.BeforeEventHandler) {
                actions[i].execute(sender, eventArgs);
            }
            else {
                hasPostActions = true;
            }
        }

        for (i = 0; i < handlers.length; i++) {
            handlers[i](sender, eventArgs);
        }
        
        if (hasPostActions) {
            for (i = 0; i < actions.length; i++) {
                if (actions[i].get_sequence() == Web.ActionSequence.AfterEventHandler) {
                    actions[i].execute(sender, eventArgs);
                }
            }
        }
        
        this._setInvoked();
    }
}

Web.EventArgs = function() {

    this.getDescriptor = function() {
        var td = new Web.TypeDescriptor();
        return td;
    }
    Web.EventArgs.registerBaseMethod(this, 'getDescriptor');
}
Type.registerClass('Web.EventArgs', null, Web.ITypeDescriptorProvider);

Web.EventArgs.Empty = new Web.EventArgs();
Web.CancelEventArgs = function() {
    Web.CancelEventArgs.initializeBase(this);
    var _canceled = false;
    
    this.get_canceled = function() {
        return _canceled;
    }
    this.set_canceled = function(value) {
        _canceled = value;
    }
    
    this.getDescriptor = function() {
        var td = Web.CancelEventArgs.callBaseMethod(this, 'getDescriptor');
        
        td.addProperty('canceled', Boolean);
        return td;
    }
    Web.CancelEventArgs.registerBaseMethod(this, 'getDescriptor');
}
Type.registerClass('Web.CancelEventArgs', Web.EventArgs);

Web.ApplicationType = Web.Enum.create('Other', 'InternetExplorer', 'Firefox');

Web._Application = function() {

    var _references;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -