PageSourceSearch

https://bvcf.ch/media/biblio/js/h5.js

js bvcf.ch collected 2026-10-08 10:15:34 UTC 2,090,515 bytes, 51,213 lines download raw bytes

1/**
2 * @version   :  - H5.NET
3 * @author    : Object.NET, Inc. http://h5.net/
4 * @copyright : Copyright 2008-2022 Object.NET, Inc. http://object.net/
5 * @license   : See license.txt and https://github.com/bridgedotnet/Bridge.NET/blob/master/LICENSE.
6 */
7
8
9    // @source Init.js
10
11(function (globals) {
12    "use strict";
13
14    if (typeof module !== "undefined" && module.exports) {
15        globals = global;
16    }
17
18    // @source Core.js
19
20    var core = {
21        global: globals,
22
23        isNode: Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]",
24
25        emptyFn: function () { },
26
27        identity: function (x) {
28            return x;
29        },
30
31        Deconstruct: function (obj) {
32            var args = Array.prototype.slice.call(arguments, 1);
33
34            for (var i = 0; i < args.length; i++) {
35                args[i].v = i == 7 ? obj["Rest"] : obj["Item" + (i + 1)];
36            }
37        },
38
39        toString: function (instance) {
40            if (instance == null) {
41                throw new System.ArgumentNullException();
42            }
43
44            var guardItem = H5.$toStringGuard[H5.$toStringGuard.length - 1];
45
46            if (instance.toString === Object.prototype.toString || guardItem && guardItem === instance) {
47                return H5.Reflection.getTypeFullName(instance);
48            }
49
50            H5.$toStringGuard.push(instance);
51
52            var result = instance.toString();
53
54            H5.$toStringGuard.pop();
55
56            return result;
57        },
58
59        geti: function (scope, name1, name2) {
60            if (scope[name1] !== undefined) {
61                return name1;
62            }
63
64            if (name2 && scope[name2] != undefined) {
65                return name2;
66            }
67
68            var name = name2 || name1;
69            var idx = name.lastIndexOf("$");
70
71            if (/\$\d+$/g.test(name)) {
72                idx = name.lastIndexOf("$", idx - 1);
73            }
74
75            return name.substr(idx + 1);
76        },
77
78        box: function (v, T, toStr, hashCode) {
79            if (v && v.$boxed) {
80                return v;
81            }
82
83            if (v == null) {
84                return v;
85            }
86
87            if (v.$clone) {
88                v = v.$clone();
89            }
90
91            return {
92                $boxed: true,
93                fn: {
94                    toString: toStr,
95                    getHashCode: hashCode
96                },
97                v: v,
98                type: T,
99                constructor: T,
100                getHashCode: function () {
101                    return this.fn.getHashCode ? this.fn.getHashCode(this.v) : H5.getHashCode(this.v);
102                },
103                equals: function (o) {
104                    if (this === o) {
105                        return true;
106                    }
107
108                    var eq = this.equals;
109                    this.equals = null;
110                    var r = H5.equals(this.v, o);
111                    this.equals = eq;
112
113                    return r;
114                },
115                valueOf: function () {
116                    return this.v;
117                },
118                toString: function () {
119                    return this.fn.toString ? this.fn.toString(this.v) : this.v.toString();
120                }
121            };
122        },
123
124        unbox: function (o, noclone) {
125            var T;
126
127            if (noclone && H5.isFunction(noclone)) {
128                T = noclone;
129                noclone = false;
130            }
131
132            if (o && o.$boxed) {
133                var v = o.v,
134                    t = o.type;
135
136                if (T && T.$nullable) {
137                    T = T.$nullableType;
138                }
139
140                if (T && T.$kind === "enum") {
141                    T = System.Enum.getUnderlyingType(T);
142                }
143
144                if (t.$nullable) {
145                    t = t.$nullableType;
146                }
147
148                if (t.$kind === "enum") {
149                    t = System.Enum.getUnderlyingType(t);
150                }
151
152                if (T && T !== t && !H5.isObject(T)) {
153                    throw new System.InvalidCastException.$ctor1("Specified cast is not val
153id.");
154                }
155
156                if (!noclone && v && v.$clone) {
157                    v = v.$clone();
158                }
159
160                return v;
161            }
162
163            if (H5.isArray(o)) {
164                for (var i = 0; i < o.length; i++) {
165                    var item = o[i];
166
167                    if (item && item.$boxed) {
168                        item = item.v;
169
170                        if (item.$clone) {
171                            item = item.$clone();
172                        }
173                    } else if (!noclone && item && item.$clone) {
174                        item = item.$clone();
175                    }
176
177                    o[i] = item;
178                }
179            }
180
181            if (o && !noclone && o.$clone) {
182                o = o.$clone();
183            }
184
185            return o;
186        },
187
188        virtualc: function (name) {
189            return H5.virtual(name, true);
190        },
191
192        virtual: function (name, isClass) {
193            var type = H5.unroll(name);
194
195            if (!type || !H5.isFunction(type)) {
196                var old = H5.Class.staticInitAllow;
197                type = isClass ? H5.define(name) : H5.definei(name);
198                H5.Class.staticInitAllow = true;
199
200                if (type.$staticInit) {
201                    type.$staticInit();
202                }
203
204                H5.Class.staticInitAllow = old;
205            }
206
207            return type;
208        },
209
210        safe: function (fn) {
211            try {
212                return fn();
213            } catch (ex) {
214            }
215
216            return false;
217        },
218
219        literal: function (type, obj) {
220            obj.$getType = function () { return type };
221
222            return obj;
223        },
224
225        isJSObject: function (value) {
226            return Object.prototype.toString.call(value) === "[object Object]";
227        },
228
229        isPlainObject: function (obj) {
230            if (typeof obj == "object" && obj !== null) {
231                if (typeof Object.getPrototypeOf == "function") {
232                    var proto = Object.getPrototypeOf(obj);
233
234                    return proto === Object.prototype || proto === null;
235                }
236
237                return Object.prototype.toString.call(obj) === "[object Object]";
238            }
239
240            return false;
241        },
242
243        toPlain: function (o) {
244            if (!o || H5.isPlainObject(o) || typeof o != "object") {
245                return o;
246            }
247
248            if (typeof o.toJSON == "function") {
249                return o.toJSON();
250            }
251
252            if (H5.isArray(o)) {
253                var arr = [];
254
255                for (var i = 0; i < o.length; i++) {
256                    arr.push(H5.toPlain(o[i]));
257                }
258
259                return arr;
260            }
261
262            var newo = {},
263                m;
264
265            for (var key in o) {
266                m = o[key];
267
268                if (!H5.isFunction(m)) {
269                    newo[key] = m;
270                }
271            }
272
273            return newo;
274        },
275
276        ref: function (o, n) {
277            if (H5.isArray(n)) {
278                n = System.Array.toIndex(o, n);
279            }
280
281            var proxy = {};
282
283            Object.defineProperty(proxy, "v", {
284                get: function () {
285                    if (n == null) {
286                        return o;
287                    }
288
289                    return o[n];
290                },
291
292                set: function (value) {
293                    if (n == null) {
294                        if (value && value.$clone) {
295                            value.$clone(o);
296                        } else {
297                            o = value;
298                        }
299                    }
300
301                    o[n] = value;
302                }
303            });
304
305            return proxy;
306        },
307
308        ensureBaseProperty: function (scope, name, alias) {
309            var scopeType = H5.getType(scope),
310                descriptors = scopeType.$descriptors || [];
311
312            scope.$propMap = scope.$propMap || {};
313
314            if (scope.$propMap[name]) {
315                return scope;
316            }
317
318            if ((!scopeType.$descriptors || scopeType.$descriptors.length === 0) && alias) {
319                var aliasCfg = {},
320                    aliasName = "$" + alias + "$" + name;
321
322                aliasCfg.get = function () {
323                    return scope[name];
324                };
325
326                aliasCfg.set = function (value) {
327                    scope[name] = value;
328                };
329
330                H5.property(scope, aliasName, aliasCfg, false, scopeType, true);
331            }
332            else {
333                for (var j = 0; j < descriptors.length; j++) {
334                    var d = descriptors[j];
335
336                    if (d.name === name) {
337                        var aliasCfg = {},
338                            aliasName = "$" + H5.getTypeAlias(d.cls) + "$" + name;
339
340                        if (d.get) {
341                            aliasCfg.get = d.get;
342                        }
343
344                        if (d.set) {
345                            aliasCfg.set = d.set;
346                        }
347
348                        H5.property(scope, aliasName, aliasCfg, false, scopeType, true);
349                    }
350                }
351            }
352
353            scope.$propMap[name] = true;
354
355            return scope;
356        },
357
358        property: function (scope, name, v, statics, cls, alias) {
359            var cfg = {
360                enumerable: alias ? false : true,
361                configurable: true
362            };
363
364            if (v && v.get) {
365                cfg.get = v.get;
366            }
367
368            if (v && v.set) {
369                cfg.set = v.set;
370            }
371
372            if (!v || !(v.get || v.set)) {
373                var backingField = H5.getTypeAlias(cls) + "$" + name;
374
375                cls.$init = cls.$init || {};
376
377                if (statics) {
378                    cls.$init[backingField] = v;
379                }
380
381                (function (cfg, scope, backingField, v) {
382                    cfg.get = function () {
383                        var o = this.$init[backingField];
384
385                        return o === undefined ? v : o;
386                    };
387
388                    cfg.set = function (value) {
389                        this.$init[backingField] = value;
390                    };
391                })(cfg, scope, backingField, v);
392            }
393
394            Object.defineProperty(scope, name, cfg);
395
396            return cfg;
397        },
398
399        event: function (scope, name, v, statics) {
400            scope[name] = v;
401
402            var rs = name.charAt(0) === "$",
403                cap = rs ? name.slice(1) : name,
404                addName = "add" + cap,
405                removeName = "remove" + cap,
406                lastSep = name.lastIndexOf("$"),
407                endsNum = lastSep > 0 && ((name.length - lastSep - 1) > 0) && !isNaN(parseInt(name.substr(lastSep + 1)));
408
409            if (endsNum) {
410                lastSep = name.substring(0, lastSep - 1).lastIndexOf("$");
411            }
412
413            if (lastSep > 0 && lastSep !== (name.length - 1)) {
414                addName = name.substring(0, lastSep) + "add" + name.substr(lastSep + 1);
415                removeName = name.substring(0, lastSep) + "remove" + name.substr(lastSep + 1);
416            }
417
418            scope[addName] = (function (name, scope, statics) {
419                return statics ? function (value) {
420                    scope[name] = H5.fn.combine(scope[name], value);
421                } : function (value) {
422                    this[name] = H5.fn.combine(this[name], value);
423                };
424            })(name, scope, statics);
425
426            scope[removeName] = (function (name, scope, statics) {
427                return statics ? function (value) {
428                    scope[name] = H5.fn.remove(scope[name], value);
429                } : function (value) {
430                    this[name] = H5.fn.remove(this[name], value);
431                };
432            })(name, scope, statics);
433        },
434
435        createInstance: function (type, nonPublic, args) {
436            if (H5.isArray(nonPublic)) {
437                args = nonPublic;
438                nonPublic = false;
439            }
440
441            if (type === System.Decimal) {
442                return System.Decimal.Zero;
443            }
444
445            if (type === System.Int64) {
446                return System.Int64.Zero;
447            }
448
449            if (type === System.UInt64) {
450                return System.UInt64.Zero;
451            }
452
453            if (type === System.Double ||
454                type === System.Single ||
455                type === System.Byte ||
456                type === System.SByte ||
457                type === System.Int16 ||
458                type === System.UInt16 ||
459                type === System.Int32 ||
460                type === System.UInt32 ||
461                type === H5.Int) {
462                return 0;
463            }
464
465            if (typeof (type.createInstance) === "function") {
466                return type.createInstance();
467            } else if (typeof (type.getDefaultValue) === "function") {
468                return type.getDefaultValue();
469            } else if (type === Boolean || type === System.Boolean) {
470                return false;
471            } else if (type === System.DateTime) {
472                return System.DateTime.getDefaultValue();
473            } else if (type === Date) {
474                return new Date();
475            } else if (type === Number) {
476                return 0;
477            } else if (type === String || type === System.String) {
478                return "";
479            } else if (type && type.$literal) {
480                return type.ctor();
481            } else if (args && args.length > 0) {
482                return H5.Reflection.applyConstructor(type, args);
483            }
484
485            if (type.$kind === 'interface') {
486                throw new System.MissingMethodException.$ctor1('Default constructor not found for type ' + H5.getTypeName(type));
487            }
488
489            var ctors = H5.Reflection.getMembers(type, 1, 54);
490
491            if (ctors.length > 0) {
492                var pctors = ctors.filter(function (c) { return !c.isSynthetic && !c.sm; });
493
494                for (var idx = 0; idx < pctors.length; idx++) {
495                    var c = pctors[idx],
496                        isDefault = (c.pi || []).length === 0;
497
498                    if (isDefault) {
499                        if (nonPublic || c.a === 2) {
500                            return H5.Reflection.invokeCI(c, []);
501                        }
502                        throw new System.MissingMethodException.$ctor1('Default constructor not found for type ' + H5.getTypeName(type));
503                    }
504                }
505
506                if (type.$$name && !(ctors.length == 1 && ctors[0].isSynthetic)) {
507                    throw new System.MissingMethodException.$ctor1('Default constructor not found for type ' + H5.getTypeName(type));
508                }
509            }
510
511            return new type();
512        },
513
514        clone: function (obj) {
515            if (obj == null) {
516                return obj;
517            }
518
519            if (H5.isArray(obj)) {
520                return System.Array.clone(obj);
521            }
522
523            if (H5.isString(obj)) {
524                return obj;
525            }
526
527            var name;
528
529            if (H5.isFunction(H5.getProperty(obj, name = "System$ICloneable$clone"))) {
530                return obj[name]();
531            }
532
533            if (H5.is(obj, System.ICloneable)) {
534                return obj.clone();
535            }
536
537            if (H5.isFunction(obj.$clone)) {
538                return obj.$clone();
539            }
540
541            return null;
542        },
543
544        copy: function (to, from, keys, toIf) {
545            if (typeof keys === "string") {
546                keys = keys.split(/[,;\s]+/);
547            }
548
549            for (var name, i = 0, n = keys ? keys.length : 0; i < n; i++) {
550                name = keys[i];
551
552                if (toIf !== true || to[name] == undefined) {
553                    if (H5.is(from[name], System.ICloneable)) {
554                        to[name] = H5.clone(from[name]);
555                    } else {
556                        to[name] = from[name];
557                    }
558                }
559            }
560
561            return to;
562        },
563
564        get: function (t) {
565            if (t && t.$staticInit !== null) {
566                t.$staticInit();
567            }
568
569            return t;
570        },
571
572        ns: function (ns, scope) {
573            var nsParts = ns.split("."),
574                i = 0;
575
576            if (!scope) {
577                scope = H5.global;
578            }
579
580            for (i = 0; i < nsParts.length; i++) {
581                if (typeof scope[nsParts[i]] === "undefined") {
582                    scope[nsParts[i]] = {};
583                }
584
585                scope = scope[nsParts[i]];
586            }
587
588            return scope;
589        },
590
591        ready: function (fn, scope) {
592            var delayfn = function () {
593                if (scope) {
594                    fn.apply(scope);
595                } else {
596                    fn();
597                }
598            };
599
600            if (typeof H5.global.jQuery !== "undefined") {
601                H5.global.jQuery(delayfn);
602            } else {
603                if (typeof H5.global.document === "undefined" ||
604                    H5.global.document.readyState === "complete" ||
605                    H5.global.document.readyState === "loaded" ||
606                    H5.global.document.readyState === "interactive") {
607                    delayfn();
608                } else {
609                    H5.on("DOMContentLoaded", H5.global.document, delayfn);
610                }
611            }
612        },
613
614        on: function (event, elem, fn, scope) {
615            var listenHandler = function (e) {
616                var ret = fn.apply(scope || this, arguments);
617
618                if (ret === false) {
619                    e.stopPropagation();
620                    e.preventDefault();
621                }
622
623                return (ret);
624            };
625
626            var attachHandler = function () {
627                var ret = fn.call(scope || elem, H5.global.event);
628
629                if (ret === false) {
630                    H5.global.event.returnValue = false;
631                    H5.global.event.cancelBubble = true;
632                }
633
634                return (ret);
635            };
636
637            if (elem.addEventListener) {
638                elem.addEventListener(event, listenHandler, false);
639            } else {
640                elem.attachEvent("on" + event, attachHandler);
641            }
642        },
643
644        addHash: function (v, r, m) {
645            if (isNaN(r)) {
646                r = 17;
647            }
648
649            if (isNaN(m)) {
650                m = 23;
651            }
652
653            if (H5.isArray(v)) {
654                for (var i = 0; i < v.length; i++) {
655                    r = r + ((r * m | 0) + (v[i] == null ? 0 : H5.getHashCode(v[i]))) | 0;
656                }
657
658                return r;
659            }
660
661            return r = r + ((r * m | 0) + (v == null ? 0 : H5.getHashCode(v))) | 0;
662        },
663
664        getHashCode: function (value, safe, deep) {
665            // In CLR: mutable object should keep on returning same value
666            // H5 goals: make it deterministic (to make testing easier) without breaking CLR contracts
667            //     for value types it returns deterministic values (f.e. for int 3 it returns 3)
668            //     for reference types it returns random value
669
670            if (value && value.$boxed && value.type.getHashCode) {
671                return value.type.getHashCode(H5.unbox(value, true));
672            }
673
674            value = H5.unbox(value, true);
675
676            if (H5.isEmpty(value, true)) {
677                if (safe) {
678                    return 0;
679                }
680
681                throw new System.InvalidOperationException.$ctor1("HashCode cannot be calculated for empty value");
682            }
683
684            if (value.getHashCode && H5.isFunction(value.getHashCode) && !value.__insideHashCode && value.getHashCode.length === 0) {
685                value.__insideHashCode = true;
686                var r = value.getHashCode();
687
688                delete value.__insideHashCode;
689
690                return r;
691            }
692
693            if (H5.isBoolean(value)) {
694                return value ? 1 : 0;
695            }
696
697            if (H5.isDate(value)) {
698                var val = value.ticks !== undefined ? value.ticks : System.DateTime.getTicks(value);
699
700                return val.toNumber() & 0xFFFFFFFF;
701            }
702
703            if (value === Number.POSITIVE_INFINITY) {
704                return 0x7FF00000;
705            }
706
707            if (value === Number.NEGATIVE_INFINITY) {
708                return 0xFFF00000;
709            }
710
711            if (H5.isNumber(value)) {
712                if (Math.floor(value) === value) {
713                    return value;
714                }
715
716                value = value.toExponential();
717            }
718
719            if (H5.isString(value)) {
720                if (Math.imul) {
721                    for (var i = 0, h = 0; i < value.length; i++)
722                        h = Math.imul(31, h) + value.charCodeAt(i) | 0;
723                    return h;
724                } else {
725                    var h = 0, l = value.length, i = 0;
726                    if (l > 0)
727                        while (i < l)
728                            h = (h << 5) - h + value.charCodeAt(i++) | 0;
729                    return h;
730                }
731            }
732
733            if (value.$$hashCode) {
734                return value.$$hashCode;
735            }
736
737            if (deep !== false && value.hasOwnProperty("Item1") && H5.isPlainObject(value)) {
738                deep = true;
739            }
740
741            if (deep && typeof value == "object") {
742                var result = 0,
743                    temp;
744
745                for (var property in value) {
746                    if (value.hasOwnProperty(property)) {
747                        temp = H5.isEmpty(value[property], true) ? 0 : H5.getHashCode(value[property]);
748                        result = 29 * result + temp;
749                    }
750                }
751
752                if (result !== 0) {
753                    value.$$hashCode = result;
754
755                    return result;
756                }
757            }
758
759            value.$$hashCode = (Math.random() * 0x100000000) | 0;
760
761            return value.$$hashCode;
762        },
763
764        getDefaultValue: function (type) {
765            if (type == null) {
766                throw new System.ArgumentNullException.$ctor1("type");
767            } else if ((type.getDefaultValue) && type.getDefaultValue.length === 0) {
768                return type.getDefaultValue();
769            } else if (H5.Reflection.isEnum(type)) {
770                return System.Enum.parse(type, 0);
771            } else if (type === Boolean || type === System.Boolean) {
772                return false;
773            } else if (type === System.DateTime) {
774                return System.DateTime.getDefaultValue();
775            } else if (type === Date) {
776                return new Date();
777            } else if (type === Number) {
778                return 0;
779            }
780
781            return null;
782        },
783
784        $$aliasCache: [],
785
786        getTypeAlias: function (obj) {
787            if (obj.$$alias) {
788                return obj.$$alias;
789            }
790
791            var type = (obj.$$name || typeof obj === "function") ? obj : H5.getType(obj),
792                alias;
793
794            if (type.$$alias) {
795                return type.$$alias;
796            }
797
798            alias = H5.$$aliasCache[type];
799            if (alias) {
800                return alias;
801            }
802
803            if (type.$isArray) {
804                var elementName = H5.getTypeAlias(type.$elementType);
805                alias = elementName + "$Array" + (type.$rank > 1 ? ("$" + type.$rank) : "");
806
807                if (type.$$name) {
808                    type.$$alias = alias;
809                } else {
810                    H5.$$aliasCache[type] = alias;
811                }
812
813                return alias;
814            }
815
816            var name = obj.$$name || H5.getTypeName(obj);
817
818            if (type.$typeArguments && !type.$isGenericTypeDefinition) {
819                name = type.$genericTypeDefinition.$$name;
820
821                for (var i = 0; i < type.$typeArguments.length; i++) {
822                    var ta = type.$typeArguments[i];
823                    name += "$" + H5.getTypeAlias(ta);
824                }
825            }
826
827            alias = name.replace(/[\.\(\)\,\+]/g, "$");
828
829            if (type.$module) {
830                alias = type.$module + "$" + alias;
831            }
832
833            if (type.$$name) {
834                type.$$alias = alias;
835            } else {
836                H5.$$aliasCache[type] = alias;
837            }
838
839            return alias;
840        },
841
842        getTypeName: function (obj) {
843            return H5.Reflection.getTypeFullName(obj);
844        },
845
846        hasValue: function (obj) {
847            return H5.unbox(obj, true) != null;
848        },
849
850        hasValue$1: function () {
851            if (arguments.length === 0) {
852                return false;
853            }
854
855            var i = 0;
856
857            for (i; i < arguments.length; i++) {
858                if (H5.unbox(arguments[i], true) == null) {
859                    return false;
860                }
861            }
862
863            return true;
864        },
865
866        isObject: function (type) {
867            return type === Object || type === System.Object;
868        },
869
870        is: function (obj, type, ignoreFn, allowNull) {
871            if (obj == null) {
872                return !!allowNull;
873            }
874
875            if (type === System.Object) {
876                type = Object;
877            }
878
879            var tt = typeof type;
880
881            if (tt === "boolean") {
882                return type;
883            }
884
885            if (obj.$boxed) {
886                if (obj.type.$kind === "enum" && (obj.type.prototype.$utype === type || type === System.Enum || type === System.IFormattable || type === System.IComparable)) {
887                    return true;
888                } else if (!H5.Reflection.isInterface(type) && !type.$nullable) {
889                    return obj.type === type || H5.isObject(type) || type === System.ValueType && H5.Reflection.isValueType(obj.type);
890                }
891
892                if (ignoreFn !== true && type.$is) {
893                    return type.$is(H5.unbox(obj, true));
894                }
895
896                if (H5.Reflection.isAssignableFrom(type, obj.type)) {
897                    return true;
898                }
899
900                obj = H5.unbox(obj, true);
901            }
902
903            var ctor = obj.constructor === Object && obj.$getType ? obj.$getType() : H5.Reflection.convertType(obj.constructor);
904
905            if (type.constructor === Function && obj instanceof type || ctor === type || H5.isObject(type)) {
906                return true;
907            }
908
909            var hasObjKind = ctor.$kind || ctor.$$inherits,
910                hasTypeKind = type.$kind;
911
912            if (hasObjKind || hasTypeKind) {
913                var isInterface = type.$isInterface;
914
915                if (isInterface) {
916                    if (hasObjKind) {
917                        if (ctor.$isArrayEnumerator) {
918                            return System.Array.is(obj, type);
919                        }
920
921                        return type.isAssignableFrom ? type.isAssignableFrom(ctor) : H5.Reflection.getInterfaces(ctor).indexOf(type) >= 0;
922                    }
923
924                    if (H5.isArray(obj, ctor)) {
925                        return System.Array.is(obj, type);
926                    }
927                }
928
929                if (ignoreFn !== true && type.$is) {
930                    return type.$is(obj);
931                }
932
933                if (type.$literal) {
934                    if (H5.isPlainObject(obj)) {
935                        if (obj.$getType) {
936                            return H5.Reflection.isAssignableFrom(type, obj.$getType());
937                        }
938
939                        return true;
940                    }
941                }
942
943                return false;
944            }
945
946            if (tt === "string") {
947                type = H5.unroll(type);
948            }
949
950            if (tt === "function" && (H5.getType(obj).prototype instanceof type)) {
951                return true;
952            }
953
954            if (ignoreFn !== true) {
955                if (typeof (type.$is) === "function") {
956                    return type.$is(obj);
957                }
958
959                if (typeof (type.isAssignableFrom) === "function") {
960                    return type.isAssignableFrom(H5.getType(obj));
961                }
962            }
963
964            if (H5.isArray(obj)) {
965                return System.Array.is(obj, type);
966            }
967
968            return tt === "object" && ((ctor === type) || (obj instanceof type));
969        },
970
971        as: function (obj, type, allowNull) {
972            if (H5.is(obj, type, false, allowNull)) {
973                return obj != null && obj.$boxed && type !== Object && type !== System.Object ? obj.v : obj;
974            }
975            return null;
976        },
977
978        cast: function (obj, type, allowNull) {
979            if (obj == null) {
980                return obj;
981            }
982
983            var result = H5.is(obj, type, false, allowNull) ? obj : null;
984
985            if (result === null) {
986                throw new System.InvalidCastException.$ctor1("Unable to cast type " + (obj ? H5.getTypeName(obj) : "'null'") + " to type " + H5.getTypeName(type));
987            }
988
989            if (obj.$boxed && type !== Object && type !== System.Object) {
990                return obj.v;
991            }
992
993            return result;
994        },
995
996        apply: function (obj, values, callback) {
997            var names = H5.getPropertyNames(values, true),
998                i;
999
1000            for (i = 0; i < names.length; i++) {
1001                var name = names[i];
1002
1003                if (typeof obj[name] === "function" && typeof values[name] !== "function") {
1004                    obj[name](values[name]);
1005                } else {
1006                    obj[name] = values[name];
1007                }
1008            }
1009
1010            if (callback) {
1011                callback.call(obj, obj);
1012            }
1013
1014            return obj;
1015        },
1016
1017        copyProperties: function (to, from) {
1018            var names = H5.getPropertyNames(from, false),
1019                i;
1020
1021            for (i = 0; i < names.length; i++) {
1022                var name = names[i],
1023                    own = from.hasOwnProperty(name),
1024                    dcount = name.split("$").length;
1025
1026                if (own && (dcount === 1 || dcount === 2 && name.match("\$\d+$"))) {
1027                    to[name] = from[name];
1028                }
1029
1030            }
1031
1032            return to;
1033        },
1034
1035        merge: function (to, from, callback, elemFactory) {
1036            if (to == null) {
1037                return from;
1038            }
1039
1040            // Maps instance of plain JS value or Object into H5 object.
1041            // Used for deserialization. Proper deserialization requires reflection that is currently not supported in H5.
1042            // It currently is only capable to deserialize:
1043            // -instance of single class or primitive
1044            // -array of primitives
1045            // -array of single class
1046            if (to instanceof System.Decimal && typeof from === "number") {
1047                return new System.Decimal(from);
1048            }
1049
1050            if (to instanceof System.Int64 && H5.isNumber(from)) {
1051                return new System.Int64(from);
1052            }
1053
1054            if (to instanceof System.UInt64 && H5.isNumber(from)) {
1055                return new System.UInt64(from);
1056            }
1057
1058            if (to instanceof Boolean || H5.isBoolean(to) ||
1059                typeof to === "number" ||
1060                to instanceof String || H5.isString(to) ||
1061                to instanceof Function || H5.isFunction(to) ||
1062                to instanceof Date || H5.isDate(to) ||
1063                H5.getType(to).$number) {
1064                return from;
1065            }
1066
1067            var key,
1068                i,
1069                value,
1070                toValue,
1071                fn;
1072
1073            if (H5.isArray(from) && H5.isFunction(to.add || to.push)) {
1074                fn = H5.isArray(to) ? to.push : to.add;
1075
1076                for (i = 0; i < from.length; i++) {
1077                    var item = from[i];
1078
1079                    if (!H5.isArray(item)) {
1080                        item = [typeof elemFactory === "undefined" ? item : H5.merge(elemFactory(), item)];
1081                    }
1082
1083                    fn.apply(to, item);
1084                }
1085            } else {
1086                var t = H5.getType(to),
1087                    descriptors = t && t.$descriptors;
1088
1089                if (from) {
1090                    for (key in from) {
1091                        value = from[key];
1092
1093                        var descriptor = null;
1094
1095                        if (descriptors) {
1096                            for (var i = descriptors.length - 1; i >= 0; i--) {
1097                                if (descriptors[i].name === key) {
1098                                    descriptor = descriptors[i];
1099
1100                                    break;
1101                                }
1102                            }
1103                        }
1104
1105                        if (descriptor != null) {
1106                            if (descriptor.set) {
1107                                to[key] = H5.merge(to[key], value);
1108                            } else {
1109                                H5.merge(to[key], value);
1110                            }
1111                        } else if (typeof to[key] === "function") {
1112                            if (key.match(/^\s*get[A-Z]/)) {
1113                                H5.merge(to[key](), value);
1114                            } else {
1115                                to[key](value);
1116                            }
1117                        } else {
1118                            var setter1 = "set" + key.charAt(0).toUpperCase() + key.slice(1),
1119                                setter2 = "set" + key,
1120                                getter;
1121
1122                            if (typeof to[setter1] === "function" && typeof value !== "function") {
1123                                getter = "g" + setter1.slice(1);
1124
1125                                if (typeof to[getter] === "function") {
1126                                    to[setter1](H5.merge(to[getter](), value));
1127                                } else {
1128                                    to[setter1](value);
1129                                }
1130                            } else if (typeof to[setter2] === "function" && typeof value !== "function") {
1131                                getter = "g" + setter2.slice(1);
1132
1133                                if (typeof to[getter] === "function") {
1134                                    to[setter2](H5.merge(to[getter](), value));
1135                                } else {
1136                                    to[setter2](value);
1137                                }
1138                            } else if (value && value.constructor === Object && to[key]) {
1139                                toValue = to[key];
1140                                H5.merge(toValue, value);
1141                            } else {
1142                                var isNumber = H5.isNumber(from);
1143
1144                                if (to[key] instanceof System.Decimal && isNumber) {
1145                                    return new System.Decimal(from);
1146                                }
1147
1148                                if (to[key] instanceof System.Int64 && isNumber) {
1149                                    return new System.Int64(from);
1150                                }
1151
1152                                if (to[key] instanceof System.UInt64 && isNumber) {
1153                                    return new System.UInt64(from);
1154                                }
1155
1156                                to[key] = value;
1157                            }
1158                        }
1159                    }
1160                } else {
1161                    if (callback) {
1162                        callback.call(to, to);
1163                    }
1164
1165                    return from;
1166                }
1167            }
1168
1169            if (callback) {
1170                callback.call(to, to);
1171            }
1172
1173            return to;
1174        },
1175
1176        getEnumerator: function (obj, fnName, T) {
1177            if (typeof obj === "string") {
1178                obj = System.String.toCharArray(obj);
1179            }
1180
1181            if (arguments.length === 2 && H5.isFunction(fnName)) {
1182                T = fnName;
1183                fnName = null;
1184            }
1185
1186            if (fnName && obj && obj[fnName]) {
1187                return obj[fnName].call(obj);
1188            }
1189
1190            if (!T && obj && obj.GetEnumerator) {
1191                return obj.GetEnumerator();
1192            }
1193
1194            var name;
1195
1196            if (T && H5.isFunction(H5.getProperty(obj, name = "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator"))) {
1197                return obj[name]();
1198            }
1199
1200            if (T && H5.isFunction(H5.getProperty(obj, name = "System$Collections$Generic$IEnumerable$1$GetEnumerator"))) {
1201                return obj[name]();
1202            }
1203
1204            if (H5.isFunction(H5.getProperty(obj, name = "System$Collections$IEnumerable$GetEnumerator"))) {
1205                return obj[name]();
1206            }
1207
1208            if (T && obj && obj.GetEnumerator) {
1209                return obj.GetEnumerator();
1210            }
1211
1212            if ((Object.prototype.toString.call(obj) === "[object Array]") ||
1213                (obj && H5.isDefined(obj.length))) {
1214                return new H5.ArrayEnumerator(obj, T);
1215            }
1216
1217            throw new System.InvalidOperationException.$ctor1("Cannot create Enumerator.");
1218        },
1219
1220        getPropertyNames: function (obj, includeFunctions) {
1221            var names = [],
1222                name;
1223
1224            for (name in obj) {
1225                if (includeFunctions || typeof obj[name] !== "function") {
1226                    names.push(name);
1227                }
1228            }
1229
1230            return names;
1231        },
1232
1233        getProperty: function (obj, propertyName) {
1234            if (H5.isHtmlAttributeCollection(obj) && !this.isValidHtmlAttributeName(propertyName)) {
1235                return undefined;
1236            }
1237
1238            return obj[propertyName];
1239        },
1240
1241        isValidHtmlAttributeName : function (name) {
1242            // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1243
1244            if (!name || !name.length) {
1245                return false;
1246            }
1247
1248            var r = /^[a-zA-Z_][\w\-]*$/;
1249
1250            return r.test(name);
1251        },
1252
1253        isHtmlAttributeCollection: function (obj) {
1254            return typeof obj !== "undefined" && (Object.prototype.toString.call(obj) === "[object NamedNodeMap]");
1255        },
1256
1257        isDefined: function (value, noNull) {
1258            return typeof value !== "undefined" && (noNull ? value !== null : true);
1259        },
1260
1261        isEmpty: function (value, allowEmpty) {
1262            return (typeof value === "undefined" || value === null) || (!allowEmpty ? value === "" : false) || ((!allowEmpty && H5.isArray(value)) ? value.length === 0 : false);
1263        },
1264
1265        toArray: function (ienumerable) {
1266            var i,
1267                item,
1268                len,
1269                result = [];
1270
1271            if (H5.isArray(ienumerable)) {
1272                for (i = 0, len = ienumerable.length; i < len; ++i) {
1273                    result.push(ienumerable[i]);
1274                }
1275            } else {
1276                i = H5.getEnumerator(ienumerable);
1277
1278                while (i.moveNext()) {
1279                    item = i.Current;
1280                    result.push(item);
1281                }
1282            }
1283
1284            return result;
1285        },
1286
1287        toList: function (ienumerable, T) {
1288            return new (System.Collections.Generic.List$1(T || System.Object).$ctor1)(ienumerable);
1289        },
1290
1291        arrayTypes: [globals.Array, globals.Uint8Array, globals.Int8Array, globals.Int16Array, globals.Uint16Array, globals.Int32Array, globals.Uint32Array, globals.Float32Array, globals.Float64Array, globals.Uint8ClampedArray],
1292
1293        isArray: function (obj, ctor) {
1294            var c = ctor || (obj != null ? obj.constructor : null);
1295
1296            if (!c) {
1297                return false;
1298            }
1299
1300            return H5.arrayTypes.indexOf(c) >= 0 || c.$isArray || Array.isArray(obj);
1301        },
1302
1303        isFunction: function (obj) {
1304            return typeof (obj) === "function";
1305        },
1306
1307        isDate: function (obj) {
1308            return obj instanceof Date || Object.prototype.toString.call(obj) === "[object Date]";
1309        },
1310
1311        isNull: function (value) {
1312            return (value === null) || (value === undefined);
1313        },
1314
1315        isBoolean: function (value) {
1316            return typeof value === "boolean";
1317        },
1318
1319        isNumber: function (value) {
1320            return typeof value === "number" && isFinite(value);
1321        },
1322
1323        isString: function (value) {
1324            return typeof value === "string";
1325        },
1326
1327        unroll: function (value, scope) {
1328            if (H5.isArray(value)) {
1329                for (var i = 0; i < value.length; i++) {
1330                    var v = value[i];
1331
1332                    if (H5.isString(v)) {
1333                        value[i] = H5.unroll(v, scope);
1334                    }
1335                }
1336
1337                return;
1338            }
1339
1340            var d = value.split("."),
1341                o = (scope || H5.global)[d[0]],
1342                i = 1;
1343
1344            for (i; i < d.length; i++) {
1345                if (!o) {
1346                    return null;
1347                }
1348
1349                o = o[d[i]];
1350            }
1351
1352            return o;
1353        },
1354
1355        referenceEquals: function (a, b) {
1356            return H5.hasValue(a) ? a === b : !H5.hasValue(b);
1357        },
1358
1359        rE: function (a, b) {
1360            return H5.hasValue(a) ? a === b : !H5.hasValue(b);
1361        },
1362
1363        staticEquals: function (a, b) {
1364            if (!H5.hasValue(a)) {
1365                return !H5.hasValue(b);
1366            }
1367
1368            return H5.hasValue(b) ? H5.equals(a, b) : false;
1369        },
1370
1371        equals: function (a, b) {
1372            if (a == null && b == null) {
1373                return true;
1374            }
1375
1376            var guardItem = H5.$equalsGuard[H5.$equalsGuard.length - 1];
1377
1378            if (guardItem && guardItem.a === a && guardItem.b === b) {
1379                return a === b;
1380            }
1381
1382            H5.$equalsGuard.push({a: a, b: b});
1383
1384            var fn = function (a, b) {
1385                if (a && a.$boxed && a.type.equals && a.type.equals.length === 2) {
1386                    return a.type.equals(a, b);
1387                }
1388
1389                if (b && b.$boxed && b.type.equals && b.type.equals.length === 2) {
1390                    return b.type.equals(b, a);
1391                }
1392
1393                if (a && H5.isFunction(a.equals) && a.equals.length === 1) {
1394                    return a.equals(b);
1395                }
1396
1397                if (b && H5.isFunction(b.equals) && b.equals.length === 1) {
1398                    return b.equals(a);
1399                } if (H5.isFunction(a) && H5.isFunction(b)) {
1400                    return H5.fn.equals.call(a, b);
1401                } else if (H5.isDate(a) && H5.isDate(b)) {
1402                    if (a.kind !== undefined && a.ticks !== undefined && b.kind !== undefined && b.ticks !== undefined) {
1403                        return a.ticks.equals(b.ticks);
1404                    }
1405
1406                    return a.valueOf() === b.valueOf();
1407                } else if (H5.isNull(a) && H5.isNull(b)) {
1408                    return true;
1409                } else if (H5.isNull(a) !== H5.isNull(b)) {
1410                    return false;
1411                }
1412
1413                var eq = a === b;
1414
1415                if (!eq && typeof a === "object" && typeof b === "object" && a !== null && b !== null && a.$kind === "struct" && b.$kind === "struct" && a.$$name === b.$$name) {
1416                    return H5.getHashCode(a) === H5.getHashCode(b) && H5.objectEquals(a, b);
1417                }
1418
1419                if (!eq && a && b && a.hasOwnProperty("Item1") && H5.isPlainObject(a) && b.hasOwnProperty("Item1") && H5.isPlainObject(b)) {
1420                    return H5.objectEquals(a, b, true);
1421                }
1422
1423                return eq;
1424            };
1425
1426            var result = fn(a, b);
1427            H5.$equalsGuard.pop();
1428
1429            return result;
1430        },
1431
1432        objectEquals: function (a, b, oneLevel) {
1433            H5.$$leftChain = [];
1434            H5.$$rightChain = [];
1435
1436            var result = H5.deepEquals(a, b, oneLevel);
1437
1438            delete H5.$$leftChain;
1439            delete H5.$$rightChain;
1440
1441            return result;
1442        },
1443
1444        deepEquals: function (a, b, oneLevel) {
1445            if (typeof a === "object" && typeof b === "object") {
1446                if (a === b) {
1447                    return true;
1448                }
1449
1450                if (H5.$$leftChain.indexOf(a) > -1 || H5.$$rightChain.indexOf(b) > -1) {
1451                    return false;
1452                }
1453
1454                var p;
1455
1456                for (p in b) {
1457                    if (b.hasOwnProperty(p) !== a.hasOwnProperty(p)) {
1458                        return false;
1459                    } else if (typeof b[p] !== typeof a[p]) {
1460                        return false;
1461                    }
1462                }
1463
1464                for (p in a) {
1465                    if (b.hasOwnProperty(p) !== a.hasOwnProperty(p)) {
1466                        return false;
1467                    } else if (typeof a[p] !== typeof b[p]) {
1468                        return false;
1469                    }
1470
1471                    if (a[p] === b[p]) {
1472                        continue;
1473                    }
1473 else if (typeof (a[p]) === "object" && !oneLevel) {
1474                        H5.$$leftChain.push(a);
1475                        H5.$$rightChain.push(b);
1476
1477                        if (!H5.deepEquals(a[p], b[p])) {
1478                            return false;
1479                        }
1480
1481                        H5.$$leftChain.pop();
1482                        H5.$$rightChain.pop();
1483                    } else {
1484                        if (!H5.equals(a[p], b[p])) {
1485                            return false;
1486                        }
1487                    }
1488                }
1489
1490                return true;
1491            } else {
1492                return H5.equals(a, b);
1493            }
1494        },
1495
1496        numberCompare : function (a, b) {
1497            if (a < b) {
1498                return -1;
1499            }
1500
1501            if (a > b) {
1502                return 1;
1503            }
1504
1505            if (a == b) {
1506                return 0;
1507            }
1508
1509            if (!isNaN(a)) {
1510                return 1;
1511            }
1512
1513            if (!isNaN(b)) {
1514                return -1;
1515            }
1516
1517            return 0;
1518        },
1519
1520        compare: function (a, b, safe, T) {
1521            if (a && a.$boxed) {
1522                a = H5.unbox(a, true);
1523            }
1524
1525            if (b && b.$boxed) {
1526                b = H5.unbox(b, true);
1527            }
1528
1529            if (typeof a === "number" && typeof b === "number") {
1530                return H5.numberCompare(a, b);
1531            }
1532
1533            if (!H5.isDefined(a, true)) {
1534                if (safe) {
1535                    return 0;
1536                }
1537
1538                throw new System.NullReferenceException();
1539            } else if (H5.isString(a)) {
1540                return System.String.compare(a, b);
1541            } else if (H5.isNumber(a) || H5.isBoolean(a)) {
1542                return a < b ? -1 : (a > b ? 1 : 0);
1543            } else if (H5.isDate(a)) {
1544                if (a.kind !== undefined && a.ticks !== undefined) {
1545                    return H5.compare(System.DateTime.getTicks(a), System.DateTime.getTicks(b));
1546                }
1547
1548                return H5.compare(a.valueOf(), b.valueOf());
1549            }
1550
1551            var name;
1552
1553            if (T && H5.isFunction(H5.getProperty(a, name = "System$IComparable$1$" + H5.getTypeAlias(T) + "$compareTo"))) {
1554                return a[name](b);
1555            }
1556
1557            if (T && H5.isFunction(H5.getProperty(a, name = "System$IComparable$1$compareTo"))) {
1558                return a[name](b);
1559            }
1560
1561            if (H5.isFunction(H5.getProperty(a, name = "System$IComparable$compareTo"))) {
1562                return a[name](b);
1563            }
1564
1565            if (H5.isFunction(a.compareTo)) {
1566                return a.compareTo(b);
1567            }
1568
1569            if (T && H5.isFunction(H5.getProperty(b, name = "System$IComparable$1$" + H5.getTypeAlias(T) + "$compareTo"))) {
1570                return -b[name](a);
1571            }
1572
1573            if (T && H5.isFunction(H5.getProperty(b, name = "System$IComparable$1$compareTo"))) {
1574                return -b[name](a);
1575            }
1576
1577            if (H5.isFunction(H5.getProperty(b, name = "System$IComparable$compareTo"))) {
1578                return -b[name](a);
1579            }
1580
1581            if (H5.isFunction(b.compareTo)) {
1582                return -b.compareTo(a);
1583            }
1584
1585            if (safe) {
1586                return 0;
1587            }
1588
1589            throw new System.Exception("Cannot compare items");
1590        },
1591
1592        equalsT: function (a, b, T) {
1593            if (a && a.$boxed && a.type.equalsT && a.type.equalsT.length === 2) {
1594                return a.type.equalsT(a, b);
1595            }
1596
1597            if (b && b.$boxed && b.type.equalsT && b.type.equalsT.length === 2) {
1598                return b.type.equalsT(b, a);
1599            }
1600
1601            if (!H5.isDefined(a, true)) {
1602                throw new System.NullReferenceException();
1603            } else if (H5.isNumber(a) || H5.isString(a) || H5.isBoolean(a)) {
1604                return a === b;
1605            } else if (H5.isDate(a)) {
1606                if (a.kind !== undefined && a.ticks !== undefined) {
1607                    return System.DateTime.getTicks(a).equals(System.DateTime.getTicks(b));
1608                }
1609
1610                return a.valueOf() === b.valueOf();
1611            }
1612
1613            var name;
1614
1615            if (T && a != null && H5.isFunction(H5.getProperty(a, name = "System$IEquatable$1$" + H5.getTypeAlias(T) + "$equalsT"))) {
1616                return a[name](b);
1617            }
1618
1619            if (T && b != null && H5.isFunction(H5.getProperty(b, name = "System$IEquatable$1$" + H5.getTypeAlias(T) + "$equalsT"))) {
1620                return b[name](a);
1621            }
1622
1623            if (H5.isFunction(a) && H5.isFunction(b)) {
1624                return H5.fn.equals.call(a, b);
1625            }
1626
1627            return a.equalsT ? a.equalsT(b) : b.equalsT(a);
1628        },
1629
1630        format: function (obj, formatString, provider) {
1631            if (obj && obj.$boxed) {
1632                if (obj.type.$kind === "enum") {
1633                    return System.Enum.format(obj.type, obj.v, formatString);
1634                } else if (obj.type === System.Char) {
1635                    return System.Char.format(H5.unbox(obj, true), formatString, provider);
1636                } else if (obj.type.format) {
1637                    return obj.type.format(H5.unbox(obj, true), formatString, provider);
1638                }
1639            }
1640
1641            if (H5.isNumber(obj)) {
1642                return H5.Int.format(obj, formatString, provider);
1643            } else if (H5.isDate(obj)) {
1644                return System.DateTime.format(obj, formatString, provider);
1645            }
1646
1647            var name;
1648
1649            if (H5.isFunction(H5.getProperty(obj, name = "System$IFormattable$format"))) {
1650                return obj[name](formatString, provider);
1651            }
1652
1653            return obj.format(formatString, provider);
1654        },
1655
1656        getType: function (instance, T) {
1657            if (instance && instance.$boxed) {
1658                return instance.type;
1659            }
1660
1661            if (instance == null) {
1662                throw new System.NullReferenceException.$ctor1("instance is null");
1663            }
1664
1665            if (T) {
1666                var type = H5.getType(instance);
1667                return H5.Reflection.isAssignableFrom(T, type) ? type : T;
1668            }
1669
1670            if (typeof (instance) === "number") {
1671                if (!isNaN(instance) && isFinite(instance) && Math.floor(instance, 0) === instance) {
1672                    return System.Int32;
1673                } else {
1674                    return System.Double;
1675                }
1676            }
1677
1678            if (instance.$type) {
1679                return instance.$type;
1680            }
1681
1682            if (instance.$getType) {
1683                return instance.$getType();
1684            }
1685
1686            var result = null;
1687
1688            try {
1689                result = instance.constructor;
1690            } catch (ex) {
1691                result = Object;
1692            }
1693
1694            if (result === Object) {
1695                var str = instance.toString(),
1696                    match = (/\[object (.{1,})\]/).exec(str),
1697                    name = (match && match.length > 1) ? match[1] : "Object";
1698
1699                if (name != "Object") {
1700                    result = instance;
1701                }
1702            }
1703
1704            return H5.Reflection.convertType(result);
1705        },
1706
1707        isLower: function (c) {
1708            var s = String.fromCharCode(c);
1709
1710            return s === s.toLowerCase() && s !== s.toUpperCase();
1711        },
1712
1713        isUpper: function (c) {
1714            var s = String.fromCharCode(c);
1715
1716            return s !== s.toLowerCase() && s === s.toUpperCase();
1717        },
1718
1719        coalesce: function (a, b) {
1720            return H5.hasValue(a) ? a : b;
1721        },
1722
1723        fn: {
1724            equals: function (fn) {
1725                if (this === fn) {
1726                    return true;
1727                }
1728
1729                if (fn == null || (this.constructor !== fn.constructor)) {
1730                    return false;
1731                }
1732
1733                if (this.$invocationList && fn.$invocationList) {
1734                    if (this.$invocationList.length !== fn.$invocationList.length) {
1735                        return false;
1736                    }
1737
1738                    for (var i = 0; i < this.$invocationList.length; i++) {
1739                        if (this.$invocationList[i] !== fn.$invocationList[i]) {
1740                            return false;
1741                        }
1742                    }
1743
1744                    return true;
1745                }
1746
1747                return this.equals && (this.equals === fn.equals) && this.$method && (this.$method === fn.$method) && this.$scope && (this.$scope === fn.$scope);
1748            },
1749
1750            call: function (obj, fnName) {
1751                var args = Array.prototype.slice.call(arguments, 2);
1752
1753                obj = obj || H5.global;
1754
1755                return obj[fnName].apply(obj, args);
1756            },
1757
1758            makeFn: function (fn, length) {
1759                switch (length) {
1760                    case 0:
1761                        return function () {
1762                            return fn.apply(this, arguments);
1763                        };
1764                    case 1:
1765                        return function (a) {
1766                            return fn.apply(this, arguments);
1767                        };
1768                    case 2:
1769                        return function (a, b) {
1770                            return fn.apply(this, arguments);
1771                        };
1772                    case 3:
1773                        return function (a, b, c) {
1774                            return fn.apply(this, arguments);
1775                        };
1776                    case 4:
1777                        return function (a, b, c, d) {
1778                            return fn.apply(this, arguments);
1779                        };
1780                    case 5:
1781                        return function (a, b, c, d, e) {
1782                            return fn.apply(this, arguments);
1783                        };
1784                    case 6:
1785                        return function (a, b, c, d, e, f) {
1786                            return fn.apply(this, arguments);
1787                        };
1788                    case 7:
1789                        return function (a, b, c, d, e, f, g) {
1790                            return fn.apply(this, arguments);
1791                        };
1792                    case 8:
1793                        return function (a, b, c, d, e, f, g, h) {
1794                            return fn.apply(this, arguments);
1795                        };
1796                    case 9:
1797                        return function (a, b, c, d, e, f, g, h, i) {
1798                            return fn.apply(this, arguments);
1799                        };
1800                    case 10:
1801                        return function (a, b, c, d, e, f, g, h, i, j) {
1802                            return fn.apply(this, arguments);
1803                        };
1804                    case 11:
1805                        return function (a, b, c, d, e, f, g, h, i, j, k) {
1806                            return fn.apply(this, arguments);
1807                        };
1808                    case 12:
1809                        return function (a, b, c, d, e, f, g, h, i, j, k, l) {
1810                            return fn.apply(this, arguments);
1811                        };
1812                    case 13:
1813                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m) {
1814                            return fn.apply(this, arguments);
1815                        };
1816                    case 14:
1817                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n) {
1818                            return fn.apply(this, arguments);
1819                        };
1820                    case 15:
1821                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) {
1822                            return fn.apply(this, arguments);
1823                        };
1824                    case 16:
1825                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {
1826                            return fn.apply(this, arguments);
1827                        };
1828                    case 17:
1829                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) {
1830                            return fn.apply(this, arguments);
1831                        };
1832                    case 18:
1833                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) {
1834                            return fn.apply(this, arguments);
1835                        };
1836                    case 19:
1837                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) {
1838                            return fn.apply(this, arguments);
1839                        };
1840                    default:
1841                        return function (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) {
1842                            return fn.apply(this, arguments);
1843                        };
1844                }
1845            },
1846
1847            cacheBind: function (obj, method, args, appendArgs) {
1848                return H5.fn.bind(obj, method, args, appendArgs, true);
1849            },
1850
1851            bind: function (obj, method, args, appendArgs, cache) {
1852                if (method && method.$method === method && method.$scope === obj) {
1853                    return method;
1854                }
1855
1856                if (obj && cache && obj.$$bind) {
1857                    for (var i = 0; i < obj.$$bind.length; i++) {
1858                        if (obj.$$bind[i].$method === method) {
1859                            return obj.$$bind[i];
1860                        }
1861                    }
1862                }
1863
1864                var fn;
1865
1866                if (arguments.length === 2) {
1867                    fn = H5.fn.makeFn(function () {
1868                        H5.caller.unshift(this);
1869
1870                        var result = null;
1871
1872                        try {
1873                            result = method.apply(obj, arguments);
1874                        } finally {
1875                            H5.caller.shift(this);
1876                        }
1877
1878                        return result;
1879                    }, method.length);
1880                } else {
1881                    fn = H5.fn.makeFn(function () {
1882                        var callArgs = args || arguments;
1883
1884                        if (appendArgs === true) {
1885                            callArgs = Array.prototype.slice.call(arguments, 0);
1886                            callArgs = callArgs.concat(args);
1887                        } else if (typeof appendArgs === "number") {
1888                            callArgs = Array.prototype.slice.call(arguments, 0);
1889
1890                            if (appendArgs === 0) {
1891                                callArgs.unshift.apply(callArgs, args);
1892                            } else if (appendArgs < callArgs.length) {
1893                                callArgs.splice.apply(callArgs, [appendArgs, 0].concat(args));
1894                            } else {
1895                                callArgs.push.apply(callArgs, args);
1896                            }
1897                        }
1898
1899                        H5.caller.unshift(this);
1900
1901                        var result = null;
1902
1903                        try {
1904                            result = method.apply(obj, callArgs);
1905                        } finally {
1906                            H5.caller.shift(this);
1907                        }
1908
1909                        return result;
1910                    }, method.length);
1911                }
1912
1913                if (obj && cache) {
1914                    obj.$$bind = obj.$$bind || [];
1915                    obj.$$bind.push(fn);
1916                }
1917
1918                fn.$method = method;
1919                fn.$scope = obj;
1920                fn.equals = H5.fn.equals;
1921
1922                return fn;
1923            },
1924
1925            bindScope: function (obj, method) {
1926                var fn = H5.fn.makeFn(function 
1926() {
1927                    var callArgs = Array.prototype.slice.call(arguments, 0);
1928
1929                    callArgs.unshift.apply(callArgs, [obj]);
1930
1931                    H5.caller.unshift(this);
1932
1933                    var result = null;
1934
1935                    try {
1936                        result = method.apply(obj, callArgs);
1937                    } finally {
1938                        H5.caller.shift(this);
1939                    }
1940
1941                    return result;
1942                }, method.length);
1943
1944                fn.$method = method;
1945                fn.$scope = obj;
1946                fn.equals = H5.fn.equals;
1947
1948                return fn;
1949            },
1950
1951            $build: function (handlers) {
1952                if (!handlers || handlers.length === 0) {
1953                    return null;
1954                }
1955
1956                var fn = function () {
1957                    var result = null,
1958                        i,
1959                        handler;
1960
1961                    for (i = 0; i < handlers.length; i++) {
1962                        handler = handlers[i];
1963                        result = handler.apply(null, arguments);
1964                    }
1965
1966                    return result;
1967                };
1968
1969                fn.$invocationList = handlers ? Array.prototype.slice.call(handlers, 0) : [];
1970                handlers = fn.$invocationList.slice();
1971
1972                return fn;
1973            },
1974
1975            combine: function (fn1, fn2) {
1976                if (!fn1 || !fn2) {
1977                    var fn = fn1 || fn2;
1978
1979                    return fn ? H5.fn.$build([fn]) : fn;
1980                }
1981
1982                var list1 = fn1.$invocationList ? fn1.$invocationList : [fn1],
1983                    list2 = fn2.$invocationList ? fn2.$invocationList : [fn2];
1984
1985                return H5.fn.$build(list1.concat(list2));
1986            },
1987
1988            getInvocationList: function (fn) {
1989                if (fn == null) {
1990                    throw new System.ArgumentNullException();
1991                }
1992
1993                if (!fn.$invocationList) {
1994                    fn.$invocationList = [fn];
1995                }
1996
1997                return fn.$invocationList;
1998            },
1999
2000            remove: function (fn1, fn2) {
2001                if (!fn1 || !fn2) {
2002                    return fn1 || null;
2003                }
2004
2005                var list1 = fn1.$invocationList ? fn1.$invocationList.slice(0) : [fn1],
2006                    list2 = fn2.$invocationList ? fn2.$invocationList : [fn2],
2007                    result = [],
2008                    exclude,
2009                    i,
2010                    j;
2011
2012                exclude = -1;
2013
2014                for (i = list1.length - list2.length; i >= 0; i--) {
2015                    if (H5.fn.equalInvocationLists(list1, list2, i, list2.length)) {
2016                        if (list1.length - list2.length == 0) {
2017                            return null;
2018                        } else if (list1.length - list2.length == 1) {
2019                            return list1[i != 0 ? 0 : list1.length - 1];
2020                        } else {
2021                            list1.splice(i, list2.length);
2022
2023                            return H5.fn.$build(list1);
2024                        }
2025                    }
2026                }
2027
2028                return fn1;
2029            },
2030
2031            equalInvocationLists: function (a, b, start, count) {
2032                for (var i = 0; i < count; i = (i + 1) | 0) {
2033                    if (!(H5.equals(a[System.Array.index(((start + i) | 0), a)], b[System.Array.index(i, b)]))) {
2034                        return false;
2035                    }
2036                }
2037
2038                return true;
2039            },
2040        },
2041
2042        sleep: function (ms, timeout) {
2043            if (H5.hasValue(timeout)) {
2044                ms = timeout.getTotalMilliseconds();
2045            }
2046
2047            if (isNaN(ms) || ms < -1 || ms > 2147483647) {
2048                throw new System.ArgumentOutOfRangeException.$ctor4("timeout", "Number must be either non-negative and less than or equal to Int32.MaxValue or -1");
2049            }
2050
2051            if (ms == -1) {
2052                ms = 2147483647;
2053            }
2054
2055            var start = new Date().getTime();
2056
2057            while ((new Date().getTime() - start) < ms) {
2058                if ((new Date().getTime() - start) > 2147483647) {
2059                    break;
2060                }
2061            }
2062        },
2063
2064        getMetadata: function (t) {
2065            var m = t.$getMetadata ? t.$getMetadata() : t.$metadata;
2066
2067            return m;
2068        },
2069
2070        loadModule: function (config, callback) {
2071            var amd = config.amd,
2072                cjs = config.cjs,
2073                fnName = config.fn;
2074
2075            var tcs = new System.Threading.Tasks.TaskCompletionSource(),
2076                fn = H5.global[fnName || "require"];
2077
2078            if (amd && amd.length > 0) {
2079                fn(amd, function () {
2080                    var loads = Array.prototype.slice.call(arguments, 0);
2081
2082                    if (cjs && cjs.length > 0) {
2083                        for (var i = 0; i < cjs.length; i++) {
2084                            loads.push(fn(cjs[i]));
2085                        }
2086                    }
2087
2088                    callback.apply(H5.global, loads);
2089                    tcs.setResult();
2090                });
2091            } else if (cjs && cjs.length > 0) {
2092                var t = new System.Threading.Tasks.Task();
2093                t.status = System.Threading.Tasks.TaskStatus.ranToCompletion;
2094
2095                var loads = [];
2096
2097                for (var j = 0; j < cjs.length; j++) {
2098                    loads.push(fn(cjs[j]));
2099                }
2100
2101                callback.apply(H5.global, loads);
2102
2103                return t;
2104            } else {
2105                var t = new System.Threading.Tasks.Task();
2106                t.status = System.Threading.Tasks.TaskStatus.ranToCompletion;
2107
2108                return t;
2109            }
2110
2111            return tcs.task;
2112        }
2113    };
2114
2115    if (!globals.setImmediate) {
2116        core.setImmediate = (function () {
2117            var head = {},
2118                tail = head;
2119
2120            var id = Math.random();
2121
2122            function onmessage (e) {
2123                if (e.data != id) {
2124                    return;
2125                }
2126
2127                head = head.next;
2128                var func = head.func;
2129                delete head.func;
2130                func();
2131            }
2132
2133            if (typeof window !== "undefined") {
2134                if (window.addEventListener) {
2135                    window.addEventListener("message", onmessage);
2136                } else {
2137                    window.attachEvent("onmessage", onmessage);
2138                }
2139            }
2140
2141            return function (func) {
2142                tail = tail.next = { func: func };
2143
2144                if (typeof window !== "undefined") {
2145                    window.postMessage(id, "*");
2146                }
2147            };
2148        }());
2149    } else {
2150        core.setImmediate = globals.setImmediate.bind(globals);
2151    }
2152
2153    globals.H5 = core;
2154    globals.H5.caller = [];
2155    globals.H5.$equalsGuard = [];
2156    globals.H5.$toStringGuard = [];
2157
2158    if (globals.console) {
2159        globals.H5.Console = globals.console;
2160    }
2161
2162    globals.System = {};
2163    globals.System.Diagnostics = {};
2164    globals.System.Diagnostics.Contracts = {};
2165    globals.System.Threading = {};
2166
2167    // @source Browser.js
2168
2169    var check = function (regex) {
2170        return H5.global.navigator && regex.test(H5.global.navigator.userAgent.toLowerCase());
2171    },
2172
2173    isStrict = H5.global.document && H5.global.document.compatMode === "CSS1Compat",
2174
2175    version = function (is, regex) {
2176        var m;
2177
2178        return H5.global.navigator && (is && (m = regex.exec(navigator.userAgent.toLowerCase()))) ? parseFloat(m[1]) : 0;
2179    },
2180
2181    docMode = H5.global.document ? H5.global.document.documentMode : null,
2182    isOpera = check(/opera/),
2183    isOpera10_5 = isOpera && check(/version\/10\.5/),
2184    isChrome = check(/\bchrome\b/),
2185    isWebKit = check(/webkit/),
2186    isSafari = !isChrome && check(/safari/),
2187    isSafari2 = isSafari && check(/applewebkit\/4/),
2188    isSafari3 = isSafari && check(/version\/3/),
2189    isSafari4 = isSafari && check(/version\/4/),
2190    isSafari5_0 = isSafari && check(/version\/5\.0/),
2191    isSafari5 = isSafari && check(/version\/5/),
2192    isIE = !isOpera && (check(/msie/) || check(/trident/)),
2193    isIE7 = isIE && ((check(/msie 7/) && docMode !== 8 && docMode !== 9 && docMode !== 10) || docMode === 7),
2194    isIE8 = isIE && ((check(/msie 8/) && docMode !== 7 && docMode !== 9 && docMode !== 10) || docMode === 8),
2195    isIE9 = isIE && ((check(/msie 9/) && docMode !== 7 && docMode !== 8 && docMode !== 10) || docMode === 9),
2196    isIE10 = isIE && ((check(/msie 10/) && docMode !== 7 && docMode !== 8 && docMode !== 9) || docMode === 10),
2197    isIE11 = isIE && ((check(/trident\/7\.0/) && docMode !== 7 && docMode !== 8 && docMode !== 9 && docMode !== 10) || docMode === 11),
2198    isIE6 = isIE && check(/msie 6/),
2199    isGecko = !isWebKit && !isIE && check(/gecko/),
2200    isGecko3 = isGecko && check(/rv:1\.9/),
2201    isGecko4 = isGecko && check(/rv:2\.0/),
2202    isGecko5 = isGecko && check(/rv:5\./),
2203    isGecko10 = isGecko && check(/rv:10\./),
2204    isFF3_0 = isGecko3 && check(/rv:1\.9\.0/),
2205    isFF3_5 = isGecko3 && check(/rv:1\.9\.1/),
2206    isFF3_6 = isGecko3 && check(/rv:1\.9\.2/),
2207    isWindows = check(/windows|win32/),
2208    isMac = check(/macintosh|mac os x/),
2209    isLinux = check(/linux/),
2210    scrollbarSize = null,
2211    chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/),
2212    firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/),
2213    ieVersion = version(isIE, /msie (\d+\.\d+)/),
2214    operaVersion = version(isOpera, /version\/(\d+\.\d+)/),
2215    safariVersion = version(isSafari, /version\/(\d+\.\d+)/),
2216    webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/),
2217    isSecure = H5.global.location ? /^https/i.test(H5.global.location.protocol) : false,
2218    isiPhone = H5.global.navigator && /iPhone/i.test(H5.global.navigator.platform),
2219    isiPod = H5.global.navigator && /iPod/i.test(H5.global.navigator.platform),
2220    isiPad = H5.global.navigator && /iPad/i.test(H5.global.navigator.userAgent),
2221    isBlackberry = H5.global.navigator && /Blackberry/i.test(H5.global.navigator.userAgent),
2222    isAndroid = H5.global.navigator && /Android/i.test(H5.global.navigator.userAgent),
2223    isDesktop = isMac || isWindows || (isLinux && !isAndroid),
2224    isTablet = isiPad,
2225    isPhone = !isDesktop && !isTablet;
2226
2227    var browser = {
2228        isStrict: isStrict,
2229        isIEQuirks: isIE && (!isStrict && (isIE6 || isIE7 || isIE8 || isIE9)),
2230        isOpera: isOpera,
2231        isOpera10_5: isOpera10_5,
2232        isWebKit: isWebKit,
2233        isChrome: isChrome,
2234        isSafari: isSafari,
2235        isSafari3: isSafari3,
2236        isSafari4: isSafari4,
2237        isSafari5: isSafari5,
2238        isSafari5_0: isSafari5_0,
2239        isSafari2: isSafari2,
2240        isIE: isIE,
2241        isIE6: isIE6,
2242        isIE7: isIE7,
2243        isIE7m: isIE6 || isIE7,
2244        isIE7p: isIE && !isIE6,
2245        isIE8: isIE8,
2246        isIE8m: isIE6 || isIE7 || isIE8,
2247        isIE8p: isIE && !(isIE6 || isIE7),
2248        isIE9: isIE9,
2249        isIE9m: isIE6 || isIE7 || isIE8 || isIE9,
2250        isIE9p: isIE && !(isIE6 || isIE7 || isIE8),
2251        isIE10: isIE10,
2252        isIE10m: isIE6 || isIE7 || isIE8 || isIE9 || isIE10,
2253        isIE10p: isIE && !(isIE6 || isIE7 || isIE8 || isIE9),
2254        isIE11: isIE11,
2255        isIE11m: isIE6 || isIE7 || isIE8 || isIE9 || isIE10 || isIE11,
2256        isIE11p: isIE && !(isIE6 || isIE7 || isIE8 || isIE9 || isIE10),
2257        isGecko: isGecko,
2258        isGecko3: isGecko3,
2259        isGecko4: isGecko4,
2260        isGecko5: isGecko5,
2261        isGecko10: isGecko10,
2262        isFF3_0: isFF3_0,
2263        isFF3_5: isFF3_5,
2264        isFF3_6: isFF3_6,
2265        isFF4: 4 <= firefoxVersion && firefoxVersion < 5,
2266        isFF5: 5 <= firefoxVersion && firefoxVersion < 6,
2267        isFF10: 10 <= firefoxVersion && firefoxVersion < 11,
2268        isLinux: isLinux,
2269        isWindows: isWindows,
2270        isMac: isMac,
2271        chromeVersion: chromeVersion,
2272        firefoxVersion: firefoxVersion,
2273        ieVersion: ieVersion,
2274        operaVersion: operaVersion,
2275        safariVersion: safariVersion,
2276        webKitVersion: webKitVersion,
2277        isSecure: isSecure,
2278        isiPhone: isiPhone,
2279        isiPod: isiPod,
2280        isiPad: isiPad,
2281        isBlackberry: isBlackberry,
2282        isAndroid: isAndroid,
2283        isDesktop: isDesktop,
2284        isTablet: isTablet,
2285        isPhone: isPhone,
2286        iOS: isiPhone || isiPad || isiPod,
2287        standalone: H5.global.navigator ? !!H5.global.navigator.standalone : false
2288    };
2289
2290    H5.Browser = browser;
2291
2292    // @source Class.js
2293
2294        var base = {
2295        _initialize: function () {
2296            if (this.$init) {
2297                return;
2298            }
2299
2300            this.$init = {};
2301
2302            if (this.$staticInit) {
2303                this.$staticInit();
2304            }
2305
2306            if (this.$initMembers) {
2307                this.$initMembers();
2308            }
2309        },
2310
2311        initConfig: function (extend, base, config, statics, scope, prototype) {
2312            var initFn,
2313                name,
2314                cls = (statics ? scope : scope.ctor),
2315                descriptors = cls.$descriptors,
2316                aliases = cls.$aliases;
2317
2318            if (config.fields) {
2319                for (name in config.fields) {
2320                    scope[name] = config.fields[name];
2321                }
2322            }
2323
2324            var props = config.properties;
2325            if (props) {
2326                for (name in props) {
2327                    var v = props[name],
2328                        d,
2329                        cfg;
2330
2331                    if (v != null && H5.isPlainObject(v) && (!v.get || !v.set)) {
2332                        for (var k = 0; k < descriptors.length; k++) {
2333                            if (descriptors[k].name === name) {
2334                                d = descriptors[k];
2335                            }
2336                        }
2337
2338                        if (d && d.get && !v.get) {
2339                            v.get = d.get;
2340                        }
2341
2342                        if (d && d.set && !v.set) {
2343                            v.set = d.set;
2344                        }
2345                    }
2346
2347                    cfg = H5.property(statics ? scope : prototype, name, v, statics, cls);
2348                    cfg.name = name;
2349                    cfg.cls = cls;
2350
2351                    descriptors.push(cfg);
2352                }
2353            }
2354
2355            if (config.events) {
2356                for (name in config.events) {
2357                    H5.event(scope, name, config.events[name], statics);
2358                }
2359            }
2360
2361            if (config.alias) {
2362                for (var i = 0; i < config.alias.length; i++) {
2363                    (function (obj, name, alias, cls) {
2364                        var descriptor = null;
2365
2366                        for (var i = descriptors.length - 1; i >= 0; i--) {
2367                            if (descriptors[i].name === name) {
2368                                descriptor = descriptors[i];
2369
2370                                break;
2371                            }
2372                        }
2373
2374                        var arr = Array.isArray(alias) ? alias : [alias];
2375
2376                        for (var j = 0; j < arr.length; j++) {
2377                            alias = arr[j];
2378
2379                            if (descriptor != null) {
2380                                Object.defineProperty(obj, alias, descriptor);
2381                                aliases.push({ alias: alias, descriptor: descriptor });
2382                            } else {
2383                                var m;
2384
2385                                if (scope.hasOwnProperty(name) || !prototype) {
2386                                    m = scope[name];
2387
2388                                    if (m === undefined && prototype) {
2389                                        m = prototype[name];
2390                                    }
2391                                } else {
2392                                    m = prototype[name];
2393
2394                                    if (m === undefined) {
2395                                        m = scope[name];
2396                                    }
2397                                }
2398
2399                                if (!H5.isFunction(m)) {
2400                                    descriptor = {
2401                                        get: function () {
2402                                            return this[name];
2403                                        },
2404
2405                                        set: function (value) {
2406                                            this[name] = value;
2407                                        }
2408                                    };
2409                                    Object.defineProperty(obj, alias, descriptor);
2410                                    aliases.push({ alias: alias, descriptor: descriptor });
2411                                } else {
2412                                    obj[alias] = m;
2413                                    aliases.push({ fn: name, alias: alias });
2414                                }
2415                            }
2416                        }
2417                    })(statics ? scope : prototype, config.alias[i], config.alias[i + 1], cls);
2418
2419                    i++;
2420                }
2421            }
2422
2423            if (config.init) {
2424                initFn = config.init;
2425            }
2426
2427            if (initFn || (extend && !statics && base.$initMembers)) {
2428                scope.$initMembers = function () {
2429                    if (extend && !statics && base.$initMembers) {
2430                        base.$initMembers.call(this);
2431                    }
2432
2433                    if (initFn) {
2434                        initFn.call(this);
2435                    }
2436                };
2437            }
2438        },
2439
2440        convertScheme: function (obj) {
2441            var result = {},
2442                copy = function (obj, to) {
2443
2444                var reserved = ["fields", "methods", "events", "props", "properties", "alias", "ctors"],
2445                    keys = Object.keys(obj);
2446
2447                for (var i = 0; i < keys.length; i++) {
2448                    var name = keys[i];
2449
2450                    if (reserved.indexOf(name) === -1) {
2451                        to[name] = obj[name];
2452                    }
2453                }
2454
2455                if (obj.fields) {
2456                    H5.apply(to, obj.fields);
2457                }
2458
2459                if (obj.methods) {
2460                    H5.apply(to, obj.methods);
2461                }
2462
2463                var config = {},
2464                    write = false;
2465
2466                if (obj.props) {
2467                    config.properties = obj.props;
2468                    write = true;
2469                } else if (obj.properties) {
2470                    config.properties = obj.properties;
2471                    write = true;
2472                }
2473
2474                if (obj.events) {
2475                    config.events = obj.events;
2476                    write = true;
2477                }
2478
2479                if (obj.alias) {
2480                    config.alias = obj.alias;
2481                    write = true;
2482                }
2483
2484                if (obj.ctors) {
2485                    if (obj.ctors.init) {
2486                        config.init = obj.ctors.init;
2487                        write = true;
2488                        delete obj.ctors.init;
2489                    }
2490
2491                    H5.apply(to, obj.ctors);
2492                }
2493
2494                if (write) {
2495                    to.$config = config;
2496                }
2497            };
2498
2499            if (obj.main) {
2500                result.$main = obj.main;
2501                delete obj.main;
2502            }
2503
2504            copy(obj, result);
2505
2506            if (obj.statics || obj.$statics) {
2507                result.$statics = {};
2508                copy(obj.statics || obj.$statics, result.$statics);
2509            }
2510
2511            return result;
2512        },
2513
2514        definei: function (className, gscope, prop) {
2515            if ((prop === true || !prop) && gscope) {
2516                gscope.$kind = "interface";
2517            } else if (prop) {
2518                prop.$kind = "interface";
2519            } else {
2520                gscope = { $kind: "interface" };
2521            }
2522
2523            var c = H5.define(className, gscope, prop);
2524
2525            c.$kind = "interface";
2526            c.$isInterface = true;
2527
2528            return c;
2529        },
2530
2531        // Create a new Class that inherits from this class
2532        define: function (className, gscope, prop, gCfg) {
2533            var isGenericInstance = false;
2534
2535            if (prop === true) {
2536                isGenericInstance = true;
2537                prop = gscope;
2538                gscope = H5.global;
2539            } else if (!prop) {
2540                prop = gscope;
2541                gscope = H5.global;
2542            }
2543
2544            var fn;
2545
2546            if (H5.isFunction(prop)) {
2547                fn = function () {
2548                    var args,
2549                        key,
2550                        obj,
2551                        c;
2552
2553                    key = H5.Class.getCachedType(fn, arguments);
2554
2555                    if (key) {
2556                        return key.type;
2557                    }
2558
2559                    args = Array.prototype.slice.call(arguments);
2560                    obj = prop.apply(null, args);
2561                    c = H5.define(H5.Class.genericName(className, args), obj, true, { fn: fn, args: args });
2562
2563                    if (!H5.Class.staticInitAllow && !H5.Class.queueIsBlocked) {
2564                        H5.Class.$queue.push(c);
2565                    }
2566
2567                    return H5.get(c);
2568                };
2569
2570                fn.$cache = [];
2571
2572                return H5.Class.generic(className, gscope, fn, prop);
2573            }
2574
2575            if (!isGenericInstance) {
2576                H5.Class.staticInitAllow = false;
2577            }
2578
2579            prop = prop || {};
2580            prop.$kind = prop.$kind || "class";
2581
2582            var isNested = false;
2583
2584            if (prop.$kind.match("^nested ") !== null) {
2585                isNested = true;
2586                prop.$kind = prop.$kind.substr(7);
2587            }
2588
2589            if (prop.$kind === "enum" && !prop.inherits) {
2590                prop.inherits = [System.IComparable, System.IFormattable];
2591            }
2592
2593            var rNames = ["fields", "events", "props", "ctors", "methods"],
2594                defaultScheme = H5.isFunction(prop.main) ? 0 : 1,
2595                check = function (scope) {
2596                    if (scope.config && H5.isPlainObject(scope.config) ||
2597                        scope.$main && H5.isFunction(scope.$main) ||
2598                        scope.hasOwnProperty("ctor") && H5.isFunction(scope.ctor)) {
2599                        defaultScheme = 1;
2600
2601                        return false;
2602                    }
2603
2604                    if (scope.alias && H5.isArray(scope.alias) && scope.alias.length > 0 && scope.alias.length % 2 === 0) {
2605                        return true;
2606                    }
2607
2608                    for (var j = 0; j < rNames.length; j++) {
2609                        if (scope[rNames[j]] && H5.isPlainObject(scope[rNames[j]])) {
2610                            return true;
2611                        }
2612                    }
2613
2614                    return false;
2615                },
2616                alternateScheme = check(prop);
2617
2618            if (!alternateScheme && prop.statics) {
2619                alternateScheme = check(prop.statics);
2620            }
2621
2622            if (!alternateScheme) {
2623                alternateScheme = defaultScheme == 0;
2624            }
2625
2626            if (alternateScheme) {
2627                prop = H5.Class.convertScheme(prop);
2628            }
2629
2630            var extend = prop.$inherits || prop.inherits,
2631                statics = prop.$statics || prop.statics,
2632                isEntryPoint = prop.$entryPoint,
2633                base,
2634                prototype,
2635                scope = prop.$scope || gscope || H5.global,
2636                objectType = H5.global.System && H5.global.System.Object || Object,
2637                i,
2638                v,
2639                isCtor,
2640                ctorName,
2641                name,
2642                registerT = true;
2643
2644            if (prop.$kind === "enum") {
2645                extend = [System.Enum];
2646            }
2647
2648            if (prop.$noRegister === true) {
2649                registerT = false;
2650                delete prop.$noRegister;
2651            }
2652
2653            if (prop.$inherits) {
2654                delete prop.$inherits;
2655            } else {
2656                delete prop.inherits;
2657            }
2658
2659            if (isEntryPoint) {
2660                delete prop.$entryPoint;
2661            }
2662
2663            if (H5.isFunction(statics)) {
2664                statics = null;
2665            } else if (prop.$statics) {
2666                delete prop.$statics;
2667            } else {
2668                delete prop.statics;
2669            }
2670
2671            var Class,
2672                cls = prop.hasOwnProperty("ctor") && prop.ctor;
2673
2674            if (!cls) {
2675                if (prop.$literal) {
2676                    Class = function (obj) {
2677                        obj = obj || {};
2678                        obj.$getType = function () { return Class };
2679
2680                        return obj;
2681                    };
2682                } else {
2683                    Class = function () {
2684                        this.$initialize();
2685
2686                        if (Class.$base) {
2687                            if (Class.$$inherits && Class.$$inherits.length > 0 && Class.$$inherits[0].$staticInit) {
2688                                Class.$$inherits[0].$staticInit();
2689                            }
2690
2691                            if (Class.$base.ctor) {
2692                                Class.$base.ctor.call(this);
2693                            } else if (H5.isFunction(Class.$base.constructor)) {
2694                                Class.$base.constructor.call(this);
2695                            }
2696                        }
2697                    };
2698                }
2699
2700                prop.ctor = Class;
2701            } else {
2702                Class = cls;
2703            }
2704
2705            if (prop.$literal) {
2706                if ((!statics || !statics.createInstance)) {
2707                    Class.createInstance = function () {
2708                        var obj = {};
2709
2710                        obj.$getType = function () { return Class };
2711
2712                        return obj;
2713                    };
2714                }
2715
2716                Class.$literal = true;
2717                delete prop.$literal;
2718            }
2719
2720            if (!isGenericInstance && registerT) {
2721                scope = H5.Class.set(scope, className, Class);
2722            }
2723
2724            if (gCfg) {
2725                gCfg.fn.$cache.push({ type: Class, args: gCfg.args });
2726            }
2727
2728            Class.$$name = className;
2729
2730            if (isNested) {
2731                var lastIndex = Class.$$name.lastIndexOf(".");
2732
2733                Class.$$name = Class.$$name.substr(0, lastIndex) + "+" + Class.$$name.substr(lastIndex + 1)
2734            }
2735
2736            Class.$kind = prop.$kind;
2737
2738            if (prop.$module) {
2739                Class.$module = prop.$module;
2740            }
2741
2742            if (prop.$metadata) {
2743                Class.$metadata = prop.$metadata;
2744            }
2745
2746            if (gCfg && isGenericInstance) {
2747                Class.$genericTypeDefinition = gCfg.fn;
2748                Class.$typeArguments = gCfg.args;
2749                Class.$assembly = gCfg.fn.$assembly || H5.$currentAssembly;
2750
2751                var result = H5.Reflection.getTypeFullName(gCfg.fn);
2752
2753                for (i = 0; i < gCfg.args.length; i++) {
2754                    result += (i === 0 ? "[" : ",") + "[" + H5.Reflection.getTypeQName(gCfg.args[i]) + "]";
2755                }
2756
2757                result += "]";
2758
2759                Class.$$fullname = result;
2760            } else {
2761                Class.$$fullname = Class.$$name;
2762            }
2763
2764            if (extend && H5.isFunction(extend)) {
2765                extend = extend();
2766            }
2767
2768            H5.Class.createInheritors(Class, extend);
2769
2770            var noBase = extend ? extend[0].$kind === "interface" : true;
2771
2772            if (noBase) {
2773                extend = null;
2774            }
2775
2776            base = extend ? extend[0].prototype : this.prototype;
2777            Class.$base = base;
2778
2779            if (extend && !extend[0].$$initCtor) {
2780                var cls = extend[0];
2781                var $$initCtor = function () { };
2782                $$initCtor.prototype = cls.prototype;
2783                $$initCtor.prototype.constructor = cls;
2784                $$initCtor.prototype.$$fullname = H5.Reflection.getTypeFullName(cls);
2785
2786                prototype = new $$initCtor();
2787            }
2788            else {
2789                prototype = extend ? new extend[0].$$initCtor() : (objectType.$$initCtor ? new objectType.$$initCtor() : new objectType());
2790            }
2791
2792            Class.$$initCtor = function () { };
2793            Class.$$initCtor.prototype = prototype;
2794            Class.$$initCtor.prototype.constructor = Class;
2795            Class.$$initCtor.prototype.$$fullname = gCfg && isGenericInstance ? Class.$$fullname : Class.$$name;
2796
2797            if (statics) {
2798                var staticsConfig = statics.$config || statics.config;
2799
2800                if (staticsConfig && !H5.isFunction(staticsConfig)) {
2801                    H5.Class.initConfig(extend, base, staticsConfig, true, Class);
2802
2803                    if (statics.$config) {
2804                        delete statics.$config;
2805                    } else {
2806                        delete statics.config;
2807                    }
2808                }
2809            }
2810
2811            var instanceConfig = prop.$config || prop.config;
2812
2813            if (instanceConfig && !H5.isFunction(instanceConfig)) {
2814                H5.Class.initConfig(extend, base, instanceConfig, false, prop, prototype);
2815
2816                if (prop.$config) {
2817                    delete prop.$config;
2818                } else {
2819                    delete prop.config;
2820                }
2821            } else if (extend && base.$initMembers) {
2822                prop.$initMembers = function () {
2823                    base.$initMembers.call(this);
2824                };
2825            }
2826
2827            prop.$initialize = H5.Class._initialize;
2828
2829            var keys = [];
2830
2831            for (name in prop) {
2832                keys.push(name);
2833            }
2834
2835            for (i = 0; i < keys.length; i++) {
2836                name = keys[i];
2837
2838                v = prop[name];
2839                isCtor = name === "ctor";
2840                ctorName = name;
2841
2842                if (H5.isFunction(v) && (isCtor || name.match("^\\$ctor") !== null)) {
2843                    isCtor = true;
2844                }
2845
2846                var member = prop[name];
2847
2848                if (isCtor) {
2849                    Class[ctorName] = member;
2850                    Class[ctorName].prototype = prototype;
2851                    Class[ctorName].prototype.constructor = Class;
2852                    prototype[ctorName] = member;
2853                } else {
2854                    prototype[ctorName] = member;
2855                }
2856            }
2857
2858            prototype.$$name = className;
2859
2860            if (!prototype.toJSON) {
2861                prototype.toJSON = H5.Class.toJSON;
2862            }
2863
2864            if (statics) {
2865                for (name in statics) {
2866                    var member = statics[name];
2867
2868                    if (name === "ctor") {
2869                        Class["$ctor"] = member;
2870                    } else {
2871                        if (prop.$kind === "enum" && !H5.isFunction(member) && name.charAt(0) !== "$") {
2872                            Class.$names = Class.$names || [];
2873                            Class.$names.push({name: name, value: member});
2874                        }
2875
2876                        Class[name] = member;
2877                    }
2878                }
2879
2880                if (prop.$kind === "enum" && Class.$names) {
2881                    Class.$names = Class.$names.sort(function (i1, i2) {
2882                        if (H5.isFunction(i1.value.eq)) {
2883                            return i1.value.sub(i2.value).sign();
2884                        }
2885
2886                        return i1.value - i2.value;
2887                    }).map(function (i) {
2888                        return i.name;
2889                    });
2890                }
2891            }
2892
2893            if (!extend) {
2894                extend = [objectType].concat(Class.$interfaces);
2895            }
2896
2897            H5.Class.setInheritors(Class, extend);
2898
2899            fn = function () {
2900                if (H5.Class.staticInitAllow && !Class.$isGenericTypeDefinition) {
2901                    Class.$staticInit = null;
2902
2903                    if (Class.$initMembers) {
2904                        Class.$initMembers();
2905                    }
2906
2907                    if (Class.$ctor) {
2908                        Class.$ctor();
2909                    }
2910                }
2911            };
2912
2913            if (isEntryPoint || H5.isFunction(prototype.$main)) {
2914                if (prototype.$main) {
2915                    var entryName = prototype.$main.name || "Main";
2916
2917                    if (!Class[entryName]) {
2918                        Class[entryName] = prototype.$main;
2919                    }
2920                }
2921
2922                H5.Class.$queueEntry.push(Class);
2923            }
2924
2925            Class.$staticInit = fn;
2926
2927            if (!isGenericInstance && registerT) {
2928                H5.Class.registerType(className, Class);
2929            }
2930
2931            if (H5.Reflection) {
2932                Class.$getMetadata = H5.Reflection.getMetadata;
2933            }
2934
2935            if (Class.$kind === "enum") {
2936                if (!Class.prototype.$utype) {
2937                    Class.prototype.$utype = System.Int32;
2938                }
2939                Class.$is = function (instance) {
2940                    var utype = Class.prototype.$utype;
2941
2942                    if (utype === String) {
2943                        return typeof (instance) == "string";
2944                    }
2945
2946                    if (utype && utype.$is) {
2947                        return utype.$is(instance);
2948                    }
2949
2950                    return typeof (instance) == "number";
2951                };
2952
2953                Class.getDefaultValue = function () {
2954                    var utype = Class.prototype.$utype;
2955
2956                    if (utype === String || utype === System.String) {
2957                        return null;
2958                    }
2959
2960                    return 0;
2961                };
2962            }
2963
2964            if (Class.$kind === "interface") {
2965                if (Class.prototype.$variance) {
2966                    Class.isAssignableFrom = H5.Class.varianceAssignable;
2967                }
2968
2969                Class.$isInterface = true;
2970            }
2971
2972            return Class;
2973        },
2974
2975        toCtorString: function () {
2976            return H5.Reflection.getTypeName(this);
2977        },
2978
2979        createInheritors: function (cls, extend) {
2980            var interfaces = [],
2981                baseInterfaces = [],
2982                descriptors = [],
2983                aliases = [];
2984
2985            if (extend) {
2986                for (var j = 0; j < extend.length; j++) {
2987                    var baseType = extend[j],
2988                        baseI = (baseType.$interfaces || []).concat(baseType.$baseInterfaces || []),
2989                        baseDescriptors = baseType.$descriptors,
2990                        baseAliases = baseType.$aliases;
2991
2992                    if (baseDescriptors && baseDescriptors.length > 0) {
2993                        for (var d = 0; d < baseDescriptors.length; d++) {
2994                            descriptors.push(baseDescriptors[d]);
2995                        }
2996                    }
2997
2998                    if (baseAliases && baseAliases.length > 0) {
2999                        for (var d = 0; d < baseAliases.length; d++) {
3000                            aliases.push(baseAliases[d]);
3001                        }
3002                    }
3003
3004                    if (baseI.length > 0) {
3005                        for (var k = 0; k < baseI.length; k++) {
3006                            if (baseInterfaces.indexOf(baseI[k]) < 0) {
3007                                baseInterfaces.push(baseI[k]);
3008                            }
3009                        }
3010                    }
3011
3012                    if (baseType.$kind === "interface") {
3013                        interfaces.push(baseType);
3014                    }
3015                }
3016            }
3017
3018            cls.$descriptors = descriptors;
3019            cls.$aliases = aliases;
3020            cls.$baseInterfaces = baseInterfaces;
3021            cls.$interfaces = interfaces;
3022            cls.$allInterfaces = interfaces.concat(baseInterfaces);
3023        },
3024
3025        toJSON: function () {
3026            var obj = {},
3027                t = H5.getType(this),
3028                descriptors = t.$descriptors || [];
3029
3030            for (var key in this) {
3031                var own = this.hasOwnProperty(key),
3032                    descriptor = null;
3033
3034                if (!own) {
3035                    for (var i = descriptors.length - 1; i >= 0; i--) {
3036                        if (descriptors[i].name === key) {
3037                            descriptor = descriptors[i];
3038
3039                            break;
3040                        }
3041                    }
3042                }
3043
3044                var dcount = key.split("$").length;
3045
3046                if ((own || descriptor != null) && (dcount === 1 || dcount === 2 && key.match("\$\d+$"))) {
3047                    obj[key] = this[key];
3048                }
3049            }
3050
3051            return obj;
3052        },
3053
3054        setInheritors: function (cls, extend) {
3055            cls.$$inherits = extend;
3056
3057            for (var i = 0; i < extend.length; i++) {
3058                var scope = extend[i];
3059
3060                if (!scope.$$inheritors) {
3061                    scope.$$inheritors = [];
3062                }
3063
3064                scope.$$inheritors.push(cls);
3065            }
3066        },
3067
3068        varianceAssignable: function (source) {
3069            var check = function (target, type) {
3070                if (type.$genericTypeDefinition === target.$genericTypeDefinition && type.$typeArguments.length === target.$typeArguments.length) {
3071                    for (var i = 0; i < target.$typeArguments.length; i++) {
3072                        var v = target.prototype.$variance[i], t = target.$typeArguments[i], s = type.$typeArguments[i];
3073
3074                        switch (v) {
3075                            case 1: if (!H5.Reflection.isAssignableFrom(t, s))
3076                                return false;
3077
3078                                break;
3079                            case 2: if (!H5.Reflection.isAssignableFrom(s, t))
3080                                return false;
3081
3082                                break;
3083                            default: if (s !== t)
3084                                return false;
3085                        }
3086                    }
3087
3088                    return true;
3089                }
3090
3091                return false;
3092            };
3093
3094            if (source.$kind === "interface" && check(this, source)) {
3095                return true;
3096            }
3097
3098            var ifs = H5.Reflection.getInterfaces(source);
3099
3100            for (var i = 0; i < ifs.length; i++) {
3101                if (ifs[i] === this || check(this, ifs[i])) {
3102                    return true;
3103                }
3104            }
3105
3106            return false;
3107        },
3108
3109        registerType: function (className, cls) {
3110            if (H5.$currentAssembly) {
3111                H5.$currentAssembly.$types[className] = cls;
3112                cls.$assembly = H5.$currentAssembly;
3113            }
3114        },
3115
3116        addExtend: function (cls, extend) {
3117            var i,
3118                scope;
3119
3120            Array.prototype.push.apply(cls.$$inherits, extend);
3121            cls.$interfaces = cls.$interfaces || [];
3122            cls.$baseInterfaces = cls.$baseInterfaces || [];
3123
3124            for (i = 0; i < extend.length; i++) {
3125                scope = extend[i];
3126
3127                if (!scope.$$inheritors) {
3128                    scope.$$inheritors = [];
3129                }
3130
3131                scope.$$inheritors.push(cls);
3132
3133                var baseI = (scope.$interfaces || []).concat(scope.$baseInterfaces || []);
3134
3135                if (baseI.length > 0) {
3136                    for (var k = 0; k < baseI.length; k++) {
3137                        if (cls.$baseInterfaces.indexOf(baseI[k]) < 0) {
3138                            cls.$baseInterfaces.push(baseI[k]);
3139                        }
3140                    }
3141                }
3142
3143                if (scope.$kind === "interface") {
3144                    cls.$interfaces.push(scope);
3145                }
3146            }
3147
3148            cls.$allInterfaces = cls.$interfaces.concat(cls.$baseInterfaces);
3149        },
3150
3151        set: function (scope, className, cls, noDefineProp) {
3152            var nameParts = className.split("."),
3153                name,
3154                key,
3155                exists,
3156                i;
3157
3158            for (i = 0; i < (nameParts.length - 1) ; i++) {
3159                if (typeof scope[nameParts[i]] == "undefined") {
3160                    scope[nameParts[i]] = {};
3161                }
3162
3163                scope = scope[nameParts[i]];
3164            }
3165
3166            name = nameParts[nameParts.length - 1];
3167            exists = scope[name];
3168
3169            if (exists) {
3170                if (exists.$$name === className) {
3171                    throw "Class '" + className + "' is already defined";
3172                }
3173
3174                for (key in exists) {
3175                    var o = exists[key];
3176
3177                    if (typeof o === "function" && o.$$name) {
3178                        (function (cls, key, o) {
3179                            Object.defineProperty(cls, key, {
3180                                get: function () {
3181                                    if (H5.Class.staticInitAllow) {
3182                                        if (o.$staticInit) {
3183                                            o.$staticInit();
3184                                        }
3185
3186                                        H5.Class.defineProperty(cls, key, o);
3187                                    }
3188
3189                                    return o;
3190                                },
3191
3192                                set: function (newValue) {
3193                                    o = newValue;
3194                                },
3195
3196                                enumerable: true,
3197
3198                                configurable: true
3199                            });
3200                        })(cls, key, o);
3201                    }
3202                }
3203            }
3204
3205            if (noDefineProp !== true) {
3206                (function (scope, name, cls) {
3207                    Object.defineProperty(scope, name, {
3208                        get: function () {
3209                            if (H5.Class.staticInitAllow) {
3210                                if (cls.$staticInit) {
3211                                    cls.$staticInit();
3212                                }
3213
3214                                H5.Class.defineProperty(scope, name, cls);
3215                            }
3216
3217                            return cls;
3218                        },
3219
3220                        set: function (newValue) {
3221                            cls = newValue;
3222                        },
3223
3224                        enumerable: true,
3225
3226                        configurable: true
3227                    });
3228                })(scope, name, cls);
3229            } else {
3230                scope[name] = cls;
3231            }
3232
3233            return scope;
3234        },
3235
3236        defineProperty: function (scope, name, cls) {
3237            Object.defineProperty(scope, name, {
3238                value: cls,
3239                enumerable: true,
3240                configurable: true
3241            });
3242        },
3243
3244        genericName: function (name, typeArguments) {
3245            var gName = name;
3246
3247            for (var i = 0; i < typeArguments.length; i++) {
3248                var ta = typeArguments[i];
3249
3250                gName += "$" + (ta.$$name || H5.getTypeName(ta));
3251            }
3252
3253            return gName;
3254        },
3255
3256        getCachedType: function (fn, args) {
3257            var arr = fn.$cache,
3258                len = arr.length,
3259                key,
3260                found,
3261                i, g;
3262
3263            for (i = 0; i < len; i++) {
3264                key = arr[i];
3265
3266                if (key.args.length === args.length) {
3267                    found = true;
3268
3269                    for (g = 0; g < key.args.length; g++) {
3270                        if (key.args[g] !== args[g]) {
3271                            found = false;
3272
3273                            break;
3274                        }
3275                    }
3276
3277                    if (found) {
3278                        return key;
3279                    }
3280                }
3281            }
3282
3283            return null;
3284        },
3285
3286        generic: function (className, scope, fn, prop) {
3287            fn.$$name = className;
3288            fn.$kind = "class";
3289
3290            H5.Class.set(scope, className, fn, true);
3291            H5.Class.registerType(className, fn);
3292
3293            fn.$typeArgumentCount = prop.length;
3294            fn.$isGenericTypeDefinition = true;
3295            fn.$getMetadata = H5.Reflection.getMetadata;
3296
3297            fn.$staticInit = function () {
3298                fn.$typeArguments = H5.Reflection.createTypeParams(prop);
3299
3300                var old = H5.Class.staticInitAllow,
3301                    oldIsBlocked = H5.Class.queueIsBlocked;
3302
3303                H5.Class.staticInitAllow = false;
3304                H5.Class.queueIsBlocked = true;
3305
3306                var cfg = prop.apply(null, fn.$typeArguments),
3307                    extend = cfg.$inherits || cfg.inherits;
3308
3309                H5.Class.staticInitAllow = old;
3310                H5.Class.queueIsBlocked = oldIsBlocked;
3311
3312                if (extend && H5.isFunction(extend)) {
3313                    extend = extend();
3314                }
3315
3316                H5.Class.createInheritors(fn, extend);
3317
3318                var objectType = H5.global.System && H5.global.System.Object || Object;
3319
3320                if (!extend) {
3321                    extend = [objectType].concat(fn.$interfaces);
3322                }
3323
3324                H5.Class.setInheritors(fn, extend);
3325
3326                var prototype = extend ? (extend[0].$$initCtor ? new extend[0].$$initCtor() : new extend[0]()) : new objectType();
3327
3328                fn.prototype = prototype;
3329                fn.prototype.constructor = fn;
3330                fn.$kind = cfg.$kind || "class";
3331
3332                if (cfg.$module) {
3333                    fn.$module = cfg.$module;
3334                }
3335            };
3336
3337            H5.Class.$queue.push(fn);
3338
3339            return fn;
3340        },
3341
3342        init: function (fn) {
3343            if (H5.Reflection) {
3344                var metas = H5.Reflection.deferredMeta,
3345                    len = metas.length;
3346
3347                if (len > 0) {
3348                    H5.Reflection.deferredMeta = [];
3349
3350                    for (var i = 0; i < len; i++) {
3351                        var item = metas[i];
3352
3353                        H5.setMetadata(item.typeName, item.metadata, item.ns);
3354                    }
3355                }
3356            }
3357
3358            if (fn) {
3359                var old = H5.Class.staticInitAllow;
3360
3361                H5.Class.staticInitAllow = true;
3362                fn();
3363                H5.Class.staticInitAllow = old;
3364
3365                return;
3366            }
3367
3368            H5.Class.staticInitAllow = true;
3369
3370            var queue = H5.Class.$queue.concat(H5.Class.$queueEntry);
3371
3372            H5.Class.$queue.length = 0;
3373            H5.Class.$queueEntry.length = 0;
3374
3375            for (var i = 0; i < queue.length; i++) {
3376                var t = queue[i];
3377
3378                if (t.$staticInit) {
3379                    t.$staticInit();
3380                }
3381
3382                if (t.prototype.$main) {
3383                    (function (cls, name) {
3384                        H5.ready(function () {
3385                            var task = cls[name]();
3386
3387                            if (task && task.continueWith) {
3388                                task.continueWith(function () {
3389                                    setTimeout(function () {
3390                                        task.getAwaitedResult();
3391                                    }, 0);
3392                                });
3393                            }
3394                        });
3395                    })(t, t.prototype.$main.name || "Main");
3396
3397                    t.prototype.$main = null;
3398                }
3399            }
3400        }
3401    };
3402
3403    H5.Class = base;
3404    H5.Class.$queue = [];
3405    H5.Class.$queueEntry = [];
3406    H5.define = H5.Class.define;
3407    H5.definei = H5.Class.definei;
3408    H5.init = H5.Class.init;
3409
3410    function TCS() { return new System.Threading.Tasks.TaskCompletionSource(); }
3411    function STEP(steps, currentStep) { return System.Array.min(steps, currentStep); }
3412
3413    H5.TCS = TCS;
3414    H5.STEP = STEP;
3415
3416    // @source ReflectionAssembly.js
3417
3418    H5.assemblyVersion = function (assemblyName, version) {
3419        System.Reflection.Assembly.versions[assemblyName || "H5.$Unknown"] = version;
3420    };
3421
3422    H5.assembly = function (assemblyName, res, callback, restore) {
3423        if (!callback) {
3424            callback = res;
3425            res = {};
3426        }
3427
3428        assemblyName = assemblyName || "H5.$Unknown";
3429
3430        var asm = System.Reflection.Assembly.assemblies[assemblyName];
3431
3432        if (!asm) {
3433            asm = new System.Reflection.Assembly(assemblyName, res);
3434        } else {
3435            H5.apply(asm.res, res || {});
3436        }
3437
3438        var oldAssembly = H5.$currentAssembly;
3439
3440        H5.$currentAssembly = asm;
3441
3442        if (callback) {
3443            var old = H5.Class.staticInitAllow;
3444            H5.Class.staticInitAllow = false;
3445
3446            callback.call(H5.global, asm, H5.global);
3447
3448            H5.Class.staticInitAllow = old;
3449        }
3450
3451        H5.init();
3452
3453        if (restore) {
3454            H5.$currentAssembly = oldAssembly;
3455        }
3456    };
3457
3458    H5.define("System.Reflection.Assembly", {
3459        statics: {
3460            assemblies: {},
3461            versions: {}
3462        },
3463
3464        ctor: function (name, res) {
3465            this.$initialize();
3466            this.name = name;
3467            this.res = res || {};
3468            this.$types = {};
3469            this.$ = {};
3470
3471            System.Reflection.Assembly.assemblies[name] = this;
3472        },
3473
3474        toString: function () {
3475            return this.name;
3476        },
3477
3478        getVersion: function () {
3479            return System.Reflection.Assembly.versions[this.name] || "";
3480        },
3481
3482        getManifestResourceNames: function () {
3483            return Object.keys(this.res);
3484        },
3485
3486        getManifestResourceDataAsBase64: function (type, name) {
3487            if (arguments.length === 1) {
3488                name = type;
3489                type = null;
3490            }
3491
3492            if (type) {
3493                name = H5.Reflection.getTypeNamespace(type) + "." + name;
3494            }
3495
3496            return this.res[name] || null;
3497        },
3498
3499        getManifestResourceData: function (type, name) {
3500            if (arguments.length === 1) {
3501                name = type;
3502                type = null;
3503            }
3504
3505            if (type) {
3506                name = H5.Reflection.getTypeNamespace(type) + '.' + name;
3507            }
3508
3509            var r = this.res[name];
3510
3511            return r ? System.Convert.fromBase64String(r) : null;
3512        },
3513
3514        getCustomAttributes: function (attributeType) {
3515            if (this.attr && attributeType && !H5.isBoolean(attributeType)) {
3516                return this.attr.filter(function (a) {
3517                    return H5.is(a, attributeType);
3518                });
3519            }
3520
3521            return this.attr || [];
3522        }
3523    });
3524
3525    H5.$currentAssembly = new System.Reflection.Assembly("mscorlib");
3526    H5.SystemAssembly = H5.$currentAssembly;
3527    H5.SystemAssembly.$types["System.Reflection.Assembly"] = System.Reflection.Assembly;
3528    System.Reflection.Assembly.$assembly = H5.SystemAssembly;
3529
3530    var $asm = H5.$currentAssembly;
3531
3532    // @source Object.js
3533
3534    H5.define("System.Object", { });
3535
3536    // @source Void.js
3537
3538    H5.define("System.Void", {
3539        $kind: "struct",
3540        statics: {
3541            methods: {
3542                getDefaultValue: function () { return new System.Void(); }
3543            }
3544        },
3545        methods: {
3546            $clone: function (to) { return this; }
3547        }
3548    });
3549
3550    // @source SystemAssemblyVersion.js
3551
3552    H5.init(function () {
3553        H5.SystemAssembly.version = "";
3554        H5.SystemAssembly.compiler = "0.0.34002";
3555    });
3556
3557    H5.define("H5.Utils.SystemAssemblyVersion");
3558
3559    // @source Reflection.js
3560
3561    H5.Reflection = {
3562        deferredMeta: [],
3563
3564        setMetadata: function (type, metadata, ns) {
3565            if (H5.isString(type)) {
3566                var typeName = type;
3567                type = H5.unroll(typeName);
3568
3569                if (type == null) {
3570                    H5.Reflection.deferredMeta.push({ typeName: typeName, metadata: metadata, ns: ns });
3571                    return;
3572                }
3573            }
3574
3575            ns = H5.unroll(ns);
3576            type.$getMetadata = H5.Reflection.getMetadata;
3577            type.$metadata = metadata;
3578        },
3579
3580        initMetaData: function (type, metadata) {
3581            if (metadata.m) {
3582                for (var i = 0; i < metadata.m.length; i++) {
3583                    var m = metadata.m[i];
3584
3585                    m.td = type;
3586
3587                    if (m.ad) {
3588                        m.ad.td = type;
3589                    }
3590
3591                    if (m.r) {
3592                        m.r.td = type;
3593                    }
3594
3595                    if (m.g) {
3596                        m.g.td = type;
3597                    }
3598
3599                    if (m.s) {
3600                        m.s.td = type;
3601                    }
3602
3603                    if (m.tprm && H5.isArray(m.tprm)) {
3604                        for (var j = 0; j < m.tprm.length; j++) {
3605                            m.tprm[j] = H5.Reflection.createTypeParam(m.tprm[j], type, m, j);
3606                        }
3607                    }
3608                }
3609            }
3610
3611            type.$metadata = metadata;
3612            type.$initMetaData = true;
3613        },
3614
3615        getMetadata: function () {
3616            if (!this.$metadata && this.$genericTypeDefinition) {
3617                this.$metadata = this.$genericTypeDefinition.$factoryMetadata || this.$genericTypeDefinition.$metadata;
3618            }
3619
3620            var metadata = this.$metadata;
3621
3622            if (typeof (metadata) === "function") {
3623                if (this.$isGenericTypeDefinition && !this.$factoryMetadata) {
3624                    this.$factoryMetadata = this.$metadata;
3625                }
3626
3627                if (this.$typeArguments) {
3628                    metadata = this.$metadata.apply(null, this.$typeArguments);
3629                } else if (this.$isGenericTypeDefinition) {
3630                    var arr = H5.Reflection.createTypeParams(this.$metadata);
3631                    this.$typeArguments = arr;
3632                    metadata = this.$metadata.apply(null, arr);
3633                } else {
3634                    metadata = this.$metadata();
3635                }
3636            }
3637
3638            if (!this.$initMetaData && metadata) {
3639                H5.Reflection.initMetaData(this, metadata);
3640            }
3641
3642            return metadata;
3643        },
3644
3645        createTypeParams: function (fn, t) {
3646            var args,
3647                names = [],
3648                fnStr = fn.toString();
3649
3650            args = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(/([^\s,]+)/g) || [];
3651
3652            for (var i = 0; i < args.length; i++) {
3653                names.push(H5.Reflection.createTypeParam(args[i], t, null, i));
3654            }
3655
3656            return names;
3657        },
3658
3659        createTypeParam: function (name, t, m, idx) {
3660            var fn = function TypeParameter() { };
3661
3662            fn.$$name = name;
3663            fn.$isTypeParameter = true;
3664
3665            if (t) {
3666                fn.td = t;
3667            }
3668
3669            if (m) {
3670                fn.md = m;
3671            }
3672
3673            if (idx != null) {
3674                fn.gPrmPos = idx;
3675            }
3676
3677            return fn;
3678        },
3679
3680        load: function (name) {
3681            return System.Reflection.Assembly.assemblies[name] || require(name);
3682        },
3683
3684        getGenericTypeDefinition: function (type) {
3685            if (type.$isGenericTypeDefinition) {
3686                return type;
3687            }
3688
3689            if (!type.$genericTypeDefinition) {
3690                throw new System.InvalidOperationException.$ctor1("This operation is only valid on generic types.");
3691            }
3692
3693            return type.$genericTypeDefinition;
3694        },
3695
3696        getGenericParameterCount: function (type) {
3697            return type.$typeArgumentCount || 0;
3698        },
3699
3700        getGenericArguments: function (type) {
3701            return type.$typeArguments || [];
3702        },
3703
3704        getMethodGenericArguments: function (m) {
3705            return m.tprm || [];
3706        },
3707
3708        isGenericTypeDefinition: function (type) {
3709            return type.$isGenericTypeDefinition || false;
3710        },
3711
3712        isGenericType: function (type) {
3713            return type.$genericTypeDefinition != null || H5.Reflection.isGenericTypeDefinition(type);
3714        },
3715
3716        convertType: function (type) {
3717            if (type === Boolean) {
3718                return System.Boolean;
3719            }
3720
3721            if (type === String) {
3722                return System.String;
3723            }
3724
3725            if (type === Object) {
3726                return System.Object;
3727            }
3728
3729            if (type === Date) {
3730                return System.DateTime;
3731            }
3732
3733            return type;
3734        },
3735
3736        getBaseType: function (type) {
3737            if (H5.isObject(type) || H5.Reflection.isInterface(type) || type.prototype == null) {
3738                return null;
3739            } else if (Object.getPrototypeOf) {
3740                return H5.Reflection.convertType(Object.getPrototypeOf(type.prototype).constructor);
3741            } else {
3742                var p = type.prototype;
3743
3744                if (Object.prototype.hasOwnProperty.call(p, "constructor")) {
3745                    var ownValue;
3746
3747                    try {
3748                        ownValue = p.constructor;
3749                        delete p.constructor;
3750                        return H5.Reflection.convertType(p.constructor);
3751                    } finally {
3752                        p.constructor = ownValue;
3753                    }
3754                }
3755
3756                return H5.Reflection.convertType(p.constructor);
3757            }
3758        },
3759
3760        getTypeFullName: function (obj) {
3761            var str;
3762
3763            if (obj.$$fullname) {
3764                str = obj.$$fullname;
3765            } else if (obj.$$name) {
3766                str = obj.$$name;
3767            }
3768
3769            if (str) {
3770                var ns = H5.Reflection.getTypeNamespace(obj, str);
3771
3772                if (ns) {
3773                    var idx = str.indexOf("[");
3774                    var name = str.substring(ns.length + 1, idx === -1 ? str.length : idx);
3775
3776                    if (new RegExp(/[\.\$]/).test(name)) {
3777                        str = ns + "." + name.replace(/\.|\$/g, function (match) { return (match === ".") ? "+" : "`"; }) + (idx === -1 ? "" : str.substring(idx));
3778                    }
3779                }
3780
3781                return str;
3782            }
3783
3784            if (obj.constructor === Object) {
3785                str = obj.toString();
3786
3787                var match = (/\[object (.{1,})\]/).exec(str);
3788                var name = (match && match.length > 1) ? match[1] : "Object";
3789
3790                return name == "Object" ? "System.Object" : name;
3791            } else if (obj.constructor === Function) {
3792                str = obj.toString();
3793            } else {
3794                str = obj.constructor.toString();
3795            }
3796
3797            var results = (/function (.{1,})\(/).exec(str);
3798
3799            if ((results && results.length > 1)) {
3800                return results[1];
3801            }
3802
3803            return "System.Object";
3804        },
3805
3806        _makeQName: function (name, asm) {
3807            return name + (asm ? ", " + asm.name : "");
3808        },
3809
3810        getTypeQName: function (type) {
3811            return H5.Reflection._makeQName(H5.Reflection.getTypeFullName(type), type.$assembly);
3812        },
3813
3814        getTypeName: function (type) {
3815            var fullName = H5.Reflection.getTypeFullName(type),
3816                bIndex = fullName.indexOf("["),
3817                pIndex = fullName.lastIndexOf("+", bIndex >= 0 ? bIndex : fullName.length),
3818                nsIndex = pIndex > -1 ? pIndex : fullName.lastIndexOf(".", bIndex >= 0 ? bIndex : fullName.length);
3819
3820            var name = nsIndex > 0 ? (bIndex >= 0 ? fullName.substring(nsIndex + 1, bIndex) : fullName.substr(nsIndex + 1)) : fullName;
3821
3822            return type.$isArray ? name + "[]" : name;
3823        },
3824
3825        getTypeNamespace: function (type, name) {
3826            var fullName = name || H5.Reflection.getTypeFullName(type),
3827                bIndex = fullName.indexOf("["),
3828                nsIndex = fullName.lastIndexOf(".", bIndex >= 0 ? bIndex : fullName.length),
3829                ns = nsIndex > 0 ? fullName.substr(0, nsIndex) : "";
3830
3831            if (type.$assembly) {
3832                var parentType = H5.Reflection._getAssemblyType(type.$assembly, ns);
3833
3834                if (parentType) {
3835                    ns = H5.Reflection.getTypeNamespace(parentType);
3836                }
3837            }
3838
3839            return ns;
3840        },
3841
3842        getTypeAssembly: function (type) {
3843            if (type.$isArray) {
3844                return H5.Reflection.getTypeAssembly(type.$elementType);
3845            }
3846
3847            if (System.Array.contains([Date, Number, Boolean, String, Function, Array], type)) {
3848                return H5.SystemAssembly;
3849            }
3850
3851            return type.$assembly || H5.SystemAssembly;
3852        },
3853
3854        _extractArrayRank: function (name) {
3855            var rank = -1,
3856                m = (/<(\d+)>$/g).exec(name);
3857
3858            if (m) {
3859                name = name.substring(0, m.index);
3860                rank = parseInt(m[1]);
3861            }
3862
3863            m = (/\[(,*)\]$/g).exec(name);
3864
3865            if (m) {
3866                name = name.substring(0, m.index);
3867                rank = m[1].length + 1;
3868            }
3869
3870            return {
3871                rank: rank,
3872                name: name
3873            };
3874        },
3875
3876        _getAssemblyType: function (asm, name) {
3877            var noAsm = false,
3878                rank = -1;
3879
3880            if (new RegExp(/[\+\`]/).test(name)) {
3881                name = name.replace(/\+|\`/g, function (match) { return match === "+" ? "." : "$"});
3882            }
3883
3884            if (!asm) {
3885                asm = H5.SystemAssembly;
3886                noAsm = true;
3887            }
3888
3889            var rankInfo = H5.Reflection._extractArrayRank(name);
3890            rank = rankInfo.rank;
3891            name = rankInfo.name;
3892
3893            if (asm.$types) {
3894                var t = asm.$types[name] || null;
3895
3896                if (t) {
3897                    return rank > -1 ? System.Array.type(t, rank) : t;
3898                }
3899
3900                if (asm.name === "mscorlib") {
3901                    asm = H5.global;
3902                } else {
3903                    return null;
3904                }
3905            }
3906
3907            var a = name.split("."),
3908                scope = asm;
3909
3910            for (var i = 0; i < a.length; i++) {
3911                scope = scope[a[i]];
3912
3913                if (!scope) {
3914                    return null;
3915                }
3916            }
3917
3918            if (typeof scope !== "function" || !noAsm && scope.$assembly && asm.name !== scope.$assembly.name) {
3919                return null;
3920            }
3921
3922            return rank > -1 ? System.Array.type(scope, rank) : scope;
3923        },
3924
3925        getAssemblyTypes: function (asm) {
3926            var result = [];
3927
3928            if (asm.$types) {
3929                for (var t in asm.$types) {
3930                    if (asm.$types.hasOwnProperty(t)) {
3931                        result.push(asm.$types[t]);
3932                    }
3933                }
3934            } else {
3935                var traverse = function (s, n) {
3936                    for (var c in s) {
3937                        if (s.hasOwnProperty(c)) {
3938                            traverse(s[c], c);
3939                        }
3940                    }
3941
3942                    if (typeof (s) === "function" && H5.isUpper(n.charCodeAt(0))) {
3943                        result.push(s);
3944                    }
3945                };
3946
3947                traverse(asm, "");
3948            }
3949
3950            return result;
3951        },
3952
3953        createAssemblyInstance: function (asm, typeName) {
3954            var t = H5.Reflection.getType(typeName, asm);
3955
3956            return t ? H5.createInstance(t) : null;
3957        },
3958
3959        getInterfaces: function (type) {
3960            var t;
3961
3962            if (type.$allInterfaces) {
3963                return type.$allInterfaces;
3964            } else if (type === Date) {
3965                return [System.IComparable$1(Date), System.IEquatable$1(Date), System.IComparable, System.IFormattable];
3966            } else if (type === Number) {
3967                return [System.IComparable$1(H5.Int), System.IEquatable$1(H5.Int), System.IComparable, System.IFormattable];
3968            } else if (type === Boolean) {
3969                return [System.IComparable$1(Boolean), System.IEquatable$1(Boolean), System.IComparable];
3970            } else if (type === String) {
3971                return [System.IComparable$1(String), System.IEquatable$1(String), System.IComparable, System.ICloneable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerable$1(System.Char)];
3972            } else if (type === Array || type.$isArray || (t = System.Array._typedArrays[H5.getTypeName(type)])) {
3973                t = t || type.$elementType || System.Object;
3974                return [System.Collections.IEnumerable, System.Collections.ICollection, System.ICloneable, System.Collections.IList, System.Collections.Generic.IEnumerable$1(t), System.Collections.Generic.ICollection$1(t), System.Collections.Generic.IList$1(t)];
3975            } else {
3976                return [];
3977            }
3978        },
3979
3980        isInstanceOfType: function (instance, type) {
3981            return H5.is(instance, type);
3982        },
3983
3984        isAssignableFrom: function (baseType, type) {
3985            if (baseType == null) {
3986                throw new System.NullReferenceException();
3987            }
3988
3989            if (type == null) {
3990                return false;
3991            }
3992
3993            if (baseType === type || H5.isObject(baseType)) {
3994                return true;
3995            }
3996
3997            if (H5.isFunction(baseType.isAssignableFrom)) {
3998                return baseType.isAssignableFrom(type);
3999            }
4000
4001            if (type === Array) {
4002                return System.Array.is([], baseType);
4003            }
4004
4005            if (H5.Reflection.isInterface(baseType) && System.Array.contains(H5.Reflection.getInterfaces(type), baseType)) {
4006                return true;
4007            }
4008
4009            if (baseType.$elementType && baseType.$isArray && type.$elementType && type.$isArray) {
4010                if (H5.Reflection.isValueType(baseType.$elementType) !== H5.Reflection.isValueType(type.$elementType)) {
4011                    return false;
4012                }
4013
4014                return baseType.$rank === type.$rank && H5.Reflection.isAssignableFrom(baseType.$elementType, type.$elementType);
4015            }
4016
4017            var inheritors = type.$$inherits,
4018                i,
4019                r;
4020
4021            if (inheritors) {
4022                for (i = 0; i < inheritors.length; i++) {
4023        
4023            r = H5.Reflection.isAssignableFrom(baseType, inheritors[i]);
4024
4025                    if (r) {
4026                        return true;
4027                    }
4028                }
4029            } else {
4030                return baseType.isPrototypeOf(type);
4031            }
4032
4033            return false;
4034        },
4035
4036        isClass: function (type) {
4037            return (type.$kind === "class" || type.$kind === "nested class" || type === Array || type === Function || type === RegExp || type === String || type === Error || type === Object);
4038        },
4039
4040        isEnum: function (type) {
4041            return type.$kind === "enum";
4042        },
4043
4044        isFlags: function (type) {
4045            return !!(type.prototype && type.prototype.$flags);
4046        },
4047
4048        isInterface: function (type) {
4049            return type.$kind === "interface" || type.$kind === "nested interface";
4050        },
4051
4052        isAbstract: function (type) {
4053            if (type === Function || type === System.Type) {
4054                return true;
4055            }
4056            return ((H5.Reflection.getMetaValue(type, "att", 0) & 128) != 0);
4057        },
4058
4059        _getType: function (typeName, asm, re, noinit) {
4060            var outer = !re;
4061
4062            if (outer) {
4063                typeName = typeName.replace(/\[(,*)\]/g, function (match, g1) {
4064                    return "<" + (g1.length + 1) + ">"
4065                });
4066            }
4067
4068            var next = function () {
4069                for (; ;) {
4070                    var m = re.exec(typeName);
4071
4072                    if (m && m[0] == "[" && (typeName[m.index + 1] === "]" || typeName[m.index + 1] === ",")) {
4073                        continue;
4074                    }
4075
4076                    if (m && m[0] == "]" && (typeName[m.index - 1] === "[" || typeName[m.index - 1] === ",")) {
4077                        continue;
4078                    }
4079
4080                    if (m && m[0] == "," && (typeName[m.index + 1] === "]" || typeName[m.index + 1] === ",")) {
4081                        continue;
4082                    }
4083
4084                    return m;
4085                }
4086            };
4087
4088            re = re || /[[,\]]/g;
4089
4090            var last = re.lastIndex,
4091                m = next(),
4092                tname,
4093                targs = [],
4094                t,
4095                noasm = !asm;
4096
4097            //asm = asm || H5.$currentAssembly;
4098
4099            if (m) {
4100                tname = typeName.substring(last, m.index);
4101
4102                switch (m[0]) {
4103                    case "[":
4104                        if (typeName[m.index + 1] !== "[") {
4105                            return null;
4106                        }
4107
4108                        for (; ;) {
4109                            next();
4110                            t = H5.Reflection._getType(typeName, null, re);
4111
4112                            if (!t) {
4113                                return null;
4114                            }
4115
4116                            targs.push(t);
4117                            m = next();
4118
4119                            if (m[0] === "]") {
4120                                break;
4121                            } else if (m[0] !== ",") {
4122                                return null;
4123                            }
4124                        }
4125
4126                        var arrMatch = (/^\s*<(\d+)>/g).exec(typeName.substring(m.index + 1));
4127
4128                        if (arrMatch) {
4129                            tname = tname + "<" + parseInt(arrMatch[1]) + ">";
4130                        }
4131
4132                        m = next();
4133
4134                        if (m && m[0] === ",") {
4135                            next();
4136
4137                            if (!(asm = System.Reflection.Assembly.assemblies[(re.lastIndex > 0 ? typeName.substring(m.index + 1, re.lastIndex - 1) : typeName.substring(m.index + 1)).trim()])) {
4138                                return null;
4139                            }
4140                        }
4141                        break;
4142
4143                    case "]":
4144                        break;
4145
4146                    case ",":
4147                        next();
4148
4149                        if (!(asm = System.Reflection.Assembly.assemblies[(re.lastIndex > 0 ? typeName.substring(m.index + 1, re.lastIndex - 1) : typeName.substring(m.index + 1)).trim()])) {
4150                            return null;
4151                        }
4152
4153                        break;
4154                }
4155            } else {
4156                tname = typeName.substring(last);
4157            }
4158
4159            if (outer && re.lastIndex) {
4160                return null;
4161            }
4162
4163            tname = tname.trim();
4164
4165            var rankInfo = H5.Reflection._extractArrayRank(tname);
4166            var rank = rankInfo.rank;
4167
4168            tname = rankInfo.name;
4169
4170            t = H5.Reflection._getAssemblyType(asm, tname);
4171
4172            if (noinit) {
4173                return t;
4174            }
4175
4176            if (!t && noasm) {
4177                for (var asmName in System.Reflection.Assembly.assemblies) {
4178                    if (System.Reflection.Assembly.assemblies.hasOwnProperty(asmName) && System.Reflection.Assembly.assemblies[asmName] !== asm) {
4179                        t = H5.Reflection._getType(typeName, System.Reflection.Assembly.assemblies[asmName], null,true);
4180
4181                        if (t) {
4182                            break;
4183                        }
4184                    }
4185                }
4186            }
4187
4188            t = targs.length ? t.apply(null, targs) : t;
4189
4190            if (t && t.$staticInit) {
4191                t.$staticInit();
4192            }
4193
4194            if (rank > -1) {
4195                t = System.Array.type(t, rank);
4196            }
4197
4198            return t;
4199        },
4200
4201        getType: function (typeName, asm) {
4202            if (typeName == null) {
4203                throw new System.ArgumentNullException.$ctor1("typeName");
4204            }
4205
4206            return typeName ? H5.Reflection._getType(typeName, asm) : null;
4207        },
4208
4209        isPrimitive: function (type) {
4210            if (type === System.Int64 ||
4211                type === System.UInt64 ||
4212                type === System.Double ||
4213                type === System.Single ||
4214                type === System.Byte ||
4215                type === System.SByte ||
4216                type === System.Int16 ||
4217                type === System.UInt16 ||
4218                type === System.Int32 ||
4219                type === System.UInt32 ||
4220                type === System.Boolean ||
4221                type === Boolean ||
4222                type === System.Char ||
4223                type === Number) {
4224                return true;
4225            }
4226
4227            return false;
4228        },
4229
4230        canAcceptNull: function (type) {
4231            if (type.$kind === "struct" ||
4232                type.$kind === "enum" ||
4233                type === System.Decimal ||
4234                type === System.Int64 ||
4235                type === System.UInt64 ||
4236                type === System.Double ||
4237                type === System.Single ||
4238                type === System.Byte ||
4239                type === System.SByte ||
4240                type === System.Int16 ||
4241                type === System.UInt16 ||
4242                type === System.Int32 ||
4243                type === System.UInt32 ||
4244                type === H5.Int ||
4245                type === System.Boolean ||
4246                type === System.DateTime ||
4247                type === Boolean ||
4248                type === Date ||
4249                type === Number) {
4250                return false;
4251            }
4252
4253            return true;
4254        },
4255
4256        applyConstructor: function (constructor, args) {
4257            if (!args || args.length === 0) {
4258                return new constructor();
4259            }
4260
4261            if (constructor.$$initCtor && constructor.$kind !== "anonymous") {
4262                var md = H5.getMetadata(constructor),
4263                    count = 0;
4264
4265                if (md) {
4266                    var ctors = H5.Reflection.getMembers(constructor, 1, 28),
4267                        found;
4268
4269                    for (var j = 0; j < ctors.length; j++) {
4270                        var ctor = ctors[j];
4271
4272                        if (ctor.p && ctor.p.length === args.length) {
4273                            found = true;
4274
4275                            for (var k = 0; k < ctor.p.length; k++) {
4276                                var p = ctor.p[k];
4277
4278                                if (!H5.is(args[k], p) || args[k] == null && !H5.Reflection.canAcceptNull(p)) {
4279                                    found = false;
4280
4281                                    break;
4282                                }
4283                            }
4284
4285                            if (found) {
4286                                constructor = constructor[ctor.sn];
4287                                count++;
4288                            }
4289                        }
4290                    }
4291                } else {
4292                    if (H5.isFunction(constructor.ctor) && constructor.ctor.length === args.length) {
4293                        constructor = constructor.ctor;
4294                    } else {
4295                        var name = "$ctor",
4296                            i = 1;
4297
4298                        while (H5.isFunction(constructor[name + i])) {
4299                            if (constructor[name + i].length === args.length) {
4300                                constructor = constructor[name + i];
4301                                count++;
4302                            }
4303
4304                            i++;
4305                        }
4306                    }
4307                }
4308
4309                if (count > 1) {
4310                    throw new System.Exception("The ambiguous constructor call");
4311                }
4312            }
4313
4314            var f = function () {
4315                constructor.apply(this, args);
4316            };
4317
4318            f.prototype = constructor.prototype;
4319
4320            return new f();
4321        },
4322
4323        getAttributes: function (type, attrType, inherit) {
4324            var result = [],
4325                i,
4326                t,
4327                a,
4328                md,
4329                type_md;
4330
4331            if (inherit) {
4332                var b = H5.Reflection.getBaseType(type);
4333
4334                if (b) {
4335                    a = H5.Reflection.getAttributes(b, attrType, true);
4336
4337                    for (i = 0; i < a.length; i++) {
4338                        t = H5.getType(a[i]);
4339                        md = H5.getMetadata(t);
4340
4341                        if (!md || !md.ni) {
4342                            result.push(a[i]);
4343                        }
4344                    }
4345                }
4346            }
4347
4348            type_md = H5.getMetadata(type);
4349
4350            if (type_md && type_md.at) {
4351                for (i = 0; i < type_md.at.length; i++) {
4352                    a = type_md.at[i];
4353
4354                    if (attrType == null || H5.Reflection.isInstanceOfType(a, attrType)) {
4355                        t = H5.getType(a);
4356                        md = H5.getMetadata(t);
4357
4358                        if (!md || !md.am) {
4359                            for (var j = result.length - 1; j >= 0; j--) {
4360                                if (H5.Reflection.isInstanceOfType(result[j], t)) {
4361                                    result.splice(j, 1);
4362                                }
4363                            }
4364                        }
4365
4366                        result.push(a);
4367                    }
4368                }
4369            }
4370
4371            return result;
4372        },
4373
4374        getMembers: function (type, memberTypes, bindingAttr, name, params) {
4375            var result = [];
4376
4377            if ((bindingAttr & 72) === 72 || (bindingAttr & 6) === 4) {
4378                var b = H5.Reflection.getBaseType(type);
4379
4380                if (b) {
4381                    result = H5.Reflection.getMembers(b, memberTypes & ~1, bindingAttr & (bindingAttr & 64 ? 255 : 247) & (bindingAttr & 2 ? 251 : 255), name, params);
4382                }
4383            }
4384
4385            var idx = 0,
4386                f = function (m) {
4387                if ((memberTypes & m.t) && (((bindingAttr & 4) && !m.is) || ((bindingAttr & 8) && m.is)) && (!name || ((bindingAttr & 1) === 1 ? (m.n.toUpperCase() === name.toUpperCase()) : (m.n === name)))) {
4388                    if ((bindingAttr & 16) === 16 && m.a === 2 ||
4389                        (bindingAttr & 32) === 32 && m.a !== 2) {
4390                        if (params) {
4391                            if ((m.p || []).length !== params.length) {
4392                                return;
4393                            }
4394
4395                            for (var i = 0; i < params.length; i++) {
4396                                if (params[i] !== m.p[i]) {
4397                                    return;
4398                                }
4399                            }
4400                        }
4401
4402                        if (m.ov || m.v) {
4403                            result = result.filter(function (a) {
4404                                return !(a.n == m.n && a.t == m.t);
4405                            });
4406                        }
4407
4408                        result.splice(idx++, 0, m);
4409                    }
4410                }
4411            };
4412
4413            var type_md = H5.getMetadata(type);
4414
4415            if (type_md && type_md.m) {
4416                var mNames = ["g", "s", "ad", "r"];
4417
4418                for (var i = 0; i < type_md.m.length; i++) {
4419                    var m = type_md.m[i];
4420
4421                    f(m);
4422
4423                    for (var j = 0; j < 4; j++) {
4424                        var a = mNames[j];
4425
4426                        if (m[a]) {
4427                            f(m[a]);
4428                        }
4429                    }
4430                }
4431            }
4432
4433            if (bindingAttr & 256) {
4434                while (type) {
4435                    var r = [];
4436
4437                    for (var i = 0; i < result.length; i++) {
4438                        if (result[i].td === type) {
4439                            r.push(result[i]);
4440                        }
4441                    }
4442
4443                    if (r.length > 1) {
4444                        throw new System.Reflection.AmbiguousMatchException.$ctor1("Ambiguous match");
4445                    } else if (r.length === 1) {
4446                        return r[0];
4447                    }
4448
4449                    type = H5.Reflection.getBaseType(type);
4450                }
4451
4452                return null;
4453            }
4454
4455            return result;
4456        },
4457
4458        createDelegate: function (mi, firstArgument) {
4459            var isStatic = mi.is || mi.sm,
4460                bind = firstArgument != null && !isStatic,
4461                method = H5.Reflection.midel(mi, firstArgument, null, bind);
4462
4463            if (!bind) {
4464                if (isStatic) {
4465                    return function () {
4466                        var args = firstArgument != null ? [firstArgument] : [];
4467
4468                        return method.apply(mi.td, args.concat(Array.prototype.slice.call(arguments, 0)));
4469                    };
4470                } else {
4471                    return function (target) {
4472                        return method.apply(target, Array.prototype.slice.call(arguments, 1));
4473                    };
4474                }
4475            }
4476
4477            return method;
4478        },
4479
4480        midel: function (mi, target, typeArguments, bind) {
4481            if (bind !== false) {
4482                if (mi.is && !!target) {
4483                    throw new System.ArgumentException.$ctor1("Cannot specify target for static method");
4484                } else if (!mi.is && !target) {
4485                    throw new System.ArgumentException.$ctor1("Must specify target for instance method");
4486                }
4487            }
4488
4489            var method;
4490
4491            if (mi.fg) {
4492                method = function () { return (mi.is ? mi.td : this)[mi.fg]; };
4493            } else if (mi.fs) {
4494                method = function (v) { (mi.is ? mi.td : this)[mi.fs] = v; };
4495            } else {
4496                method = mi.def || (mi.is || mi.sm ? mi.td[mi.sn] : (target ? target[mi.sn] : mi.td.prototype[mi.sn]));
4497
4498                if (mi.tpc) {
4499                    if (mi.constructed && (!typeArguments || typeArguments.length == 0)) {
4500                        typeArguments = mi.tprm;
4501                    }
4502
4503                    if (!typeArguments || typeArguments.length !== mi.tpc) {
4504                        throw new System.ArgumentException.$ctor1("Wrong number of type arguments");
4505                    }
4506
4507                    var gMethod = method;
4508
4509                    method = function () {
4510                        return gMethod.apply(this, typeArguments.concat(Array.prototype.slice.call(arguments)));
4511                    }
4512                } else {
4513                    if (typeArguments && typeArguments.length) {
4514                        throw new System.ArgumentException.$ctor1("Cannot specify type arguments for non-generic method");
4515                    }
4516                }
4517
4518                if (mi.exp) {
4519                    var _m1 = method;
4520
4521                    method = function () { return _m1.apply(this, Array.prototype.slice.call(arguments, 0, arguments.length - 1).concat(arguments[arguments.length - 1])); };
4522                }
4523
4524                if (mi.sm) {
4525                    var _m2 = method;
4526
4527                    method = function () { return _m2.apply(null, [this].concat(Array.prototype.slice.call(arguments))); };
4528                }
4529            }
4530
4531            var orig = method;
4532
4533            method = function () {
4534                var args = [],
4535                    params = mi.pi || [],
4536                    v,
4537                    p;
4538
4539                if (!params.length && mi.p && mi.p.length) {
4540                    params = mi.p.map(function (t) {
4541                        return {pt: t};
4542                    });
4543                }
4544
4545                for (var i = 0; i < arguments.length; i++) {
4546                    p = params[i] || params[params.length - 1];
4547                    v = arguments[i];
4548
4549                    args[i] = p && p.pt === System.Object ? v : H5.unbox(arguments[i]);
4550
4551                    if (v == null && p && H5.Reflection.isValueType(p.pt)) {
4552                        args[i] = H5.getDefaultValue(p.pt);
4553                    }
4554                }
4555
4556                var v = orig.apply(this, args);
4557
4558                return v != null && mi.box ? mi.box(v) : v;
4559            };
4560
4561            return bind !== false ? H5.fn.bind(target, method) : method;
4562        },
4563
4564        invokeCI: function (ci, args) {
4565            if (ci.exp) {
4566                args = args.slice(0, args.length - 1).concat(args[args.length - 1]);
4567            }
4568
4569            if (ci.def) {
4570                return ci.def.apply(null, args);
4571            } else if (ci.sm) {
4572                return ci.td[ci.sn].apply(null, args);
4573            } else {
4574                if (ci.td.$literal) {
4575                    return (ci.sn ? ci.td[ci.sn] : ci.td).apply(ci.td, args);
4576                }
4577
4578                return H5.Reflection.applyConstructor(ci.sn ? ci.td[ci.sn] : ci.td, args);
4579            }
4580        },
4581
4582        fieldAccess: function (fi, obj) {
4583            if (fi.is && !!obj) {
4584                throw new System.ArgumentException.$ctor1("Cannot specify target for static field");
4585            } else if (!fi.is && !obj) {
4586                throw new System.ArgumentException.$ctor1("Must specify target for instance field");
4587            }
4588
4589            obj = fi.is ? fi.td : obj;
4590
4591            if (arguments.length === 3) {
4592                var v = arguments[2];
4593
4594                if (v == null && H5.Reflection.isValueType(fi.rt)) {
4595                    v = H5.getDefaultValue(fi.rt);
4596                }
4597
4598                obj[fi.sn] = v;
4599            } else {
4600                return fi.box ? fi.box(obj[fi.sn]) : obj[fi.sn];
4601            }
4602        },
4603
4604        getMetaValue: function (type, name, dv) {
4605            var md = type.$isTypeParameter ? type : H5.getMetadata(type);
4606
4607            return md ? (md[name] || dv) : dv;
4608        },
4609
4610        isArray: function (type) {
4611            return H5.arrayTypes.indexOf(type) >= 0;
4612        },
4613
4614        isValueType: function (type) {
4615            return !H5.Reflection.canAcceptNull(type);
4616        },
4617
4618        getNestedTypes: function (type, flags) {
4619            var types = H5.Reflection.getMetaValue(type, "nested", []);
4620
4621            if (flags) {
4622                var tmp = [];
4623                for (var i = 0; i < types.length; i++) {
4624                    var nestedType = types[i],
4625                        attrs = H5.Reflection.getMetaValue(nestedType, "att", 0),
4626                        access = attrs & 7,
4627                        isPublic = access === 1 || access === 2;
4628
4629                    if ((flags & 16) === 16 && isPublic ||
4630                        (flags & 32) === 32 && !isPublic) {
4631                        tmp.push(nestedType);
4632                    }
4633                }
4634
4635                types = tmp;
4636            }
4637
4638            return types;
4639        },
4640
4641        getNestedType: function (type, name, flags) {
4642            var types = H5.Reflection.getNestedTypes(type, flags);
4643
4644            for (var i = 0; i < types.length; i++) {
4645                if (H5.Reflection.getTypeName(types[i]) === name) {
4646                    return types[i];
4647                }
4648            }
4649
4650            return null;
4651        },
4652
4653        isGenericMethodDefinition: function (mi) {
4654            return H5.Reflection.isGenericMethod(mi) && !mi.constructed;
4655        },
4656
4657        isGenericMethod: function (mi) {
4658            return !!mi.tpc;
4659        },
4660
4661        containsGenericParameters: function (mi) {
4662            if (mi.$typeArguments) {
4663                for (var i = 0; i < mi.$typeArguments.length; i++) {
4664                    if (mi.$typeArguments[i].$isTypeParameter) {
4665                        return true;
4666                    }
4667                }
4668            }
4669
4670            var tprm = mi.tprm || [];
4671
4672            for (var i = 0; i < tprm.length; i++) {
4673                if (tprm[i].$isTypeParameter) {
4674                    return true;
4675                }
4676            }
4677
4678            return false;
4679        },
4680
4681        genericParameterPosition: function (type) {
4682            if (!type.$isTypeParameter) {
4683                throw new System.InvalidOperationException.$ctor1("The current type does not represent a type parameter.");
4684            }
4685            return type.gPrmPos || 0;
4686        },
4687
4688        makeGenericMethod: function (mi, args) {
4689            var cmi = H5.apply({}, mi);
4690            cmi.tprm = args;
4691            cmi.p = args;
4692            cmi.gd = mi;
4693            cmi.constructed = true;
4694
4695            return cmi;
4696        },
4697
4698        getGenericMethodDefinition: function (mi) {
4699            if (!mi.tpc) {
4700                throw new System.InvalidOperationException.$ctor1("The current method is not a generic method. ");
4701            }
4702
4703            return mi.gd || mi;
4704        }
4705    };
4706
4707    H5.setMetadata = H5.Reflection.setMetadata;
4708
4709    System.Reflection.ConstructorInfo = {
4710        $is: function (obj) {
4711            return obj != null && obj.t === 1;
4712        }
4713    };
4714
4715    System.Reflection.EventInfo = {
4716        $is: function (obj) {
4717            return obj != null && obj.t === 2;
4718        }
4719    };
4720
4721    System.Reflection.FieldInfo = {
4722        $is: function (obj) {
4723            return obj != null && obj.t === 4;
4724        }
4725    };
4726
4727    System.Reflection.MethodBase = {
4728        $is: function (obj) {
4729            return obj != null && (obj.t === 1 || obj.t === 8);
4730        }
4731    };
4732
4733    System.Reflection.MethodInfo = {
4734        $is: function (obj) {
4735            return obj != null && obj.t === 8;
4736        }
4737    };
4738
4739    System.Reflection.PropertyInfo = {
4740        $is: function (obj) {
4741            return obj != null && obj.t === 16;
4742        }
4743    };
4744
4745    System.AppDomain = {
4746        getAssemblies: function () {
4747            return Object.keys(System.Reflection.Assembly.assemblies).map(function (n) { return System.Reflection.Assembly.assemblies[n]; });
4748        }
4749    };
4750
4751    // @source Interfaces.js
4752
4753    H5.define("System.IFormattable", {
4754        $kind: "interface",
4755        statics: {
4756            $is: function (obj) {
4757                if (H5.isNumber(obj) || H5.isDate(obj)) {
4758                    return true;
4759                }
4760
4761                return H5.is(obj, System.IFormattable, true);
4762            }
4763        }
4764    });
4765
4766    H5.define("System.IComparable", {
4767        $kind: "interface",
4768
4769        statics: {
4770            $is: function (obj) {
4771                if (H5.isNumber(obj) || H5.isDate(obj) || H5.isBoolean(obj) || H5.isString(obj)) {
4772                    return true;
4773                }
4774
4775                return H5.is(obj, System.IComparable, true);
4776            }
4777        }
4778    });
4779
4780    H5.define("System.IFormatProvider", {
4781        $kind: "interface"
4782    });
4783
4784    H5.define("System.ICloneable", {
4785        $kind: "interface"
4786    });
4787
4788    H5.define("System.IComparable$1", function (T) {
4789        return {
4790            $kind: "interface",
4791
4792            statics: {
4793                $is: function (obj) {
4794                    if (H5.isNumber(obj) && T.$number && T.$is(obj) || H5.isDate(obj) && (T === Date || T === System.DateTime) || H5.isBoolean(obj) && (T === Boolean || T === System.Boolean) || H5.isString(obj) && (T === String || T === System.String)) {
4795                        return true;
4796                    }
4797
4798                    return H5.is(obj, System.IComparable$1(T), true);
4799                },
4800
4801                isAssignableFrom: function (type) {
4802                    if (type === System.DateTime && T === Date) {
4803                        return true;
4804                    }
4805
4806                    return H5.Reflection.getInterfaces(type).indexOf(System.IComparable$1(T)) >= 0;
4807                }
4808            }
4809        };
4810    });
4811
4812    H5.define("System.IEquatable$1", function (T) {
4813        return {
4814            $kind: "interface",
4815
4816            statics: {
4817                $is: function (obj) {
4818                    if (H5.isNumber(obj) && T.$number && T.$is(obj) || H5.isDate(obj) && (T === Date || T === System.DateTime) || H5.isBoolean(obj) && (T === Boolean || T === System.Boolean) || H5.isString(obj) && (T === String || T === System.String)) {
4819                        return true;
4820                    }
4821
4822                    return H5.is(obj, System.IEquatable$1(T), true);
4823                },
4824
4825                isAssignableFrom: function (type) {
4826                    if (type === System.DateTime && T === Date) {
4827                        return true;
4828                    }
4829
4830                    return H5.Reflection.getInterfaces(type).indexOf(System.IEquatable$1(T)) >= 0;
4831                }
4832            }
4833        };
4834    });
4835
4836    H5.define("H5.IPromise", {
4837        $kind: "interface"
4838    });
4839
4840    H5.define("System.IDisposable", {
4841        $kind: "interface"
4842    });
4843
4844    H5.define("System.IAsyncResult", {
4845        $kind: "interface"
4846    });
4847
4848    // @source ValueType.js
4849
4850H5.define("System.ValueType", {
4851    statics: {
4852        methods: {
4853            $is: function (obj) {
4854                return H5.Reflection.isValueType(H5.getType(obj));
4855            }
4856        }
4857    }
4858});
4859
4860    // @source Enum.js
4861
4862    var enumMethods = {
4863        nameEquals: function (n1, n2, ignoreCase) {
4864            if (ignoreCase) {
4865                return n1.toLowerCase() === n2.toLowerCase();
4866            }
4867
4868            return (n1.charAt(0).toLowerCase() + n1.slice(1)) === (n2.charAt(0).toLowerCase() + n2.slice(1));
4869        },
4870
4871        checkEnumType: function (enumType) {
4872            if (!enumType) {
4873                throw new System.ArgumentNullException.$ctor1("enumType");
4874            }
4875
4876            if (enumType.prototype && enumType.$kind !== "enum") {
4877                throw new System.ArgumentException.$ctor1("", "enumType");
4878            }
4879        },
4880
4881        getUnderlyingType: function (type) {
4882            System.Enum.checkEnumType(type);
4883
4884            return type.prototype.$utype || System.Int32;
4885        },
4886
4887        toName: function (name) {
4888            return name;
4889        },
4890
4891        toObject: function (enumType, value) {
4892            value = H5.unbox(value, true);
4893
4894            if (value == null) {
4895                return null;
4896            }
4897
4898            return enumMethods.parse(enumType, value.toString(), false, true);
4899        },
4900
4901        parse: function (enumType, s, ignoreCase, silent) {
4902            System.Enum.checkEnumType(enumType);
4903
4904            if (s != null) {
4905                if (enumType === Number || enumType === System.String || enumType.$number) {
4906                    return s;
4907                }
4908
4909                var intValue = {};
4910
4911                if (System.Int32.tryParse(s, intValue)) {
4912                    return H5.box(intValue.v, enumType, function (obj) { return System.Enum.toString(enumType, obj); });
4913                }
4914
4915                var names = System.Enum.getNames(enumType),
4916                    values = enumType;
4917
4918                if (!enumType.prototype || !enumType.prototype.$flags) {
4919                    for (var i = 0; i < names.length; i++) {
4920                        var name = names[i];
4921
4922                        if (enumMethods.nameEquals(name, s, ignoreCase)) {
4923                            return H5.box(values[name], enumType, function (obj) { return System.Enum.toString(enumType, obj); });
4924                        }
4925                    }
4926                } else {
4927                    var parts = s.split(","),
4928                        value = 0,
4929                        parsed = true;
4930
4931                    for (var i = parts.length - 1; i >= 0; i--) {
4932                        var part = parts[i].trim(),
4933                            found = false;
4934
4935                        for (var n = 0; n < names.length; n++) {
4936                            var name = names[n];
4937
4938                            if (enumMethods.nameEquals(name, part, ignoreCase)) {
4939                                value |= values[name];
4940                                found = true;
4941
4942                                break;
4943                            }
4944                        }
4945
4946                        if (!found) {
4947                            parsed = false;
4948
4949                            break;
4950                        }
4951                    }
4952
4953                    if (parsed) {
4954                        return H5.box(value, enumType, function (obj) { return System.Enum.toString(enumType, obj); });
4955                    }
4956                }
4957            }
4958
4959            if (silent !== true) {
4960                throw new System.ArgumentException.$ctor3("silent", "Invalid Enumeration Value");
4961            }
4962
4963            return null;
4964        },
4965
4966        toStringFn: function (type) {
4967            return function (value) {
4968                return System.Enum.toString(type, value);
4969            };
4970        },
4971
4972        toString: function (enumType, value, forceFlags) {
4973            if (arguments.length === 0) {
4974                return "System.Enum";
4975            }
4976
4977            if (value && value.$boxed && enumType === System.Enum) {
4978                enumType = value.type;
4979            }
4980
4981            value = H5.unbox(value, true);
4982
4983            if (enumType === Number || enumType === System.String || enumType.$number) {
4984                return value.toString();
4985            }
4986
4987            System.Enum.checkEnumType(enumType);
4988
4989            var values = enumType,
4990                names = System.Enum.getNames(enumType),
4991                isLong = System.Int64.is64Bit(value);
4992
4993            if (((!enumType.prototype || !enumType.prototype.$flags) && forceFlags !== true) || (value === 0)) {
4994                for (var i = 0; i < names.length; i++) {
4995                    var name = names[i];
4996
4997                    if (isLong && System.Int64.is64Bit(values[name]) ? (values[name].eq(value)) : (values[name] === value)) {
4998                        return enumMethods.toName(name);
4999                    }
5000                }
5001
5002                return value.toString();
5003            } else {
5004                var parts = [],
5005                    entries = System.Enum.getValuesAndNames(enumType),
5006                    index = entries.length - 1,
5007                    saveResult = value;
5008
5009                while (index >= 0) {
5010                    var entry = entries[index],
5011                        long = isLong && System.Int64.is64Bit(entry.value);
5012
5013                    if ((index == 0) && (long ? entry.value.isZero() : entry.value == 0)) {
5014                        break;
5015                    }
5016
5017                    if (long ? (value.and(entry.value).eq(entry.value)) : ((value & entry.value) == entry.value)) {
5018                        if (long) {
5019                            value = value.sub(entry.value);
5020                        } else {
5021                            value -= entry.value;
5022                        }
5023
5024                        parts.unshift(entry.name);
5025                    }
5026
5027                    index--;
5028                }
5029
5030                if (isLong ? !value.isZero() : value !== 0) {
5031                    return saveResult.toString();
5032                }
5033
5034                if (isLong ? saveResult.isZero() : saveResult === 0) {
5035                    var entry = entries[0];
5036
5037                    if (entry && (System.Int64.is64Bit(entry.value) ? entry.value.isZero() : (entry.value == 0))) {
5038                        return entry.name;
5039                    }
5040
5041                    return "0";
5042                }
5043
5044                return parts.join(", ");
5045            }
5046        },
5047
5048        getValuesAndNames: function (enumType) {
5049            System.Enum.checkEnumType(enumType);
5050
5051            var parts = [],
5052                names = System.Enum.getNames(enumType),
5053                values = enumType;
5054
5055            for (var i = 0; i < names.length; i++) {
5056                parts.push({ name: names[i], value: values[names[i]] });
5057            }
5058
5059            return parts.sort(function (i1, i2) {
5060                return System.Int64.is64Bit(i1.value) ? i1.value.sub(i2.value).sign() : (i1.value - i2.value);
5061            });
5062        },
5063
5064        getValues: function (enumType) {
5065            System.Enum.checkEnumType(enumType);
5066
5067            var parts = [],
5068                names = System.Enum.getNames(enumType),
5069                values = enumType;
5070
5071            for (var i = 0; i < names.length; i++) {
5072                parts.push(values[names[i]]);
5073            }
5074
5075            return parts.sort(function (i1, i2) {
5076                return System.Int64.is64Bit(i1) ? i1.sub(i2).sign() : (i1 - i2);
5077            });
5078        },
5079
5080        format: function (enumType, value, format) {
5081            System.Enum.checkEnumType(enumType);
5082
5083            var name;
5084
5085            if (!H5.hasValue(value) && (name = "value") || !H5.hasValue(format) && (name = "format")) {
5086                throw new System.ArgumentNullException.$ctor1(name);
5087            }
5088
5089            value = H5.unbox(value, true);
5090
5091            switch (format) {
5092                case "G":
5093                case "g":
5094                    return System.Enum.toString(enumType, value);
5095                case "x":
5096                case "X":
5097                    return value.toString(16);
5098                case "d":
5099                case "D":
5100                    return value.toString();
5101                case "f":
5102                case "F":
5103                    return System.Enum.toString(enumType, value, true);
5104                default:
5105                    throw new System.FormatException();
5106            }
5107        },
5108
5109        getNames: function (enumType) {
5110            System.Enum.checkEnumType(enumType);
5111
5112            var parts = [],
5113                values = enumType;
5114
5115            if (enumType.$names) {
5116                return enumType.$names.slice(0);
5117            }
5118
5119            for (var i in values) {
5120                if (values.hasOwnProperty(i) && i.indexOf("$") < 0 && typeof values[i] !== "function") {
5121                    parts.push([enumMethods.toName(i), values[i]]);
5122                }
5123            }
5124
5125            return parts.sort(function (i1, i2) {
5126                return System.Int64.is64Bit(i1[1]) ? i1[1].sub(i2[1]).sign() : (i1[1] - i2[1]);
5127            }).map(function (i) {
5128                return i[0];
5129            });
5130        },
5131
5132        getName: function (enumType, value) {
5133            value = H5.unbox(value, true);
5134
5135            if (value == null) {
5136                throw new System.ArgumentNullException.$ctor1("value");
5137            }
5138
5139            var isLong = System.Int64.is64Bit(value);
5140
5141            if (!isLong && !(typeof (value) === "number" && Math.floor(value, 0) === value)) {
5142                throw new System.ArgumentException.$ctor1("Argument must be integer", "value");
5143            }
5144
5145            System.Enum.checkEnumType(enumType);
5146
5147            var names = System.Enum.getNames(enumType),
5148                values = enumType;
5149
5150            for (var i = 0; i < names.length; i++) {
5151                var name = names[i];
5152
5153                if (isLong ? value.eq(values[name]) : (values[name] === value)) {
5154                    return name;
5155                }
5156            }
5157
5158            return null;
5159        },
5160
5161        hasFlag: function (value, flag) {
5162            flag = H5.unbox(flag, true);
5163            var isLong = System.Int64.is64Bit(value);
5164
5165            return flag === 0 || (isLong ? !value.and(flag).isZero() : !!(value & flag));
5166        },
5167
5168        isDefined: function (enumType, value) {
5169            value = H5.unbox(value, true);
5170
5171            System.Enum.checkEnumType(enumType);
5172
5173            var values = enumType,
5174                names = System.Enum.getNames(enumType),
5175                isString = H5.isString(value),
5176                isLong = System.Int64.is64Bit(value);
5177
5178            for (var i = 0; i < names.length; i++) {
5179                var name = names[i];
5180
5181                if (isString ? enumMethods.nameEquals(name, value, false) : (isLong ? value.eq(values[name]) : (values[name] === value))) {
5182                    return true;
5183                }
5184            }
5185
5186            return false;
5187        },
5188
5189        tryParse: function (enumType, value, result, ignoreCase) {
5190            result.v = H5.unbox(enumMethods.parse(enumType, value, ignoreCase, true), true);
5191
5192            if (result.v == null) {
5193                result.v = 0;
5194
5195                return false;
5196            }
5197
5198            return true;
5199        },
5200
5201        equals: function (v1, v2, T) {
5202            if (v2 && v2.$boxed && (v1 && v1.$boxed || T)) {
5203                if (v2.type !== (v1.type || T)) {
5204                    return false;
5205                }
5206            }
5207
5208            return System.Enum.equalsT(v1, v2);
5209        },
5210
5211        equalsT: function (v1, v2) {
5212            return H5.equals(H5.unbox(v1, true), H5.unbox(v2, true));
5213        }
5214    };
5215
5216    H5.define("System.Enum", {
5217        inherits: [System.IComparable, System.IFormattable],
5218        statics: {
5219            methods: enumMethods
5220        }
5221    });
5222
5223    // @source Nullable.js
5224
5225    var nullable = {
5226        hasValue: H5.hasValue,
5227
5228        getValue: function (obj) {
5229            obj = H5.unbox(obj, true);
5230
5231            if (!H5.hasValue(obj)) {
5232                throw new System.InvalidOperationException.$ctor1("Nullable instance doesn't have a value.");
5233            }
5234
5235            return obj;
5236        },
5237
5238        getValueOrDefault: function (obj, defValue) {
5239            return H5.hasValue(obj) ? obj : defValue;
5240        },
5241
5242        add: function (a, b) {
5243            return H5.hasValue$1(a, b) ? a + b : null;
5244        },
5245
5246        band: function (a, b) {
5247            return H5.hasValue$1(a, b) ? a & b : null;
5248        },
5249
5250        bor: function (a, b) {
5251            return H5.hasValue$1(a, b) ? a | b : null;
5252        },
5253
5254        and: function (a, b) {
5255            if (a === true && b === true) {
5256                return true;
5257            } else if (a === false || b === false) {
5258                return false;
5259            }
5260
5261            return null;
5262        },
5263
5264        or: function (a, b) {
5265            if (a === true || b === true) {
5266                return true;
5267            } else if (a === false && b === false) {
5268                return false;
5269            }
5270
5271            return null;
5272        },
5273
5274        div: function (a, b) {
5275            return H5.hasValue$1(a, b) ? a / b : null;
5276        },
5277
5278        eq: function (a, b) {
5279            return !H5.hasValue(a) ? !H5.hasValue(b) : (a === b);
5280        },
5281
5282        equals: function (a, b, fn) {
5283            return !H5.hasValue(a) ? !H5.hasValue(b) : (fn ? fn(a, b) : H
52835.equals(a, b));
5284        },
5285
5286        toString: function (a, fn) {
5287            return !H5.hasValue(a) ? "" : (fn ? fn(a) : a.toString());
5288        },
5289
5290        toStringFn: function (fn) {
5291            return function (v) {
5292                return System.Nullable.toString(v, fn);
5293            };
5294        },
5295
5296        getHashCode: function (a, fn) {
5297            return !H5.hasValue(a) ? 0 : (fn ? fn(a) : H5.getHashCode(a));
5298        },
5299
5300        getHashCodeFn: function (fn) {
5301            return function (v) {
5302                return System.Nullable.getHashCode(v, fn);
5303            };
5304        },
5305
5306        xor: function (a, b) {
5307            if (H5.hasValue$1(a, b)) {
5308                if (H5.isBoolean(a) && H5.isBoolean(b)) {
5309                    return a != b;
5310                }
5311
5312                return a ^ b;
5313            }
5314
5315            return null;
5316        },
5317
5318        gt: function (a, b) {
5319            return H5.hasValue$1(a, b) && a > b;
5320        },
5321
5322        gte: function (a, b) {
5323            return H5.hasValue$1(a, b) && a >= b;
5324        },
5325
5326        neq: function (a, b) {
5327            return !H5.hasValue(a) ? H5.hasValue(b) : (a !== b);
5328        },
5329
5330        lt: function (a, b) {
5331            return H5.hasValue$1(a, b) && a < b;
5332        },
5333
5334        lte: function (a, b) {
5335            return H5.hasValue$1(a, b) && a <= b;
5336        },
5337
5338        mod: function (a, b) {
5339            return H5.hasValue$1(a, b) ? a % b : null;
5340        },
5341
5342        mul: function (a, b) {
5343            return H5.hasValue$1(a, b) ? a * b : null;
5344        },
5345
5346        imul: function (a, b) {
5347            return H5.hasValue$1(a, b) ? H5.Int.mul(a, b) : null;
5348        },
5349
5350        sl: function (a, b) {
5351            return H5.hasValue$1(a, b) ? a << b : null;
5352        },
5353
5354        sr: function (a, b) {
5355            return H5.hasValue$1(a, b) ? a >> b : null;
5356        },
5357
5358        srr: function (a, b) {
5359            return H5.hasValue$1(a, b) ? a >>> b : null;
5360        },
5361
5362        sub: function (a, b) {
5363            return H5.hasValue$1(a, b) ? a - b : null;
5364        },
5365
5366        bnot: function (a) {
5367            return H5.hasValue(a) ? ~a : null;
5368        },
5369
5370        neg: function (a) {
5371            return H5.hasValue(a) ? -a : null;
5372        },
5373
5374        not: function (a) {
5375            return H5.hasValue(a) ? !a : null;
5376        },
5377
5378        pos: function (a) {
5379            return H5.hasValue(a) ? +a : null;
5380        },
5381
5382        lift: function () {
5383            for (var i = 1; i < arguments.length; i++) {
5384                if (!H5.hasValue(arguments[i])) {
5385                    return null;
5386                }
5387            }
5388
5389            if (arguments[0] == null) {
5390                return null;
5391            }
5392
5393            if (arguments[0].apply == undefined) {
5394                return arguments[0];
5395            }
5396
5397            return arguments[0].apply(null, Array.prototype.slice.call(arguments, 1));
5398        },
5399
5400        lift1: function (f, o) {
5401            return H5.hasValue(o) ? (typeof f === "function" ? f.apply(null, Array.prototype.slice.call(arguments, 1)) : o[f].apply(o, Array.prototype.slice.call(arguments, 2))) : null;
5402        },
5403
5404        lift2: function (f, a, b) {
5405            return H5.hasValue$1(a, b) ? (typeof f === "function" ? f.apply(null, Array.prototype.slice.call(arguments, 1)) : a[f].apply(a, Array.prototype.slice.call(arguments, 2))) : null;
5406        },
5407
5408        liftcmp: function (f, a, b) {
5409            return H5.hasValue$1(a, b) ? (typeof f === "function" ? f.apply(null, Array.prototype.slice.call(arguments, 1)) : a[f].apply(a, Array.prototype.slice.call(arguments, 2))) : false;
5410        },
5411
5412        lifteq: function (f, a, b) {
5413            var va = H5.hasValue(a),
5414                vb = H5.hasValue(b);
5415
5416            return (!va && !vb) || (va && vb && (typeof f === "function" ? f.apply(null, Array.prototype.slice.call(arguments, 1)) : a[f].apply(a, Array.prototype.slice.call(arguments, 2))));
5417        },
5418
5419        liftne: function (f, a, b) {
5420            var va = H5.hasValue(a),
5421                vb = H5.hasValue(b);
5422
5423            return (va !== vb) || (va && (typeof f === "function" ? f.apply(null, Array.prototype.slice.call(arguments, 1)) : a[f].apply(a, Array.prototype.slice.call(arguments, 2)))
5423);
5424        },
5425
5426        getUnderlyingType: function (nullableType) {
5427            if (!nullableType) {
5428                throw new System.ArgumentNullException.$ctor1("nullableType");
5429            }
5430
5431            if (H5.Reflection.isGenericType(nullableType) &&
5432                !H5.Reflection.isGenericTypeDefinition(nullableType)) {
5433                var genericType = H5.Reflection.getGenericTypeDefinition(nullableType);
5434
5435                if (genericType === System.Nullable$1) {
5436                    return H5.Reflection.getGenericArguments(nullableType)[0];
5437                }
5438            }
5439
5440            return null;
5441        },
5442
5443        compare: function (n1, n2) {
5444            return System.Collections.Generic.Comparer$1.$default.compare(n1, n2);
5445        }
5446    };
5447
5448    System.Nullable = nullable;
5449
5450    H5.define("System.Nullable$1", function (T) {
5451        return {
5452            $kind: "struct",
5453
5454            statics: {
5455                $nullable: true,
5456                $nullableType: T,
5457                getDefaultValue: function () {
5458                    return null;
5459                },
5460
5461                $is: function (obj) {
5462                    return H5.is(obj, T);
5463                }
5464            }
5465        };
5466    });
5467
5468    // @source Char.js
5469
5470    H5.define("System.Char", {
5471        inherits: [System.IComparable, System.IFormattable],
5472        $kind: "struct",
5473        statics: {
5474            min: 0,
5475
5476            max: 65535,
5477
5478            $is: function (instance) {
5479                return typeof (instance) === "number" && Math.round(instance, 0) == instance && instance >= System.Char.min && instance <= System.Char.max;
5480            },
5481
5482            getDefaultValue: function () {
5483                return 0;
5484            },
5485
5486            parse: function (s) {
5487                if (!H5.hasValue(s)) {
5488                    throw new System.ArgumentNullException.$ctor1("s");
5489                }
5490
5491                if (s.length !== 1) {
5492                    throw new System.FormatException();
5493                }
5494
5495                return s.charCodeAt(0);
5496            },
5497
5498            tryParse: function (s, result) {
5499                var b = s && s.length === 1;
5500
5501                result.v = b ? s.charCodeAt(0) : 0;
5502
5503                return b;
5504            },
5505
5506            format: function (number, format, provider) {
5507                return H5.Int.format(number, format, provider);
5508            },
5509
5510            charCodeAt: function (str, index) {
5511                if (str == null) {
5512                    throw new System.ArgumentNullException();
5513                }
5514
5515                if (str.length != 1) {
5516                    throw new System.FormatException.$ctor1("String must be exactly one character long");
5517                }
5518
5519                return str.charCodeAt(index);
5520            },
5521
5522            _isWhiteSpaceMatch: /[^\s\x09-\x0D\x85\xA0]/,
5523
5524            isWhiteSpace: function (s) {
5525                return !System.Char._isWhiteSpaceMatch.test(s);
5526            },
5527
5528            _isDigitMatch: new RegExp(/[0-9\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]/),
5529
5530            isDigit: function (value) {
5531                if (value < 256) {
5532                    return (value >= 48 && value <= 57);
5533                }
5534
5535                return System.Char._isDigitMatch.test(String.fromCharCode(value));
5536            },
5537
5538            _isLetterMatch: new RegExp(/[A-Za-z\u0061-\u007A\u00B5\u00DF-\u00F6\u00F8-\u00FF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01D
5538D\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0561-\u0587\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7FA\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A\u0041-\u005A\u00C0-\u00D6\u00D8-\u00DE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u01
553878\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA\uFF21-\uFF3A\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5\u06E6\u07F4\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA717-\uA71F\uA770\uA788\uA7F8\uA7F9\uA9CF\uAA70\uAADD\uAAF3\uAAF4\uFF70\uFF9E\uFF9F\u00AA\u00BA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E45\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u
55380EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A\uA62B\uA66E\uA6A0-\uA6E5\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/),
5539
5540            isLetter: function (value) {
5541                if (value < 256) {
5542                    return (value >= 65 && value <= 90) || (value >= 97 && value <= 122);
5543                }
5544
5545                return System.Char._isLetterMatch.test(String.fromCharCode(value));
5546            },
5547
5548            _isHighSurrogateMatch: new RegExp(/[\uD800-\uDBFF]/),
5549
5550            isHighSurrogate: function (value) {
5551                return System.Char._isHighSurrogateMatch.test(String.fromCharCode(value));
5552            },
5553
5554            _isLowSurrogateMatch: new RegExp(/[\uDC00-\uDFFF]/),
5555
5556            isLowSurrogate: function (value) {
5557                return System.Char._isLowSurrogateMatch.test(String.fromCharCode(value));
5558            },
5559
5560            _isSurrogateMatch: new RegExp(/[\uD800-\uDFFF]/),
5561
5562            isSurrogate: function (value) {
5563                return System.Char._isSurrogateMatch.test(String.fromCharCode(value));
5564            },
5565
5566            _isNullMatch: new RegExp("\u0000"),
5567
5568            isNull: function (value) {
5569                return System.Char._isNullMatch.test(String.fromCharCode(value));
5570            },
5571
5572            _isSymbolMatch: new RegExp(/[\u20A0-\u20CF\u20D0-\u20FF\u2100-\u214F\u2150-\u218F\u2190-\u21FF\u2200-\u22FF\u2300-\u23FF\u25A0-\u25FF\u2600-\u26FF\u2700-\u27BF\u27C0-\u27EF\u27F0-\u27FF\u2800-\u28FF\u2900-\u297F\u2980-\u29FF\u2A00-\u2AFF\u2B00-\u2BFF]/),
5573
5574            isSymbol: function (value) {
5575                if (value < 256) {
5576                    return ([36, 43, 60, 61, 62, 94, 96, 124, 126, 162, 163, 164, 165, 166, 167, 168, 169, 172, 174, 175, 176, 177, 180, 182, 184, 215, 247].indexOf(value) != -1);
5577                }
5578
5579                return System.Char._isSymbolMatch.test(String.fromCharCode(value));
5580            },
5581
5582            _isSeparatorMatch: new RegExp(/[\u2028\u2029\u0020\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]/),
5583
5584            isSeparator: function (value) {
5585                if (value < 256) {
5586                    return (value == 32 || value == 160);
5587                }
5588
5589                return System.Char._isSeparatorMatch.test(String.fromCharCode(value));
5590            },
5591
5592            _isPunctuationMatch: new RegExp(/[\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u00
55927D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65\u002D\u058A\u05BE\u1400\u1806\u2010-\u2015\u2E17\u2E1A\u2E3A\u2E3B\u301C\u3030\u30A0\uFE31\uFE32\uFE58\uFE63\uFF0D\u0028\u005B\u007B\u0F3A\u0F3C\u169B\u201A\u201E\u2045\u207D\u208D\u2329\u2768\u276A\u276C\u276E\u2770\u2772\u2774\u27C5\u27E6\u27E8\u27EA\u27EC\u27EE\u2983\u2985\u2987\u2989\u298B\u298D\u298F\u2991\u2993\u2995\u2997\u29D8\u29DA\u29FC\u2E22\u2E24\u2E26\u2E28\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u301D\uFD3E\uFE17\uFE35\uFE37\uFE39\uFE3B\uFE3D\uFE3F\uFE41\uFE43\uFE47\uFE59\uFE5B\uFE5D\uFF08\uFF3B\uFF5B\uFF5F\uFF62\u0029\u005D\u007D\u0F3B\u0F3D\u169C\u2046\u207E\u208E\u232A\u2769\u276B\u276D\u276F\u2771\u2773\u2775\u27C6\u27E7\u27E9\u27EB\u27ED\u27EF\u2984\u2986\u2988\u298A\u298C\u298E\u2990\u2992\u2994\u2996\u2998\u29D9\u29DB\u29FD\u2E23\u2E25\u2E27\u2E29\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u301E\u301F\uFD3F\uFE18\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE48\uFE5A\uFE5C\uFE5E\uFF09\uFF3D\uFF5D\uFF60\uFF63\u00AB\u2018\u201B\u201C\u201F\u2039\u2E02\u2E04\u2E09\u2E0C\u2E1C\u2E20\u00BB\u2019\u201D\u203A\u2E03\u2E05\u2E0A\u2E0D\u2E1D\u2E21\u005F\u203F\u2040\u2054\uFE33\uFE34\uFE4D-\uFE4F\uFF3F\u0021-\u0023\u0025-\u0027\u002A\u002C\u002E\u002F\u003A\u003B\u003F\u0040\u005C\u00A1\u00A7\u00B6\u00B7\u00BF\u037E\u0387\u055A-\u055F\u0589\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u166D\u166E\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u1805\u1807-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2016\u2017\u2020-\u2027\u2030-\u2038\u203B-\u203E\u2041-\u2043\u2047-\u2051\u2053\u2055-\u205E\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00\u2E01\u2E06-\u2E08\u2E0B\u2E0E-\u2E16\u2E18\u2E19\u2E1B\u2E1E\u2E1F\u2E2A-\u2E2E\u2E30-\u2E39\u3001-\u3003\u303D\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFE10-\uFE16\uFE19\uFE30\uFE45\uFE46\uFE49-\uFE4C\uFE50-\uFE52\uFE54-\uFE57\uFE5F-\uFE61\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF07\uFF0A\uFF0C\uFF0E\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3C\uFF61\uFF64\uFF65]/),
5593
5594            isPunctuation: function (value) {
5595                if (value < 256) {
5596                    return ([33, 34, 35, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 58, 59, 63, 64, 91, 92, 93, 95, 123, 125, 161, 171, 173, 183, 187, 191].indexOf(value) != -1);
5597                }
5598
5599                return System.Char._isPunctuationMatch.test(String.fromCharCode(value));
5600            },
5601
5602            _isNumberMatch: new RegExp(/[\u0030-\u0039\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u
56020C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19\u16EE-\u16F0\u2160-\u2182\u2185-\u2188\u3007\u3021-\u3029\u3038-\u303A\uA6E6-\uA6EF\u00B2\u00B3\u00B9\u00BC-\u00BE\u09F4-\u09F9\u0B72-\u0B77\u0BF0-\u0BF2\u0C78-\u0C7E\u0D70-\u0D75\u0F2A-\u0F33\u1369-\u137C\u17F0-\u17F9\u19DA\u2070\u2074-\u2079\u2080-\u2089\u2150-\u215F\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA830-\uA835]/),
5603
5604            isNumber: function (value) {
5605                if (value < 256) {
5606                    return ([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 178, 179, 185, 188, 189, 190].indexOf(value) != -1);
5607                }
5608
5609                return System.Char._isNumberMatch.test(String.fromCharCode(value));
5610            },
5611
5612            _isControlMatch: new RegExp(/[\u0000-\u001F\u007F\u0080-\u009F]/),
5613
5614            isControl: function (value) {
5615                if (value < 256) {
5616                    return (value >= 0 && value <= 31) || (value >= 127 && value <= 159);
5617                }
5618
5619                return System.Char._isControlMatch.test(String.fromCharCode(value));
5620            },
5621
5622            isLatin1: function (ch) {
5623                return (ch <= 255);
5624            },
5625
5626            isAscii: function (ch) {
5627                return (ch <= 127);
5628            },
5629
5630            isUpper: function (s, index) {
5631                if (s == null) {
5632                    throw new System.ArgumentNullException.$ctor1("s");
5633                }
5634
5635                if ((index >>> 0) >= ((s.length) >>> 0)) {
5636                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
5637                }
5638
5639                var c = s.charCodeAt(index);
5640
5641                if (System.Char.isLatin1(c)) {
5642                    if (System.Char.isAscii(c)) {
5643                        return (c >= 65 && c <= 90);
5644                    }
5645                }
5646
5647                return H5.isUpper(c);
5648            },
5649
5650            equals: function (v1, v2) {
5651                if (H5.is(v1, System.Char) && H5.is(v2, System.Char)) {
5652                    return H5.unbox(v1, true) === H5.unbox(v2, true);
5653                }
5654
5655                return false;
5656            },
5657
5658            equalsT: function (v1, v2) {
5659                return H5.unbox(v1, true) === H5.unbox(v2, true);
5660            },
5661
5662            getHashCode: function (v) {
5663                return v | (v << 16);
5664            }
5665        }
5666    });
5667
5668    H5.Class.addExtend(System.Char, [System.IComparable$1(System.Char), System.IEquatable$1(System.Char)]);
5669
5670    // @source Ref.js
5671
5672    H5.define("H5.Ref$1", function (T) { return {
5673        statics: {
5674            methods: {
5675                op_Implicit: function (reference) {
5676                    return reference.Value;
5677                }
5678            }
5679        },
5680        fields: {
5681            getter: null,
5682            setter: null
5683        },
5684        props: {
5685            Value: {
5686                get: function () {
5687                    return this.getter();
5688                },
5689                set: function (value) {
5690                    this.setter(value);
5691                }
5692            },
5693            v: {
5694                get: function () {
5695                    return this.Value;
5696                },
5697                set: function (value) {
5698                    this.Value = value;
5699                }
5700            }
5701        },
5702        ctors: {
5703            ctor: function (getter, setter) {
5704                this.$initialize();
5705                this.getter = getter;
5706                this.setter = setter;
5707            }
5708        },
5709        methods: {
5710            toString: function () {
5711                return H5.toString(this.Value);
5712            },
5713            valueOf: function () {
5714                return this.Value;
5715            }
5716        }
5717    }; });
5718
5719    // @source IConvertible.js
5720
5721    H5.define("System.IConvertible", {
5722        $kind: "interface"
5723    });
5724
5725    // @source HResults.js
5726
5727    H5.define("System.HResults");
5728
5729    // @source Exception.js
5730
5731    H5.define("System.Exception", {
5732        config: {
5733            properties: {
5734                Message: {
5735                    get: function () {
5736                        return this.message;
5737                    }
5738                },
5739
5740                InnerException: {
5741                    get: function () {
5742                        return this.innerException;
5743                    }
5744                },
5745
5746                StackTrace: {
5747                    get: function () {
5748                        return this.errorStack.stack;
5749                    }
5750                },
5751
5752                Data: {
5753                    get: function () {
5754                        return this.data;
5755                    }
5756                },
5757
5758                HResult: {
5759                    get: function () {
5760                        return this._HResult;
5761                    },
5762                    set: function (value) {
5763                        this._HResult = value;
5764                    }
5765                }
5766            }
5767        },
5768
5769        ctor: function (message, innerException) {
5770            this.$initialize();
5771            this.message = message ? message : ("Exception of type '" + H5.getTypeName(this) + "' was thrown.");
5772            this.innerException = innerException ? innerException : null;
5773            this.errorStack = new Error(this.message);
5774            this.data = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object))();
5775        },
5776
5777        getBaseException: function () {
5778            var inner = this.innerException;
5779            var back = this;
5780
5781            while (inner != null) {
5782                back = inner;
5783                inner = inner.innerException;
5784            }
5785
5786            return back;
5787        },
5788
5789        toString: function () {
5790            var builder = H5.getTypeName(this);
5791
5792            if (this.Message != null) {
5793                builder += ": " + this.Message + "\n";
5794            } else {
5795                builder += "\n";
5796            }
5797
5798            if (this.StackTrace != null) {
5799                builder += this.StackTrace + "\n";
5800            }
5801
5802            return builder;
5803        },
5804
5805        statics: {
5806            create: function (error) {
5807                if (H5.is(error, System.Exception)) {
5808                    return error;
5809                }
5810
5811                var ex;
5812
5813                if (error instanceof TypeError) {
5814                    ex = new System.NullReferenceException.$ctor1(error.message);
5815                } else if (error instanceof RangeError) {
5816                    ex = new System.ArgumentOutOfRangeException.$ctor1(error.message);
5817                } else if (error instanceof Error) {
5818                    return new System.SystemException.$ctor1(error);
5819                } else if (error && error.error && error.error.stack) {
5820                    ex = new System.Exception(error.error.stack);
5821                } else {
5822                    ex = new System.Exception(error ? error.message ? error.message : error.toString() : null);
5823                }
5824
5825                ex.errorStack = error;
5826
5827                return ex;
5828            }
5829        }
5830    });
5831
5832    // @source SystemException.js
5833
5834    H5.define("System.SystemException", {
5835        inherits: [System.Exception],
5836        ctors: {
5837            ctor: function () {
5838                this.$initialize();
5839                System.Exception.ctor.call(this, "System error.");
5840                this.HResult = -2146233087;
5841            },
5842            $ctor1: function (message) {
5843                this.$initialize();
5844                System.Exception.ctor.call(this, message);
5845                this.HResult = -2146233087;
5846            },
5847            $ctor2: function (message, innerException) {
5848                this.$initialize();
5849                System.Exception.ctor.call(this, message, innerException);
5850                this.HResult = -2146233087;
5851            }
5852        }
5853    });
5854
5855    // @source OutOfMemoryException.js
5856
5857    H5.define("System.OutOfMemoryException", {
5858        inherits: [System.SystemException],
5859        ctors: {
5860            ctor: function () {
5861                this.$initialize();
5862                System.SystemException.$ctor1.call(this, "Insufficient memory to continue the execution of the program.");
5863                this.HResult = -2147024362;
5864            },
5865            $ctor1: function (message) {
5866                this.$initialize();
5867                System.SystemException.$ctor1.call(this, message);
5868                this.HResult = -2147024362;
5869            },
5870            $ctor2: function (message, innerException) {
5871                this.$initialize();
5872                System.SystemException.$ctor2.call(this, message, innerException);
5873                this.HResult = -2147024362;
5874            }
5875        }
5876    });
5877
5878    // @source ArrayTypeMismatchException.js
5879
5880    H5.define("System.ArrayTypeMismatchException", {
5881        inherits: [System.SystemException],
5882        ctors: {
5883            ctor: function () {
5884                this.$initialize();
5885                System.SystemException.$ctor1.call(this, "Attempted to access an element as a type incompatible with the array.");
5886                this.HResult = -2146233085;
5887            },
5888            $ctor1: function (message) {
5889                this.$initialize();
5890                System.SystemException.$ctor1.call(this, message);
5891                this.HResult = -2146233085;
5892            },
5893            $ctor2: function (message, innerException) {
5894                this.$initialize();
5895                System.SystemException.$ctor2.call(this, message, innerException);
5896                this.HResult = -2146233085;
5897            }
5898        }
5899    });
5900
5901    // @source MissingManifestResourceException.js
5902
5903    H5.define("System.Resources.MissingManifestResourceException", {
5904        inherits: [System.SystemException],
5905        ctors: {
5906            ctor: function () {
5907                this.$initialize();
5908                System.SystemException.$ctor1.call(this, "Unable to find manifest resource.");
5909                this.HResult = -2146233038;
5910            },
5911            $ctor1: function (message) {
5912                this.$initialize();
5913                System.SystemException.$ctor1.call(this, message);
5914                this.HResult = -2146233038;
5915            },
5916            $ctor2: function (message, inner) {
5917                this.$initialize();
5918                System.SystemException.$ctor2.call(this, message, inner);
5919                this.HResult = -2146233038;
5920            }
5921        }
5922    });
5923
5924    // @source TextInfo.js
5925
5926    H5.define("System.Globalization.TextInfo", {
5927        inherits: [System.ICloneable],
5928        fields: {
5929            listSeparator: null
5930        },
5931        props: {
5932            ANSICodePage: 0,
5933            CultureName: null,
5934            EBCDICCodePage: 0,
5935            IsReadOnly: false,
5936            IsRightToLeft: false,
5937            LCID: 0,
5938            ListSeparator: {
5939                get: function () {
5940                    return this.listSeparator;
5941                },
5942                set: function (value) {
5943                    this.VerifyWritable();
5944
5945                    this.listSeparator = value;
5946                }
5947            },
5948            MacCodePage: 0,
5949            OEMCodePage: 0
5950        },
5951        alias: ["clone", "System$ICloneable$clone"],
5952        methods: {
5953            clone: function () {
5954                return H5.copy(new System.Globalization.TextInfo(), this, System.Array.init(["ANSICodePage", "CultureName", "EBCDICCodePage", "IsRightToLeft", "LCID", "listSeparator", "MacCodePage", "OEMCodePage", "IsReadOnly"], System.String));
5955            },
5956            VerifyWritable: function () {
5957                if (this.IsReadOnly) {
5958                    throw new System.InvalidOperationException.$ctor1("Instance is read-only.");
5959                }
5960            }
5961        }
5962    });
5963
5964    // @source BidiCategory.js
5965
5966    H5.define("System.Globalization.BidiCategory", {
5967        $kind: "enum",
5968        statics: {
5969            fields: {
5970                LeftToRight: 0,
5971                LeftToRightEmbedding: 1,
5972                LeftToRightOverride: 2,
5973                RightToLeft: 3,
5974                RightToLeftArabic: 4,
5975                RightToLeftEmbedding: 5,
5976                RightToLeftOverride: 6,
5977                PopDirectionalFormat: 7,
5978                EuropeanNumber: 8,
5979                EuropeanNumberSeparator: 9,
5980                EuropeanNumberTerminator: 10,
5981                ArabicNumber: 11,
5982                CommonNumberSeparator: 12,
5983                NonSpacingMark: 13,
5984                BoundaryNeutral: 14,
5985                ParagraphSeparator: 15,
5986                SegmentSeparator: 16,
5987                Whitespace: 17,
5988                OtherNeutrals: 18,
5989                LeftToRightIsolate: 19,
5990                RightToLeftIsolate: 20,
5991                FirstStrongIsolate: 21,
5992                PopDirectionIsolate: 22
5993            }
5994        }
5995    });
5996
5997    // @source SortVersion.js
5998
5999    H5.define("System.Globalization.SortVersion", {
6000        inherits: function () { return [System.IEquatable$1(System.Globalization.SortVersion)]; },
6001        statics: {
6002            methods: {
6003                op_Equality: function (left, right) {
6004                    if (left != null) {
6005                        return left.equalsT(right);
6006                    }
6007
6008                    if (right != null) {
6009                        return right.equalsT(left);
6010                    }
6011
6012                    return true;
6013                },
6014                op_Inequality: function (left, right) {
6015                    return !(System.Globalization.SortVersion.op_Equality(left, right));
6016                }
6017            }
6018        },
6019        fields: {
6020            m_NlsVersion: 0,
6021            m_SortId: null
6022        },
6023        props: {
6024            FullVersion: {
6025                get: function () {
6026                    return this.m_NlsVersion;
6027                }
6028            },
6029            SortId: {
6030                get: function () {
6031                    return this.m_SortId;
6032                }
6033            }
6034        },
6035        alias: ["equalsT", "System$IEquatable$1$System$Globalization$SortVersion$equalsT"],
6036        ctors: {
6037            init: function () {
6038                this.m_SortId = new System.Guid();
6039            },
6040            ctor: function (fullVersion, sortId) {
6041                this.$initialize();
6042                this.m_SortId = sortId;
6043                this.m_NlsVersion = fullVersion;
6044            },
6045            $ctor1: function (nlsVersion, effectiveId, customVersion) {
6046                this.$initialize();
6047                this.m_NlsVersion = nlsVersion;
6048
6049                if (System.Guid.op_Equality(customVersion, System.Guid.Empty)) {
6050                    var b1 = (effectiveId >> 24) & 255;
6051                    var b2 = ((effectiveId & 16711680) >> 16) & 255;
6052                    var b3 = ((effectiveId & 65280) >> 8) & 255;
6053                    var b4 = (effectiveId & 255) & 255;
6054                    customVersion = new System.Guid.$ctor2(0, 0, 0, 0, 0, 0, 0, b1, b2, b3, b4);
6055                }
6056
6057                this.m_SortId = customVersion;
6058            }
6059        },
6060        methods: {
6061            equals: function (obj) {
6062                var n = H5.as(obj, System.Globalization.SortVersion);
6063                if (System.Globalization.SortVersion.op_Inequality(n, null)) {
6064                    return this.equalsT(n);
6065                }
6066
6067                return false;
6068            },
6069            equalsT: function (other) {
6070                if (System.Globalization.SortVersion.op_Equality(other, null)) {
6071                    return false;
6072                }
6073
6074                return this.m_NlsVersion === other.m_NlsVersion && System.Guid.op_Equality(this.m_SortId, other.m_SortId);
6075            },
6076            getHashCode: function () {
6077                return H5.Int.mul(this.m_NlsVersion, 7) | this.m_SortId.getHashCode();
6078            }
6079        }
6080    });
6081
6082    // @source UnicodeCategory.js
6083
6084    H5.define("System.Globalization.UnicodeCategory", {
6085        $kind: "enum",
6086        statics: {
6087            fields: {
6088                UppercaseLetter: 0,
6089                LowercaseLetter: 1,
6090                TitlecaseLetter: 2,
6091                ModifierLetter: 3,
6092                OtherLetter: 4,
6093                NonSpacingMark: 5,
6094                SpacingCombiningMark: 6,
6095                EnclosingMark: 7,
6096                DecimalDigitNumber: 8,
6097                LetterNumber: 9,
6098                OtherNumber: 10,
6099                SpaceSeparator: 11,
6100                LineSeparator: 12,
6101                ParagraphSeparator: 13,
6102                Control: 14,
6103                Format: 15,
6104                Surrogate: 16,
6105                PrivateUse: 17,
6106                ConnectorPunctuation: 18,
6107                DashPunctuation: 19,
6108                OpenPunctuation: 20,
6109                ClosePunctuation: 21,
6110                InitialQuotePunctuation: 22,
6111                FinalQuotePunctuation: 23,
6112                OtherPunctuation: 24,
6113                MathSymbol: 25,
6114                CurrencySymbol: 26,
6115                ModifierSymbol: 27,
6116                OtherSymbol: 28,
6117                OtherNotAssigned: 29
6118            }
6119        }
6120    });
6121
6122    // @source DaylightTimeStruct.js
6123
6124    H5.define("System.Globalization.DaylightTimeStruct", {
6125        $kind: "struct",
6126        statics: {
6127            methods: {
6128                getDefaultValue: function () { return new System.Globalization.DaylightTimeStruct(); }
6129            }
6130        },
6131        fields: {
6132            Start: null,
6133            End: null,
6134            Delta: null
6135        },
6136        ctors: {
6137            init: function () {
6138                this.Start = System.DateTime.getDefaultValue();
6139                this.End = System.DateTime.getDefaultValue();
6140                this.Delta = new System.TimeSpan();
6141            },
6142            $ctor1: function (start, end, delta) {
6143                this.$initialize();
6144                this.Start = start;
6145                this.End = end;
6146                this.Delta = delta;
6147            },
6148            ctor: function () {
6149                this.$initialize();
6150            }
6151        },
6152        methods: {
6153            getHashCode: function () {
6154                var h = H5.addHash([7445027511, this.Start, this.End, this.Delta]);
6155                return h;
6156            },
6157            equals: function (o) {
6158                if (!H5.is(o, System.Globalization.DaylightTimeStruct)) {
6159                    return false;
6160                }
6161                return H5.equals(this.Start, o.Start) && H5.equals(this.End, o.End) && H5.equals(this.Delta, o.Delta);
6162            },
6163            $clone: function (to) {
6164                var s = to || new System.Globalization.DaylightTimeStruct();
6165                s.Start = this.Start;
6166                s.End = this.End;
6167                s.Delta = this.Delta;
6168                return s;
6169            }
6170        }
6171    });
6172
6173    // @source DaylightTime.js
6174
6175    H5.define("System.Globalization.DaylightTime", {
6176        fields: {
6177            _start: null,
6178            _end: null,
6179            _delta: null
6180        },
6181        props: {
6182            Start: {
6183                get: function () {
6184                    return this._start;
6185                }
6186            },
6187            End: {
6188                get: function () {
6189                    return this._end;
6190                }
6191            },
6192            Delta: {
6193                get: function () {
6194                    return this._delta;
6195                }
6196            }
6197        },
6198        ctors: {
6199            init: function () {
6200                this._start = System.DateTime.getDefaultValue();
6201                this._end = System.DateTime.getDefaultValue();
6202                this._delta = new System.TimeSpan();
6203            },
6204            ctor: function () {
6205                this.$initialize();
6206            },
6207            $ctor1: function (start, end, delta) {
6208                this.$initialize();
6209                this._start = start;
6210                this._end = end;
6211                this._delta = delta;
6212            }
6213        }
6214    });
6215
6216    // @source Globalization.js
6217
6218    H5.define("System.Globalization.DateTimeFormatInfo", {
6219        inherits: [System.IFormatProvider, System.ICloneable],
6220
6221        config: {
6222            alias: [
6223                "getFormat", "System$IFormatProvider$getFormat"
6224            ]
6225        },
6226
6227        statics: {
6228            $allStandardFormats: {
6229                "d": "shortDatePattern",
6230                "D": "longDatePattern",
6231                "f": "longDatePattern shortTimePattern",
6232                "F": "longDatePattern longTimePattern",
6233                "g": "shortDatePattern shortTimePattern",
6234                "G": "shortDatePattern longTimePattern",
6235                "m": "monthDayPattern",
6236                "M": "monthDayPattern",
6237                "o": "roundtripFormat",
6238                "O": "roundtripFormat",
6239                "r": "rfc1123",
6240                "R": "rfc1123",
6241                "s": "sortableDateTimePattern",
6242                "S": "sortableDateTimePattern1",
6243                "t": "shortTimePattern",
6244                "T": "longTimePattern",
6245                "u": "universalSortableDateTimePattern",
6246                "U": "longDatePattern longTimePattern",
6247                "y": "yearMonthPattern",
6248                "Y": "yearMonthPattern"
6249            },
6250
6251            ctor: function () {
6252                this.invariantInfo = H5.merge(new System.Globalization.DateTimeFormatInfo(), {
6253                    abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
6254                    abbreviatedMonthGenitiveNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""],
6255                    abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""],
6256                    amDesignator: "AM",
6257                    dateSeparator: "/",
6258                    dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
6259                    firstDayOfWeek: 0,
6260                    fullDateTimePattern: "dddd, dd MMMM yyyy HH:mm:ss",
6261                    longDatePattern: "dddd, dd MMMM yyyy",
6262                    longTimePattern: "HH:mm:ss",
6263                    monthDayPattern: "MMMM dd",
6264                    monthGenitiveNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
6264November", "December", ""],
6265                    monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""],
6266                    pmDesignator: "PM",
6267                    rfc1123: "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'",
6268                    shortDatePattern: "MM/dd/yyyy",
6269                    shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
6270                    shortTimePattern: "HH:mm",
6271                    sortableDateTimePattern: "yyyy'-'MM'-'dd'T'HH':'mm':'ss",
6272                    sortableDateTimePattern1: "yyyy'-'MM'-'dd",
6273                    timeSeparator: ":",
6274                    universalSortableDateTimePattern: "yyyy'-'MM'-'dd HH':'mm':'ss'Z'",
6275                    yearMonthPattern: "yyyy MMMM",
6276                    roundtripFormat: "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffzzz"
6277                });
6278            }
6279        },
6280
6281        getFormat: function (type) {
6282            switch (type) {
6283                case System.Globalization.DateTimeFormatInfo:
6284                    return this;
6285                default:
6286                    return null;
6287            }
6288        },
6289
6290        getAbbreviatedDayName: function (dayofweek) {
6291            if (dayofweek < 0 || dayofweek > 6) {
6292                throw new System.ArgumentOutOfRangeException$ctor1("dayofweek");
6293            }
6294
6295            return this.abbreviatedDayNames[dayofweek];
6296        },
6297
6298        getAbbreviatedMonthName: function (month) {
6299            if (month < 1 || month > 13) {
6300                throw new System.ArgumentOutOfRangeException.$ctor1("month");
6301            }
6302
6303            return this.abbreviatedMonthNames[month - 1];
6304        },
6305
6306        getAllDateTimePatterns: function (format, returnNull) {
6307            var f = System.Globalization.DateTimeFormatInfo.$allStandardFormats,
6308                formats,
6309                names,
6310                pattern,
6311                i,
6312                result = [];
6313
6314            if (format) {
6315                if (!f[format]) {
6316                    if (returnNull) {
6317                        return null;
6318                    }
6319
6320                    throw new System.ArgumentException.$ctor3("", "format");
6321                }
6322
6323                formats = {};
6324                formats[format] = f[format];
6325            } else {
6326                formats = f;
6327            }
6328
6329            for (f in formats) {
6330                names = formats[f].split(" ");
6331                pattern = "";
6332
6333                for (i = 0; i < names.length; i++) {
6334                    pattern = (i === 0 ? "" : (pattern + " ")) + this[names[i]];
6335                }
6336
6337                result.push(pattern);
6338            }
6339
6340            return result;
6341        },
6342
6343        getDayName: function (dayofweek) {
6344            if (dayofweek < 0 || dayofweek > 6) {
6345                throw new System.ArgumentOutOfRangeException.$ctor1("dayofweek");
6346            }
6347
6348            return this.dayNames[dayofweek];
6349        },
6350
6351        getMonthName: function (month) {
6352            if (month < 1 || month > 13) {
6353                throw new System.ArgumentOutOfRangeException.$ctor1("month");
6354            }
6355
6356            return this.monthNames[month - 1];
6357        },
6358
6359        getShortestDayName: function (dayOfWeek) {
6360            if (dayOfWeek < 0 || dayOfWeek > 6) {
6361                throw new System.ArgumentOutOfRangeException.$ctor1("dayOfWeek");
6362            }
6363
6364            return this.shortestDayNames[dayOfWeek];
6365        },
6366
6367        clone: function () {
6368            return H5.copy(new System.Globalization.DateTimeFormatInfo(), this, [
6369                "abbreviatedDayNames",
6370                "abbreviatedMonthGenitiveNames",
6371                "abbreviatedMonthNames",
6372                "amDesignator",
6373                "dateSeparator",
6374                "dayNames",
6375                "firstDayOfWeek",
6376                "fullDateTimePattern",
6377                "longDatePattern",
6378                "longTimePattern",
6379                "monthDayPattern",
6380                "monthGenitiveNames",
6381                "monthNames",
6382                "pmDesignator",
6383                "rfc1123",
6384                "shortDatePattern",
6385                "shortestDayNames",
6386                "shortTimePattern",
6387                "sortableDateTimePattern",
6388                "timeSeparator",
6389                "universalSortableDateTimePattern",
6390                "yearMonthPattern",
6391                "roundtripFormat"
6392            ]);
6393        }
6394    });
6395
6396    H5.define("System.Globalization.NumberFormatInfo", {
6397        inherits: [System.IFormatProvider, System.ICloneable],
6398
6399        config: {
6400            alias: [
6401                "getFormat", "System$IFormatProvider$getFormat"
6402            ]
6403        },
6404
6405        statics: {
6406            ctor: function () {
6407                this.numberNegativePatterns = ["(n)", "-n", "- n", "n-", "n -"];
6408                this.currencyNegativePatterns = ["($n)", "-$n", "$-n", "$n-", "(n$)", "-n$", "n-$", "n$-", "-n $", "-$ n", "n $-", "$ n-", "$ -n", "n- $", "($ n)", "(n $)"];
6409                this.currencyPositivePatterns = ["$n", "n$", "$ n", "n $"];
6410                this.percentNegativePatterns = ["-n %", "-n%", "-%n", "%-n", "%n-", "n-%", "n%-", "-% n", "n %-", "% n-", "% -n", "n- %"];
6411                this.percentPositivePatterns = ["n %", "n%", "%n", "% n"];
6412
6413                this.invariantInfo = H5.merge(new System.Globalization.NumberFormatInfo(), {
6414                    nanSymbol: "NaN",
6415                    negativeSign: "-",
6416                    positiveSign: "+",
6417                    negativeInfinitySymbol: "-Infinity",
6418                    positiveInfinitySymbol: "Infinity",
6419
6420                    percentSymbol: "%",
6421                    percentGroupSizes: [3],
6422                    percentDecimalDigits: 2,
6423                    percentDecimalSeparator: ".",
6424                    percentGroupSeparator: ",",
6425                    percentPositivePattern: 0,
6426                    percentNegativePattern: 0,
6427
6428                    currencySymbol: "¤",
6429                    currencyGroupSizes: [3],
6430                    currencyDecimalDigits: 2,
6431                    currencyDecimalSeparator: ".",
6432                    currencyGroupSeparator: ",",
6433                    currencyNegativePattern: 0,
6434                    currencyPositivePattern: 0,
6435
6436                    numberGroupSizes: [3],
6437                    numberDecimalDigits: 2,
6438                    numberDecimalSeparator: ".",
6439                    numberGroupSeparator: ",",
6440                    numberNegativePattern: 1
6441                });
6442            }
6443        },
6444
6445        getFormat: function (type) {
6446            switch (type) {
6447                case System.Globalization.NumberFormatInfo:
6448                    return this;
6449                default:
6450                    return null;
6451            }
6452        },
6453
6454        clone: function () {
6455            return H5.copy(new System.Globalization.NumberFormatInfo(), this, [
6456                "nanSymbol",
6457                "negativeSign",
6458                "positiveSign",
6459                "negativeInfinitySymbol",
6460                "positiveInfinitySymbol",
6461                "percentSymbol",
6462                "percentGroupSizes",
6463                "percentDecimalDigits",
6464                "percentDecimalSeparator",
6465                "percentGroupSeparator",
6466                "percentPositivePattern",
6467                "percentNegativePattern",
6468                "currencySymbol",
6469                "currencyGroupSizes",
6470                "currencyDecimalDigits",
6471                "currencyDecimalSeparator",
6472                "currencyGroupSeparator",
6473                "currencyNegativePattern",
6474                "currencyPositivePattern",
6475                "numberGroupSizes",
6476                "numberDecimalDigits",
6477                "numberDecimalSeparator",
6478                "numberGroupSeparator",
6479                "numberNegativePattern"
6480            ]);
6481        }
6482    });
6483
6484    H5.define("System.Globalization.CultureInfo", {
6485        inherits: [System.IFormatProvider, System.ICloneable],
6486
6487        config: {
6488            alias: [
6489                "getFormat", "System$IFormatProvider$getFormat"
6490            ]
6491        },
6492
6493        $entryPoint: true,
6494
6495        statics: {
6496            ctor: function () {
6497                this.cultures = this.cultures || {};
6498
6499                this.invariantCulture = H5.merge(new System.Globalization.CultureInfo("iv", true), {
6500                    englishName: "Invariant Language (Invariant Country)",
6501                    nativeName: "Invariant Language (Invariant Country)",
6502                    numberFormat: System.Globalization.NumberFormatInfo.invariantInfo,
6503                    dateTimeFormat: System.Globalization.DateTimeFormatInfo.invariantInfo,
6504                    TextInfo: H5.merge(new System.Globalization.TextInfo(), {
6505                        ANSICodePage: 1252,
6506                        CultureName: "",
6507                        EBCDICCodePage: 37,
6508                        listSeparator: ",",
6509                        IsRightToLeft: false,
6510                        LCID: 127,
6511                        MacCodePage: 10000,
6512                        OEMCodePage: 437,
6513                        IsReadOnly: true
6514                    })
6515                });
6516
6517                this.setCurrentCulture(System.Globalization.CultureInfo.invariantCulture);
6518            },
6519
6520            getCurrentCulture: function () {
6521                return this.currentCulture;
6522            },
6523
6524            setCurrentCulture: function (culture) {
6525                this.currentCulture = culture;
6526
6527                System.Globalization.DateTimeFormatInfo.currentInfo = culture.dateTimeFormat;
6528                System.Globalization.NumberFormatInfo.currentInfo = culture.numberFormat;
6529            },
6530
6531            getCultureInfo: function (name) {
6532                if (name == null) {
6533                    throw new System.ArgumentNullException.$ctor1("name");
6534                } else if (name === "") {
6535                    return System.Globalization.CultureInfo.invariantCulture;
6536                }
6537
6538                var c = this.cultures[name];
6539
6540                if (c == null) {
6541                    throw new System.Globalization.CultureNotFoundException.$ctor5("name", name);
6542                }
6543
6544                return c;
6545            },
6546
6547            getCultures: function () {
6548                var names = H5.getPropertyNames(this.cultures),
6549                    result = [],
6550                    i;
6551
6552                for (i = 0; i < names.length; i++) {
6553                    result.push(this.cultures[names[i]]);
6554                }
6555
6556                return result;
6557            }
6558        },
6559
6560        ctor: function (name, create) {
6561            this.$initialize();
6562            this.name = name;
6563
6564            if (!System.Globalization.CultureInfo.cultures) {
6565                System.Globalization.CultureInfo.cultures = {};
6566            }
6567
6568            if (name == null) {
6569                throw new System.ArgumentNullException.$ctor1("name");
6570            }
6571
6572            var c;
6573
6574            if (name === "") {
6575                c =  System.Globalization.CultureInfo.invariantCulture;
6576            } else {
6577                c = System.Globalization.CultureInfo.cultures[name];
6578            }
6579
6580            if (c == null) {
6581                if (!create) {
6582                    throw new System.Globalization.CultureNotFoundException.$ctor5("name", name);
6583                }
6584
6585                System.Globalization.CultureInfo.cultures[name] = this;
6586            } else {
6587                H5.copy(this, c, [
6588                            "englishName",
6589                            "nativeName",
6590                            "numberFormat",
6591                            "dateTimeFormat",
6592                            "TextInfo"
6593                ]);
6594
6595                this.TextInfo.IsReadOnly = false;
6596            }
6597        },
6598
6599        getFormat: function (type) {
6600            switch (type) {
6601                case System.Globalization.NumberFormatInfo:
6602                    return this.numberFormat;
6603                case System.Globalization.DateTimeFormatInfo:
6604                    return this.dateTimeFormat;
6605                default:
6606                    return null;
6607            }
6608        },
6609
6610        clone: function () {
6611            return new System.Globalization.CultureInfo(this.name);
6612        }
6613    });
6614
6615    // @source Environment.js
6616
6617    H5.define("System.Environment", {
6618        statics: {
6619            fields: {
6620                Variables: null
6621            },
6622            props: {
6623                Location: {
6624                    get: function () {
6625                        var g = H5.global;
6626
6627                        if (g && g.location) {
6628                            return g.location;
6629                        }
6630
6631                        return null;
6632                    }
6633                },
6634                CommandLine: {
6635                    get: function () {
6636                        return (System.Environment.GetCommandLineArgs()).join(" ");
6637                    }
6638                },
6639                CurrentDirectory: {
6640                    get: function () {
6641                        var l = System.Environment.Location;
6642
6643                        return l ? l.pathname : "";
6644                    },
6645                    set: function (value) {
6646                        var l = System.Environment.Location;
6647
6648                        if (l) {
6649                            l.pathname = value;
6650                        }
6651                    }
6652                },
6653                ExitCode: 0,
6654                Is64BitOperatingSystem: {
6655                    get: function () {
6656                        var n = H5.global ? H5.global.navigator : null;
6657
6658                        if (n && (!H5.referenceEquals(n.userAgent.indexOf("WOW64"), -1) || !H5.referenceEquals(n.userAgent.indexOf("Win64"), -1))) {
6659                            return true;
6660                        }
6661
6662                        return false;
6663                    }
6664                },
6665                ProcessorCount: {
6666                    get: function () {
6667                        var n = H5.global ? H5.global.navigator : null;
6668
6669                        if (n && n.hardwareConcurrency) {
6670                            return n.hardwareConcurrency;
6671                        }
6672
6673                        return 1;
6674                    }
6675                },
6676                StackTrace: {
6677                    get: function () {
6678                        var err = new Error();
6679                        var s = err.stack;
6680
6681                        if (!System.String.isNullOrEmpty(s)) {
6682                            if (System.String.indexOf(s, "at") >= 0) {
6683                                return s.substr(System.String.indexOf(s, "at"));
6684                            }
6685                        }
6686
6687                        return "";
6688                    }
6689                },
6690                Version: {
6691                    get: function () {
6692                        var s = H5.SystemAssembly.compiler;
6693
6694                        var v = { };
6695
6696                        if (System.Version.tryParse(s, v)) {
6697                            return v.v;
6698                        }
6699
6700                        return new System.Version.ctor();
6701                    }
6702                }
6703            },
6704            ctors: {
6705                init: function () {
6706                    this.ExitCode = 0;
6707                },
6708                ctor: function () {
6709                    System.Environment.Variables = new (System.Collections.Generic.Dictionary$2(System.String,System.String)).ctor();
6710                    System.Environment.PatchDictionary(System.Environment.Variables);
6711                }
6712            },
6713            methods: {
6714                GetResourceString: function (key) {
6715                    return key;
6716                },
6717                GetResourceString$1: function (key, values) {
6718                    if (values === void 0) { values = []; }
6719                    var s = System.Environment.GetResourceString(key);
6720                    return System.String.formatProvider.apply(System.String, [System.Globalization.CultureInfo.getCurrentCulture(), s].concat(values));
6721                },
6722                PatchDictionary: function (d) {
6723                    d.noKeyCheck = true;
6724
6725                    return d;
6726                },
6727                Exit: function (exitCode) {
6728                    System.Environment.ExitCode = exitCode;
6729                },
6730                ExpandEnvironmentVariables: function (name) {
6731                    var $t;
6732                    if (name == null) {
6733                        throw new System.ArgumentNullException.$ctor1(name);
6734                    }
6735
6736                    $t = H5.getEnumerator(System.Environment.Variables);
6737                    try {
6738                        while ($t.moveNext()) {
6739                            var pair = $t.Current;
6740                            name = System.String.replaceAll(name, "%" + (pair.key || "") + "%", pair.value);
6741                        }
6742                    } finally {
6743                        if (H5.is($t, System.IDisposable)) {
6744                            $t.System$IDisposable$Dispose();
6745                        }
6746                    }
6747
6748                    return name;
6749                },
6750                FailFast: function (message) {
6751                    throw new System.Exception(message);
6752                },
6753                FailFast$1: function (message, exception) {
6754                    throw new System.Exception(message, exception);
6755                },
6756                GetCommandLineArgs: function () {
6757                    var l = System.Environment.Location;
6758
6759                    if (l) {
6760                        var args = new (System.Collections.Generic.List$1(System.String)).ctor();
6761
6762                        var path = l.pathname;
6763
6764                        if (!System.String.isNullOrEmpty(path)) {
6765                            args.add(path);
6766                        }
6767
6768                        var search = l.search;
6769
6770                        if (!System.String.isNullOrEmpty(search) && search.length > 1) {
6771                            var query = System.String.split(search.substr(1), [38].map(function (i) {{ return String.fromCharCode(i); }}));
6772
6773                            for (var i = 0; i < query.length; i = (i + 1) | 0) {
6774                                var param = System.String.split(query[System.Array.index(i, query)], [61].map(function (i) {{ return String.fromCharCode(i); }}));
6775
6776                                for (var j = 0; j < param.length; j = (j + 1) | 0) {
6777                                    args.add(param[System.Array.index(j, param)]);
6778                                }
6779                            }
6780                        }
6781
6782                        return args.ToArray();
6783                    }
6784
6785                    return System.Array.init(0, null, System.String);
6786                },
6787                GetEnvironmentVariable: function (variable) {
6788                    if (variable == null) {
6789                        throw new System.ArgumentNullException.$ctor1("variable");
6790                    }
6791
6792                    var r = { };
6793
6794                    if (System.Environment.Variables.tryGetValue(variable.toLowerCase(), r)) {
6795                        return r.v;
6796                    }
6797
6798                    return null;
6799                },
6800                GetEnvironmentVariable$1: function (variable, target) {
6801                    return System.Environment.GetEnvironmentVariable(variable);
6802                },
6803                GetEnvironmentVariables: function () {
6804                    return System.Environment.PatchDictionary(new (System.Collections.Generic.Dictionary$2(System.String,System.String)).$ctor1(System.Environment.Variables));
6805                },
6806                GetEnvironmentVariables$1: function (target) {
6807                    return System.Environment.GetEnvironmentVariables();
6808                },
6809                GetLogicalDrives: function () {
6810                    return System.Array.init(0, null, System.String);
6811                },
6812                SetEnvironmentVariable: function (variable, value) {
6813                    if (variable == null) {
6814                        throw new System.ArgumentNullException.$ctor1("variable");
6815                    }
6816
6817                    if (System.String.isNullOrEmpty(variable) || System.String.startsWith(variable, String.fromCharCode(0)) || System.String.contains(variable,"=") || variable.length > 32767) {
6818                        throw new System.ArgumentException.$ctor1("Incorrect variable (cannot be empty, contain zero character nor equal sign, be longer than 32767).");
6819                    }
6820
6821                    variable = variable.toLowerCase();
6822
6823                    if (System.String.isNullOrEmpty(value)) {
6824                        if (System.Environment.Variables.containsKey(variable)) {
6825                            System.Environment.Variables.remove(variable);
6826                        }
6827                    } else {
6828                        System.Environment.Variables.setItem(variable, value);
6829                    }
6830                },
6831                SetEnvironmentVariable$1: function (variable, value, target) {
6832                    System.Environment.SetEnvironmentVariable(variable, value);
6833                }
6834            }
6835        }
6836    });
6837
6838    // @source StringSplitOptions.js
6839
6840    H5.define("System.StringSplitOptions", {
6841        $kind: "enum",
6842        statics: {
6843            fields: {
6844                None: 0,
6845                RemoveEmptyEntries: 1
6846            }
6847        },
6848        $flags: true
6849    });
6850
6851    // @source TypeCode.js
6852
6853    H5.define("System.TypeCode", {
6854        $kind: "enum",
6855        statics: {
6856            fields: {
6857                Empty: 0,
6858                Object: 1,
6859                DBNull: 2,
6860                Boolean: 3,
6861                Char: 4,
6862                SByte: 5,
6863                Byte: 6,
6864                Int16: 7,
6865                UInt16: 8,
6866                Int32: 9,
6867                UInt32: 10,
6868                Int64: 11,
6869                UInt64: 12,
6870                Single: 13,
6871                Double: 14,
6872                Decimal: 15,
6873                DateTime: 16,
6874                String: 18
6875            }
6876        }
6877    });
6878
6879    // @source TypeCodeValues.js
6880
6881    H5.define("System.TypeCodeValues", {
6882        statics: {
6883            fields: {
6884                Empty: null,
6885                Object: null,
6886                DBNull: null,
6887                Boolean: null,
6888                Char: null,
6889                SByte: null,
6890                Byte: null,
6891                Int16: null,
6892                UInt16: null,
6893                Int32: null,
6894                UInt32: null,
6895                Int64: null,
6896                UInt64: null,
6897                Single: null,
6898                Double: null,
6899                Decimal: null,
6900                DateTime: null,
6901                String: null
6902            },
6903            ctors: {
6904                init: function () {
6905                    this.Empty = "0";
6906                    this.Object = "1";
6907                    this.DBNull = "2";
6908                    this.Boolean = "3";
6909                    this.Char = "4";
6910                    this.SByte = "5";
6911                    this.Byte = "6";
6912                    this.Int16 = "7";
6913                    this.UInt16 = "8";
6914                    this.Int32 = "9";
6915                    this.UInt32 = "10";
6916                    this.Int64 = "11";
6917                    this.UInt64 = "12";
6918                    this.Single = "13";
6919                    this.Double = "14";
6920                    this.Decimal = "15";
6921                    this.DateTime = "16";
6922                    this.String = "18";
6923                }
6924            }
6925        }
6926    });
6927
6928    // @source Type.js
6929
6930H5.define("System.Type", {
6931
6932    statics: {
6933        $is: function (instance) {
6934            return instance && instance.constructor === Function;
6935        },
6936
6937        getTypeCode: function (t) {
6938            if (t == null) {
6939                return System.TypeCode.Empty;
6940            }
6941            if (t === System.Double) {
6942                return System.TypeCode.Double;
6943            }
6944            if (t === System.Single) {
6945                return System.TypeCode.Single;
6946            }
6947            if (t === System.Decimal) {
6948                return System.TypeCode.Decimal;
6949            }
6950            if (t === System.Byte) {
6951                return System.TypeCode.Byte;
6952            }
6953            if (t === System.SByte) {
6954                return System.TypeCode.SByte;
6955            }
6956            if (t === System.UInt16) {
6957                return System.TypeCode.UInt16;
6958            }
6959            if (t === System.Int16) {
6960                return System.TypeCode.Int16;
6961            }
6962            if (t === System.UInt32) {
6963                return System.TypeCode.UInt32;
6964            }
6965            if (t === System.Int32) {
6966                return System.TypeCode.Int32;
6967            }
6968            if (t === System.UInt64) {
6969                return System.TypeCode.UInt64;
6970            }
6971            if (t === System.Int64) {
6972                return System.TypeCode.Int64;
6973            }
6974            if (t === System.Boolean) {
6975                return System.TypeCode.Boolean;
6976            }
6977            if (t === System.Char) {
6978                return System.TypeCode.Char;
6979            }
6980            if (t === System.DateTime) {
6981                return System.TypeCode.DateTime;
6982            }
6983            if (t === System.String) {
6984                return System.TypeCode.String;
6985            }
6986            return System.TypeCode.Object;
6987        }
6988    }
6989});
6990    // @source Math.js
6991
6992    H5.Math = {
6993        divRem: function (a, b, result) {
6994            var remainder = a % b;
6995
6996            result.v = remainder;
6997
6998            return (a - remainder) / b;
6999        },
7000
7001        round: function (n, d, rounding) {
7002            var m = Math.pow(10, d || 0);
7003
7004            n *= m;
7005
7006            var sign = (n > 0) | -(n < 0);
7007
7008            if (n % 1 === 0.5 * sign) {
7009                var f = Math.floor(n);
7010
7011                return (f + (rounding === 4 ? (sign > 0) : (f % 2 * sign))) / m;
7012            }
7013
7014            return Math.round(n) / m;
7015        },
7016
7017        log10: Math.log10 || function (x) {
7018            return Math.log(x) / Math.LN10;
7019        },
7020
7021        logWithBase: function (x, newBase) {
7022            if (isNaN(x)) {
7023                return x;
7024            }
7025
7026            if (isNaN(newBase)) {
7027                return newBase;
7028            }
7029
7030            if (newBase === 1) {
7031                return NaN
7032            }
7033
7034            if (x !== 1 && (newBase === 0 || newBase === Number.POSITIVE_INFINITY)) {
7035                return NaN;
7036            }
7037
7038            return H5.Math.log10(x) / H5.Math.log10(newBase);
7039        },
7040
7041        log: function (x) {
7042            if (x === 0.0) {
7043                return Number.NEGATIVE_INFINITY;
7044            }
7045
7046            if (x < 0.0 || isNaN(x)) {
7047                return NaN;
7048            }
7049
7050            if (x === Number.POSITIVE_INFINITY) {
7051                return Number.POSITIVE_INFINITY;
7052            }
7053
7054            if (x === Number.NEGATIVE_INFINITY) {
7055                return NaN;
7056            }
7057
7058            return Math.log(x);
7059        },
7060
7061        sinh: Math.sinh || function (x) {
7062            return (Math.exp(x) - Math.exp(-x)) / 2;
7063        },
7064
7065        cosh: Math.cosh || function (x) {
7066            return (Math.exp(x) + Math.exp(-x)) / 2;
7067        },
7068
7069        tanh: Math.tanh || function (x) {
7070            if (x === Infinity) {
7071                return 1;
7072            } else if (x === -Infinity) {
7073                return -1;
7074            } else {
7075                var y = Math.exp(2 * x);
7076
7077                return (y - 1) / (y + 1);
7078            }
7079        },
7080
7081        IEEERemainder: function (x, y) {
7082            var regularMod = x % y;
7083            if (isNaN(regularMod)) {
7084                return Number.NaN;
7085            }
7086            if (regularMod === 0) {
7087                if (x < 0) {
7088                    return -0;
7089                }
7090            }
7091            var alternativeResult;
7092            alternativeResult = regularMod - (Math.abs(y) * H5.Int.sign(x));
7093            if (Math.abs(alternativeResult) === Math.abs(regularMod)) {
7094                var divisionResult = x / y;
7095                var roundedResult = H5.Math.round(divisionResult, 0, 6);
7096                if (Math.abs(roundedResult) > Math.abs(divisionResult)) {
7097                    return alternativeResult;
7098                } else {
7099                    return regularMod;
7100                }
7101            }
7102            if (Math.abs(alternativeResult) < Math.abs(regularMod)) {
7103                return alternativeResult;
7104            } else {
7105                return regularMod;
7106            }
7107        }
7108    };
7109
7110    // @source Bool.js
7111
7112    H5.define("System.Boolean", {
7113        inherits: [System.IComparable],
7114
7115        statics: {
7116            trueString: "True",
7117            falseString: "False",
7118
7119            $is: function (instance) {
7120                return typeof (instance) === "boolean";
7121            },
7122
7123            getDefaultValue: function () {
7124                return false;
7125            },
7126
7127            createInstance: function () {
7128                return false;
7129            },
7130
7131            toString: function (v) {
7132                return v ? System.Boolean.trueString : System.Boolean.falseString;
7133            },
7134
7135            parse: function (value) {
7136                if (!H5.hasValue(value)) {
7137                    throw new System.ArgumentNullException.$ctor1("value");
7138                }
7139
7140                var result = {
7141                    v: false
7142                };
7143
7144                if (!System.Boolean.tryParse(value, result)) {
7145                    throw new System.FormatException.$ctor1("Bad format for Boolean value");
7146                }
7147
7148                return result.v;
7149            },
7150
7151            tryParse: function (value, result) {
7152                result.v = false;
7153
7154                if (!H5.hasValue(value)) {
7155                    return false;
7156                }
7157
7158                if (System.String.equals(System.Boolean.trueString, value, 5)) {
7159                    result.v = true;
7160                    return true;
7161                }
7162
7163                if (System.String.equals(System.Boolean.falseString, value, 5)) {
7164                    result.v = false;
7165                    return true;
7166                }
7167
7168                var start = 0,
7169                    end = value.length - 1;
7170
7171                while (start < value.length) {
7172                    if (!System.Char.isWhiteSpace(value[start]) && !System.Char.isNull(value.charCodeAt(start))) {
7173                        break;
7174                    }
7175
7176                    start++;
7177                }
7178
7179                while (end >= start) {
7180                    if (!System.Char.isWhiteSpace(value[end]) && !System.Char.isNull(value.charCodeAt(end))) {
7181                        break;
7182                    }
7183
7184                    end--;
7185                }
7186
7187                value = value.substr(start, end - start + 1);
7188
7189                if (System.String.equals(System.Boolean.trueString, value, 5)) {
7190                    result.v = true;
7191
7192                    return true;
7193                }
7194
7195                if (System.String.equals(System.Boolean.falseString, value, 5)) {
7196                    result.v = false;
7197
7198                    return true;
7199                }
7200
7201                return false;
7202            }
7203        }
7204    });
7205
7206    System.Boolean.$kind = "";
7207    H5.Class.addExtend(System.Boolean, [System.IComparable$1(System.Boolean), System.IEquatable$1(System.Boolean)]);
7208
7209    // @source Integer.js
7210
7211
7212    H5.define("H5.Int", {
7213        inherits: [System.IComparable, System.IFormattable],
7214        statics: {
7215            $number: true,
7216
7217            MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1,
7218            MIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1),
7219
7220            $is: function (instance) {
7221                return typeof (instance) === "number" && isFinite(instance) && Math.floor(instance, 0) === instance;
7222            },
7223
7224            getDefaultValue: function () {
7225                return 0;
7226            },
7227
7228            format: function (number, format, provider, T, toUnsign) {
7229                var nf = (provider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.NumberFormatInfo),
7230                    decimalSeparator = nf.numberDecimalSeparator,
7231                    groupSeparator = nf.numberGroupSeparator,
7232                    isDecimal = number instanceof System.Decimal,
7233                    isLong = number instanceof System.Int64 || number instanceof System.UInt64,
7234                    isNeg = isDecimal || isLong ? (number.isZero() ? false : number.isNegative()) : number < 0,
7235                    match,
7236                    precision,
7237                    groups,
7238                    fs;
7239
7240                if (!isLong && (isDecimal ? !number.isFinite() : !isFinite(number))) {
7241                    return Number.NEGATIVE_INFINITY === number || (isDecimal && isNeg) ? nf.negativeInfinitySymbol : (isNaN(number) ? nf.nanSymbol : nf.positiveInfinitySymbol);
7242                }
7243
7244                if (!format) {
7245                    format = "G";
7246                }
7247
7248                match = format.match(/^([a-zA-Z])(\d*)$/);
7249
7250                if (match) {
7251                    fs = match[1].toUpperCase();
7252                    precision = parseInt(match[2], 10);
7253                    //precision = precision > 15 ? 15 : precision;
7254
7255                    switch (fs) {
7256                        case "D":
7257                            return this.defaultFormat(number, isNaN(precision) ? 1 : precision, 0, 0, nf, true);
7258                        case "F":
7259                        case "N":
7260                            if (isNaN(precision)) {
7261                                precision = nf.numberDecimalDigits;
7262                            }
7263
7264                            return this.defaultFormat(number, 1, precision, precision, nf, fs === "F");
7265                        case "G":
7266                        case "E":
7267                            var exponent = 0,
7268                                coefficient = isDecimal || isLong ? (isLong && number.eq(System.Int64.MinValue) ? System.Int64(number.value.toUnsigned()) : number.abs()) : Math.abs(number),
7269                                exponentPrefix = match[1],
7270                                exponentPrecision = 3,
7271                                minDecimals,
7272                                maxDecimals;
7273
7274                            while (isDecimal || isLong ? coefficient.gte(10) : (coefficient >= 10)) {
7275                                if (isDecimal || isLong) {
7276                                    coefficient = coefficient.div(10);
7277                                } else {
7278                                    coefficient /= 10;
7279                                }
7280
7281                                exponent++;
7282                            }
7283
7284                            while (isDecimal || isLong ? (coefficient.ne(0) && coefficient.lt(1)) : (coefficient !== 0 && coefficient < 1)) {
7285                                if (isDecimal || isLong) {
7286                                    coefficient = coefficient.mul(10);
7287                                } else {
7288                                    coefficient *= 10;
7289                                }
7290
7291                                exponent--;
7292                            }
7293
7294                            if (fs === "G") {
7295                                var noPrecision = isNaN(precision);
7296
7297                                if (noPrecision) {
7298                                    if (isDecimal) {
7299                                        precision = 29;
7300                                    } else if (isLong) {
7301                                        precision = number instanceof System.Int64 ? 19 : 20;
7302                                    } else if (T && T.precision) {
7303                                        precision = T.precision;
7304                                    } else {
7305                                        precision = 15;
7306                                    }
7307                                }
7308
7309                                if ((exponent > -5 && exponent < precision) || isDecimal && noPrecision) {
7310                                    minDecimals = 0;
7311                                    maxDecimals = precision - (exponent > 0 ? exponent + 1 : 1);
7312
7313                                    return this.defaultFormat(number, 1, isDecimal ? Math.min(27, Math.max(minDecimals, number.$precision)) : minDecimals, maxDecimals, nf, true);
7314                                }
7315
7316                                exponentPrefix = exponentPrefix === "G" ? "E" : "e";
7317                                exponentPrecision = 2;
7318                                minDecimals = 0;
7319                                maxDecimals = (precision || 15) - 1;
7320                            } else {
7321                                minDecimals = maxDecimals = isNaN(precision) ? 6 : precision;
7322                            }
7323
7324                            if (exponent >= 0) {
7325                                exponentPrefix += nf.positiveSign;
7326                            } else {
7327                                exponentPrefix += nf.negativeSign;
7328                                exponent = -exponent;
7329                            }
7330
7331                            if (isNeg) {
7332                                if (isDecimal || isLong) {
7333                                    coefficient = coefficient.mul(-1);
7334                                } else {
7335                                    coefficient *= -1;
7336                                }
7337                            }
7338
7339                            return this.defaultFormat(coefficient, 1, isDecimal ? Math.min(27, Math.max(minDecimals, number.$precision)) : minDecimals, maxDecimals, nf) + exponentPrefix + this.defaultFormat(exponent, exponentPrecision, 0, 0, nf, true);
7340                        case "P":
7341                            if (isNaN(precision)) {
7342                                precision = nf.percentDecimalDigits;
7343                            }
7344
7345                            return this.defaultFormat(number * 100, 1, precision, precision, nf, false, "percent");
7346                        case "X":
7347                            var result;
7348
7349                            if (isDecimal) {
7350                                result = number.round().value.toHex().substr(2);
7351                            } else if (isLong) {
7352                                var uvalue = toUnsign ? toUnsign(number) : number;
7353                                result = uvalue.toString(16);
7354                            } else {
7355                                var uvalue = toUnsign ? toUnsign(Math.round(number)) : Math.round(number) >>> 0;
7356                                result = uvalue.toString(16);
7357                            }
7358
7359                            if (match[1] === "X") {
7360                                result = result.toUpperCase();
7361                            }
7362
7363                            precision -= result.length;
7364
7365                            while (precision-- > 0) {
7366                                result = "0" + result;
7367                            }
7368
7369                            return result;
7370                        case "C":
7371                            if (isNaN(precision)) {
7372                                precision = nf.currencyDecimalDigits;
7373                            }
7374
7375                            return this.defaultFormat(number, 1, precision, precision, nf, false, "currency");
7376                        case "R":
7377                            var r_result = isDecimal || isLong ? (number.toString()) : ("" + number);
7378
7379                            if (decimalSeparator !== ".") {
7380                                r_result = r_result.replace(".", decimalSeparator);
7381                            }
7382
7383                            r_result = r_result.replace("e", "E");
7384
7385                            return r_result;
7386                    }
7387                }
7388
7389                if (format.indexOf(",.") !== -1 || System.String.endsWith(format, ",")) {
7390                    var count = 0,
7391                        index = format.indexOf(",.");
7392
7393                    if (index === -1) {
7394                        index = format.length - 1;
7395                    }
7396
7397                    while (index > -1 && format.charAt(index) === ",") {
7398                        count++;
7399                        index--;
7400                    }
7401
7402                    if (isDecimal || isLong) {
7403                        number = number.div(Math.pow(1000, count));
7404                    } else {
7405                        number /= Math.pow(1000, count);
7406                    }
7407                }
7408
7409                if (format.indexOf("%") !== -1) {
7410                    if (isDecimal || isLong) {
7411                        number = number.mul(100);
7412                    } else {
7413                        number *= 100;
7414                    }
7415                }
7416
7417                if (format.indexOf("‰") !== -1) {
7418                    if (isDecimal || isLong) {
7419                        number = number.mul(1000);
7420                    } else {
7421                        number *= 1000;
7422                    }
7423                }
7424
7425                groups = format.split(";");
7426
7427                if ((isDecimal || isLong ? number.lt(0) : (number < 0)) && groups.length > 1) {
7428                    if (isDecimal || isLong) {
7429                        number = number.mul(-1);
7430                    } else {
7431                        number *= -1;
7432                    }
7433
7434                    format = groups[1];
7435                } else {
7436                    format = groups[(isDecimal || isLong ? number.ne(0) : !number) && groups.length > 2 ? 2 : 0];
7437                }
7438
7439                return this.customFormat(number, format, nf, !format.match(/^[^\.]*[0#],[0#]/));
7440            },
7441
7442            defaultFormat: function (number, minIntLen, minDecLen, maxDecLen, provider, noGroup, name) {
7443                name = name || "number";
7444
7445                var nf = (provider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.NumberFormatInfo),
7446                    str,
7447                    decimalIndex,
7448                    pattern,
7449                    roundingFactor,
7450                    groupIndex,
7451                    groupSize,
7452                    groups = nf[name + "GroupSizes"],
7453                    decimalPart,
7454                    index,
7455                    done,
7456                    startIndex,
7457                    length,
7458                    part,
7459                    sep,
7460                    buffer = "",
7461                    isDecimal = number instanceof System.Decimal,
7462                    isLong = number instanceof System.Int64 || number instanceof System.UInt64,
7463                    isNeg = isDecimal || isLong ? (number.isZero() ? false : number.isNegative()) : number < 0,
7464                    isZero = false;
7465
7466                roundingFactor = Math.pow(10, maxDecLen);
7467
7468                if (isDecimal) {
7469                    str = number.abs().toDecimalPlaces(maxDecLen).toFixed();
7470                } else if (isLong) {
7471                    str = number.eq(System.Int64.MinValue) ? number.value.toUnsigned().toString() : number.abs().toString();
7472                } else {
7473                    str = "" + (+Math.abs(number).toFixed(maxDecLen));
7474                }
7475
7476                isZero = str.split("").every(function (s) { return s === "0" || s === "."; });
7477
7478                decimalIndex = str.indexOf(".");
7479
7480                if (decimalIndex > 0) {
7481                    decimalPart = nf[name + "DecimalSeparator"] + str.substr(decimalIndex + 1);
7482                    str = str.substr(0, decimalIndex);
7483                }
7484
7485                if (str.length < minIntLen) {
7486                    str = Array(minIntLen - str.length + 1).join("0") + str;
7487                }
7488
7489                if (decimalPart) {
7490                    if ((decimalPart.length - 1) < minDecLen) {
7491                        decimalPart += Array(minDecLen - decimalPart.length + 2).join("0");
7492                    }
7493
7494                    if (maxDecLen === 0) {
7495                        decimalPart = null;
7496                    } else if ((decimalPart.length - 1) > maxDecLen) {
7497                        decimalPart = decimalPart.substr(0, maxDecLen + 1);
7498                    }
7499                } else if (minDecLen > 0) {
7500                    decimalPart = nf[name + "DecimalSeparator"] + Array(minDecLen + 1).join("0");
7501                }
7502
7503                groupIndex = 0;
7504                groupSize = groups[groupIndex];
7505
7506                if (str.length < groupSize) {
7507                    buffer = str;
7508
7509                    if (decimalPart) {
7510                        buffer += decimalPart;
7511                    }
7512                } else {
7513                    index = str.length;
7514                    done = false;
7515                    sep = noGroup ? "" : nf[name + "GroupSeparator"];
7516
7517                    while (!done) {
7518                        length = groupSize;
7519                        startIndex = index - length;
7520
7521                        if (startIndex < 0) {
7522                            groupSize += startIndex;
7523                            length += startIndex;
7524                            startIndex = 0;
7525                            done = true;
7526                        }
7527
7528                        if (!length) {
7529                            break;
7530                        }
7531
7532                        part = str.substr(startIndex, length);
7533
7534                        if (buffer.length) {
7535                            buffer = part + sep + buffer;
7536                        } else {
7537                            buffer = part;
7538                        }
7539
7540                        index -= length;
7541
7542                        if (groupIndex < groups.length - 1) {
7543                            groupIndex++;
7544                            groupSize = groups[groupIndex];
7545                        }
7546                    }
7547
7548                    if (decimalPart) {
7549                        buffer += decimalPart;
7550                    }
7551                }
7552
7553                if (isNeg && !isZero) {
7554                    pattern = System.Globalization.NumberFormatInfo[name + "NegativePatterns"][nf[name + "NegativePattern"]];
7555
7556                    return pattern.replace("-", nf.negativeSign).replace("%", nf.percentSymbol).replace("$", nf.currencySymbol).replace("n", buffer);
7557                } else if (System.Globalization.NumberFormatInfo[name + "PositivePatterns"]) {
7558                    pattern = System.Globalization.NumberFormatInfo[name + "PositivePatterns"][nf[name + "PositivePattern"]];
7559
7560                    return pattern.replace("%", nf.percentSymbol).replace("$", nf.currencySymbol).replace("n", buffer);
7561                }
7562
7563                return buffer;
7564            },
7565
7566            customFormat: function (number, format, nf, noGroup) {
7567                var digits = 0,
7568                    forcedDigits = -1,
7569                    integralDigits = -1,
7570                    decimals = 0,
7571                    forcedDecimals = -1,
7572                    atDecimals = 0,
7573                    unused = 1,
7574                    c, i, f,
7575                    endIndex,
7576                    roundingFactor,
7577                    decimalIndex,
7578                    isNegative = false,
7579                    isZero = false,
7580                    name,
7581                    groupCfg,
7582                    buffer = "",
7583                    isZeroInt = false,
7584                    wasSeparator = false,
7585                    wasIntPart = false,
7586                    isDecimal = number instanceof System.Decimal,
7587                    isLong = number instanceof System.Int64 || number instanceof System.UInt64,
7588                    isNeg = isDecimal || isLong ? (number.isZero() ? false : number.isNegative()) : number < 0;
7589
7590                name = "number";
7591
7592                if (format.indexOf("%") !== -1) {
7593                    name = "percent";
7594                } else if (format.indexOf("$") !== -1) {
7595                    name = "currency";
7596                }
7597
7598                for (i = 0; i < format.length; i++) {
7599                    c = format.charAt(i);
7600
7601                    if (c === "'" || c === '"') {
7602                        i = format.indexOf(c, i + 1);
7603
7604                        if (i < 0) {
7605                            break;
7606                        }
7607                    } else if (c === "\\") {
7608                        i++;
7609                    } else {
7610                        if (c === "0" || c === "#") {
7611                            decimals += atDecimals;
7612
7613                            if (c === "0") {
7614                                if (atDecimals) {
7615                                    forcedDecimals = decimals;
7616                                } else if (forcedDigits < 0) {
7617                                    forcedDigits = digits;
7618                                }
7619                            }
7620
7621                            digits += !atDecimals;
7622                        }
7623
7624                        atDecimals = atDecimals || c === ".";
7625                    }
7626                }
7627                forcedDigits = forcedDigits < 0 ? 1 : digits - forcedDigits;
7628
7629                if (isNeg) {
7630                    isNegative = true;
7631                }
7632
7633                roundingFactor = Math.pow(10, decimals);
7634
7635                if (isDecimal) {
7636                    number = System.Decimal.round(number.abs().mul(rou
7636ndingFactor), 4).div(roundingFactor).toString();
7637                } else if (isLong) {
7638                    number = (number.eq(System.Int64.MinValue) ? System.Int64(number.value.toUnsigned()) : number.abs()).mul(roundingFactor).div(roundingFactor).toString();
7639                } else {
7640                    number = "" + (Math.round(Math.abs(number) * roundingFactor) / roundingFactor);
7641                }
7642
7643                isZero = number.split("").every(function (s) { return s === "0" || s === "."; });
7644
7645                decimalIndex = number.indexOf(".");
7646                integralDigits = decimalIndex < 0 ? number.length : decimalIndex;
7647                i = integralDigits - digits;
7648
7649                groupCfg = {
7650                    groupIndex: Math.max(integralDigits, forcedDigits),
7651                    sep: noGroup ? "" : nf[name + "GroupSeparator"]
7652                };
7653
7654                if (integralDigits === 1 && number.charAt(0) === "0") {
7655                    isZeroInt = true;
7656                }
7657
7658                for (f = 0; f < format.length; f++) {
7659                    c = format.charAt(f);
7660
7661                    if (c === "'" || c === '"') {
7662                        endIndex = format.indexOf(c, f + 1);
7663
7664                        buffer += format.substring(f + 1, endIndex < 0 ? format.length : endIndex);
7665
7666                        if (endIndex < 0) {
7667                            break;
7668                        }
7669
7670                        f = endIndex;
7671                    } else if (c === "\\") {
7672                        buffer += format.charAt(f + 1);
7673                        f++;
7674                    } else if (c === "#" || c === "0") {
7675                        wasIntPart = true;
7676
7677                        if (!wasSeparator && isZeroInt && c === "#") {
7678                            i++;
7679                        } else {
7680                            groupCfg.buffer = buffer;
7681
7682                            if (i < integralDigits) {
7683                                if (i >= 0) {
7684                                    if (unused) {
7685                                        this.addGroup(number.substr(0, i), groupCfg);
7686                                    }
7687
7688                                    this.addGroup(number.charAt(i), groupCfg);
7689                                } else if (i >= integralDigits - forcedDigits) {
7690                                    this.addGroup("0", groupCfg);
7691                                }
7692
7693                                unused = 0;
7694                            } else if (forcedDecimals-- > 0 || i < number.length) {
7695                                this.addGroup(i >= number.length ? "0" : number.charAt(i), groupCfg);
7696                            }
7697
7698                            buffer = groupCfg.buffer;
7699
7700                            i++;
7701                        }
7702                    } else if (c === ".") {
7703                        if (!wasIntPart && !isZeroInt) {
7704                            buffer += number.substr(0, integralDigits);
7705                            wasIntPart = true;
7706                        }
7707
7708                        if (number.length > ++i || forcedDecimals > 0) {
7709                            wasSeparator = true;
7710                            buffer += nf[name + "DecimalSeparator"];
7711                        }
7712                    } else if (c !== ",") {
7713                        buffer += c;
7714                    }
7715                }
7716
7717                if (isNegative && !isZero) {
7718                    buffer = "-" + buffer;
7719                }
7720
7721                return buffer;
7722            },
7723
7724            addGroup: function (value, cfg) {
7725                var buffer = cfg.buffer,
7726                    sep = cfg.sep,
7727                    groupIndex = cfg.groupIndex;
7728
7729                for (var i = 0, length = value.length; i < length; i++) {
7730                    buffer += value.charAt(i);
7731
7732                    if (sep && groupIndex > 1 && groupIndex-- % 3 === 1) {
7733                        buffer += sep;
7734                    }
7735                }
7736
7737                cfg.buffer = buffer;
7738                cfg.groupIndex = groupIndex;
7739            },
7740
7741            parseFloat: function (s, provider) {
7742                var res = { };
7743
7744                H5.Int.tryParseFloat(s, provider, res, false);
7745
7746                return res.v;
7747            },
7748
7749            tryParseFloat: function (s, provider, result, safe) {
7750                result.v = 0;
7751
7752                if (safe == null) {
7753                    safe = true;
7754                }
7755
7756                if (s == null) {
7757                    if (safe) {
7758                        return false;
7759                    }
7760
7761                    throw new System.ArgumentNullException.$ctor1("s");
7762                }
7763
7764                s = s.trim();
7765
7766                var nfInfo = (provider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.NumberFormatInfo),
7767                    point = nfInfo.numberDecimalSeparator,
7768                    thousands = nfInfo.numberGroupSeparator;
7769
7770                var errMsg = "Input string was not in a correct format.";
7771
7772                var pointIndex = s.indexOf(point);
7773                var thousandIndex = thousands ? s.indexOf(thousands) : -1;
7774
7775                if (pointIndex > -1) {
7776                    // point before thousands is not allowed
7777                    // "10.2,5" -> FormatException
7778                    // "1,0.2,5" -> FormatException
7779                    if (((pointIndex < thousandIndex) || ((thousandIndex > -1) && (pointIndex < s.indexOf(thousands, pointIndex))))
7780                        // only one point is allowed
7781                        || (s.indexOf(point, pointIndex + 1) > -1)) {
7782                        if (safe) {
7783                            return false;
7784                        }
7785
7786                        throw new System.FormatException.$ctor1(errMsg);
7787                    }
7788                }
7789
7790                if ((point !== ".") && (thousands !== ".") && (s.indexOf(".") > -1)) {
7791                    if (safe) {
7792                        return false;
7793                    }
7794
7795                    throw new System.FormatException.$ctor1(errMsg);
7796                }
7797
7798                if (thousandIndex > -1) {
7799                    // mutiple thousands are allowed, so we remove them before going further
7800                    var tmpStr = "";
7801
7802                    for (var i = 0; i < s.length; i++) {
7803                        if (s[i] !== thousands) {
7804                            tmpStr += s[i];
7805                        }
7806                    }
7807
7808                    s = tmpStr;
7809                }
7810
7811                if (s === nfInfo.negativeInfinitySymbol) {
7812                    result.v = Number.NEGATIVE_INFINITY;
7813
7814                    return true;
7815                } else if (s === nfInfo.positiveInfinitySymbol) {
7816                    result.v = Number.POSITIVE_INFINITY;
7817
7818                    return true;
7819                } else if (s === nfInfo.nanSymbol) {
7820                    result.v = Number.NaN;
7821
7822                    return true;
7823                }
7824
7825                var countExp = 0,
7826                    ePrev = false;
7827
7828                for (var i = 0; i < s.length; i++) {
7829                    if (!System.Char.isNumber(s[i].charCodeAt(0)) &&
7830                        s[i] !== "." &&
7831                        s[i] !== "," &&
7832                        (s[i] !== nfInfo.positiveSign || i !== 0 && !ePrev) &&
7833                        (s[i] !== nfInfo.negativeSign || i !== 0 && !ePrev) &&
7834                        s[i] !== point &&
7835                        s[i] !== thousands) {
7836                        if (s[i].toLowerCase() === "e") {
7837                            ePrev = true;
7838                            countExp++;
7839
7840                            if (countExp > 1) {
7841                                if (safe) {
7842                                    return false;
7843                                }
7844
7845                                throw new System.FormatException.$ctor1(errMsg);
7846                            }
7847                        } else {
7848                            ePrev = false;
7849                            if (safe) {
7850                                return false;
7851                            }
7852
7853                            throw new System.FormatException.$ctor1(errMsg);
7854                        }
7855                    } else {
7856                        ePrev = false;
7857                    }
7858                }
7859
7860                var r = parseFloat(s.replace(point, "."));
7861
7862                if (isNaN(r)) {
7863                    if (safe) {
7864                        return false;
7865                    }
7866
7867                    throw new System.FormatException.$ctor1(errMsg);
7868                }
7869
7870                result.v = r;
7871
7872                return true;
7873            },
7874
7875            parseInt: function (str, min, max, radix) {
7876                radix = radix || 10;
7877
7878                if (str == null) {
7879                    throw new System.ArgumentNullException.$ctor1("str");
7880                }
7881
7882                str = str.trim();
7883
7884                if ((radix <= 10 && !/^[+-]?[0-9]+$/.test(str))
7885                    || (radix == 16 && !/^[+-]?[0-9A-F]+$/gi.test(str))) {
7886                    throw new System.FormatException.$ctor1("Input string was not in a correct format.");
7887                }
7888
7889                var result = parseInt(str, radix);
7890
7891                if (isNaN(result)) {
7892                    throw new System.FormatException.$ctor1("Input string was not in a correct format.");
7893                }
7894
7895                if (result < min || result > max) {
7896                    throw new System.OverflowException();
7897                }
7898
7899                return result;
7900            },
7901
7902            tryParseInt: function (str, result, min, max, radix) {
7903                result.v = 0;
7904                radix = radix || 10;
7905
7906                if (str != null && str.trim === "".trim) {
7907                    str = str.trim();
7908                }
7909
7910                if ((radix <= 10 && !/^[+-]?[0-9]+$/.test(str))
7911                    || (radix == 16 && !/^[+-]?[0-9A-F]+$/gi.test(str))) {
7912                    return false;
7913                }
7914
7915                result.v = parseInt(str, radix);
7916
7917                if (result.v < min || result.v > max) {
7918                    result.v = 0;
7919
7920                    return false;
7921                }
7922
7923                return true;
7924            },
7925
7926            isInfinite: function (x) {
7927                return x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY;
7928            },
7929
7930            trunc: function (num) {
7931                if (!H5.isNumber(num)) {
7932                    return H5.Int.isInfinite(num) ? num : null;
7933                }
7934
7935                return num > 0 ? Math.floor(num) : Math.ceil(num);
7936            },
7937
7938            div: function (x, y) {
7939                if (x == null || y == null) {
7940                    return null;
7941                }
7942
7943                if (y === 0) {
7944                    throw new System.DivideByZeroException();
7945                }
7946
7947                return this.trunc(x / y);
7948            },
7949
7950            mod: function (x, y) {
7951                if (x == null || y == null) {
7952                    return null;
7953                }
7954
7955                if (y === 0) {
7956                    throw new System.DivideByZeroException();
7957                }
7958
7959                return x % y;
7960            },
7961
7962            check: function (x, type) {
7963                if (System.Int64.is64Bit(x)) {
7964                    return System.Int64.check(x, type);
7965                } else if (x instanceof System.Decimal) {
7966                    return System.Decimal.toInt(x, type);
7967                }
7968
7969                if (H5.isNumber(x)) {
7970                    if (System.Int64.is64BitType(type)) {
7971                        if (type === System.UInt64 && x < 0) {
7972                            throw new System.OverflowException();
7973                        }
7974
7975                        return type === System.Int64 ? System.Int64(x) : System.UInt64(x);
7976                    } else if (!type.$is(x)) {
7977                        throw new System.OverflowException();
7978                    }
7979                }
7980
7981                if (H5.Int.isInfinite(x) || isNaN(x)) {
7982                    if (System.Int64.is64BitType(type)) {
7983                        return type.MinValue;
7984                    }
7985
7986                    return type.min;
7987                }
7988
7989                return x;
7990            },
7991
7992            sxb: function (x) {
7993                return H5.isNumber(x) ? (x | (x & 0x80 ? 0xffffff00 : 0)) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.SByte.min : null);
7994            },
7995
7996            sxs: function (x) {
7997                return H5.isNumber(x) ? (x | (x & 0x8000 ? 0xffff0000 : 0)) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.Int16.min : null);
7998            },
7999
8000            clip8: function (x) {
8001                return H5.isNumber(x) ? H5.Int.sxb(x & 0xff) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.SByte.min : null);
8002            },
8003
8004            clipu8: function (x) {
8005                return H5.isNumber(x) ? x & 0xff : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.Byte.min : null);
8006            },
8007
8008            clip16: function (x) {
8009                return H5.isNumber(x) ? H5.Int.sxs(x & 0xffff) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.Int16.min : null);
8010            },
8011
8012            clipu16: function (x) {
8013                return H5.isNumber(x) ? x & 0xffff : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.UInt16.min : null);
8014            },
8015
8016            clip32: function (x) {
8017                return H5.isNumber(x) ? x | 0 : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.Int32.min : null);
8018            },
8019
8020            clipu32: function (x) {
8021                return H5.isNumber(x) ? x >>> 0 : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.UInt32.min : null);
8022            },
8023
8024            clip64: function (x) {
8025                return H5.isNumber(x) ? System.Int64(H5.Int.trunc(x)
8025) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.Int64.MinValue : null);
8026            },
8027
8028            clipu64: function (x) {
8029                return H5.isNumber(x) ? System.UInt64(H5.Int.trunc(x)) : ((H5.Int.isInfinite(x) || isNaN(x)) ? System.UInt64.MinValue : null);
8030            },
8031
8032            sign: function (x) {
8033                if (x === Number.POSITIVE_INFINITY) {
8034                    return 1;
8035                }
8036
8037                if (x === Number.NEGATIVE_INFINITY) {
8038                    return -1;
8039                }
8040
8041                return H5.isNumber(x) ? (x === 0 ? 0 : (x < 0 ? -1 : 1)) : null;
8042            },
8043
8044            $mul: Math.imul || function (a, b) {
8045                var ah = (a >>> 16) & 0xffff,
8046                    al = a & 0xffff,
8047                    bh = (b >>> 16) & 0xffff,
8048                    bl = b & 0xffff;
8049
8050                return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
8051            },
8052
8053            mul: function (a, b, overflow) {
8054                if (a == null || b == null) {
8055                    return null;
8056                }
8057
8058                if (overflow) {
8059                    H5.Int.check(a * b, System.Int32)
8060                }
8061
8062                return H5.Int.$mul(a, b);
8063            },
8064
8065            umul: function (a, b, overflow) {
8066                if (a == null || b == null) {
8067                    return null;
8068                }
8069
8070                if (overflow) {
8071                    H5.Int.check(a * b, System.UInt32)
8072                }
8073
8074                return H5.Int.$mul(a, b) >>> 0;
8075            }
8076        }
8077    });
8078
8079    H5.Int.$kind = "";
8080    H5.Class.addExtend(H5.Int, [System.IComparable$1(H5.Int), System.IEquatable$1(H5.Int)]);
8081
8082    (function () {
8083        var createIntType = function (name, min, max, precision, toUnsign) {
8084            var type = H5.define(name, {
8085                inherits: [System.IComparable, System.IFormattable],
8086
8087                statics: {
8088                    $number: true,
8089                    toUnsign: toUnsign,
8090                    min: min,
8091                    max: max,
8092                    precision: precision,
8093
8094                    $is: function (instance) {
8095                        return typeof (instance) === "number" && Math.floor(instance, 0) === instance && instance >= min && instance <= max;
8096                    },
8097                    getDefaultValue: function () {
8098                        return 0;
8099                    },
8100                    parse: function (s, radix) {
8101                        return H5.Int.parseInt(s, min, max, radix);
8102                    },
8103                    tryParse: function (s, result, radix) {
8104                        return H5.Int.tryParseInt(s, result, min, max, radix);
8105                    },
8106                    format: function (number, format, provider) {
8107                        return H5.Int.format(number, format, provider, type, toUnsign);
8108                    },
8109                    equals: function (v1, v2) {
8110                        if (H5.is(v1, type) && H5.is(v2, type)) {
8111                            return H5.unbox(v1, true) === H5.unbox(v2, true);
8112                        }
8113
8114                        return false;
8115                    },
8116                    equalsT: function (v1, v2) {
8117                        return H5.unbox(v1, true) === H5.unbox(v2, true);
8118                    }
8119                }
8120            });
8121
8122            type.$kind = "";
8123            H5.Class.addExtend(type, [System.IComparable$1(type), System.IEquatable$1(type)]);
8124        };
8125
8126        createIntType("System.Byte", 0, 255, 3);
8127        createIntType("System.SByte", -128, 127, 3, H5.Int.clipu8);
8128        createIntType("System.Int16", -32768, 32767, 5, H5.Int.clipu16);
8129        createIntType("System.UInt16", 0, 65535, 5);
8130        createIntType("System.Int32", -2147483648, 2147483647, 10, H5.Int.clipu32);
8131        createIntType("System.UInt32", 0, 4294967295, 10);
8132    })();
8133
8134    // @source Double.js
8135
8136    H5.define("System.Double", {
8137        inherits: [System.IComparable, System.IFormattable],
8138        statics: {
8139            min: -Number.MAX_VALUE,
8140
8141            max: Number.MAX_VALUE,
8142
8143            precision: 15,
8144
8145            $number: true,
8146
8147            $is: function (instance) {
8148                return typeof (instance) === "number";
8149            },
8150
8151            getDefaultValue: function () {
8152                return 0;
8153            },
8154
8155            parse: function (s, provider) {
8156                return H5.Int.parseFloat(s, provider);
8157            },
8158
8159            tryParse: function (s, provider, result) {
8160                return H5.Int.tryParseFloat(s, provider, result);
8161            },
8162
8163            format: function (number, format, provider) {
8164                return H5.Int.format(number, format || 'G', provider, System.Double);
8165            },
8166
8167            equals: function (v1, v2) {
8168                if (H5.is(v1, System.Double) && H5.is(v2, System.Double)) {
8169                    v1 = H5.unbox(v1, true);
8170                    v2 = H5.unbox(v2, true);
8171
8172                    if (isNaN(v1) && isNaN(v2)) {
8173                        return true;
8174                    }
8175
8176                    return v1 === v2;
8177                }
8178
8179                return false;
8180            },
8181
8182            equalsT: function (v1, v2) {
8183                return H5.unbox(v1, true) === H5.unbox(v2, true);
8184            },
8185
8186            getHashCode: function (v) {
8187                var value = H5.unbox(v, true);
8188
8189                if (value === 0) {
8190                    return 0;
8191                }
8192
8193                if (value === Number.POSITIVE_INFINITY) {
8194                    return 0x7FF00000;
8195                }
8196
8197                if (value === Number.NEGATIVE_INFINITY) {
8198                    return 0xFFF00000;
8199                }
8200
8201                return H5.getHashCode(value.toExponential());
8202            }
8203        }
8204    });
8205
8206    System.Double.$kind = "";
8207    H5.Class.addExtend(System.Double, [System.IComparable$1(System.Double), System.IEquatable$1(System.Double)]);
8208
8209    H5.define("System.Single", {
8210        inherits: [System.IComparable, System.IFormattable],
8211        statics: {
8212            min: -3.40282346638528859e+38,
8213
8214            max: 3.40282346638528859e+38,
8215
8216            precision: 7,
8217
8218            $number: true,
8219
8220            $is: System.Double.$is,
8221
8222            getDefaultValue: System.Double.getDefaultValue,
8223
8224            parse: System.Double.parse,
8225
8226            tryParse: System.Double.tryParse,
8227
8228            format: function (number, format, provider) {
8229                return H5.Int.format(number, format || 'G', provider, System.Single);
8230            },
8231
8232            equals: function (v1, v2) {
8233                if (H5.is(v1, System.Single) && H5.is(v2, System.Single)) {
8234                    v1 = H5.unbox(v1, true);
8235                    v2 = H5.unbox(v2, true);
8236
8237                    if (isNaN(v1) && isNaN(v2)) {
8238                        return true;
8239                    }
8240
8241                    return v1 === v2;
8242                }
8243
8244                return false;
8245            },
8246
8247            equalsT: function (v1, v2) {
8248                return H5.unbox(v1, true) === H5.unbox(v2, true);
8249            },
8250
8251            getHashCode: System.Double.getHashCode
8252        }
8253    });
8254
8255    System.Single.$kind = "";
8256    H5.Class.addExtend(System.Single, [System.IComparable$1(System.Single), System.IEquatable$1(System.Single)]);
8257
8258    // @source Long.js
8259
8260    /* long.js https://github.com/dcodeIO/long.js/blob/master/LICENSE */
8261    (function (b) {
8262        function d(a, b, c) { this.low = a | 0; this.high = b | 0; this.unsigned = !!c } function g(a) { return !0 === (a && a.__isLong__) } function m(a, b) { var c, u; if (b) { a >>>= 0; if (u = 0 <= a && 256 > a) if (c = A[a]) return c; c = e(a, 0 > (a | 0) ? -1 : 0, !0); u && (A[a] = c) } else { a |= 0; if (u = -128 <= a && 128 > a) if (c = B[a]) return c; c = e(a, 0 > a ? -1 : 0, !1); u && (B[a] = c) } return c } function n(a, b) {
8263            if (isNaN(a) || !isFinite(a)) return b ? p : k; if (b) { if (0 > a) return p; if (a >= C) return D } else { if (a <= -E) return l; if (a + 1 >= E) return F } return 0 > a ? n(-a, b).neg() : e(a % 4294967296 | 0, a / 4294967296 |
8264            0, b)
8265        } function e(a, b, c) { return new d(a, b, c) } function y(a, b, c) {
8266            if (0 === a.length) throw Error("empty string"); if ("NaN" === a || "Infinity" === a || "+Infinity" === a || "-Infinity" === a) return k; "number" === typeof b ? (c = b, b = !1) : b = !!b; c = c || 10; if (2 > c || 36 < c) throw RangeError("radix"); var u; if (0 < (u = a.indexOf("-"))) throw Error("interior hyphen"); if (0 === u) return y(a.substring(1), b, c).neg(); u = n(w(c, 8)); for (var e = k, f = 0; f < a.length; f += 8) {
8267                var d = Math.min(8, a.length - f), g = parseInt(a.substring(f, f + d), c); 8 > d ? (d = n(w(c, d)), e = e.mul(d).add(n(g))) :
8268                (e = e.mul(u), e = e.add(n(g)))
8269            } e.unsigned = b; return e
8270        } function q(a) { return a instanceof d ? a : "number" === typeof a ? n(a) : "string" === typeof a ? y(a) : e(a.low, a.high, a.unsigned) } b.H5.$Long = d; d.__isLong__; Object.defineProperty(d.prototype, "__isLong__", { value: !0, enumerable: !1, configurable: !1 }); d.isLong = g; var B = {}, A = {}; d.fromInt = m; d.fromNumber = n; d.fromBits = e; var w = Math.pow; d.fromString = y; d.fromValue = q; var C = 4294967296 * 4294967296, E = C / 2, G = m(16777216), k = m(0); d.ZERO = k; var p = m(0, !0); d.UZERO = p; var r = m(1); d.ONE = r; var H =
8271        m(1, !0); d.UONE = H; var z = m(-1); d.NEG_ONE = z; var F = e(-1, 2147483647, !1); d.MAX_VALUE = F; var D = e(-1, -1, !0); d.MAX_UNSIGNED_VALUE = D; var l = e(0, -2147483648, !1); d.MIN_VALUE = l; b = d.prototype; b.toInt = function () { return this.unsigned ? this.low >>> 0 : this.low }; b.toNumber = function () { return this.unsigned ? 4294967296 * (this.high >>> 0) + (this.low >>> 0) : 4294967296 * this.high + (this.low >>> 0) }; b.toString = function (a) {
8272            a = a || 10; if (2 > a || 36 < a) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) {
8273                if (this.eq(l)) {
8274                    var b =
8275                    n(a), c = this.div(b), b = c.mul(b).sub(this); return c.toString(a) + b.toInt().toString(a)
8276                } return ("undefined" === typeof a || 10 === a ? "-" : "") + this.neg().toString(a)
8277            } for (var c = n(w(a, 6), this.unsigned), b = this, e = ""; ;) { var d = b.div(c), f = (b.sub(d.mul(c)).toInt() >>> 0).toString(a), b = d; if (b.isZero()) return f + e; for (; 6 > f.length;) f = "0" + f; e = "" + f + e }
8278        }; b.getHighBits = function () { return this.high }; b.getHighBitsUnsigned = function () { return this.high >>> 0 }; b.getLowBits = function () { return this.low }; b.getLowBitsUnsigned = function () {
8279            return this.low >>>
8280            0
8281        }; b.getNumBitsAbs = function () { if (this.isNegative()) return this.eq(l) ? 64 : this.neg().getNumBitsAbs(); for (var a = 0 != this.high ? this.high : this.low, b = 31; 0 < b && 0 == (a & 1 << b) ; b--); return 0 != this.high ? b + 33 : b + 1 }; b.isZero = function () { return 0 === this.high && 0 === this.low }; b.isNegative = function () { return !this.unsigned && 0 > this.high }; b.isPositive = function () { return this.unsigned || 0 <= this.high }; b.isOdd = function () { return 1 === (this.low & 1) }; b.isEven = function () { return 0 === (this.low & 1) }; b.equals = function (a) {
8282            g(a) || (a = q(a)); return this.unsigned !==
8283            a.unsigned && 1 === this.high >>> 31 && 1 === a.high >>> 31 ? !1 : this.high === a.high && this.low === a.low
8284        }; b.eq = b.equals; b.notEquals = function (a) { return !this.eq(a) }; b.neq = b.notEquals; b.lessThan = function (a) { return 0 > this.comp(a) }; b.lt = b.lessThan; b.lessThanOrEqual = function (a) { return 0 >= this.comp(a) }; b.lte = b.lessThanOrEqual; b.greaterThan = function (a) { return 0 < this.comp(a) }; b.gt = b.greaterThan; b.greaterThanOrEqual = function (a) { return 0 <= this.comp(a) }; b.gte = b.greaterThanOrEqual; b.compare = function (a) {
8285            g(a) || (a = q(a)); if (this.eq(a)) return 0;
8286            var b = this.isNegative(), c = a.isNegative(); return b && !c ? -1 : !b && c ? 1 : this.unsigned ? a.high >>> 0 > this.high >>> 0 || a.high === this.high && a.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(a).isNegative() ? -1 : 1
8287        }; b.comp = b.compare; b.negate = function () { return !this.unsigned && this.eq(l) ? l : this.not().add(r) }; b.neg = b.negate; b.add = function (a) {
8288            g(a) || (a = q(a)); var b = this.high >>> 16, c = this.high & 65535, d = this.low >>> 16, l = a.high >>> 16, f = a.high & 65535, n = a.low >>> 16, k; k = 0 + ((this.low & 65535) + (a.low & 65535)); a = 0 + (k >>> 16); a += d + n; d = 0 + (a >>> 16); d += c + f; c =
8289            0 + (d >>> 16); c = c + (b + l) & 65535; return e((a & 65535) << 16 | k & 65535, c << 16 | d & 65535, this.unsigned)
8290        }; b.subtract = function (a) { g(a) || (a = q(a)); return this.add(a.neg()) }; b.sub = b.subtract; b.multiply = function (a) {
8291            if (this.isZero()) return k; g(a) || (a = q(a)); if (a.isZero()) return k; if (this.eq(l)) return a.isOdd() ? l : k; if (a.eq(l)) return this.isOdd() ? l : k; if (this.isNegative()) return a.isNegative() ? this.neg().mul(a.neg()) : this.neg().mul(a).neg(); if (a.isNegative()) return this.mul(a.neg()).neg(); if (this.lt(G) && a.lt(G)) return n(this.toNumber() *
8292            a.toNumber(), this.unsigned); var b = this.high >>> 16, c = this.high & 65535, d = this.low >>> 16, x = this.low & 65535, f = a.high >>> 16, m = a.high & 65535, p = a.low >>> 16; a = a.low & 65535; var v, h, t, r; r = 0 + x * a; t = 0 + (r >>> 16); t += d * a; h = 0 + (t >>> 16); t = (t & 65535) + x * p; h += t >>> 16; t &= 65535; h += c * a; v = 0 + (h >>> 16); h = (h & 65535) + d * p; v += h >>> 16; h &= 65535; h += x * m; v += h >>> 16; h &= 65535; v = v + (b * a + c * p + d * m + x * f) & 65535; return e(t << 16 | r & 65535, v << 16 | h, this.unsigned)
8293        }; b.mul = b.multiply; b.divide = function (a) {
8294            g(a) || (a = q(a)); if (a.isZero()) throw Error("division by zero"); if (this.isZero()) return this.unsigned ?
8295                    p : k; var b, c, d; if (this.unsigned) a.unsigned || (a = a.toUnsigned()); else { if (this.eq(l)) { if (a.eq(r) || a.eq(z)) return l; if (a.eq(l)) return r; b = this.shr(1).div(a).shl(1); if (b.eq(k)) return a.isNegative() ? r : z; c = this.sub(a.mul(b));
8295 return d = b.add(c.div(a)) } if (a.eq(l)) return this.unsigned ? p : k; if (this.isNegative()) return a.isNegative() ? this.neg().div(a.neg()) : this.neg().div(a).neg(); if (a.isNegative()) return this.div(a.neg()).neg() } if (this.unsigned) { if (a.gt(this)) return p; if (a.gt(this.shru(1))) return H; d = p } else d =
8296                    k; for (c = this; c.gte(a) ;) { b = Math.max(1, Math.floor(c.toNumber() / a.toNumber())); for (var e = Math.ceil(Math.log(b) / Math.LN2), e = 48 >= e ? 1 : w(2, e - 48), f = n(b), m = f.mul(a) ; m.isNegative() || m.gt(c) ;) b -= e, f = n(b, this.unsigned), m = f.mul(a); f.isZero() && (f = r); d = d.add(f); c = c.sub(m) } return d
8297        }; b.div = b.divide; b.modulo = function (a) { g(a) || (a = q(a)); return this.sub(this.div(a).mul(a)) }; b.mod = b.modulo; b.not = function () { return e(~this.low, ~this.high, this.unsigned) }; b.and = function (a) {
8298            g(a) || (a = q(a)); return e(this.low & a.low, this.high &
8299            a.high, this.unsigned)
8300        }; b.or = function (a) { g(a) || (a = q(a)); return e(this.low | a.low, this.high | a.high, this.unsigned) }; b.xor = function (a) { g(a) || (a = q(a)); return e(this.low ^ a.low, this.high ^ a.high, this.unsigned) }; b.shiftLeft = function (a) { g(a) && (a = a.toInt()); return 0 === (a &= 63) ? this : 32 > a ? e(this.low << a, this.high << a | this.low >>> 32 - a, this.unsigned) : e(0, this.low << a - 32, this.unsigned) }; b.shl = b.shiftLeft; b.shiftRight = function (a) {
8301            g(a) && (a = a.toInt()); return 0 === (a &= 63) ? this : 32 > a ? e(this.low >>> a | this.high << 32 - a, this.high >>
8302            a, this.unsigned) : e(this.high >> a - 32, 0 <= this.high ? 0 : -1, this.unsigned)
8303        }; b.shr = b.shiftRight; b.shiftRightUnsigned = function (a) { g(a) && (a = a.toInt()); a &= 63; if (0 === a) return this; var b = this.high; return 32 > a ? e(this.low >>> a | b << 32 - a, b >>> a, this.unsigned) : 32 === a ? e(b, 0, this.unsigned) : e(b >>> a - 32, 0, this.unsigned) }; b.shru = b.shiftRightUnsigned; b.toSigned = function () { return this.unsigned ? e(this.low, this.high, !1) : this }; b.toUnsigned = function () { return this.unsigned ? this : e(this.low, this.high, !0) }
8304    })(H5.global);
8305
8306    System.Int64 = function (l) {
8307        if (this.constructor !== System.Int64) {
8308            return new System.Int64(l);
8309        }
8310
8311        if (!H5.hasValue(l)) {
8312            l = 0;
8313        }
8314
8315        this.T = System.Int64;
8316        this.unsigned = false;
8317        this.value = System.Int64.getValue(l);
8318    }
8319
8320    System.Int64.$number = true;
8321    System.Int64.TWO_PWR_16_DBL = 1 << 16;
8322    System.Int64.TWO_PWR_32_DBL = System.Int64.TWO_PWR_16_DBL * System.Int64.TWO_PWR_16_DBL;
8323    System.Int64.TWO_PWR_64_DBL = System.Int64.TWO_PWR_32_DBL * System.Int64.TWO_PWR_32_DBL;
8324    System.Int64.TWO_PWR_63_DBL = System.Int64.TWO_PWR_64_DBL / 2;
8325
8326    System.Int64.$$name = "System.Int64";
8327    System.Int64.prototype.$$name = "System.Int64";
8328    System.Int64.$kind = "struct";
8329    System.Int64.prototype.$kind = "struct";
8330
8331    System.Int64.$$inherits = [];
8332    H5.Class.addExtend(System.Int64, [System.IComparable, System.IFormattable, System.IComparable$1(System.Int64), System.IEquatable$1(System.Int64)]);
8333
8334    System.Int64.$is = function (instance) {
8335        return instance instanceof System.Int64;
8336    };
8337
8338    System.Int64.is64Bit = function (instance) {
8339        return instance instanceof System.Int64 || instance instanceof System.UInt64;
8340    };
8341
8342    System.Int64.is64BitType = function (type) {
8343        return type === System.Int64 || type === System.UInt64;
8344    };
8345
8346    System.Int64.getDefaultValue = function () {
8347        return System.Int64.Zero;
8348    };
8349
8350    System.Int64.getValue = function (l) {
8351        if (!H5.hasValue(l)) {
8352            return null;
8353        }
8354
8355        if (l instanceof H5.$Long) {
8356            return l;
8357        }
8358
8359        if (l instanceof System.Int64) {
8360            return l.value;
8361        }
8362
8363        if (l instanceof System.UInt64) {
8364            return l.value.toSigned();
8365        }
8366
8367        if (H5.isArray(l)) {
8368            return new H5.$Long(l[0], l[1]);
8369        }
8370
8371        if (H5.isString(l)) {
8372            return H5.$Long.fromString(l);
8373        }
8374
8375        if (H5.isNumber(l)) {
8376            if (l + 1 >= System.Int64.TWO_PWR_63_DBL) {
8377                return (new System.UInt64(l)).value.toSigned();
8378            }
8379            return H5.$Long.fromNumber(l);
8380        }
8381
8382        if (l instanceof System.Decimal) {
8383            return H5.$Long.fromString(l.toString());
8384        }
8385
8386        return H5.$Long.fromValue(l);
8387    };
8388
8389    System.Int64.create = function (l) {
8390        if (!H5.hasValue(l)) {
8391            return null;
8392        }
8393
8394        if (l instanceof System.Int64) {
8395            return l;
8396        }
8397
8398        return new System.Int64(l);
8399    };
8400
8401    System.Int64.lift = function (l) {
8402        if (!H5.hasValue(l)) {
8403            return null;
8404        }
8405        return System.Int64.create(l);
8406    };
8407
8408    System.Int64.toNumber = function (value) {
8409        if (!value) {
8410            return null;
8411        }
8412
8413        return value.toNumber();
8414    };
8415
8416    System.Int64.prototype.toNumberDivided = function (divisor) {
8417        var integral = this.div(divisor),
8418            remainder = this.mod(divisor),
8419            scaledRemainder = remainder.toNumber() / divisor;
8420
8421        return integral.toNumber() + scaledRemainder;
8422    };
8423
8424    System.Int64.prototype.toJSON = function () {
8425        return this.gt(H5.Int.MAX_SAFE_INTEGER) || this.lt(H5.Int.MIN_SAFE_INTEGER) ? this.toString() : this.toNumber();
8426    };
8427
8428    System.Int64.prototype.toString = function (format, provider) {
8429        if (!format && !provider) {
8430            return this.value.toString();
8431        }
8432
8433        if (H5.isNumber(format) && !provider) {
8434            return this.value.toString(format);
8435        }
8436
8437        return H5.Int.format(this, format, provider, System.Int64, System.Int64.clipu64);
8438    };
8439
8440    System.Int64.prototype.format = function (format, provider) {
8441        return H5.Int.format(this, format, provider, System.Int64, System.Int64.clipu64);
8442    };
8443
8444    System.Int64.prototype.isNegative = function () {
8445        return this.value.isNegative();
8446    };
8447
8448    System.Int64.prototype.abs = function () {
8449        if (this.T === System.Int64 && this.eq(System.Int64.MinValue)) {
8450            throw new System.OverflowException();
8451        }
8452        return new this.T(this.value.isNegative() ? this.value.neg() : this.value);
8453    };
8454
8455    System.Int64.prototype.compareTo = function (l) {
8456        return this.value.compare(this.T.getValue(l));
8457    };
8458
8459    System.Int64.prototype.add = function (l, overflow) {
8460        var addl = this.T.getValue(l),
8461            r = new this.T(this.value.add(addl));
8462
8463        if (overflow) {
8464            var neg1 = this.value.isNegative(),
8465                neg2 = addl.isNegative(),
8466                rneg = r.value.isNegative();
8467
8468            if ((neg1 && neg2 && !rneg) ||
8469                (!neg1 && !neg2 && rneg) ||
8470                (this.T === System.UInt64 && r.lt(System.UInt64.max(this, addl)))) {
8471                throw new System.OverflowException();
8472            }
8473        }
8474
8475        return r;
8476    };
8477
8478    System.Int64.prototype.sub = function (l, overflow) {
8479        var subl = this.T.getValue(l),
8480            r = new this.T(this.value.sub(subl));
8481
8482        if (overflow) {
8483            var neg1 = this.value.isNegative(),
8484                neg2 = subl.isNegative(),
8485                rneg = r.value.isNegative();
8486
8487            if ((neg1 && !neg2 && !rneg) ||
8488                (!neg1 && neg2 && rneg) ||
8489                (this.T === System.UInt64 && this.value.lt(subl))) {
8490                throw new System.OverflowException();
8491            }
8492        }
8493
8494        return r;
8495    };
8496
8497    System.Int64.prototype.isZero = function () {
8498        return this.value.isZero();
8499    };
8500
8501    System.Int64.prototype.mul = function (l, overflow) {
8502        var arg = this.T.getValue(l),
8503            r = new this.T(this.value.mul(arg));
8504
8505        if (overflow) {
8506            var s1 = this.sign(),
8507                s2 = arg.isZero() ? 0 : (arg.isNegative() ? -1 : 1),
8508                rs = r.sign();
8509
8510            if (this.T === System.Int64) {
8511                if (this.eq(System.Int64.MinValue) || this.eq(System.Int64.MaxValue)) {
8512                    if (arg.neq(1) && arg.neq(0)) {
8513                        throw new System.OverflowException();
8514                    }
8515
8516                    return r;
8517                }
8518
8519                if (arg.eq(H5.$Long.MIN_VALUE) || arg.eq(H5.$Long.MAX_VALUE)) {
8520                    if (this.neq(1) && this.neq(0)) {
8521                        throw new System.OverflowException();
8522                    }
8523
8524                    return r;
8525                }
8526
8527                if ((s1 === -1 && s2 === -1 && rs !== 1) ||
8528                    (s1 === 1 && s2 === 1 && rs !== 1) ||
8529                    (s1 === -1 && s2 === 1 && rs !== -1) ||
8530                    (s1 === 1 && s2 === -1 && rs !== -1)) {
8531                    throw new System.OverflowException();
8532                }
8533
8534                var r_abs = r.abs();
8535
8536                if (r_abs.lt(this.abs()) || r_abs.lt(System.Int64(arg).abs())) {
8537                    throw new System.OverflowException();
8538                }
8539            } else {
8540                if (this.eq(System.UInt64.MaxValue)) {
8541                    if (arg.neq(1) && arg.neq(0)) {
8542                        throw new System.OverflowException();
8543                    }
8544
8545                    return r;
8546                }
8547
8548                if (arg.eq(H5.$Long.MAX_UNSIGNED_VALUE)) {
8549                    if (this.neq(1) && this.neq(0)) {
8550                        throw new System.OverflowException();
8551                    }
8552
8553                    return r;
8554                }
8555
8556                var r_abs = r.abs();
8557
8558                if (r_abs.lt(this.abs()) || r_abs.lt(System.Int64(arg).abs())) {
8559                    throw new System.OverflowException();
8560                }
8561            }
8562        }
8563
8564        return r;
8565    };
8566
8567    System.Int64.prototype.div = function (l) {
8568        return new this.T(this.value.div(this.T.getValue(l)));
8569    };
8570
8571    System.Int64.prototype.mod = function (l) {
8572        return new this.T(this.value.mod(this.T.getValue(l)));
8573    };
8574
8575    System.Int64.prototype.neg = function (overflow) {
8576        if (overflow && this.T === System.Int64 && this.eq(System.Int64.MinValue)) {
8577            throw new System.OverflowException();
8578        }
8579        return new this.T(this.value.neg());
8580    };
8581
8582    System.Int64.prototype.inc = function (overflow) {
8583        return this.add(1, overflow);
8584    };
8585
8586    System.Int64.prototype.dec = function (overflow) {
8587        return this.sub(1, overflow);
8588    };
8589
8590    System.Int64.prototype.sign = function () {
8591        return this.value.isZero() ? 0 : (this.value.isNegative() ? -1 : 1);
8592    };
8593
8594    System.Int64.prototype.clone = function () {
8595        return new this.T(this);
8596    };
8597
8598    System.Int64.prototype.ne = function (l) {
8599        return this.value.neq(this.T.getValue(l));
8600    };
8601
8602    System.Int64.prototype.neq = function (l) {
8603        return this.value.neq(this.T.getValue(l));
8604    };
8605
8606    System.Int64.prototype.eq = function (l) {
8607        return this.value.eq(this.T.getValue(l));
8608    };
8609
8610    System.Int64.prototype.lt = function (l) {
8611        return this.value.lt(this.T.getValue(l));
8612    };
8613
8614    System.Int64.prototype.lte = function (l) {
8615        return this.value.lte(this.T.getValue(l));
8616    };
8617
8618    System.Int64.prototype.gt = function (l) {
8619        return this.value.gt(this.T.getValue(l));
8620    };
8621
8622    System.Int64.prototype.gte = function (l) {
8623        return this.value.gte(this.T.getValue(l));
8624    };
8625
8626    System.Int64.prototype.equals = function (l) {
8627        return this.value.eq(this.T.getValue(l));
8628    };
8629
8630    System.Int64.prototype.equalsT = function (l) {
8631        return this.equals(l);
8632    };
8633
8634    System.Int64.prototype.getHashCode = function () {
8635        var n = (this.sign() * 397 + this.value.high) | 0;
8636        n = (n * 397 + this.value.low) | 0;
8637
8638        return n;
8639    };
8640
8641    System.Int64.prototype.toNumber = function () {
8642        return this.value.toNumber();
8643    };
8644
8645    System.Int64.parse = function (str) {
8646        if (str == null) {
8647            throw new System.ArgumentNullException.$ctor1("str");
8648        }
8649
8650        if (!/^[+-]?[0-9]+$/.test(str)) {
8651            throw new System.FormatException.$ctor1("Input string was not in a correct format.");
8652        }
8653
8654        var result = new System.Int64(str);
8655
8656        if (System.String.trimStartZeros(str) !== result.toString()) {
8657            throw new System.OverflowException();
8658        }
8659
8660        return result;
8661    };
8662
8663    System.Int64.tryParse = function (str, v) {
8664        try {
8665            if (str == null || !/^[+-]?[0-9]+$/.test(str)) {
8666                v.v = System.Int64(H5.$Long.ZERO);
8667                return false;
8668            }
8669
8670            v.v = new System.Int64(str);
8671
8672            if (System.String.trimStartZeros(str) !== v.v.toString()) {
8673                v.v = System.Int64(H5.$Long.ZERO);
8674                return false;
8675            }
8676
8677            return true;
8678        } catch (e) {
8679            v.v = System.Int64(H5.$Long.ZERO);
8680            return false;
8681        }
8682    };
8683
8684    System.Int64.divRem = function (a, b, result) {
8685        a = System.Int64(a);
8686        b = System.Int64(b);
8687        var remainder = a.mod(b);
8688        result.v = remainder;
8689        return a.sub(remainder).div(b);
8690    };
8691
8692    System.Int64.min = function () {
8693        var values = [],
8694            min, i, len;
8695
8696        for (i = 0, len = arguments.length; i < len; i++) {
8697            values.push(System.Int64.getValue(arguments[i]));
8698        }
8699
8700        i = 0;
8701        min = values[0];
8702        for (; ++i < values.length;) {
8703            if (values[i].lt(min)) {
8704                min = values[i];
8705            }
8706        }
8707
8708        return new System.Int64(min);
8709    };
8710
8711    System.Int64.max = function () {
8712        var values = [],
8713            max, i, len;
8714
8715        for (i = 0, len = arguments.length; i < len; i++) {
8716            values.push(System.Int64.getValue(arguments[i]));
8717        }
8718
8719        i = 0;
8720        max = values[0];
8721        for (; ++i < values.length;) {
8722            if (values[i].gt(max)) {
8723                max = values[i];
8724            }
8725        }
8726
8727        return new System.Int64(max);
8728    };
8729
8730    System.Int64.prototype.and = function (l) {
8731        return new this.T(this.value.and(this.T.getValue(l)));
8732    };
8733
8734    System.Int64.prototype.not = function () {
8735        return new this.T(this.value.not());
8736    };
8737
8738    System.Int64.prototype.or = function (l) {
8739        return new this.T(this.value.or(this.T.getValue(l)));
8740    };
8741
8742    System.Int64.prototype.shl = function (l) {
8743        return new this.T(this.value.shl(l));
8744    };
8745
8746    System.Int64.prototype.shr = function (l) {
8747        return new this.T(this.value.shr(l));
8748    };
8749
8750    System.Int64.prototype.shru = function (l) {
8751        return new this.T(this.value.shru(l));
8752    };
8753
8754    System.Int64.prototype.xor = function (l) {
8755        return new this.T(this.value.xor(this.T.getValue(l)));
8756    };
8757
8758    System.Int64.check = function (v, tp) {
8759        if (H5.Int.isInfinite(v)) {
8760            if (tp === System.Int64 || tp === System.UInt64) {
8761                return tp.MinValue;
8762            }
8763            return tp.min;
8764        }
8765
8766        if (!v) {
8767            return null;
8768        }
8769
8770        var str, r;
8771        if (tp === System.Int64) {
8772            if (v instanceof System.Int64) {
8773                return v;
8774            }
8775
8776            str = v.value.toString();
8777            r = new System.Int64(str);
8778
8779            if (str !== r.value.toString()) {
8780                throw new System.OverflowException();
8781            }
8782
8783            return r;
8784        }
8785
8786        if (tp === System.UInt64) {
8787            if (v instanceof System.UInt64) {
8788                return v;
8789            }
8790
8791            if (v.value.isNegative()) {
8792                throw new System.OverflowException();
8793            }
8794            str = v.value.toString();
8795            r = new System.UInt64(str);
8796
8797            if (str !== r.value.toString()) {
8798                throw new System.OverflowException();
8799            }
8800
8801            return r;
8802        }
8803
8804        return H5.Int.check(v.toNumber(), tp);
8805    };
8806
8807    System.Int64.clip8 = function (x) {
8808        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8809        return x ? H5.Int.sxb(x.value.low & 0xff) : (H5.Int.isInfinite(x) ? System.SByte.min : null);
8810    };
8811
8812    System.Int64.clipu8 = function (x) {
8813        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8814        return x ? x.value.low & 0xff : (H5.Int.isInfinite(x) ? System.Byte.min : null);
8815    };
8816
8817    System.Int64.clip16 = function (x) {
8818        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8819        return x ? H5.Int.sxs(x.value.low & 0xffff) : (H5.Int.isInfinite(x) ? System.Int16.min : null);
8820    };
8821
8822    System.Int64.clipu16 = function (x) {
8823        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8824        return x ? x.value.low & 0xffff : (H5.Int.isInfinite(x) ? System.UInt16.min : null);
8825    };
8826
8827    System.Int64.clip32 = function (x) {
8828        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8829        return x ? x.value.low | 0 : (H5.Int.isInfinite(x) ? System.Int32.min : null);
8830    };
8831
8832    System.Int64.clipu32 = function (x) {
8833        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8834        return x ? x.value.low >>> 0 : (H5.Int.isInfinite(x) ? System.UInt32.min : null);
8835    };
8836
8837    System.Int64.clip64 = function (x) {
8838        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.UInt64(x);
8839        return x ? new System.Int64(x.value.toSigned()) : (H5.Int.isInfinite(x) ? System.Int64.MinValue : null);
8840    };
8841
8842    System.Int64.clipu64 = function (x) {
8843        x = (x == null || System.Int64.is64Bit(x)) ? x : new System.Int64(x);
8844        return x ? new System.UInt64(x.value.toUnsigned()) : (H5.Int.isInfinite(x) ? System.UInt64.MinValue : null);
8845    };
8846
8847    System.Int64.Zero = System.Int64(H5.$Long.ZERO);
8848    System.Int64.MinValue = System.Int64(H5.$Long.MIN_VALUE);
8849    System.Int64.MaxValue = System.Int64(H5.$Long.MAX_VALUE);
8850    System.Int64.precision = 19;
8851
8852    /* ULONG */
8853
8854    System.UInt64 = function (l) {
8855        if (this.constructor !== System.UInt64) {
8856            return new System.UInt64(l);
8857        }
8858
8859        if (!H5.hasValue(l)) {
8860            l = 0;
8861        }
8862
8863        this.T = System.UInt64;
8864        this.unsigned = true;
8865        this.value = System.UInt64.getValue(l, true);
8866    }
8867
8868    System.UInt64.$number = true;
8869    System.UInt64.$$name = "System.UInt64";
8870    System.UInt64.prototype.$$name = "System.UInt64";
8871    System.UInt64.$kind = "struct";
8872    System.UInt64.prototype.$kind = "struct";
8873    System.UInt64.$$inherits = [];
8874    H5.Class.addExtend(System.UInt64, [System.IComparable, System.IFormattable, System.IComparable$1(System.UInt64), System.IEquatable$1(System.UInt64)]);
8875
8876    System.UInt64.$is = function (instance) {
8877        return instance instanceof System.UInt64;
8878    };
8879
8880    System.UInt64.getDefaultValue = function () {
8881        return System.UInt64.Zero;
8882    };
8883
8884    System.UInt64.getValue = function (l) {
8885        if (!H5.hasValue(l)) {
8886            return null;
8887        }
8888
8889        if (l instanceof H5.$Long) {
8890            return l;
8891        }
8892
8893        if (l instanceof System.UInt64) {
8894            return l.value;
8895        }
8896
8897        if (l instanceof System.Int64) {
8898            return l.value.toUnsigned();
8899        }
8900
8901        if (H5.isArray(l)) {
8902            return new H5.$Long(l[0], l[1], true);
8903        }
8904
8905        if (H5.isString(l)) {
8906            return H5.$Long.fromString(l, true);
8907        }
8908
8909        if (H5.isNumber(l)) {
8910            if (l < 0) {
8911                return (new System.Int64(l)).value.toUnsigned();
8912            }
8913
8914            return H5.$Long.fromNumber(l, true);
8915        }
8916
8917        if (l instanceof System.Decimal) {
8918            return H5.$Long.fromString(l.toString(), true);
8919        }
8920
8921        return H5.$Long.fromValue(l);
8922    };
8923
8924    System.UInt64.create = function (l) {
8925        if (!H5.hasValue(l)) {
8926            return null;
8927        }
8928
8929        if (l instanceof System.UInt64) {
8930            return l;
8931        }
8932
8933        return new System.UInt64(l);
8934    };
8935
8936    System.UInt64.lift = function (l) {
8937        if (!H5.hasValue(l)) {
8938            return null;
8939        }
8940        return System.UInt64.create(l);
8941    };
8942
8943    System.UInt64.prototype.toString = System.Int64.prototype.toString;
8944    System.UInt64.prototype.format = System.Int64.prototype.format;
8945    System.UInt64.prototype.isNegative = System.Int64.prototype.isNegative;
8946    System.UInt64.prototype.abs = System.Int64.prototype.abs;
8947    System.UInt64.prototype.compareTo = System.Int64.prototype.compareTo;
8948    System.UInt64.prototype.add = System.Int64.prototype.add;
8949    System.UInt64.prototype.sub = System.Int64.prototype.sub;
8950    System.UInt64.prototype.isZero = System.Int64.prototype.isZero;
8951    System.UInt64.prototype.mul = System.Int64.prototype.mul;
8952    System.UInt64.prototype.div = System.Int64.prototype.div;
8953    System.UInt64.prototype.toNumberDivided = System.Int64.prototype.toNumberDivided;
8954    System.UInt64.prototype.mod = System.Int64.prototype.mod;
8955    System.UInt64.prototype.neg = System.Int64.prototype.neg;
8956    System.UInt64.prototype.inc = System.Int64.prototype.inc;
8957    System.UInt64.prototype.dec = System.Int64.prototype.dec;
8958    System.UInt64.prototype.sign = System.Int64.prototype.sign;
8959    System.UInt64.prototype.clone = System.Int64.prototype.clone;
8960    System.UInt64.prototype.ne = System.Int64.prototype.ne;
8961    System.UInt64.prototype.neq = System.Int64.prototype.neq;
8962    System.UInt64.prototype.eq = System.Int64.prototype.eq;
8963    System.UInt64.prototype.lt = System.Int64.prototype.lt;
8964    System.UInt64.prototype.lte = System.Int64.prototype.lte;
8965    System.UInt64.prototype.gt = System.Int64.prototype.gt;
8966    System.UInt64.prototype.gte = System.Int64.prototype.gte;
8967    System.UInt64.prototype.equals = System.Int64.prototype.equals;
8968    System.UInt64.prototype.equalsT = System.Int64.prototype.equalsT;
8969    System.UInt64.prototype.getHashCode = System.Int64.prototype.getHashCode;
8970    System.UInt64.prototype.toNumber = System.Int64.prototype.toNumber;
8971
8972    System.UInt64.parse = function (str) {
8973        if (str == null) {
8974            throw new System.ArgumentNullException.$ctor1("str");
8975        }
8976
8977        if (!/^[+-]?[0-9]+$/.test(str)) {
8978            throw new System.FormatException.$ctor1("Input string was not in a correct format.");
8979        }
8980
8981        var result = new System.UInt64(str);
8982
8983        if (result.value.isNegative()) {
8984            throw new System.OverflowException();
8985        }
8986
8987        if (System.String.trimStartZeros(str) !== result.toString()) {
8988            throw new System.OverflowException();
8989        }
8990
8991        return result;
8992    };
8993
8994    System.UInt64.tryParse = function (str, v) {
8995        try {
8996            if (str == null || !/^[+-]?[0-9]+$/.test(str)) {
8997                v.v = System.UInt64(H5.$Long.UZERO);
8998                return false;
8999            }
9000
9001            v.v = new System.UInt64(str);
9002
9003            if (v.v.isNegative()) {
9004                v.v = System.UInt64(H5.$Long.UZERO);
9005                return false;
9006            }
9007
9008            if (System.String.trimStartZeros(str) !== v.v.toString()) {
9009                v.v = System.UInt64(H5.$Long.UZERO);
9010                return false;
9011            }
9012
9013            return true;
9014        } catch (e) {
9015            v.v = System.UInt64(H5.$Long.UZERO);
9016            return false;
9017        }
9018    };
9019
9020    System.UInt64.min = function () {
9021        var values = [],
9022            min, i, len;
9023
9024        for (i = 0, len = arguments.length; i < len; i++) {
9025            values.push(System.UInt64.getValue(arguments[i]));
9026        }
9027
9028        i = 0;
9029        min = values[0];
9030        for (; ++i < values.length;) {
9031            if (values[i].lt(min)) {
9032                min = values[i];
9033            }
9034        }
9035
9036        return new System.UInt64(min);
9037    };
9038
9039    System.UInt64.max = function () {
9040        var values = [],
9041            max, i, len;
9042
9043        for (i = 0, len = arguments.length; i < len; i++) {
9044            values.push(System.UInt64.getValue(arguments[i]));
9045        }
9046
9047        i = 0;
9048        max = values[0];
9049        for (; ++i < values.length;) {
9050            if (values[i].gt(max)) {
9051                max = values[i];
9052            }
9053        }
9054
9055        return new System.UInt64(max);
9056    };
9057
9058    System.UInt64.divRem = function (a, b, result) {
9059        a = System.UInt64(a);
9060        b = System.UInt64(b);
9061        var remainder = a.mod(b);
9062        result.v = remainder;
9063        return a.sub(remainder).div(b);
9064    };
9065
9066    System.UInt64.prototype.toJSON = function () {
9067        return this.gt(H5.Int.MAX_SAFE_INTEGER) ? this.toString() : this.toNumber();
9068    };
9069
9070    System.UInt64.prototype.and = System.Int64.prototype.and;
9071    System.UInt64.prototype.not = System.Int64.prototype.not;
9072    System.UInt64.prototype.or = System.Int64.prototype.or;
9073    System.UInt64.prototype.shl = System.Int64.prototype.shl;
9074    System.UInt64.prototype.shr = System.Int64.prototype.shr;
9075    System.UInt64.prototype.shru = System.Int64.prototype.shru;
9076    System.UInt64.prototype.xor = System.Int64.prototype.xor;
9077
9078    System.UInt64.Zero = System.UInt64(H5.$Long.UZERO);
9079    System.UInt64.MinValue = System.UInt64.Zero;
9080    System.UInt64.MaxValue = System.UInt64(H5.$Long.MAX_UNSIGNED_VALUE);
9081    System.UInt64.precision = 20;
9082
9083    // @source Decimal.js
9084
9085    /* decimal.js v7.1.0 https://github.com/MikeMcl/decimal.js/LICENCE */
9086    !function (n) { "use strict"; function e(n) { var e, i, t, r = n.length - 1, s = "", o = n[0]; if (r > 0) { for (s += o, e = 1; r > e; e++) t = n[e] + "", i = Rn - t.length, i && (s += l(i)), s += t; o = n[e], t = o + "", i = Rn - t.length, i && (s += l(i)) } else if (0 === o) return "0"; for (; o % 10 === 0;) o /= 10; return s + o } function i(n, e, i) { if (n !== ~~n || e > n || n > i) throw Error(En + n) } function t(n, e, i, t) { var r, s, o, u; for (s = n[0]; s >= 10; s /= 10)--e;
9086 return --e < 0 ? (e += Rn, r = 0) : (r = Math.ceil((e + 1) / Rn), e %= Rn), s = On(10, Rn - e), u = n[r] % s | 0, null == t ? 3 > e ? (0 == e ? u = u / 100 | 0 : 1 == e && (u = u / 10 | 0), o = 4 > i && 99999 == u || i > 3 && 49999 == u || 5e4 == u || 0 == u) : o = (4 > i && u + 1 == s || i > 3 && u + 1 == s / 2) && (n[r + 1] / s / 100 | 0) == On(10, e - 2) - 1 || (u == s / 2 || 0 == u) && 0 == (n[r + 1] / s / 100 | 0) : 4 > e ? (0 == e ? u = u / 1e3 | 0 : 1 == e ? u = u / 100 | 0 : 2 == e && (u = u / 10 | 0), o = (t || 4 > i) && 9999 == u || !t && i > 3 && 4999 == u) : o = ((t || 4 > i) && u + 1 == s || !t && i > 3 && u + 1 == s / 2) && (n[r + 1] / s / 1e3 | 0) == On(10, e - 3) - 1, o } function r(n, e, i) { for (var t, r, s = [0], o = 0, u = n.length; u > o;) { for (r = s.length; r--;) s[r] *= e; for (s[0] += wn.indexOf(n.charAt(o++)), t = 0; t < s.length; t++) s[t] > i - 1 && (void 0 === s[t + 1] && (s[t + 1] = 0), s[t + 1] += s[t] / i | 0, s[t] %= i) } return s.reverse() } function s(n, e) { var i, t, r = e.d.length; 32 > r ? (i = Math.ceil(r / 3), t = Math.pow(4, -i).toString()) : (i = 16, t = "2.3283064365386962890625e-10"), n.precision += i, e = E(n, 1, e.times(t), new n(1)); for (var s = i; s--;) { var o = e.times(e); e = o.times(o).minus(o).times(8).plus(1) } return n.precision -= i, e } function o(n, e, i, t) { var r, s, o, u, c, f, a, h, l, d = n.constructor; n: if (null != e) { if (h = n.d, !h) return n; for (r = 1, u = h[0]; u >= 10; u /= 10) r++; if (s = e - r, 0 > s) s += Rn, o = e, a = h[l = 0], c = a / On(10, r - o - 1) % 10 | 0; else if (l = Math.ceil((s + 1) / Rn), u = h.length, l >= u) { if (!t) break n; for (; u++ <= l;) h.push(0); a = c = 0, r = 1, s %= Rn, o = s - Rn + 1 } else { for (a = u = h[l], r = 1; u >= 10; u /= 10) r++; s %= Rn, o = s - Rn + r, c = 0 > o ? 0 : a / On(10, r - o - 1) % 10 | 0 } if (t = t || 0 > e || void 0 !== h[l + 1] || (0 > o ? a : a % On(10, r - o - 1)), f = 4 > i ? (c || t) && (0 == i || i == (n.s < 0 ? 3 : 2)) : c > 5 || 5 == c && (4 == i || t || 6 == i && (s > 0 ? o > 0 ? a / On(10, r - o) : 0 : h[l - 1]) % 10 & 1 || i == (n.s < 0 ? 8 : 7)), 1 > e || !h[0]) return h.length = 0, f ? (e -= n.e + 1, h[0] = On(10, (Rn - e % Rn) % Rn), n.e = -e || 0) : h[0] = n.e = 0, n; if (0 == s ? (h.length = l, u = 1, l--) : (h.length = l + 1, u = On(10, Rn - s), h[l] = o > 0 ? (a / On(10, r - o) % On(10, o) | 0) * u : 0), f) for (; ;) { if (0 == l) { for (s = 1, o = h[0]; o >= 10; o /= 10) s++; for (o = h[0] += u, u = 1; o >= 10; o /= 10) u++; s != u && (n.e++, h[0] == Pn && (h[0] = 1)); break } if (h[l] += u, h[l] != Pn) break; h[l--] = 0, u = 1 } for (s = h.length; 0 === h[--s];) h.pop() } return bn && (n.e > d.maxE ? (n.d = null, n.e = NaN) : n.e < d.minE && (n.e = 0, n.d = [0])), n } function u(n, i, t) { if (!n.isFinite()) return v(n); var r, s = n.e, o = e(n.d), u = o.length; return i ? (t && (r = t - u) > 0 ? o = o.charAt(0) + "." + o.slice(1) + l(r) : u > 1 && (o = o.charAt(0) + "." + o.slice(1)), o = o + (n.e < 0 ? "e" : "e+") + n.e) : 0 > s ? (o = "0." + l(-s - 1) + o, t && (r = t - u) > 0 && (o += l(r))) : s >= u ? (o += l(s + 1 - u), t && (r = t - s - 1) > 0 && (o = o + "." + l(r))) : ((r = s + 1) < u && (o = o.slice(0, r) + "." + o.slice(r)), t && (r = t - u) > 0 && (s + 1 === u && (o += "."), o += l(r))), o } function c(n, e) { for (var i = 1, t = n[0]; t >= 10; t /= 10) i++; return i + e * Rn - 1 } function f(n, e, i) { if (e > Un) throw bn = !0, i && (n.precision = i), Error(Mn); return o(new n(mn), e, 1, !0) } function a(n, e, i) { if (e > _n) throw Error(Mn); return o(new n(vn), e, i, !0) } function h(n) { var e = n.length - 1, i = e * Rn + 1; if (e = n[e]) { for (; e % 10 == 0; e /= 10) i--; for (e = n[0]; e >= 10; e /= 10) i++ } return i } function l(n) { for (var e = ""; n--;) e += "0"; return e } function d(n, e, i, t) { var r, s = new n(1), o = Math.ceil(t / Rn + 4); for (bn = !1; ;) { if (i % 2 && (s = s.times(e), q(s.d, o) && (r = !0)), i = qn(i / 2), 0 === i) { i = s.d.length - 1, r && 0 === s.d[i] && ++s.d[i]; break } e = e.times(e), q(e.d, o) } return bn = !0, s } function p(n) { return 1 & n.d[n.d.length - 1] } function g(n, e, i) { for (var t, r = new n(e[0]), s = 0; ++s < e.length;) { if (t = new n(e[s]), !t.s) { r = t; break } r[i](t) && (r = t) } return r } function w(n, i) { var r, s, u, c, f, a, h, l = 0, d = 0, p = 0, g = n.constructor, w = g.rounding, m = g.precision; if (!n.d || !n.d[0] || n.e > 17) return new g(n.d ? n.d[0] ? n.s < 0 ? 0 : 1 / 0 : 1 : n.s ? n.s < 0 ? 0 : n : NaN); for (null == i ? (bn = !1, h = m) : h = i, a = new g(.03125) ; n.e > -2;) n = n.times(a), p += 5; for (s = Math.log(On(2, p)) / Math.LN10 * 2 + 5 | 0, h += s, r = c = f = new g(1), g.precision = h; ;) { if (c = o(c.times(n), h, 1), r = r.times(++d), a = f.plus(Sn(c, r, h, 1)), e(a.d).slice(0, h) === e(f.d).slice(0, h)) { for (u = p; u--;) f = o(f.times(f), h, 1); if (null != i) return g.precision = m, f; if (!(3 > l && t(f.d, h - s, w, l))) return o(f, g.precision = m, w, bn = !0);
9086 g.precision = h += 10, r = c = a = new g(1), d = 0, l++ } f = a } } function m(n, i) { var r, s, u, c, a, h, l, d, p, g, w, v = 1, N = 10, b = n, x = b.d, E = b.constructor, M = E.rounding, y = E.precision; if (b.s < 0 || !x || !x[0] || !b.e && 1 == x[0] && 1 == x.length) return new E(x && !x[0] ? -1 / 0 : 1 != b.s ? NaN : x ? 0 : b); if (null == i ? (bn = !1, p = y) : p = i, E.precision = p += N, r = e(x), s = r.charAt(0), !(Math.abs(c = b.e) < 15e14)) return d = f(E, p + 2, y).times(c + ""), b = m(new E(s + "." + r.slice(1)), p - N).plus(d), E.precision = y, null == i ? o(b, y, M, bn = !0) : b; for (; 7 > s && 1 != s || 1 == s && r.charAt(1) > 3;) b = b.times(n), r = e(b.d), s = r.charAt(0), v++; for (c = b.e, s > 1 ? (b = new E("0." + r), c++) : b = new E(s + "." + r.slice(1)), g = b, l = a = b = Sn(b.minus(1), b.plus(1), p, 1), w = o(b.times(b), p, 1), u = 3; ;) { if (a = o(a.times(w), p, 1), d = l.plus(Sn(a, new E(u), p, 1)), e(d.d).slice(0, p) === e(l.d).slice(0, p)) { if (l = l.times(2), 0 !== c && (l = l.plus(f(E, p + 2, y).times(c + ""))), l = Sn(l, new E(v), p, 1), null != i) return E.precision = y, l; if (!t(l.d, p - N, M, h)) return o(l, E.precision = y, M, bn = !0); E.precision = p += N, d = a = b = Sn(g.minus(1), g.plus(1), p, 1), w = o(b.times(b), p, 1), u = h = 1 } l = d, u += 2 } } function v(n) { return String(n.s * n.s / 0) } function N(n, e) { var i, t, r; for ((i = e.indexOf(".")) > -1 && (e = e.replace(".", "")), (t = e.search(/e/i)) > 0 ? (0 > i && (i = t), i += +e.slice(t + 1), e = e.substring(0, t)) : 0 > i && (i = e.length), t = 0; 48 === e.charCodeAt(t) ; t++); for (r = e.length; 48 === e.charCodeAt(r - 1) ; --r); if (e = e.slice(t, r)) { if (r -= t, n.e = i = i - t - 1, n.d = [], t = (i + 1) % Rn, 0 > i && (t += Rn), r > t) { for (t && n.d.push(+e.slice(0, t)), r -= Rn; r > t;) n.d.push(+e.slice(t, t += Rn)); e = e.slice(t), t = Rn - e.length } else t -= r; for (; t--;) e += "0"; n.d.push(+e), bn && (n.e > n.constructor.maxE ? (n.d = null, n.e = NaN) : n.e < n.constructor.minE && (n.e = 0, n.d = [0])) } else n.e = 0, n.d = [0]; return n } function b(n, e) { var i, t, s, o, u, f, a, h, l; if ("Infinity" === e || "NaN" === e) return +e || (n.s = NaN), n.e = NaN, n.d = null, n; if (An.test(e)) i = 16, e = e.toLowerCase(); else if (Fn.test(e)) i = 2; else { if (!Dn.test(e)) throw Error(En + e); i = 8 } for (o = e.search(/p/i), o > 0 ? (a = +e.slice(o + 1), e = e.substring(2, o)) : e = e.slice(2), o = e.indexOf("."), u = o >= 0, t = n.constructor, u && (e = e.replace(".", ""), f = e.length, o = f - o, s = d(t, new t(i), o, 2 * o)), h = r(e, i, Pn), l = h.length - 1, o = l; 0 === h[o]; --o) h.pop(); return 0 > o ? new t(0 * n.s) : (n.e = c(h, l), n.d = h, bn = !1, u && (n = Sn(n, s, 4 * f)), a && (n = n.times(Math.abs(a) < 54 ? Math.pow(2, a) : Nn.pow(2, a))), bn = !0, n) } function x(n, e) { var i, t = e.d.length; if (3 > t) return E(n, 2, e, e); i = 1.4 * Math.sqrt(t), i = i >
9086 16 ? 16 : 0 | i, e = e.times(Math.pow(5, -i)), e = E(n, 2, e, e); for (var r, s = new n(5), o = new n(16), u = new n(20) ; i--;) r = e.times(e), e = e.times(s.plus(r.times(o.times(r).minus(u)))); return e } function E(n, e, i, t, r) { var s, o, u, c, f = 1, a = n.precision, h = Math.ceil(a / Rn); for (bn = !1, c = i.times(i), u = new n(t) ; ;) { if (o = Sn(u.times(c), new n(e++ * e++), a, 1), u = r ? t.plus(o) : t.minus(o), t = Sn(o.times(c), new n(e++ * e++), a, 1), o = u.plus(t), void 0 !== o.d[h]) { for (s = h; o.d[s] === u.d[s] && s--;); if (-1 == s) break } s = u, u = t, t = o, o = s, f++ } return bn = !0, o.d.length = h + 1, o } function M(n, e) { var i, t = e.s < 0, r = a(n, n.precision, 1), s = r.times(.5); if (e = e.abs(), e.lte(s)) return dn = t ? 4 : 1, e; if (i = e.divToInt(r), i.isZero()) dn = t ? 3 : 2; else { if (e = e.minus(i.times(r)), e.lte(s)) return dn = p(i) ? t ? 2 : 3 : t ? 4 : 1, e; dn = p(i) ? t ? 1 : 4 : t ? 3 : 2 } return e.minus(r).abs() } function y(n, e, t, s) { var o, c, f, a, h, l, d, p, g, w = n.constructor, m = void 0 !== t; if (m ? (i(t, 1, gn), void 0 === s ? s = w.rounding : i(s, 0, 8)) : (t = w.precision, s = w.rounding), n.isFinite()) { for (d = u(n), f = d.indexOf("."), m ? (o = 2, 16 == e ? t = 4 * t - 3 : 8 == e && (t = 3 * t - 2)) : o = e, f >= 0 && (d = d.replace(".", ""), g = new w(1), g.e = d.length - f, g.d = r(u(g), 10, o), g.e = g.d.length), p = r(d, 10, o), c = h = p.length; 0 == p[--h];) p.pop(); if (p[0]) { if (0 > f ? c-- : (n = new w(n), n.d = p, n.e = c, n = Sn(n, g, t, s, 0, o), p = n.d, c = n.e, l = hn), f = p[t], a = o / 2, l = l || void 0 !== p[t + 1], l = 4 > s ? (void 0 !== f || l) && (0 === s || s === (n.s < 0 ? 3 : 2)) : f > a || f === a && (4 === s || l || 6 === s && 1 & p[t - 1] || s === (n.s < 0 ? 8 : 7)), p.length = t, l) for (; ++p[--t] > o - 1;) p[t] = 0, t || (++c, p.unshift(1)); for (h = p.length; !p[h - 1]; --h); for (f = 0, d = ""; h > f; f++) d += wn.charAt(p[f]); if (m) { if (h > 1) if (16 == e || 8 == e) { for (f = 16 == e ? 4 : 3, --h; h % f; h++) d += "0"; for (p = r(d, o, e), h = p.length; !p[h - 1]; --h); for (f = 1, d = "1."; h > f; f++) d += wn.charAt(p[f]) } else d = d.charAt(0) + "." + d.slice(1); d = d + (0 > c ? "p" : "p+") + c } else if (0 > c) { for (; ++c;) d = "0" + d; d = "0." + d } else if (++c > h) for (c -= h; c--;) d += "0"; else h > c && (d = d.slice(0, c) + "." + d.slice(c)) } else d = m ? "0p+0" : "0"; d = (16 == e ? "0x" : 2 == e ? "0b" : 8 == e ? "0o" : "") + d } else d = v(n); return n.s < 0 ? "-" + d : d } function q(n, e) { return n.length > e ? (n.length = e, !0) : void 0 } function O(n) { return new this(n).abs() } function F(n) { return new this(n).acos() } function A(n) { return new this(n).acosh() } function D(n, e) { return new this(n).plus(e) } function Z(n) { return new this(n).asin() } function P(n) { return new this(n).asinh() } function R(n) { return new this(n).atan() } function L(n) { return new this(n).atanh() } function U(n, e) { n = new this(n), e = new this(e); var i, t = this.precision, r = this.rounding, s = t + 4; return n.s && e.s ? n.d || e.d ? !e.d || n.isZero() ? (i = e.s < 0 ? a(this, t, r) : new this(0), i.s = n.s) : !n.d || e.isZero() ? (i = a(this, s, 1).times(.5), i.s = n.s) : e.s < 0 ? (this.precision = s, this.rounding = 1, i = this.atan(Sn(n, e, s, 1)), e = a(this, s, 1), this.precision = t, this.rounding = r, i = n.s < 0 ? i.minus(e) : i.plus(e)) : i = this.atan(Sn(n, e, s, 1)) : (i = a(this, s, 1).times(e.s > 0 ? .25 : .75), i.s = n.s) : i = new this(NaN), i } function _(n) { return new this(n).cbrt() } function k(n) { return o(n = new this(n), n.e + 1, 2) } function S(n) { if (!n || "object" != typeof n) throw Error(xn + "Object expected"); var e, i, t, r = ["precision", 1, gn, "rounding", 0, 8, "toExpNeg", -pn, 0, "toExpPos", 0, pn, "maxE", 0, pn, "minE", -pn, 0, "modulo", 0, 9]; for (e = 0; e < r.length; e += 3) if (void 0 !== (t = n[i = r[e]])) { if (!(qn(t) === t && t >= r[e + 1] && t <= r[e + 2])) throw Error(En + i + ": " + t); this[i] = t } if (void 0 !== (t = n[i = "crypto"])) { if (t !== !0 && t !== !1 && 0 !== t && 1 !== t) throw Error(En + i + ": " + t); if (t) { if ("undefined" == typeof crypto || !crypto || !crypto.getRandomValues && !crypto.randomBytes) throw Error(yn); this[i] = !0 } else this[i] = !1 } return this } function T(n) { return new this(n).cos() } function C(n) { return new this(n).cosh() } function I(n) { function e(n) { var i, t, r, s = this; if (!(s instanceof e)) return new e(n); if (s.constructor = e, n instanceof e) return s.s = n.s, s.e = n.e, void (s.d = (n = n.d) ? n.slice() : n); if (r = typeof n, "number" === r) { if (0 === n) return s.s = 0 > 1 / n ? -1 : 1, s.e = 0, void (s.d = [0]); if (0 > n ? (n = -n, s.s = -1) : s.s = 1, n === ~~n && 1e7 > n) { for (i = 0, t = n; t >= 10; t /= 10) i++; return s.e = i, void (s.d = [n]) } return 0 * n !== 0 ? (n || (s.s = NaN), s.e = NaN, void (s.d = null)) : N(s, n.toString()) } if ("string" !== r) throw Error(En + n);
9086 return 45 === n.charCodeAt(0) ? (n = n.slice(1), s.s = -1) : s.s = 1, Zn.test(n) ? N(s, n) : b(s, n) } var i, t, r; if (e.prototype = kn, e.ROUND_UP = 0, e.ROUND_DOWN = 1, e.ROUND_CEIL = 2, e.ROUND_FLOOR = 3, e.ROUND_HALF_UP = 4, e.ROUND_HALF_DOWN = 5, e.ROUND_HALF_EVEN = 6, e.ROUND_HALF_CEIL = 7, e.ROUND_HALF_FLOOR = 8, e.EUCLID = 9, e.config = e.set = S, e.clone = I, e.abs = O, e.acos = F, e.acosh = A, e.add = D, e.asin = Z, e.asinh = P, e.atan = R, e.atanh = L, e.atan2 = U, e.cbrt = _, e.ceil = k, e.cos = T, e.cosh = C, e.div = H, e.exp = B, e.floor = V, e.hypot = $, e.ln = j, e.log = W, e.log10 = z, e.log2 = J, e.max = G, e.min = K, e.mod = Q, e.mul = X, e.pow = Y, e.random = nn, e.round = en, e.sign = tn, e.sin = rn, e.sinh = sn, e.sqrt = on, e.sub = un, e.tan = cn, e.tanh = fn, e.trunc = an, void 0 === n && (n = {}), n) for (r = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], i = 0; i < r.length;) n.hasOwnProperty(t = r[i++]) || (n[t] = this[t]); return e.config(n), e } function H(n, e) { return new this(n).div(e) } function B(n) { return new this(n).exp() } function V(n) { return o(n = new this(n), n.e + 1, 3) } function $() { var n, e, i = new this(0); for (bn = !1, n = 0; n < arguments.length;) if (e = new this(arguments[n++]), e.d) i.d && (i = i.plus(e.times(e))); else { if (e.s) return bn = !0, new this(1 / 0); i = e } return bn = !0, i.sqrt() } function j(n) { return new this(n).ln() } function W(n, e) { return new this(n).log(e) } function J(n) { return new this(n).log(2) } function z(n) { return new this(n).log(10) } function G() { return g(this, arguments, "lt") } function K() { return g(this, arguments, "gt") } function Q(n, e) { return new this(n).mod(e) } function X(n, e) { return new this(n).mul(e) } function Y(n, e) { return new this(n).pow(e) } function nn(n) { var e, t, r, s, o = 0, u = new this(1), c = []; if (void 0 === n ? n = this.precision : i(n, 1, gn), r = Math.ceil(n / Rn), this.crypto) if (crypto.getRandomValues) for (e = crypto.getRandomValues(new Uint32Array(r)) ; r > o;) s = e[o], s >= 429e7 ? e[o] = crypto.getRandomValues(new Uint32Array(1))[0] : c[o++] = s % 1e7; else { if (!crypto.randomBytes) throw Error(yn); for (e = crypto.randomBytes(r *= 4) ; r > o;) s = e[o] + (e[o + 1] << 8) + (e[o + 2] << 16) + ((127 & e[o + 3]) << 24), s >= 214e7 ? crypto.randomBytes(4).copy(e, o) : (c.push(s % 1e7), o += 4); o = r / 4 } else for (; r > o;) c[o++] = 1e7 * Math.random() | 0; for (r = c[--o], n %= Rn, r && n && (s = On(10, Rn - n), c[o] = (r / s | 0) * s) ; 0 === c[o]; o--) c.pop(); if (0 > o) t = 0, c = [0]; else { for (t = -1; 0 === c[0]; t -= Rn) c.shift(); for (r = 1, s = c[0]; s >= 10; s /= 10) r++; Rn > r && (t -= Rn - r) } return u.e = t, u.d = c, u } function en(n) { return o(n = new this(n), n.e + 1, this.rounding) } function tn(n) { return n = new this(n), n.d ? n.d[0] ? n.s : 0 * n.s : n.s || NaN } function rn(n) { return new this(n).sin() } function sn(n) { return new this(n).sinh() } function on(n) { return new this(n).sqrt() } function un(n, e) { return new this(n).sub(e) } function cn(n) { return new this(n).tan() } function fn(n) { return new this(n).tanh() } function an(n) { return o(n = new this(n), n.e + 1, 1) } var hn, ln, dn, pn = 9e15, gn = 1e9, wn = "0123456789abcdef", mn = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", vn = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823
9086066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", Nn = { precision: 20, rounding: 4, modulo: 1, toExpNeg: -7, toExpPos: 21, minE: -pn, maxE: pn, crypto: !1 }, bn = !0, xn = "[DecimalError] ", En = xn + "Invalid argument: ", Mn = xn + "Precision limit exceeded", yn = xn + "crypto unavailable", qn = Math.floor, On = Math.pow, Fn = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, An = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, Dn = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Zn = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, Pn = 1e7, Rn = 7, Ln = 9007199254740991, Un = mn.length - 1, _n = vn.length - 1, kn = {}; kn.absoluteValue = kn.abs = function () { var n = new this.constructor(this); return n.s < 0 && (n.s = 1), o(n) }, kn.ceil = function () { return o(new this.constructor(this), this.e + 1, 2) }, kn.comparedTo = kn.cmp = function (n) { var e, i, t, r, s = this, o = s.d, u = (n = new s.constructor(n)).d, c = s.s, f = n.s; if (!o || !u) return c && f ? c !== f ? c : o === u ? 0 : !o ^ 0 > c ? 1 : -1 : NaN; if (!o[0] || !u[0]) return o[0] ? c : u[0] ? -f : 0; if (c !== f) return c; if (s.e !== n.e) return s.e > n.e ^ 0 > c ? 1 : -1; for (t = o.length, r = u.length, e = 0, i = r > t ? t : r; i > e; ++e) if (o[e] !== u[e]) return o[e] > u[e] ^ 0 > c ? 1 : -1; return t === r ? 0 : t > r ^ 0 > c ? 1 : -1 }, kn.cosine = kn.cos = function () { var n, e, i = this, t = i.constructor; return i.d ? i.d[0] ? (n = t.precision, e = t.rounding, t.precision = n + Math.max(i.e, i.sd()) + Rn, t.rounding = 1, i = s(t, M(t, i)), t.precision = n, t.rounding = e, o(2 == dn || 3 == dn ? i.neg() : i, n, e, !0)) : new t(1) : new t(NaN) }, kn.cubeRoot = kn.cbrt = function () { var n, i, t, r, s, u, c, f, a, h, l = this, d = l.constructor; if (!l.isFinite() || l.isZero()) return new d(l); for (bn = !1, u = l.s * Math.pow(l.s * l, 1 / 3), u && Math.abs(u) != 1 / 0 ? r = new d(u.toString()) : (t = e(l.d), n = l.e, (u = (n - t.length + 1) % 3) && (t += 1 == u || -2 == u ? "0" : "00"), u = Math.pow(t, 1 / 3), n = qn((n + 1) / 3) - (n % 3 == (0 > n ? -1 : 2)), u == 1 / 0 ? t = "5e" + n : (t = u.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + n), r = new d(t), r.s = l.s), c = (n = d.precision) + 3; ;) if (f = r, a = f.times(f).times(f), h = a.plus(l), r = Sn(h.plus(l).times(f), h.plus(a), c + 2, 1), e(f.d).slice(0, c) === (t = e(r.d)).slice(0, c)) { if (t = t.slice(c - 3, c + 1), "9999" != t && (s || "4999" != t)) { (!+t || !+t.slice(1) && "5" == t.charAt(0)) && (o(r, n + 1, 1), i = !r.times(r).times(r).eq(l)); break } if (!s && (o(f, n + 1, 0), f.times(f).times(f).eq(l))) { r = f; break } c += 4, s = 1 } return bn = !0, o(r, n, d.rounding, i) }, kn.decimalPlaces = kn.dp = function () { var n, e = this.d, i = NaN; if (e) { if (n = e.length - 1, i = (n - qn(this.e / Rn)) * Rn, n = e[n]) for (; n % 10 == 0; n /= 10) i--; 0 > i && (i = 0) } return i }, kn.dividedBy = kn.div = function (n) { return Sn(this, new this.constructor(n)) }, kn.dividedToIntegerBy = kn.divToInt = function (n) { var e = this, i = e.constructor; return o(Sn(e, new i(n), 0, 1, 1), i.precision, i.rounding) }, kn.equals = kn.eq = function (n) { return 0 === this.cmp(n) }, kn.floor = function () { return o(new this.constructor(this), this.e + 1, 3) }, kn.greaterThan = kn.gt = function (n) { return this.cmp(n) > 0 }, kn.greaterThanOrEqualTo = kn.gte = function (n) { var e = this.cmp(n); return 1 == e || 0 === e }, kn.hyperbolicCosine = kn.cosh = function () { var n, e, i, t, r, s = this, u = s.constructor, c = new u(1); if (!s.isFinite()) return new u(s.s ? 1 / 0 : NaN); if (s.isZero()) return c; i = u.precision, t = u.rounding, u.precision = i + Math.max(s.e, s.sd()) + 4, u.rounding = 1, r = s.d.length, 32 > r ? (n = Math.ceil(r / 3), e = Math.pow(4, -n).toString()) : (n = 16, e = "2.3283064365386962890625e-10"), s = E(u, 1, s.times(e), new u(1), !0); for (var f, a = n, h = new u(8) ; a--;) f = s.times(s), s = c.minus(f.times(h.minus(f.times(h)))); return o(s, u.precision = i, u.rounding = t, !0) }, kn.hyperbolicSine = kn.sinh = function () { var n, e, i, t, r = this, s = r.constructor; if (!r.isFinite() || r.isZero()) return new s(r); if (e = s.precision, i = s.rounding, s.precision = e + Math.max(r.e, r.sd()) + 4, s.roun
9086ding = 1, t = r.d.length, 3 > t) r = E(s, 2, r, r, !0); else { n = 1.4 * Math.sqrt(t), n = n > 16 ? 16 : 0 | n, r = r.times(Math.pow(5, -n)), r = E(s, 2, r, r, !0); for (var u, c = new s(5), f = new s(16), a = new s(20) ; n--;) u = r.times(r), r = r.times(c.plus(u.times(f.times(u).plus(a)))) } return s.precision = e, s.rounding = i, o(r, e, i, !0) }, kn.hyperbolicTangent = kn.tanh = function () { var n, e, i = this, t = i.constructor; return i.isFinite() ? i.isZero() ? new t(i) : (n = t.precision, e = t.rounding, t.precision = n + 7, t.rounding = 1, Sn(i.sinh(), i.cosh(), t.precision = n, t.rounding = e)) : new t(i.s) }, kn.inverseCosine = kn.acos = function () { var n, e = this, i = e.constructor, t = e.abs().cmp(1), r = i.precision, s = i.rounding; return -1 !== t ? 0 === t ? e.isNeg() ? a(i, r, s) : new i(0) : new i(NaN) : e.isZero() ? a(i, r + 4, s).times(.5) : (i.precision = r + 6, i.rounding = 1, e = e.asin(), n = a(i, r + 4, s).times(.5), i.precision = r, i.rounding = s, n.minus(e)) }, kn.inverseHyperbolicCosine = kn.acosh = function () { var n, e, i = this, t = i.constructor; return i.lte(1) ? new t(i.eq(1) ? 0 : NaN) : i.isFinite() ? (n = t.precision, e = t.rounding, t.precision = n + Math.max(Math.abs(i.e), i.sd()) + 4, t.rounding = 1, bn = !1, i = i.times(i).minus(1).sqrt().plus(i), bn = !0, t.precision = n, t.rounding = e, i.ln()) : new t(i) }, kn.inverseHyperbolicSine = kn.asinh = function () { var n, e, i = this, t = i.constructor; return !i.isFinite() || i.isZero() ? new t(i) : (n = t.precision, e = t.rounding, t.precision = n + 2 * Math.max(Math.abs(i.e), i.sd()) + 6, t.rounding = 1, bn = !1, i = i.times(i).plus(1).sqrt().plus(i), bn = !0, t.precision = n, t.rounding = e, i.ln()) }, kn.inverseHyperbolicTangent = kn.atanh = function () { var n, e, i, t, r = this, s = r.constructor; return r.isFinite() ? r.e >= 0 ? new s(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (n = s.precision, e = s.rounding, t = r.sd(), Math.max(t, n) < 2 * -r.e - 1 ? o(new s(r), n, e, !0) : (s.precision = i = t - r.e, r = Sn(r.plus(1), new s(1).minus(r), i + n, 1), s.precision = n + 4, s.rounding = 1, r = r.ln(), s.precision = n, s.rounding = e, r.times(.5))) : new s(NaN) }, kn.inverseSine = kn.asin = function () { var n, e, i, t, r = this, s = r.constructor; return r.isZero() ? new s(r) : (e = r.abs().cmp(1), i = s.precision, t = s.rounding, -1 !== e ? 0 === e ? (n = a(s, i + 4, t).times(.5), n.s = r.s, n) : new s(NaN) : (s.precision = i + 6, s.rounding = 1, r = r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(), s.precision = i, s.rounding = t, r.times(2))) }, kn.inverseTangent = kn.atan = function () { var n, e, i, t, r, s, u, c, f, h = this, l = h.constructor, d = l.precision, p = l.rounding; if (h.isFinite()) { if (h.isZero()) return new l(h); if (h.abs().eq(1) && _n >= d + 4) return u = a(l, d + 4, p).times(.25), u.s = h.s, u } else { if (!h.s) return new l(NaN); if (_n >= d + 4) return u = a(l, d + 4, p).times(.5), u.s = h.s, u } for (l.precision = c = d + 10, l.rounding = 1, i = Math.min(28, c / Rn + 2 | 0), n = i; n; --n) h = h.div(h.times(h).plus(1).sqrt().plus(1)); for (bn = !1, e = Math.ceil(c / Rn), t = 1, f = h.times(h), u = new l(h), r = h; -1 !== n;) if (r = r.times(f), s = u.minus(r.div(t += 2)), r = r.times(f), u = s.plus(r.div(t += 2)), void 0 !== u.d[e]) for (n = e; u.d[n] === s.d[n] && n--;); return i && (u = u.times(2 << i - 1)), bn = !0, o(u, l.precision = d, l.rounding = p, !0) }, kn.isFinite = function () { return !!this.d }, kn.isInteger = kn.isInt = function () { return !!this.d && qn(this.e / Rn) > this.d.length - 2 }, kn.isNaN = function () { return !this.s }, kn.isNegative = kn.isNeg = function () { return this.s < 0 }, kn.isPositive = kn.isPos = function () { return this.s > 0 }, kn.isZero = function () { return !!this.d && 0 === this.d[0] }, kn.lessThan = kn.lt = function (n) { return this.cmp(n) < 0 }, kn.lessThanOrEqualTo = kn.lte = function (n) { return this.cmp(n) < 1 }, kn.logarithm = kn.log = function (n) { var i, r, s, u, c, a, h, l, d = this, p = d.constructor, g = p.precision, w = p.rounding, v = 5; if (null == n) n = new p(10), i = !0; else { if (n = new p(n), r = n.d, n.s < 0 || !r || !r[0] || n.eq(1)) return new p(NaN); i = n.eq(10) } if (r = d.d, d.s < 0 || !r || !r[0] || d.eq(1)) return new p(r && !r[0] ? -1 / 0 : 1 != d.s ? NaN : r ? 0 : 1 / 0); if (i) if (r.length > 1) c = !0; else { for (u = r[0]; u % 10 === 0;) u /= 10; c = 1 !== u } if (bn = !1, h = g + v, a = m(d, h), s = i ? f(p, h + 10) : m(n, h), l = Sn(a, s, h, 1), t(l.d, u = g, w)) do if (h += 10, a = m(d, h), s = i ? f(p, h + 10) : m(n, h), l = Sn(a, s, h, 1), !c) { +e(l.d).slice(u + 1, u + 15) + 1 == 1e14 && (l = o(l, g + 1, 0)); break } while (t(l.d, u += 10, w)); return bn = !0, o(l, g, w) }, kn.minus = kn.sub = function (n) { var e, i, t, r, s, u, f, a, h, l, d, p, g = this, w = g.constructor; if (n = new w(n), !g.d || !n.d) return g.s && n.s ? g.d ? n.s = -n.s : n = new w(n.d || g.s !== n.s ? g : NaN) : n = new w(NaN), n;
9086 if (g.s != n.s) return n.s = -n.s, g.plus(n); if (h = g.d, p = n.d, f = w.precision, a = w.rounding, !h[0] || !p[0]) { if (p[0]) n.s = -n.s; else { if (!h[0]) return new w(3 === a ? -0 : 0); n = new w(g) } return bn ? o(n, f, a) : n } if (i = qn(n.e / Rn), l = qn(g.e / Rn), h = h.slice(), s = l - i) { for (d = 0 > s, d ? (e = h, s = -s, u = p.length) : (e = p, i = l, u = h.length), t = Math.max(Math.ceil(f / Rn), u) + 2, s > t && (s = t, e.length = 1), e.reverse(), t = s; t--;) e.push(0); e.reverse() } else { for (t = h.length, u = p.length, d = u > t, d && (u = t), t = 0; u > t; t++) if (h[t] != p[t]) { d = h[t] < p[t]; break } s = 0 } for (d && (e = h, h = p, p = e, n.s = -n.s), u = h.length, t = p.length - u; t > 0; --t) h[u++] = 0; for (t = p.length; t > s;) { if (h[--t] < p[t]) { for (r = t; r && 0 === h[--r];) h[r] = Pn - 1; --h[r], h[t] += Pn } h[t] -= p[t] } for (; 0 === h[--u];) h.pop(); for (; 0 === h[0]; h.shift())--i; return h[0] ? (n.d = h, n.e = c(h, i), bn ? o(n, f, a) : n) : new w(3 === a ? -0 : 0) }, kn.modulo = kn.mod = function (n) { var e, i = this, t = i.constructor; return n = new t(n), !i.d || !n.s || n.d && !n.d[0] ? new t(NaN) : !n.d || i.d && !i.d[0] ? o(new t(i), t.precision, t.rounding) : (bn = !1, 9 == t.modulo ? (e = Sn(i, n.abs(), 0, 3, 1), e.s *= n.s) : e = Sn(i, n, 0, t.modulo, 1), e = e.times(n), bn = !0, i.minus(e)) }, kn.naturalExponential = kn.exp = function () { return w(this) }, kn.naturalLogarithm = kn.ln = function () { return m(this) }, kn.negated = kn.neg = function () { var n = new this.constructor(this); return n.s = -n.s, o(n) }, kn.plus = kn.add = function (n) { var e, i, t, r, s, u, f, a, h, l, d = this, p = d.constructor; if (n = new p(n), !d.d || !n.d) return d.s && n.s ? d.d || (n = new p(n.d || d.s === n.s ? d : NaN)) : n = new p(NaN), n; if (d.s != n.s) return n.s = -n.s, d.minus(n); if (h = d.d, l = n.d, f = p.precision, a = p.rounding, !h[0] || !l[0]) return l[0] || (n = new p(d)), bn ? o(n, f, a) : n; if (s = qn(d.e / Rn), t = qn(n.e / Rn), h = h.slice(), r = s - t) { for (0 > r ? (i = h, r = -r, u = l.length) : (i = l, t = s, u = h.length), s = Math.ceil(f / Rn), u = s > u ? s + 1 : u + 1, r > u && (r = u, i.length = 1), i.reverse() ; r--;) i.push(0); i.reverse() } for (u = h.length, r = l.length, 0 > u - r && (r = u, i = l, l = h, h = i), e = 0; r;) e = (h[--r] = h[r] + l[r] + e) / Pn | 0, h[r] %= Pn; for (e && (h.unshift(e), ++t), u = h.length; 0 == h[--u];) h.pop(); return n.d = h, n.e = c(h, t), bn ? o(n, f, a) : n }, kn.precision = kn.sd = function (n) { var e, i = this; if (void 0 !== n && n !== !!n && 1 !== n && 0 !== n) throw Error(En + n); return i.d ? (e = h(i.d), n && i.e + 1 > e && (e = i.e + 1)) : e = NaN, e }, kn.round = function () { var n = this, e = n.constructor; return o(new e(n), n.e + 1, e.rounding) }, kn.sine = kn.sin = function () { var n, e, i = this, t = i.constructor; return i.isFinite() ? i.isZero() ? new t(i) : (n = t.precision, e = t.rounding, t.precision = n + Math.max(i.e, i.sd()) + Rn, t.rounding = 1, i = x(t, M(t, i)), t.precision = n, t.rounding = e, o(dn > 2 ? i.neg() : i, n, e, !0)) : new t(NaN) }, kn.squareRoot = kn.sqrt = function () { var n, i, t, r, s, u, c = this, f = c.d, a = c.e, h = c.s, l = c.constructor; if (1 !== h || !f || !f[0]) return new l(!h || 0 > h && (!f || f[0]) ? NaN : f ? c : 1 / 0); for (bn = !1, h = Math.sqrt(+c), 0 == h || h == 1 / 0 ? (i = e(f), (i.length + a) % 2 == 0 && (i += "0"), h = Math.sqrt(i), a = qn((a + 1) / 2) - (0 > a || a % 2), h == 1 / 0 ? i = "1e" + a : (i = h.toExponential(), i = i.slice(0, i.indexOf("e") + 1) + a), r = new l(i)) : r = new l(h.toString()), t = (a = l.precision) + 3; ;) if (u = r, r = u.plus(Sn(c, u, t + 2, 1)).times(.5), e(u.d).slice(0, t) === (i = e(r.d)).slice(0, t)) { if (i = i.slice(t - 3, t + 1), "9999" != i && (s || "4999" != i)) { (!+i || !+i.slice(1) && "5" == i.charAt(0)) && (o(r, a + 1, 1), n = !r.times(r).eq(c)); break } if (!s && (o(u, a + 1, 0), u.times(u).eq(c))) { r = u; break } t += 4, s = 1 } return bn = !0, o(r, a, l.rounding, n) }, kn.tangent = kn.tan = function () { var n, e, i = this, t = i.constructor; return i.isFinite() ? i.isZero() ? new t(i) : (n = t.precision, e = t.rounding, t.precision = n + 10, t.rounding = 1, i = i.sin(), i.s = 1, i = Sn(i, new t(1).minus(i.times(i)).sqrt(), n + 10, 0), t.precision = n, t.rounding = e, o(2 == dn || 4 == dn ? i.neg() : i, n, e, !0)) : new t(NaN) }, kn.times = kn.mul = function (n) { var e, i, t, r, s, u, f, a, h, l = this, d = l.constructor, p = l.d, g = (n = new d(n)).d; if (n.s *= l.s, !(p && p[0] && g && g[0])) return new d(!n.s || p && !p[0] && !g || g && !g[0] && !p ? NaN : p && g ? 0 * n.s : n.s / 0);
9086 for (i = qn(l.e / Rn) + qn(n.e / Rn), a = p.length, h = g.length, h > a && (s = p, p = g, g = s, u = a, a = h, h = u), s = [], u = a + h, t = u; t--;) s.push(0); for (t = h; --t >= 0;) { for (e = 0, r = a + t; r > t;) f = s[r] + g[t] * p[r - t - 1] + e, s[r--] = f % Pn | 0, e = f / Pn | 0; s[r] = (s[r] + e) % Pn | 0 } for (; !s[--u];) s.pop(); for (e ? ++i : s.shift(), t = s.length; !s[--t];) s.pop(); return n.d = s, n.e = c(s, i), bn ? o(n, d.precision, d.rounding) : n }, kn.toBinary = function (n, e) { return y(this, 2, n, e) }, kn.toDecimalPlaces = kn.toDP = function (n, e) { var t = this, r = t.constructor; return t = new r(t), void 0 === n ? t : (i(n, 0, gn), void 0 === e ? e = r.rounding : i(e, 0, 8), o(t, n + t.e + 1, e)) }, kn.toExponential = function (n, e) { var t, r = this, s = r.constructor; return void 0 === n ? t = u(r, !0) : (i(n, 0, gn), void 0 === e ? e = s.rounding : i(e, 0, 8), r = o(new s(r), n + 1, e), t = u(r, !0, n + 1)), r.isNeg() && !r.isZero() ? "-" + t : t }, kn.toFixed = function (n, e) { var t, r, s = this, c = s.constructor; return void 0 === n ? t = u(s) : (i(n, 0, gn), void 0 === e ? e = c.rounding : i(e, 0, 8), r = o(new c(s), n + s.e + 1, e), t = u(r, !1, n + r.e + 1)), s.isNeg() && !s.isZero() ? "-" + t : t }, kn.toFraction = function (n) { var i, t, r, s, o, u, c, f, a, l, d, p, g = this, w = g.d, m = g.constructor; if (!w) return new m(g); if (a = t = new m(1), r = f = new m(0), i = new m(r), o = i.e = h(w) - g.e - 1, u = o % Rn, i.d[0] = On(10, 0 > u ? Rn + u : u), null == n) n = o > 0 ? i : a; else { if (c = new m(n), !c.isInt() || c.lt(a)) throw Error(En + c); n = c.gt(i) ? o > 0 ? i : a : c } for (bn = !1, c = new m(e(w)), l = m.precision, m.precision = o = w.length * Rn * 2; d = Sn(c, i, 0, 1, 1), s = t.plus(d.times(r)), 1 != s.cmp(n) ;) t = r, r = s, s = a, a = f.plus(d.times(s)), f = s, s = i, i = c.minus(d.times(s)), c = s; return s = Sn(n.minus(t), r, 0, 1, 1), f = f.plus(s.times(a)), t = t.plus(s.times(r)), f.s = a.s = g.s, p = Sn(a, r, o, 1).minus(g).abs().cmp(Sn(f, t, o, 1).minus(g).abs()) < 1 ? [a, r] : [f, t], m.precision = l, bn = !0, p }, kn.toHexadecimal = kn.toHex = function (n, e) { return y(this, 16, n, e) }, kn.toNearest = function (n, e) { var t = this, r = t.constructor; if (t = new r(t), null == n) { if (!t.d) return t; n = new r(1), e = r.rounding } else { if (n = new r(n), void 0 !== e && i(e, 0, 8), !t.d) return n.s ? t : n; if (!n.d) return n.s && (n.s = t.s), n } return n.d[0] ? (bn = !1, 4 > e && (e = [4, 5, 7, 8][e]), t = Sn(t, n, 0, e, 1).times(n), bn = !0, o(t)) : (n.s = t.s, t = n), t }, kn.toNumber = function () { return +this }, kn.toOctal = function (n, e) { return y(this, 8, n, e) }, kn.toPower = kn.pow = function (n) { var i, r, s, u, c, f, a, h = this, l = h.constructor, p = +(n = new l(n)); if (!(h.d && n.d && h.d[0] && n.d[0])) return new l(On(+h, p)); if (h = new l(h), h.eq(1)) return h; if (s = l.precision, c = l.rounding, n.eq(1)) return o(h, s, c); if (i = qn(n.e / Rn), r = n.d.length - 1, a = i >= r, f = h.s, a) { if ((r = 0 > p ? -p : p) <= Ln) return u = d(l, h, r, s), n.s < 0 ? new l(1).div(u) : o(u, s, c) } else if (0 > f) return new l(NaN); return f = 0 > f && 1 & n.d[Math.max(i, r)] ? -1 : 1, r = On(+h, p), i = 0 != r && isFinite(r) ? new l(r + "").e : qn(p * (Math.log("0." + e(h.d)) / Math.LN10 + h.e + 1)), i > l.maxE + 1 || i < l.minE - 1 ? new l(i > 0 ? f / 0 : 0) : (bn = !1, l.rounding = h.s = 1, r = Math.min(12, (i + "").length), u = w(n.times(m(h, s + r)), s), u = o(u, s + 5, 1), t(u.d, s, c) && (i = s + 10, u = o(w(n.times(m(h, i + r)), i), i + 5, 1), +e(u.d).slice(s + 1, s + 15) + 1 == 1e14 && (u = o(u, s + 1, 0))), u.s = f, bn = !0, l.rounding = c, o(u, s, c)) }, kn.toPrecision = function (n, e) { var t, r = this, s = r.constructor; return void 0 === n ? t = u(r, r.e <= s.toExpNeg || r.e >= s.toExpPos) : (i(n, 1, gn), void 0 === e ? e = s.rounding : i(e, 0, 8), r = o(new s(r), n, e), t = u(r, n <= r.e || r.e <= s.toExpNeg, n)), r.isNeg() && !r.isZero() ? "-" + t : t }, kn.toSignificantDigits = kn.toSD = function (n, e) { var t = this, r = t.constructor; return void 0 === n ? (n = r.precision, e = r.rounding) : (i(n, 1, gn), void 0 === e ? e = r.rounding : i(e, 0, 8)), o(new r(t), n, e) }, kn.toString = function () { var n = this, e = n.constructor, i = u(n, n.e <= e.toExpNeg || n.e >= e.toExpPos); return n.isNeg() && !n.isZero() ? "-" + i : i }, kn.truncated = kn.trunc = function () { return o(new this.constructor(this), this.e + 1, 1) }, kn.valueOf = kn.toJSON = function () { var n = this, e = n.constructor, i = u(n, n.e <= e.toExpNeg || n.e >= e.toExpPos); return n.isNeg() ? "-" + i : i }; var Sn = function () { function n(n, e, i) { var t, r = 0, s = n.length; for (n = n.slice() ; s--;) t = n[s] * e + r, n[s] = t % i | 0, r = t / i | 0; return r && n.unshift(r), n } function e(n, e, i, t) { var r, s; if (i != t) s = i > t ? 1 : -1; else for (r = s = 0; i > r; r++) if (n[r] != e[r]) { s = n[r] > e[r] ? 1 : -1; break } return s } function i(n, e, i, t) { for (var r = 0; i--;) n[i] -= r, r = n[i] < e[i] ? 1 : 0, n[i] = r * t + n[i] - e[i]; for (; !n[0] && n.length > 1;) n.shift() } return function (t, r, s, u, c, f) { var a, h, l, d, p, g, w, m, v, N, b, x, E, M, y, q, O, F, A, D, Z 
9086= t.constructor, P = t.s == r.s ? 1 : -1, R = t.d, L = r.d; if (!(R && R[0] && L && L[0])) return new Z(t.s && r.s && (R ? !L || R[0] != L[0] : L) ? R && 0 == R[0] || !L ? 0 * P : P / 0 : NaN); for (f ? (p = 1, h = t.e - r.e) : (f = Pn, p = Rn, h = qn(t.e / p) - qn(r.e / p)), A = L.length, O = R.length, v = new Z(P), N = v.d = [], l = 0; L[l] == (R[l] || 0) ; l++); if (L[l] > (R[l] || 0) && h--, null == s ? (M = s = Z.precision, u = Z.rounding) : M = c ? s + (t.e - r.e) + 1 : s, 0 > M) N.push(1), g = !0; else { if (M = M / p + 2 | 0, l = 0, 1 == A) { for (d = 0, L = L[0], M++; (O > l || d) && M--; l++) y = d * f + (R[l] || 0), N[l] = y / L | 0, d = y % L | 0; g = d || O > l } else { for (d = f / (L[0] + 1) | 0, d > 1 && (L = n(L, d, f), R = n(R, d, f), A = L.length, O = R.length), q = A, b = R.slice(0, A), x = b.length; A > x;) b[x++] = 0; D = L.slice(), D.unshift(0), F = L[0], L[1] >= f / 2 && ++F; do d = 0, a = e(L, b, A, x), 0 > a ? (E = b[0], A != x && (E = E * f + (b[1] || 0)), d = E / F | 0, d > 1 ? (d >= f && (d = f - 1), w = n(L, d, f), m = w.length, x = b.length, a = e(w, b, m, x), 1 == a && (d--, i(w, m > A ? D : L, m, f))) : (0 == d && (a = d = 1), w = L.slice()), m = w.length, x > m && w.unshift(0), i(b, w, x, f), -1 == a && (x = b.length, a = e(L, b, A, x), 1 > a && (d++, i(b, x > A ? D : L, x, f))), x = b.length) : 0 === a && (d++, b = [0]), N[l++] = d, a && b[0] ? b[x++] = R[q] || 0 : (b = [R[q]], x = 1); while ((q++ < O || void 0 !== b[0]) && M--); g = void 0 !== b[0] } N[0] || N.shift() } if (1 == p) v.e = h, hn = g; else { for (l = 1, d = N[0]; d >= 10; d /= 10) l++; v.e = l + h * p - 1, o(v, c ? s + v.e + 1 : s, u, g) } return v } }(); Nn = I(Nn), mn = new Nn(mn), vn = new Nn(vn), H5.$Decimal = Nn, "function" == typeof define && define.amd ? define("decimal.js", function () { return Nn }) : "undefined" != typeof module && module.exports ? module.exports = Nn["default"] = Nn.Decimal = Nn : (n || (n = "undefined" != typeof self && self && self.self == self ? self : Function("return this")()), ln = n.Decimal, Nn.noConflict = function () { return n.Decimal = ln, Nn }/*, n.Decimal = Nn*/) }(H5.global);
9087
9088    System.Decimal = function (v, provider, T) {
9089        if (this.constructor !== System.Decimal) {
9090            return new System.Decimal(v, provider, T);
9091        }
9092
9093        if (v == null) {
9094            v = 0;
9095        }
9096
9097        if (H5.isNumber(provider)) {
9098            this.$precision = provider;
9099            provider = undefined;
9100        } else {
9101            this.$precision = 0;
9102        }
9103
9104        if (typeof v === "string") {
9105            provider = provider || System.Globalization.CultureInfo.getCurrentCulture();
9106
9107            var nfInfo = provider && provider.getFormat(System.Globalization.NumberFormatInfo),
9108                dot;
9109
9110            if (nfInfo && nfInfo.numberDecimalSeparator !== ".") {
9111                v = v.replace(nfInfo.numberDecimalSeparator, ".");
9112            }
9113
9114            // Native .NET accepts the sign in postfixed form. Yet, it is documented otherwise.
9115            // https://docs.microsoft.com/en-us/dotnet/api/system.decimal.parse
9116            // True at least as with: Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
9117            if (!/^\s*[+-]?(\d+|\d+\.|\d*\.\d+)((e|E)[+-]?\d+)?\s*$/.test(v) &&
9118                !/^\s*(\d+|\d+\.|\d*\.\d+)((e|E)[+-]?\d+)?[+-]\s*$/.test(v)) {
9119                throw new System.FormatException();
9120            }
9121
9122            v = v.replace(/\s/g, "");
9123
9124            // Move the postfixed - to front, or remove "+" so the underlying
9125            // decimal handler knows what to do with the string.
9126            if (/[+-]$/.test(v)) {
9127                var vlastpos = v.length - 1;
9128                if (v.indexOf("-", vlastpos) === vlastpos) {
9129                    v = v.replace(/(.*)(-)$/, "$2$1");
9130                } else {
9131                    v = v.substr(0, vlastpos);
9132                }
9133            } else if (v.lastIndexOf("+", 0) === 0) {
9134                v = v.substr(1);
9135            }
9136
9137            if (!this.$precision && (dot = v.indexOf(".")) >= 0) {
9138                this.$precision = v.length - dot - 1;
9139            }
9140        }
9141
9142        if (isNaN(v) || System.Decimal.MaxValue && typeof v === "number" && (System.Decimal.MinValue.gt(v) || System.Decimal.MaxValue.lt(v))) {
9143            throw new System.OverflowException();
9144        }
9145
9146        if (T && T.precision && typeof v === "number" && Number.isFinite(v)) {
9147            var i = H5.Int.trunc(v);
9148            var length = (i + "").length;
9149            var p = T.precision - length;
9150            if (p < 0) {
9151                p = 0;
9152            }
9153            v = v.toFixed(p);
9154        }
9155
9156        if (v instanceof System.Decimal) {
9157            this.$precision = v.$precision;
9158        }
9159
9160        this.value = System.Decimal.getValue(v);
9161    }
9162
9163    System.Decimal.$number = true;
9164    System.Decimal.$$name = "System.Decimal";
9165    System.Decimal.prototype.$$name = "System.Decimal";
9166    System.Decimal.$kind = "struct";
9167    System.Decimal.prototype.$kind = "struct";
9168    System.Decimal.$$inherits = [];
9169    H5.Class.addExtend(System.Decimal, [System.IComparable, System.IFormattable, System.IComparable$1(System.Decimal), System.IEquatable$1(System.Decimal)]);
9170
9171    System.Decimal.$is = function (instance) {
9172        return instance instanceof System.Decimal;
9173    };
9174
9175    System.Decimal.getDefaultValue = function () {
9176        return new System.Decimal(0);
9177    };
9178
9179    System.Decimal.getValue = function (d) {
9180        if (!H5.hasValue(d)) {
9181            return this.getDefaultValue();
9182        }
9183
9184        if (d instanceof System.Decimal) {
9185            return d.value;
9186        }
9187
9188        if (d instanceof System.Int64 || d instanceof System.UInt64) {
9189            return new H5.$Decimal(d.toString());
9190        }
9191
9192        return new H5.$Decimal(d);
9193    };
9194
9195    System.Decimal.create = function (d) {
9196        if (!H5.hasValue(d)) {
9197            return null;
9198        }
9199
9200        if (d instanceof System.Decimal) {
9201            return d;
9202        }
9203
9204        return new System.Decimal(d);
9205    };
9206
9207    System.Decimal.lift = function (d) {
9208        return d == null ? null : System.Decimal.create(d);
9209    };
9210
9211    System.Decimal.prototype.toString = function (format, provider) {
9212        return H5.Int.format(this, format || "G", provider);
9213    };
9214
9215    System.Decimal.prototype.toFloat = function () {
9216        return this.value.toNumber();
9217    };
9218
9219    System.Decimal.prototype.toJSON = function () {
9220        return this.value.toNumber();
9221    };
9222
9223    System.Decimal.prototype.format = function (format, provider) {
9224        return H5.Int.format(this, format, provider);
9225    };
9226
9227    System.Decimal.prototype.decimalPlaces = function () {
9228        return this.value.decimalPlaces();
9229    };
9230
9231    System.Decimal.prototype.dividedToIntegerBy = function (d) {
9232        var d = new System.Decimal(this.value.dividedToIntegerBy(System.Decimal.getValue(d)), this.$precision);
9233        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9234        return d;
9235    };
9236
9237    System.Decimal.prototype.exponential = function () {
9238        return new System.Decimal(this.value.exponential(), this.$precision);
9239    };
9240
9241    System.Decimal.prototype.abs = function () {
9242        return new System.Decimal(this.value.abs(), this.$precision);
9243    };
9244
9245    System.Decimal.prototype.floor = function () {
9246        return new System.Decimal(this.value.floor());
9247    };
9248
9249    System.Decimal.prototype.ceil = function () {
9250        return new System.Decimal(this.value.ceil());
9251    };
9252
9253    System.Decimal.prototype.trunc = function () {
9254        return new System.Decimal(this.value.trunc());
9255    };
9256
9257    System.Decimal.round = function (obj, mode) {
9258        obj = System.Decimal.create(obj);
9259
9260        var old = H5.$Decimal.rounding;
9261
9262        H5.$Decimal.rounding = mode;
9263
9264        var d = new System.Decimal(obj.value.round());
9265
9266        H5.$Decimal.rounding = old;
9267
9268        return d;
9269    };
9270
9271    System.Decimal.toDecimalPlaces = function (obj, decimals, mode) {
9272        obj = System.Decimal.create(obj);
9273        var d = new System.Decimal(obj.value.toDecimalPlaces(decimals, mode));
9274        return d;
9275    };
9276
9277    System.Decimal.prototype.compareTo = function (another) {
9278        return this.value.comparedTo(System.Decimal.getValue(another));
9279    };
9280
9281    System.Decimal.prototype.add = function (another) {
9282        var d = new System.Decimal(this.value.plus(System.Decimal.getValue(another)));
9283        d.$precision = Math.max(d.value.decimalPlaces(), Math.max(another.$precision || 0, this.$precision));
9284        return d;
9285    };
9286
9287    System.Decimal.prototype.sub = function (another) {
9288        var d = new System.Decimal(this.value.minus(System.Decimal.getValue(another)));
9289        d.$precision = Math.max(d.value.decimalPlaces(), Math.max(another.$precision || 0, this.$precision));
9290        return d;
9291    };
9292
9293    System.Decimal.prototype.isZero = function () {
9294        return this.value.isZero;
9295    };
9296
9297    System.Decimal.prototype.mul = function (another) {
9298        var d = new System.Decimal(this.value.times(System.Decimal.getValue(another)));
9299        d.$precision = Math.max(d.value.decimalPlaces(), Math.max(another.$precision || 0, this.$precision));
9300        return d;
9301    };
9302
9303    System.Decimal.prototype.div = function (another) {
9304        var d = new System.Decimal(this.value.dividedBy(System.Decimal.getValue(another)));
9305        d.$precision = Math.max(d.value.decimalPlaces(), Math.max(another.$precision || 0, this.$precision));
9306        return d;
9307    };
9308
9309    System.Decimal.prototype.mod = function (another) {
9310        var d = new System.Decimal(this.value.modulo(System.Decimal.getValue(another)));
9311        d.$precision = Math.max(d.value.decimalPlaces(), Math.max(another.$precision || 0, this.$precision));
9312        return d;
9313    };
9314
9315    System.Decimal.prototype.neg = function () {
9316        return new System.Decimal(this.value.negated(), this.$precision);
9317    };
9318
9319    System.Decimal.prototype.inc = function () {
9320        return new System.Decimal(this.value.plus(System.Decimal.getValue(1)), this.$precision);
9321    };
9322
9323    System.Decimal.prototype.dec = function () {
9324        return new System.Decimal(this.value.minus(System.Decimal.getValue(1)), this.$precision);
9325    };
9326
9327    System.Decimal.prototype.sign = function () {
9328        return this.value.isZero() ? 0 : (this.value.isNegative() ? -1 : 1);
9329    };
9330
9331    System.Decimal.prototype.clone = function () {
9332        return new System.Decimal(this, this.$precision);
9333    };
9334
9335    System.Decimal.prototype.ne = function (v) {
9336        return !!this.compareTo(v);
9337    };
9338
9339    System.Decimal.prototype.lt = function (v) {
9340        return this.compareTo(v) < 0;
9341    };
9342
9343    System.Decimal.prototype.lte = function (v) {
9344        return this.compareTo(v) <= 0;
9345    };
9346
9347    System.Decimal.prototype.gt = function (v) {
9348        return this.compareTo(v) > 0;
9349    };
9350
9351    System.Decimal.prototype.gte = function (v) {
9352        return this.compareTo(v) >= 0;
9353    };
9354
9355    System.Decimal.prototype.equals = function (v) {
9356        if (v instanceof System.Decimal || typeof v === "number") {
9357            return !this.compareTo(v);
9358        }
9359
9360        return false;
9361    };
9362
9363    System.Decimal.prototype.equalsT = function (v) {
9364        return !this.compareTo(v);
9365    };
9366
9367    System.Decimal.prototype.getHashCode = function () {
9368        var n = (this.sign() * 397 + this.value.e) | 0;
9369
9370        for (var i = 0; i < this.value.d.length; i++) {
9371            n = (n * 397 + this.value.d[i]) | 0;
9372        }
9373
9374        return n;
9375    };
9376
9377    System.Decimal.toInt = function (v, tp) {
9378        if (!v) {
9379            return null;
9380        }
9381
9382        if (tp) {
9383            var str,
9384                r;
9385
9386            if (tp === System.Int64) {
9387                str = v.value.trunc().toString();
9388                r = new System.Int64(str);
9389
9390                if (str !== r.value.toString()) {
9391                    throw new System.OverflowException();
9392                }
9393
9394                return r;
9395            }
9396
9397            if (tp === System.UInt64) {
9398                if (v.value.isNegative()) {
9399                    throw new System.OverflowException();
9400                }
9401
9402                str = v.value.trunc().toString();
9403                r = new System.UInt64(str);
9404
9405                if (str !== r.value.toString()) {
9406                    throw new System.OverflowException();
9407                }
9408
9409                return r;
9410            }
9411
9412            return H5.Int.check(H5.Int.trunc(v.value.toNumber()), tp);
9413        }
9414
9415        var i = H5.Int.trunc(System.Decimal.getValue(v).toNumber());
9416
9417        if (!H5.Int.$is(i)) {
9418            throw new System.OverflowException();
9419        }
9420
9421        return i;
9422    };
9423
9424    System.Decimal.tryParse = function (s, provider, v) {
9425        try {
9426            v.v = new System.Decimal(s, provider);
9427
9428            return true;
9429        } catch (e) {
9430            v.v = new System.Decimal(0);
9431
9432            return false;
9433        }
9434    };
9435
9436    System.Decimal.toFloat = function (v) {
9437        if (!v) {
9438            return null;
9439        }
9440
9441        return System.Decimal.getValue(v).toNumber();
9442    };
9443
9444    System.Decimal.setConfig = function (config) {
9445        H5.$Decimal.config(config);
9446    };
9447
9448    System.Decimal.min = function () {
9449        var values = [],
9450            d, p;
9451
9452        for (var i = 0, len = arguments.length; i < len; i++) {
9453            values.push(System.Decimal.getValue(arguments[i]));
9454        }
9455
9456        d = H5.$Decimal.min.apply(H5.$Decimal, values);
9457
9458        for (var i = 0; i < arguments.length; i++) {
9459            if (d.eq(values[i])) {
9460                p = arguments[i].$precision;
9461            }
9462        }
9463
9464        return new System.Decimal(d, p);
9465    };
9466
9467    System.Decimal.max = function () {
9468        var values = [],
9469            d, p;
9470
9471        for (var i = 0, len = arguments.length; i < len; i++) {
9472            values.push(System.Decimal.getValue(arguments[i]));
9473        }
9474
9475        d = H5.$Decimal.max.apply(H5.$Decimal, values);
9476
9477        for (var i = 0; i < arguments.length; i++) {
9478            if (d.eq(values[i])) {
9479                p = arguments[i].$precision;
9480            }
9481        }
9482
9483        return new System.Decimal(d, p);
9484    };
9485
9486    System.Decimal.random = function (dp) {
9487        return new System.Decimal(H5.$Decimal.random(dp));
9488    };
9489
9490    System.Decimal.exp = function (d) {
9491        return new System.Decimal(System.Decimal.getValue(d).exp());
9492    };
9493
9494    System.Decimal.exp = function (d) {
9495        return new System.Decimal(System.Decimal.getValue(d).exp());
9496    };
9497
9498    System.Decimal.ln = function (d) {
9499        return new System.Decimal(System.Decimal.getValue(d).ln());
9500    };
9501
9502    System.Decimal.log = function (d, logBase) {
9503        return new System.Decimal(System.Decimal.getValue(d).log(logBase));
9504    };
9505
9506    System.Decimal.pow = function (d, exponent) {
9507        return new System.Decimal(System.Decimal.getValue(d).pow(exponent));
9508    };
9509
9510    System.Decimal.sqrt = function (d) {
9511        return new System.Decimal(System.Decimal.getValue(d).sqrt());
9512    };
9513
9514    System.Decimal.prototype.isFinite = function () {
9515        return this.value.isFinite();
9516    };
9517
9518    System.Decimal.prototype.isInteger = function () {
9519        return this.value.isInteger();
9520    };
9521
9522    System.Decimal.prototype.isNaN = function () {
9523        return this.value.isNaN();
9524    };
9525
9526    System.Decimal.prototype.isNegative = function () {
9527        return this.value.isNegative();
9528    };
9529
9530    System.Decimal.prototype.isZero = function () {
9531        return this.value.isZero();
9532    };
9533
9534    System.Decimal.prototype.log = function (logBase) {
9535        var d = new System.Decimal(this.value.log(logBase));
9536        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9537        return d;
9538    };
9539
9540    System.Decimal.prototype.ln = function () {
9541        var d = new System.Decimal(this.value.ln());
9542        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9543        return d;
9544    };
9545
9546    System.Decimal.prototype.precision = function () {
9547        return this.value.precision();
9548    };
9549
9550    System.Decimal.prototype.round = function () {
9551        var old = H5.$Decimal.rounding,
9552            r;
9553
9554        H5.$Decimal.rounding = 6;
9555        r = new System.Decimal(this.value.round());
9556        H5.$Decimal.rounding = old;
9557
9558        return r;
9559    };
9560
9561    System.Decimal.prototype.sqrt = function () {
9562        var d = new System.Decimal(this.value.sqrt());
9563        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9564        return d;
9565    };
9566
9567    System.Decimal.prototype.toDecimalPlaces = function (dp, rm) {
9568        return new System.Decimal(this.value.toDecimalPlaces(dp, rm));
9569    };
9570
9571    System.Decimal.prototype.toExponential = function (dp, rm) {
9572        return this.value.toExponential(dp, rm);
9573    };
9574
9575    System.Decimal.prototype.toFixed = function (dp, rm) {
9576        return this.value.toFixed(dp, rm);
9577    };
9578
9579    System.Decimal.prototype.pow = function (n) {
9580        var d = new System.Decimal(this.value.pow(n));
9581        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9582        return d;
9583    };
9584
9585    System.Decimal.prototype.toPrecision = function (dp, rm) {
9586        return this.value.toPrecision(dp, rm);
9587    };
9588
9589    System.Decimal.prototype.toSignificantDigits = function (dp, rm) {
9590        var d = new System.Decimal(this.value.toSignificantDigits(dp, rm));
9591        d.$precision = Math.max(d.value.decimalPlaces(), this.$precision);
9592        return d;
9593    };
9594
9595    System.Decimal.prototype.valueOf = function () {
9596        return this.value.valueOf();
9597    };
9598
9599    System.Decimal.prototype._toFormat = function (dp, rm, f) {
9600        var x = this.value;
9601
9602        if (!x.isFinite()) {
9603            return x.toString();
9604        }
9605
9606        var i,
9607            isNeg = x.isNeg(),
9608            groupSeparator = f.groupSeparator,
9609            g1 = +f.groupSize,
9610            g2 = +f.secondaryGroupSize,
9611            arr = x.toFixed(dp, rm).split("."),
9612            intPart = arr[0],
9613            fractionPart = arr[1],
9614            intDigits = isNeg ? intPart.slice(1) : intPart,
9615            len = intDigits.length;
9616
9617        if (g2) {
9618            len -= (i = g1, g1 = g2, g2 = i);
9619        }
9620
9621        if (g1 > 0 && len > 0) {
9622            i = len % g1 || g1;
9623            intPart = intDigits.substr(0, i);
9624
9625            for (; i < len; i += g1) {
9626                intPart += groupSeparator + intDigits.substr(i, g1);
9627            }
9628
9629            if (g2 > 0) {
9630                intPart += groupSeparator + intDigits.slice(i);
9631            }
9632
9633            if (isNeg) {
9634                intPart = "-" + intPart;
9635            }
9636        }
9637
9638        return fractionPart
9639            ? intPart + f.decimalSeparator + ((g2 = +f.fractionGroupSize)
9640                ? fractionPart.replace(new RegExp("\\d{" + g2 + "}\\B", "g"),
9641                    "$&" + f.fractionGroupSeparator)
9642                : fractionPart)
9643            : intPart;
9644    };
9645
9646    System.Decimal.prototype.toFormat = function (dp, rm, provider) {
9647        var config = {
9648                decimalSeparator: ".",
9649                groupSeparator: ",",
9650                groupSize: 3,
9651                secondaryGroupSize: 0,
9652                fractionGroupSeparator: "\xA0",
9653                fractionGroupSize: 0
9654            },
9655            d;
9656
9657        if (provider && !provider.getFormat) {
9658            config = H5.merge(config, provider);
9659            d = this._toFormat(dp, rm, config);
9660        } else {
9661            provider = provider || System.Globalization.CultureInfo.getCurrentCulture();
9662
9663            var nfInfo = provider && provider.getFormat(System.Globalization.NumberFormatInfo);
9664
9665            if (nfInfo) {
9666                config.decimalSeparator = nfInfo.numberDecimalSeparator;
9667                config.groupSeparator = nfInfo.numberGroupSeparator;
9668                config.groupSize = nfInfo.numberGroupSizes[0];
9669            }
9670
9671            d = this._toFormat(dp, rm, config);
9672        }
9673
9674        return d;
9675    };
9676
9677    System.Decimal.prototype.getBytes = function () {
9678        var s = this.value.s,
9679            e = this.value.e,
9680            d = this.value.d,
9681            bytes = System.Array.init(23, 0, System.Byte);
9682
9683        bytes[0] = s & 255;
9684        bytes[1] = e;
9685
9686        if (d && d.length > 0) {
9687            bytes[2] = d.length * 4;
9688
9689            for (var i = 0; i < d.length; i++) {
9690                bytes[i * 4 + 3] = d[i] & 255;
9691                bytes[i * 4 + 4] = (d[i] >> 8) & 255;
9692                bytes[i * 4 + 5] = (d[i] >> 16) & 255;
9693                bytes[i * 4 + 6] = (d[i] >> 24) & 255;
9694            }
9695        } else {
9696            bytes[2] = 0;
9697        }
9698
9699        return bytes;
9700    };
9701
9702    System.Decimal.fromBytes = fu
9702nction (bytes) {
9703        var value = new System.Decimal(0),
9704            s = H5.Int.sxb(bytes[0] & 255),
9705            e = bytes[1],
9706            ln = bytes[2],
9707            d = [];
9708
9709        value.value.s = s;
9710        value.value.e = e;
9711
9712        if (ln > 0) {
9713            for (var i = 3; i < (ln + 3);) {
9714                d.push(bytes[i] | bytes[i + 1] << 8 | bytes[i + 2] << 16 | bytes[i + 3] << 24);
9715                i = i + 4;
9716            }
9717        }
9718
9719        value.value.d = d;
9720
9721        return value;
9722    };
9723
9724    H5.$Decimal.config({ precision: 29 });
9725
9726    System.Decimal.Zero = System.Decimal(0);
9727    System.Decimal.One = System.Decimal(1);
9728    System.Decimal.MinusOne = System.Decimal(-1);
9729    System.Decimal.MinValue = System.Decimal("-79228162514264337593543950335");
9730    System.Decimal.MaxValue = System.Decimal("79228162514264337593543950335");
9731    System.Decimal.precision = 29;
9732
9733    // @source Date.js
9734
9735    H5.define("System.DateTime", {
9736        inherits: function () { return [System.IComparable, System.IComparable$1(System.DateTime), System.IEquatable$1(System.DateTime), System.IFormattable]; },
9737        $kind: "struct",
9738        fields: {
9739            kind: 0
9740        },
9741        methods: {
9742            $clone: function (to) { return this; }
9743        },
9744        statics: {
9745            $minTicks: null,
9746            $maxTicks: null,
9747            $minOffset: null,
9748            $maxOffset: null,
9749            $default: null,
9750            $min: null,
9751            $max: null,
9752
9753            TicksPerDay: System.Int64(864e9),
9754
9755            DaysTo1970: 719162,
9756            YearDaysByMonth: [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
9757
9758            getMinTicks: function () {
9759                if (this.$minTicks === null) {
9760                    this.$minTicks = System.Int64(0);
9761                }
9762
9763                return this.$minTicks;
9764            },
9765
9766            getMaxTicks: function () {
9767                if (this.$maxTicks === null) {
9768                    this.$maxTicks = System.Int64("3652059").mul(this.TicksPerDay).sub(1);
9769                }
9770
9771                return this.$maxTicks;
9772            },
9773
9774            // Difference in Ticks from 1-Jan-0001 to 1-Jan-1970 at UTC
9775            $getMinOffset: function () {
9776                if (this.$minOffset === null) {
9777                    this.$minOffset = System.Int64(621355968e9);
9778                }
9779
9780                return this.$minOffset;
9781            },
9782
9783            // Difference in Ticks between 1970-01-01 and 100 nanoseconds before 10000-01-01 UTC
9784            $getMaxOffset: function () {
9785                if (this.$maxOffset === null) {
9786                    this.$maxOffset = this.getMaxTicks().sub(this.$getMinOffset());
9787                }
9788
9789                return this.$maxOffset;
9790            },
9791
9792            $is: function (instance) {
9793                return H5.isDate(instance);
9794            },
9795
9796            getDefaultValue: function () {
9797                if (this.$default === null) {
9798                    this.$default = this.getMinValue();
9799                }
9800
9801                return this.$default;
9802            },
9803
9804            getMinValue: function () {
9805                if (this.$min === null) {
9806                    var d = new Date(1, 0, 1, 0, 0, 0, 0);
9807
9808                    d.setFullYear(1);
9809                    d.setSeconds(0);
9810
9811                    d.kind = 0;
9812                    d.ticks = this.getMinTicks();
9813
9814                    this.$min = d;
9815                }
9816
9817                return this.$min;
9818            },
9819
9820            getMaxValue: function () {
9821                if (this.$max === null) {
9822                    var d = new Date(9999, 11, 31, 23, 59, 59, 999);
9823
9824                    d.kind = 0;
9825                    d.ticks = this.getMaxTicks();
9826
9827                    this.$max = d;
9828                }
9829
9830                return this.$max;
9831            },
9832
9833            $getTzOffset: function (d) {
9834                // 60 seconds * 1000 milliseconds * 10000
9835                return System.Int64(d.getTimezoneOffset()).mul(6e8);
9836            },
9837
9838            toLocalTime: function (d, throwOnOverflow) {
9839                var kind = (d.kind !== undefined) ? d.kind : 0,
9840                    ticks = this.getTicks(d),
9841                    d1;
9842
9843                if (kind === 2) {
9844                    d1 = new Date(d.getTime());
9845                    d1.kind = 2;
9846                    d1.ticks = ticks;
9847
9848                    return d1;
9849                }
9850
9851                d1 = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()));
9852
9853                d1.kind = 2;
9854                d1.ticks = ticks;
9855
9856                // Check if Ticks are out of range
9857                if (d1.ticks.gt(this.getMaxTicks()) || d1.ticks.lt(0)) {
9858                    if (throwOnOverflow && throwOnOverflow === true) {
9859                        throw new System.ArgumentException.$ctor1("Specified argument was out of the range of valid values.");
9860                    } else {
9861                        d1 = this.create$2(ticks.add(this.$getTzOffset(d1)), 2);
9862                    }
9863                }
9864
9865                return d1;
9866            },
9867
9868            toUniversalTime: function (d) {
9869                var kind = (d.kind !== undefined) ? d.kind : 0,
9870                    ticks = this.getTicks(d),
9871                    d1;
9872
9873                if (kind === 1) {
9874                    d1 = new Date(d.getTime());
9875                    d1.kind = 1;
9876                    d1.ticks = ticks;
9877
9878                    return d1;
9879                }
9880
9881                d1 = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()));
9882
9883                d1.kind = 1;
9884                d1.ticks = ticks;
9885
9886                // Check if Ticks are out of range
9887                if (d1.ticks.gt(this.getMaxTicks()) || d1.ticks.lt(0)) {
9888                    d1 = this.create$2(ticks.add(this.$getTzOffset(d1)), 1);
9889                }
9890
9891                return d1;
9892            },
9893
9894            // Get the number of ticks since 0001-01-01T00:00:00.0000000 UTC
9895            getTicks: function (d) {
9896                if (d.ticks) {
9897                    return d.ticks;
9898                }
9899
9900                var kind = (d.kind !== undefined) ? d.kind : 0;
9901
9902                if (kind === 1) {
9903                    d.ticks = System.Int64(d.getTime()).mul(10000).add(this.$getMinOffset());
9904                } else {
9905                    d.ticks = System.Int64(d.getTime()).mul(10000).add(this.$getMinOffset()).sub(this.$getTzOffset(d));
9906                }
9907
9908                return d.ticks;
9909            },
9910
9911            create: function (year, month, day, hour, minute, second, millisecond, kind) {
9912                year = (year !== undefined) ? year : new Date().getFullYear();
9913                month = (month !== undefined) ? month : new Date().getMonth() + 1;
9914                day = (day !== undefined) ? day : 1;
9915                hour = (hour !== undefined) ? hour : 0;
9916                minute = (minute !== undefined) ? minute : 0;
9917                second = (second !== undefined) ? second : 0;
9918                millisecond = (millisecond !== undefined) ? millisecond : 0;
9919                kind = (kind !== undefined) ? kind : 0;
9920
9921                var d;
9922
9923                if (kind === 1) {
9924                    d = new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
9925                    d.setUTCFullYear(year);
9926                } else {
9927                    d = new Date(year, month - 1, day, hour, minute, second, millisecond);
9928                    d.setFullYear(year);
9929                }
9930
9931                d.kind = kind;
9932                d.ticks = this.getTicks(d);
9933
9934                return d;
9935            },
9936
9937            create$2: function (ticks, kind) {
9938                ticks = System.Int64.is64Bit(ticks) ? ticks : System.Int64(ticks);
9939
9940                var d;
9941
9942                if (ticks.lt(this.TicksPerDay)) {
9943                    d = new Date(0);
9944                    d.setMilliseconds(d.getMilliseconds() + this.$getTzOffset(d).div(10000).toNumber());
9945                    d.setFullYear(1);
9946                } else {
9947                    d = new Date(ticks.sub(this.$getMinOffset()).div(10000).toNumber());
9948
9949                    if (kind !== 1) {
9950                        d.setTime(d.getTime() + (d.getTimezoneOffset() * 60000));
9951                    }
9952                }
9953
9954                d.kind = (kind !== undefined) ? kind : 0;
9955                d.ticks = ticks;
9956
9957                return d;
9958            },
9959
9960            getToday: function () {
9961                var d = this.getNow()
9962
9963                d.setHours(0);
9964                d.setMinutes(0);
9965                d.setSeconds(0);
9966                d.setMilliseconds(0);
9967
9968                return d;
9969            },
9970
9971            getNow: function () {
9972                var d = new Date();
9973
9974                d.kind = 2;
9975
9976                return d;
9977            },
9978
9979            getUtcNow: function () {
9980                var d = new Date();
9981
9982                d.kind = 1;
9983
9984                return d;
9985            },
9986
9987            getTimeOfDay: function (d) {
9988                var dt = this.getDate(d);
9989
9990                return new System.TimeSpan((d - dt) * 10000);
9991            },
9992
9993            getKind: function (d) {
9994                d.kind = (d.kind !== undefined) ? d.kind : 0
9995
9996                return d.kind;
9997            },
9998
9999            specifyKind: function (d, kind) {
10000                var dt = new Date(d.getTime());
10001                dt.kind = kind;
10002                dt.ticks = d.ticks !== undefined ? d.ticks : this.getTicks(dt);
10003
10004                return dt;
10005            },
10006
10007            $FileTimeOffset: System.Int64("584388").mul(System.Int64(864e9)),
10008
10009            FromFileTime: function (fileTime) {
10010                return this.toLocalTime(this.FromFileTimeUtc(fileTime));
10011            },
10012
10013            FromFileTimeUtc: function (fileTime) {
10014                fileTime = System.Int64.is64Bit(fileTime) ? fileTime : System.Int64(fileTime);
10015
10016                return this.create$2(fileTime.add(this.$FileTimeOffset), 1);
10017            },
10018
10019            ToFileTime: function (d) {
10020                return this.ToFileTimeUtc(this.toUniversalTime(d));
10021            },
10022
10023            ToFileTimeUtc: function (d) {
10024                return (this.getKind(d) !== 0) ? this.getTicks(this.toUniversalTime(d)) : this.getTicks(d);
10025            },
10026
10027            isUseGenitiveForm: function (format, index, tokenLen, patternToMatch) {
10028                var i,
10029                    repeat = 0;
10030
10031                for (i = index - 1; i >= 0 && format[i] !== patternToMatch; i--) { }
10032
10033                if (i >= 0) {
10034                    while (--i >= 0 && format[i] === patternToMatch) {
10035                        repeat++;
10036                    }
10037
10038                    if (repeat <= 1) {
10039                        return true;
10040                    }
10041                }
10042
10043                for (i = index + tokenLen; i < format.length && format[i] !== patternToMatch; i++) { }
10044
10045                if (i < format.length) {
10046                    repeat = 0;
10047
10048                    while (++i < format.length && format[i] === patternToMatch) {
10049                        repeat++;
10050                    }
10051
10052                    if (repeat <= 1) {
10053                        return true;
10054                    }
10055                }
10056
10057                return false;
10058            },
10059
10060            format: function (d, f, p) {
10061                var me = this,
10062                    kind = d.kind || 0,
10063                    isUtc = (kind === 1 || ["u", "r", "R"].indexOf(f) > -1),
10064                    df = (p || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.DateTimeFormatInfo),
10065                    year = isUtc ? d.getUTCFullYear() : d.getFullYear(),
10066                    month = isUtc ? d.getUTCMonth() : d.getMonth(),
10067                    dayOfMonth = isUtc ? d.getUTCDate() : d.getDate(),
10068                    dayOfWeek = isUtc ? d.getUTCDay() : d.getDay(),
10069                    hour = isUtc ? d.getUTCHours() : d.getHours(),
10070                    minute = isUtc ? d.getUTCMinutes() : d.getMinutes(),
10071                    second = isUtc ? d.getUTCSeconds() : d.getSeconds(),
10072                    millisecond = isUtc ? d.getUTCMilliseconds() : d.getMilliseconds(),
10073                    timezoneOffset = d.getTimezoneOffset(),
10074                    formats;
10075
10076                f = f || "G";
10077
10078                if (f.length === 1) {
10079                    formats = df.getAllDateTimePatterns(f, true);
10080                    f = formats ? formats[0] : f;
10081                } else if (f.length === 2 && f.charAt(0) === "%") {
10082                    f = f.charAt(1);
10083                }
10084
10085                var removeDot = false;
10086
10087                f = f.replace(/(\\.|'[^']*'|"[^"]*"|d{1,4}|M{1,4}|yyyy|yy|y|HH?|hh?|mm?|ss?|tt?|u|f{1,7}|F{1,7}|K|z{1,3}|\:|\/)/g,
10088                    function (match, group, index) {
10089                        var part = match;
10090
10091                        switch (match) {
10092                            case "dddd":
10093                                part = df.dayNames[dayOfWeek];
10094
10095                                break;
10096                            case "ddd":
10097                                part = df.abbreviatedDayNames[dayOfWeek];
10098
10099                                break;
10100                            case "dd":
10101                                part = dayOfMonth < 10 ? "0" + dayOfMonth : dayOfMonth;
10102
10103                                break;
10104                            case "d":
10105                                part = dayOfMonth;
10106
10107                                break;
10108                            case "MMMM":
10109                                if (me.isUseGenitiveForm(f, index, 4, "d")) {
10110                                    part = df.monthGenitiveNames[month];
10111                                } else {
10112                                    part = df.monthNames[month];
10113                                }
10114
10115                                break;
10116                            case "MMM":
10117                                if (me.isUseGenitiveForm(f, index, 3, "d")) {
10118                                    part = df.abbreviatedMonthGenitiveNames[month];
10119                                } else {
10120                                    part = df.abbreviatedMonthNames[month];
10121                                }
10122
10123                                break;
10124                            case "MM":
10125                                part = (month + 1) < 10 ? "0" + (month + 1) : (month + 1);
10126
10127                                break;
10128                            case "M":
10129                                part = month + 1;
10130
10131                                break;
10132                            case "yyyy":
10133                                part = ("0000" + year).substring(year.toString().length);
10134
10135                                break;
10136                            case "yy":
10137                                part = (year % 100).toString();
10138
10139                                if (part.length === 1) {
10140                                    part = "0" + part;
10141                                }
10142
10143                                break;
10144                            case "y":
10145                                part = year % 100;
10146
10147                                break;
10148                            case "h":
10149                            case "hh":
10150                                part = hour % 12;
10151
10152                                if (!part) {
10153                                    part = "12";
10154                                } else if (match === "hh" && part.length === 1) {
10155                                    part = "0" + part;
10156                                }
10157
10158                                break;
10159                            case "HH":
10160                                part = hour.toString();
10161
10162                                if (part.length === 1) {
10163                                    part = "0" + part;
10164                                }
10165
10166                                break;
10167                            case "H":
10168                                part = hour;
10169                                break;
10170                            case "mm":
10171                                part = minute.toString();
10172
10173                                if (part.length === 1) {
10174                                    part = "0" + part;
10175                                }
10176
10177                                break;
10178                            case "m":
10179                                part = minute;
10180
10181                                break;
10182                            case "ss":
10183                                part = second.toString();
10184
10185                                if (part.length === 1) {
10186                                    part = "0" + part;
10187                                }
10188
10189                                break;
10190                            case "s":
10191                                part = second;
10192                                break;
10193                            case "t":
10194                            case "tt":
10195                                part = (hour < 12) ? df.amDesignator : df.pmDesignator;
10196
10197                                if (match === "t") {
10198                                    part = part.charAt(0);
10199                                }
10200
10201                                break;
10202                            case "F":
10203                            case "FF":
10204                            case "FFF":
10205                            case "FFFF":
10206                            case "FFFFF":
10207                            case "FFFFFF":
10208                            case "FFFFFFF":
10209                                part = millisecond.toString();
10210
10211                                if (part.length < 3) {
10212                                    part = Array(4 - part.length).join("0") + part;
10213                                }
10214
10215                                part = part.substr(0, match.length);
10216
10217                                var c = '0',
10218                                    i = part.length - 1;
10219
10220                                for (; i >= 0 && part.charAt(i) === c; i--);
10221                                part = part.substring(0, i + 1);
10222
10223                                removeDot = part.length == 0;
10224
10225                                break;
10226                            case "f":
10227                            case "ff":
10228                            case "fff":
10229                            case "ffff":
10230                            case "fffff":
10231                            case "ffffff":
10232                            case "fffffff":
10233                                part = millisecond.toString();
10234
10235                                if (part.length < 3) {
10236                                    part = Array(4 - part.length).join("0") + part;
10237                                }
10238
10239                                var ln = match === "u" ? 7 : match.length;
10240                                if (part.length < ln) {
10241                                    part = part + Array(8 - part.length).join("0");
10242                                }
10243
10244                                part = part.substr(0, ln);
10245
10246                                break;
10247                            case "z":
10248                                part = timezoneOffset / 60;
10249                                part = ((part >= 0) ? "-" : "+") + Math.floor(Math.abs(part));
10250
10251                                break;
10252                            case "K":
10253                            case "zz":
10254                            case "zzz":
10255                                if (kind === 0) {
10256                                    part = "";
10257                                } else if (kind === 1) {
10258                                    part = "Z";
10259                                } else {
10260                                    part = timezoneOffset / 60;
10261                                    part = ((part > 0) ? "-" : "+") + System.String.alignString(Math.floor(Math.abs(part)).toString(), 2, "0", 2);
10262
10263                                    if (match === "zzz" || match === "K") {
10264                                        part += df.timeSeparator + System.String.alignString(Math.floor(Math.abs(timezoneOffset % 60)).toString(), 2, "0", 2);
10265                                    }
10266                                }
10267
10268                                break;
10269                            case ":":
10270                                part = df.timeSeparator;
10271
10272                                break;
10273                            case "/":
10274                                part = df.dateSeparator;
10275
10276                                break;
10277                            default:
10278                                part = match.substr(1, match.length - 1 - (match.charAt(0) !== "\\"));
10279
10280                                break;
10281                        }
10282
10283                        return part;
10284                    });
10285
10286                if (removeDot) {
10287                    if (System.String.endsWith(f, ".")) {
10288                        f = f.substring(0, f.length - 1);
10289                    } else if (System.String.endsWith(f, ".Z")) {
10290                        f = f.substring(0, f.length - 2) + "Z";
10291                    }
10291 else if (kind === 2 && f.match(/\.([+-])/g) !== null) {
10292                        f = f.replace(/\.([+-])/g, '$1');
10293                    }
10294                }
10295
10296                return f;
10297            },
10298
10299            parse: function (value, provider, utc, silent) {
10300                var d = this.parseExact(value, null, provider, utc, true);
10301
10302                if (d !== null) {
10303                    return d;
10304                }
10305
10306                d = Date.parse(value);
10307
10308                if (!isNaN(d)) {
10309                    return new Date(d);
10310                } else if (!silent) {
10311                    throw new System.FormatException.$ctor1("String does not contain a valid string representation of a date and time.");
10312                }
10313            },
10314
10315            parseExact: function (str, format, provider, utc, silent) {
10316                if (!format) {
10317                    format = ["G", "g", "F", "f", "D", "d", "R", "r", "s", "S", "U", "u", "O", "o", "Y", "y", "M", "m", "T", "t"];
10318                }
10319
10320                if (H5.isArray(format)) {
10321                    var j = 0,
10322                        d;
10323
10324                    for (j; j < format.length; j++) {
10325                        d = this.parseExact(str, format[j], provider, utc, true);
10326
10327                        if (d != null) {
10328                            return d;
10329                        }
10330                    }
10331
10332                    if (silent) {
10333                        return null;
10334                    }
10335
10336                    throw new System.FormatException.$ctor1("String does not contain a valid string representation of a date and time.");
10337                } else {
10338                    // TODO: The code below assumes that there are no quotation marks around the UTC/Z format token (the format patterns
10339                    // used by H5 appear to use quotation marks throughout (see universalSortableDateTimePattern), including
10340                    // in the recent Newtonsoft.Json.JsonConvert release).
10341                    // Until the above is sorted out, manually remove quotation marks to get UTC times parsed correctly.
10342                    format = format.replace("'Z'", "Z");
10343                }
10344
10345                var now = new Date(),
10346                    df = (provider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.DateTimeFormatInfo),
10347                    am = df.amDesignator,
10348                    pm = df.pmDesignator,
10349                    idx = 0,
10350                    index = 0,
10351                    i = 0,
10352                    c,
10353                    token,
10354                    year = now.getFullYear(),
10355                    month = now.getMonth() + 1,
10356                    date = now.getDate(),
10357                    hh = 0,
10358                    mm = 0,
10359                    ss = 0,
10360                    ff = 0,
10361                    tt = "",
10362                    zzh = 0,
10363                    zzm = 0,
10364                    zzi,
10365                    sign,
10366                    neg,
10367                    names,
10368                    name,
10369                    invalid = false,
10370                    inQuotes = false,
10371                    tokenMatched,
10372                    formats,
10373                    kind = 0,
10374                    adjust = false,
10375                    offset = 0;
10376
10377                if (str == null) {
10378                    throw new System.ArgumentNullException.$ctor1("str");
10379                }
10380
10381                format = format || "G";
10382
10383                if (format.length === 1) {
10384                    formats = df.getAllDateTimePatterns(format, true);
10385                    format = formats ? formats[0] : format;
10386                } else if (format.length === 2 && format.charAt(0) === "%") {
10387                    format = format.charAt(1);
10388                }
10389
10390                while (index < format.length) {
10391                    c = format.charAt(index);
10392                    token = "";
10393
10394                    if (inQuotes === "\\") {
10395                        token += c;
10396                        index++;
10397                    } else {
10398                        var nextChar = format.charAt(index + 1);
10399                        if (c === '.' && str.charAt(idx) !== c && (nextChar === 'F' || nextChar === 'f')) {
10400                            index++;
10401                            c = nextChar;
10402                        }
10403
10404                        while ((format.charAt(index) === c) && (index < format.length)) {
10405                            token += c;
10406                            index++;
10407                        }
10408                    }
10409
10410                    tokenMatched = true;
10411
10412                    if (!inQuotes) {
10413                        if (token === "yyyy" || token === "yy" || token === "y") {
10414                            if (token === "yyyy") {
10415                                year = this.subparseInt(str, idx, 4, 4);
10416                            } else if (token === "yy") {
10417                                year = this.subparseInt(str, idx, 2, 2);
10418                            } else if (token === "y") {
10419                                year = this.subparseInt(str, idx, 2, 4);
10420                            }
10421
10422                            if (year == null) {
10423                                invalid = true;
10424                                break;
10425                            }
10426
10427                            idx += year.length;
10428
10429                            if (year.length === 2) {
10430                                year = ~~year;
10431                                year = (year > 30 ? 1900 : 2000) + year;
10432                            }
10433                        } else if (token === "MMM" || token === "MMMM") {
10434                            month = 0;
10435
10436                            if (token === "MMM") {
10437                                if (this.isUseGenitiveForm(format, index, 3, "d")) {
10438                                    names = df.abbreviatedMonthGenitiveNames;
10439                                } else {
10440                                    names = df.abbreviatedMonthNames;
10441                                }
10442                            } else {
10443                                if (this.isUseGenitiveForm(format, index, 4, "d")) {
10444                                    names = df.monthGenitiveNames;
10445                                } else {
10446                                    names = df.monthNames;
10447                                }
10448                            }
10449
10450                            for (i = 0; i < names.length; i++) {
10451                                name = names[i];
10452
10453                                if (str.substring(idx, idx + name.length).toLowerCase() === name.toLowerCase()) {
10454                                    month = (i % 12) + 1;
10455                                    idx += name.length;
10456
10457                                    break;
10458                                }
10459                            }
10460
10461                            if ((month < 1) || (month > 12)) {
10462                                invalid = true;
10463
10464                                break;
10465                            }
10466                        } else if (token === "MM" || token === "M") {
10467                            month = this.subparseInt(str, idx, token.length, 2);
10468
10469                            if (month == null || month < 1 || month > 12) {
10470                                invalid = true;
10471
10472                                break;
10473                            }
10474
10475                            idx += month.length;
10476                        } else if (token === "dddd" || token === "ddd") {
10477                            names = token === "ddd" ? df.abbreviatedDayNames : df.dayNames;
10478
10479                            for (i = 0; i < names.length; i++) {
10480                                name = names[i];
10481
10482                                if (str.substring(idx, idx + name.length).toLowerCase() === name.toLowerCase()) {
10483                                    idx += name.length;
10484
10485                                    break;
10486                                }
10487                            }
10488                        } else if (token === "dd" || token === "d") {
10489                            date = this.subparseInt(str, idx, token.length, 2);
10490
10491                            if (date == null || date < 1 || date > 31) {
10492                                invalid = true;
10493
10494                                break;
10495                            }
10496
10497                            idx += date.length;
10498                        } else if (token === "hh" || token === "h") {
10499                            hh = this.subparseInt(str, idx, token.length, 2);
10500
10501                            if (hh == null || hh < 1 || hh > 12) {
10502                                invalid = true;
10503
10504                                break;
10505                            }
10506
10507                            idx += hh.length;
10508                        } else if (token === "HH" || token === "H") {
10509                            hh = this.subparseInt(str, idx, token.length, 2);
10510
10511                            if (hh == null || hh < 0 || hh > 23) {
10512                                invalid = true;
10513
10514                                break;
10515                            }
10516
10517                            idx += hh.length;
10518                        } else if (token === "mm" || token === "m") {
10519                            mm = this.subparseInt(str, idx, token.length, 2);
10520
10521                            if (mm == null || mm < 0 || mm > 59) {
10522                                return null;
10523                            }
10524
10525                            idx += mm.length;
10526                        } else if (token === "ss" || token === "s") {
10527                            ss = this.subparseInt(str, idx, token.length, 2);
10528
10529                            if (ss == null || ss < 0 || ss > 59) {
10530                                invalid = true;
10531
10532                                break;
10533                            }
10534
10535                            idx += ss.length;
10536                        } else if (token === "u") {
10537                            ff = this.subparseInt(str, idx, 1, 7);
10538
10539                            if (ff == null) {
10540                                invalid = true;
10541
10542                                break;
10543                            }
10544
10545                            idx += ff.length;
10546
10547                            if (ff.length > 3) {
10548                                ff = ff.substring(0, 3);
10549                            }
10550                        } else if (token.match(/f{1,7}/) !== null) {
10551                            ff = this.subparseInt(str, idx, token.length, 7);
10552
10553                            if (ff == null) {
10554                                invalid = true;
10555
10556                                break;
10557                            }
10558
10559                            idx += ff.length;
10560
10561                            if (ff.length > 3) {
10562                                ff = ff.substring(0, 3);
10563                            }
10564                        } else if (token.match(/F{1,7}/) !== null) {
10565                            ff = this.subparseInt(str, idx, 0, 7);
10566
10567                            if (ff !== null) {
10568                                idx += ff.length;
10569
10570                                if (ff.length > 3) {
10571                                    ff = ff.substring(0, 3);
10572                                }
10573                            }
10574                        } else if (token === "t") {
10575                            if (str.substring(idx, idx + 1).toLowerCase() === am.charAt(0).toLowerCase()) {
10576                                tt = am;
10577                            } else if (str.substring(idx, idx + 1).toLowerCase() === pm.charAt(0).toLowerCase()) {
10578                                tt = pm;
10579                            } else {
10580                                invalid = true;
10581
10582                                break;
10583                            }
10584
10585                            idx += 1;
10586                        } else if (token === "tt") {
10587                            if (str.substring(idx, idx + 2).toLowerCase() === am.toLowerCase()) {
10588                                tt = am;
10589                            } else if (str.substring(idx, idx + 2).toLowerCase() === pm.toLowerCase()) {
10590                                tt = pm;
10591                            } else {
10592                                invalid = true;
10593
10594                                break;
10595                            }
10596
10597                            idx += 2;
10598                        } else if (token === "z" || token === "zz") {
10599                            sign = str.charAt(idx);
10600
10601                            if (sign === "-") {
10602                                neg = true;
10603                            } else if (sign === "+") {
10604                                neg = false;
10605                            } else {
10606                                invalid = true;
10607
10608                                break;
10609                            }
10610
10611                            idx++;
10612
10613                            zzh = this.subparseInt(str, idx, 1, 2);
10614
10615                            if (zzh == null || zzh > 14) {
10616                                invalid = true;
10617
10618                                break;
10619                            }
10620
10621                            idx += zzh.length;
10622
10623                            offset = zzh * 60 * 60 * 1000;
10624
10625                            if (neg) {
10626                                offset = -offset;
10627                            }
10628                        } else if (token === "Z") {
10629                            var ch = str.substring(idx, idx + 1);
10630                            if (ch === "Z" || ch === "z") {
10631                                kind = 1;
10632                                idx += 1;
10633                            } else {
10634                                invalid = true;
10635                            }
10636
10637                            break;
10638
10639                        } else if (token === "zzz" || token === "K") {
10640                            if (str.substring(idx, idx + 1) === "Z") {
10641                                kind = 2;
10642                                adjust = true;
10643                                idx += 1;
10644
10645                                break;
10646                            }
10647
10648                            name = str.substring(idx, idx + 6);
10649
10650                            if (name === "") {
10651                                kind = 0;
10652
10653                                break;
10654                            }
10655
10656                            idx += name.length;
10657
10658                            if (name.length !== 6 && name.length !== 5) {
10659                                invalid = true;
10660
10661                                break;
10662                            }
10663
10664                            sign = name.charAt(0);
10665
10666                            if (sign === "-") {
10667                                neg = true;
10668                            } else if (sign === "+") {
10669                                neg = false;
10670                            } else {
10671                                invalid = true;
10672
10673                                break;
10674                            }
10675
10676                            zzi = 1;
10677                            zzh = this.subparseInt(name, zzi, 1, name.length === 6 ? 2 : 1);
10678
10679                            if (zzh == null || zzh > 14) {
10680                                invalid = true;
10681
10682                                break;
10683                            }
10684
10685                            zzi += zzh.length;
10686
10687                            if (name.charAt(zzi) !== df.timeSeparator) {
10688                                invalid = true;
10689
10690                                break;
10691                            }
10692
10693                            zzi++;
10694
10695                            zzm = this.subparseInt(name, zzi, 1, 2);
10696
10697                            if (zzm == null || zzh > 59) {
10698                                invalid = true;
10699
10700                                break;
10701                            }
10702
10703                            offset = zzh * 60 * 60 * 1000 + zzm * 60 * 1000;
10704
10705                            if (neg) {
10706                                offset = -offset;
10707                            }
10708
10709                            kind = 2;
10710                        } else {
10711                            tokenMatched = false;
10712                        }
10713                    }
10714
10715                    if (inQuotes || !tokenMatched) {
10716                        name = str.substring(idx, idx + token.length);
10717
10718                        if (!inQuotes && name === ":" && (token === df.timeSeparator || token === ":")) {
10719
10720                        } else if ((!inQuotes && ((token === ":" && name !== df.timeSeparator) || (token === "/" && name !== df.dateSeparator))) || (name !== token && token !== "'" && token !== '"' && token !== "\\")) {
10721                            invalid = true;
10722
10723                            break;
10724                        }
10725
10726                        if (inQuotes === "\\") {
10727                            inQuotes = false;
10728                        }
10729
10730                        if (token !== "'" && token !== '"' && token !== "\\") {
10731                            idx += token.length;
10732                        } else {
10733                            if (inQuotes === false) {
10734                                inQuotes = token;
10735                            } else {
10736                                if (inQuotes !== token) {
10737                                    invalid = true;
10738                                    break;
10739                                }
10740
10741                                inQuotes = false;
10742                            }
10743                        }
10744                    }
10745                }
10746
10747                if (inQuotes) {
10748                    invalid = true;
10749                }
10750
10751                if (!invalid) {
10752                    if (idx !== str.length) {
10753                        invalid = true;
10754                    } else if (month === 2) {
10755                        if (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) {
10756                            if (date > 29) {
10757                                invalid = true;
10758                            }
10759                        } else if (date > 28) {
10760                            invalid = true;
10761                        }
10762                    } else if ((month === 4) || (month === 6) || (month === 9) || (month === 11)) {
10763                        if (date > 30) {
10764                            invalid = true;
10765                        }
10766                    }
10767                }
10768
10769                if (invalid) {
10770                    if (silent) {
10771                        return null;
10772                    }
10773
10774                    throw new System.FormatException.$ctor1("String does not contain a valid string representation of a date and time.");
10775                }
10776
10777                if (tt) {
10778                    if (hh < 12 && tt === pm) {
10779                        hh = hh - 0 + 12;
10780                    } else if (hh > 11 && tt === am) {
10781                        hh -= 12;
10782                    }
10783                }
10784
10785                var d = this.create(year, month, date, hh, mm, ss, ff, kind);
10786
10787                if (kind === 2) {
10788                    if (adjust === true) {
10789                        d = new Date(d.getTime() - d.getTimezoneOffset() * 60 * 1000);
10790                    } else if (offset !== 0) {
10791                        d = new Date(d.getTime() - d.getTimezoneOffset() * 60 * 1000);
10792                        d = this.addMilliseconds(d, -offset);
10793                    }
10794
10795                    d.kind = kind;
10796                }
10797
10798                return d;
10799            },
10800
10801            subparseInt: function (str, index, min, max) {
10802                var x,
10803                    token;
10804
10805                for (x = max; x >= min; x--) {
10806                    token = str.substring(index, index + x);
10807
10808                    if (token.length < min) {
10809                        return null;
10810                    }
10811
10812                    if (/^\d+$/.test(token)) {
10813                        return token;
10814                    }
10815                }
10816
10817                return null;
10818            },
10819
10820            tryParse: function (value, provider, result, utc) {
10821                result.v = this.parse(value, provider, utc, true);
10822
10823                if (result.v == null) {
10824                    result.v = this.getMinValue();
10825
10826                    return false;
10827                }
10828
10829                return true;
10830            },
10831
10832            tryParseExact: function (v, f, p, r, utc) {
10833                r.v = this.parseExact(v, f, p, utc, true);
10834
10835                if (r.v == null) {
10836                    r.v = this.getMinValue();
10837
10838                    return false;
10839                }
10840
10841                return true;
10842            },
10843
10844            isDaylightSavingTime: function (d) {
10845                if (d.kind !== undefined && d.kind === 1) {
10846                    return false;
10847                }
10848
10849                var tmp = new Date(d.getTime());
10850
10851                tmp.setMonth(0);
10852                tmp.setDate(1);
10853
10854                return tmp.getTimezoneOffset() !== d.getTimezoneOffset();
10855            },
10856
10857            dateAddSubTimeSpan: function (d, t, direction) {
10858                var ticks = t.getTicks().mul(direction),
10859                    dt = new Date(d.getTime() + ticks.div(10000).toNumber());
10860
10861                dt.kind = d.kind;
10862                dt.ticks = this.getTicks(dt);
10863
10864                return dt;
10865            },
10866
10867            subdt: function (d, t) {
10868                return this.dateAddSubTimeSpan(d, t, -1);
10869            },
10870
10871            adddt: function (d, t) {
10872                return this.dateAddSubTimeSpan(d, t, 1);
10873            },
10874
10875            subdd: function (a, b) {
10876                var offset = 0,
10877                    ticksA = this.getTicks(a),
10878                    ticksB = this.getTicks(b),
10879                    valA = ticksA.toNumber(),
10880                    valB = ticksB.toNumber(),
10881                    spread = ticksA.sub(ticksB);
10882
10883                if ((valA === 0 && valB !== 0) || (valB === 0 && valA !== 0)) {
10884                    offset = Math.round((spread.toNumberDivided(6e8) - (Math.round(spread.toNumberDivided(9e9)) * 15)) * 6e8);
10885                }
10886
10887                return new System.TimeSpan(spread.sub(offset));
10888            },
10889
10890            addYears: function (d, v) {
10891                return this.addMonths(d, v * 12);
10892            },
10893
10894            addMonths: function (d, v) {
10895                var dt = new Date(d.getTime()),
10896                    day = d.getDate();
10897
10898                dt.setDate(1);
10899                dt.setMonth(dt.getMonth() + v);
10900                dt.setDate(Math.min(day, this.getDaysInMonth(dt.getFullYear(), dt.getMonth() + 1)));
10901                dt.kind = (d.kind !== undefined) ? d.kind : 0;
10902                dt.ticks = this.getTicks(dt);
10903
10904                return dt;
10905            },
10906
10907            addDays: function (d, v) {
10908                var kind = (d.kind !== undefined) ? d.kind : 0,
10909                    dt = new Date(d.getTime());
10910
10911                if (kind === 1) {
10912                    dt.setUTCDate(dt.getUTCDate() + (Math.floor(v) * 1));
10913
10914                    if (v % 1 !== 0) {
10915                        dt.setUTCMilliseconds(dt.getUTCMilliseconds() + Math.round((v % 1) * 864e5));
10916                    }
10917                } else {
10918                    dt.setDate(dt.getDate() + (Math.floor(v) * 1));
10919
10920                    if (v % 1 !== 0) {
10921                        dt.setMilliseconds(dt.getMilliseconds() + Math.round((v % 1) * 864e5));
10922                    }
10923                }
10924
10925                dt.kind = kind;
10926                dt.ticks = this.getTicks(dt);
10927
10928                return dt;
10929            },
10930
10931            addHours: function (d, v) {
10932                return this.addMilliseconds(d, v * 36e5);
10933            },
10934
10935            addMinutes: function (d, v) {
10936                return this.addMilliseconds(d, v * 6e4);
10937            },
10938
10939            addSeconds: function (d, v) {
10940                return this.addMilliseconds(d, v * 1e3);
10941            },
10942
10943            addMilliseconds: function (d, v) {
10944                var dt = new Date(d.getTime());
10945                dt.setMilliseconds(dt.getMilliseconds() + v)
10946                dt.kind = (d.kind !== undefined) ? d.kind : 0;
10947                dt.ticks = this.getTicks(dt);
10948
10949                return dt;
10950            },
10951
10952            addTicks: function (d, v) {
10953                v = System.Int64.is64Bit(v) ? v : System.Int64(v);
10954
10955                var dt = new Date(d.getTime()),
10956                    ticks = this.getTicks(d).add(v);
10957
10958                dt.setMilliseconds(dt.getMilliseconds() + v.div(10000).toNumber())
10959                dt.ticks = ticks;
10960                dt.kind = (d.kind !== undefined) ? d.kind : 0;
10961
10962                return dt;
10963            },
10964
10965            add: function (d, value) {
10966                return this.addTicks(d, value.getTicks());
10967            },
10968
10969            subtract: function (d, value) {
10970                return this.addTicks(d, value.getTicks().mul(-1));
10971            },
10972
10973            // Replaced leap year calculation for performance:
10974            // https://jsperf.com/leapyear-calculation/1
10975            getIsLeapYear: function (year) {
10976                if ((year & 3) != 0) {
10977                    return false;
10978                }
10979
10980                return ((year % 100) != 0 || (year % 400) == 0);
10981            },
10982
10983            getDaysInMonth: function (year, month) {
10984                return [31, (this.getIsLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
10985            },
10986
10987            // Optimized as per: https://jsperf.com/get-day-of-year
10988            getDayOfYear: function (d) {
10989                var dt = this.getDate(d),
10990                    mn = dt.getMonth(),
10991                    dn = dt.getDate(),
10992                    dayOfYear = this.YearDaysByMonth[mn] + dn;
10993
10994                if (mn > 1 && this.getIsLeapYear(dt.getFullYear())) {
10995                    dayOfYear++;
10996                }
10997
10998                return dayOfYear;
10999            },
11000
11001            getDate: function (d) {
11002                var kind = (d.kind !== undefined) ? d.kind : 0,
11003                    dt = new Date(d.getTime());
11004
11005                if (kind === 1) {
11006                    dt.setUTCHours(0);
11007                    dt.setUTCMinutes(0);
11008                    dt.setUTCSeconds(0);
11009                    dt.setUTCMilliseconds(0);
11010                } else {
11011                    dt.setHours(0);
11012                    dt.setMinutes(0);
11013                    dt.setSeconds(0);
11014                    dt.setMilliseconds(0);
11015                }
11016
11017                dt.ticks = this.getTicks(dt);
11018                dt.kind = kind;
11019
11020                return dt;
11021            },
11022
11023            getDayOfWeek: function (d) {
11024                return d.getDay();
11025            },
11026
11027            getYear: function (d) {
11028                var kind = (d.kind !== undefined) ? d.kind : 0,
11029                    ticks = this.getTicks(d);
11030
11031                if (ticks.lt(this.TicksPerDay)) {
11032                    return 1;
11033                }
11034
11035                return kind === 1 ? d.getUTCFullYear() : d.getFullYear();
11036            },
11037
11038            getMonth: function (d) {
11039                var kind = (d.kind !== undefined) ? d.kind : 0,
11040                    ticks = this.getTicks(d);
11041
11042                if (ticks.lt(this.TicksPerDay)) {
11043                    return 1;
11044                }
11045
11046                return kind === 1 ? d.getUTCMonth() + 1 : d.getMonth() + 1;
11047            },
11048
11049            getDay: function (d) {
11050                var kind = (d.kind !== undefined) ? d.kind : 0,
11051                    ticks = this.getTicks(d);
11052
11053                if (ticks.lt(this.TicksPerDay)) {
11054                    return 1;
11055                }
11056
11057                return kind === 1 ? d.getUTCDate() : d.getDate();
11058            },
11059
11060            getHour: function (d) {
11061                var kind = (d.kind !== undefined) ? d.kind : 0;
11062
11063                return kind === 1 ? d.getUTCHours() : d.getHours();
11064            },
11065
11066            getMinute: function (d) {
11067                var kind = (d.kind !== undefined) ? d.kind : 0;
11068
11069                return kind === 1 ? d.getUTCMinutes() : d.getMinutes();
11070            },
11071
11072            getSecond: function (d) {
11073                return d.getSeconds();
11074            },
11075
11076            getMillisecond: function (d) {
11077                return d.getMilliseconds();
11078            },
11079
11080            gt: function (a, b) {
11081                return (a != null && b != null) ? (this.getTicks(a).gt(this.getTicks(b))) : false;
11082            },
11083
11084            gte: function (a, b) {
11085                return (a != null && b != null) ? (this.getTicks(a).gte(this.getTicks(b))) : false;
11086            },
11087
11088            lt: function (a, b) {
11089                return (a != null && b != null) ? (this.getTicks(a).lt(this.getTicks(b))) : false;
11090            },
11091
11092            lte: function (a, b) {
11093                return (a != null && b != null) ? (this.getTicks(a).lte(this.getTicks(b))) : false;
11094            }
11095        }
11096    });
11097
11098    // @source TimeSpan.js
11099
11100    H5.define("System.TimeSpan", {
11101        inherits: [System.IComparable],
11102
11103        config: {
11104            alias: [
11105                "compareTo", ["System$IComparable$compareTo", "System$IComparable$1$compareTo", "System$IComparable$1System$TimeSpan$compareTo"]
11106            ]
11107        },
11108
11109        $kind: "struct",
11110        statics: {
11111            fromDays: function (value) {
11112                return new System.TimeSpan(value * 864e9);
11113            },
11114
11115            fromHours: function (value) {
11116                return new System.TimeSpan(value * 36e9);
11117            },
11118
11119            fromMilliseconds: function (value) {
11120                return new System.TimeSpan(value * 1e4);
11121            },
11122
11123            fromMinutes: function (value) {
11124                return new System.TimeSpan(value * 6e8);
11125            },
11126
11127            fromSeconds: function (value) {
11128                return new System.TimeSpan(value * 1e7);
11129            },
11130
11131            fromTicks: function (value) {
11132                return new System.TimeSpan(value);
11133            },
11134
11135            ctor: function () {
11136                this.zero = new System.TimeSpan(System.Int64.Zero);
11137                this.maxValue = new System.TimeSpan(System.Int64.MaxValue);
11138                this.minValue = new System.TimeSpan(System.Int64.MinValue);
11139            },
11140
11141            getDefaultValue: function () {
11142                return new System.TimeSpan(System.Int64.Zero);
11143            },
11144
11145            neg: function (t) {
11146                return H5.hasValue(t) ? (new System.TimeSpan(t.ticks.neg())) : null;
11147            },
11148
11149            sub: function (t1, t2) {
11150                return H5.hasValue$1(t1, t2) ? (new System.TimeSpan(t1.ticks.sub(t2.ticks))) : null;
11151            },
11152
11153            eq: function (t1, t2) {
11154                if (t1 === null && t2 === null) {
11155                    return true;
11156                }
11157
11158                return H5.hasValue$1(t1, t2) ? (t1.ticks.eq(t2.ticks)) : false;
11159            },
11160
11161            neq: function (t1, t2) {
11162                if (t1 === null && t2 === null) {
11163                    return false;
11164                }
11165
11166                return H5.hasValue$1(t1, t2) ? (t1.ticks.ne(t2.ticks)) : true;
11167            },
11168
11169            plus: function (t) {
11170                return H5.hasValue(t) ? (new System.TimeSpan(t.ticks)) : null;
11171            },
11172
11173            add: function (t1, t2) {
11174                return H5.hasValue$1(t1, t2) ? (new System.TimeSpan(t1.ticks.add(t2.ticks))) : null;
11175            },
11176
11177            gt: function (a, b) {
11178                return H5.hasValue$1(a, b) ? (a.ticks.gt(b.ticks)) : false;
11179            },
11180
11181            gte: function (a, b) {
11182                return H5.hasValue$1(a, b) ? (a.ticks.gte(b.ticks)) : false;
11183            },
11184
11185            lt: function (a, b) {
11186                return H5.hasValue$1(a, b) ? (a.ticks.lt(b.ticks)) : false;
11187            },
11188
11189            lte: function (a, b) {
11190                return H5.hasValue$1(a, b) ? (a.ticks.lte(b.ticks)) : false;
11191            },
11192
11193            timeSpanWithDays: /^(\-)?(\d+)[\.|:](\d+):(\d+):(\d+)(\.\d+)?/,
11194            timeSpanNoDays: /^(\-)?(\d+):(\d+):(\d+)(\.\d+)?/,
11195
11196            parse: function(value) {
11197                var match,
11198                    milliseconds;
11199
11200                function parseMilliseconds(value) {
11201                    return value ? parseFloat('0' + value) * 1000 : 0;
11202                }
11203
11204                if ((match = value.match(System.TimeSpan.timeSpanWithDays))) {
11205                    var ts = new System.TimeSpan(match[2], match[3], match[4], match[5], parseMilliseconds(match[6]));
11206
11207                    return match[1] ? new System.TimeSpan(ts.ticks.neg()) : ts;
11208                }
11209
11210                if ((match = value.match(System.TimeSpan.timeSpanNoDays))) {
11211                    var ts = new System.TimeSpan(0, match[2], match[3], match[4], parseMilliseconds(match[5]));
11212
11213                    return match[1] ? new System.TimeSpan(ts.ticks.neg()) : ts;
11214                }
11215
11216                return null;
11217            },
11218
11219            tryParse: function (value, provider, result) {
11220                result.v = this.parse(value);
11221
11222                if (result.v == null) {
11223                    result.v = this.minValue;
11224
11225                    return false;
11226                }
11227
11228                return true;
11229            }
11230        },
11231
11232        ctor: function () {
11233            this.$initialize();
11234            this.ticks = System.Int64.Zero;
11235
11236            if (arguments.length === 1) {
11237                this.ticks = arguments[0] instanceof System.Int64 ? arguments[0] : new System.Int64(arguments[0]);
11238            } else if (arguments.length === 3) {
11239                this.ticks = new System.Int64(arguments[0]).mul(60).add(arguments[1]).mul(60).add(arguments[2]).mul(1e7);
11240            } else if (arguments.length === 4) {
11241                this.ticks = new System.Int64(arguments[0]).mul(24).add(arguments[1]).mul(60).add(arguments[2]).mul(60).add(arguments[3]).mul(1e7);
11242            } else if (arguments.length === 5) {
11243                this.ticks = new System.Int64(arguments[0]).mul(24).add(arguments[1]).mul(60).add(arguments[2]).mul(60).add(arguments[3]).mul(1e3).add(arguments[4]).mul(1e4);
11244            }
11245        },
11246
11247        TimeToTicks: function (hour, minute, second) {
11248            var totalSeconds = System.Int64(hour).mul("3600").add(System.Int64(minute).mul("60")).add(System.Int64(second));
11249            return totalSeconds.mul("10000000");
11250        },
11251
11252        getTicks: function () {
11253            return this.ticks;
11254        },
11255
11256        getDays: function () {
11257            return this.ticks.div(864e9).toNumber();
11258        },
11259
11260        getHours: function () {
11261            return this.ticks.div(36e9).mod(24).toNumber();
11262        },
11263
11264        getMilliseconds: function () {
11265            return this.ticks.div(1e4).mod(1e3).toNumber();
11266        },
11267
11268        getMinutes: function () {
11269            return this.ticks.div(6e8).mod(60).toNumber();
11270        },
11271
11272        getSeconds: function () {
11273            return this.ticks.div(1e7).mod(60).toNumber();
11274        },
11275
11276        getTotalDays: function () {
11277            return this.ticks.toNumberDivided(864e9);
11278        },
11279
11280        getTotalHours: function () {
11281            return this.ticks.toNumberDivided(36e9);
11282        },
11283
11284        getTotalMilliseconds: function () {
11285            return this.ticks.toNumberDivided(1e4);
11286        },
11287
11288        getTotalMinutes: function () {
11289            return this.ticks.toNumberDivided(6e8);
11290        },
11291
11292        getTotalSeconds: function () {
11293            return this.ticks.toNumberDivided(1e7);
11294        },
11295
11296        get12HourHour: function () {
11297            return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours();
11298        },
11299
11300        add: function (ts) {
11301            return new System.TimeSpan(this.ticks.add(ts.ticks));
11302        },
11303
11304        subtract: function (ts) {
11305            return new System.TimeSpan(this.ticks.sub(ts.ticks));
11306        },
11307
11308        duration: function () {
11309            return new System.TimeSpan(this.ticks.abs());
11310        },
11311
11312        negate: function () {
11313            return new System.TimeSpan(this.ticks.neg());
11314        },
11315
11316        compareTo: function (other) {
11317            return this.ticks.compareTo(other.ticks);
11318        },
11319
11320        equals: function (other) {
11321            return H5.is(other, System.TimeSpan) ? other.ticks.eq(this.ticks) : false;
11322        },
11323
11324        equalsT: function (other) {
11325            return other.ticks.eq(this.ticks);
11326        },
11327
11328        format: function (formatStr, provider) {
11329            return this.toString(formatStr, provider);
11330        },
11331
11332        getHashCode: function () {
11333            return this.ticks.getHashCode();
11334        },
11335
11336        toString: function (formatStr, provider) {
11337            var ticks = this.ticks,
11338                result = "",
11339                me = this,
11340                dtInfo = (provider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.DateTimeFormatInfo),
11341                format = function (t, n, dir, cut) {
11342                    return System.String.alignString(Math.abs(t | 0).toString(), n || 2, "0", dir || 2, cut || false);
11343                },
11344                isNeg = ticks < 0;
11345
11346            if (formatStr) {
11347                return formatStr.replace(/(\\.|'[^']*'|"[^"]*"|dd?|HH?|hh?|mm?|ss?|tt?|f{1,7}|\:|\/)/g,
11348                    function (match, group, index) {
11349                        var part = match;
11350
11351                        switch (match) {
11352                            case "d":
11353                                return me.getDays();
11354                            case "dd":
11355                                return format(me.getDays());
11356                            case "H":
11357                                return me.getHours();
11358                            case "HH":
11359                                return format(me.getHours());
11360                            case "h":
11361                                return me.get12HourHour();
11362                            case "hh":
11363                                return format(me.get12HourHour());
11364                            case "m":
11365                                return me.getMinutes();
11366                            case "mm":
11367                                return format(me.getMinutes());
11368                            case "s":
11369                                return me.getSeconds();
11370                            case "ss":
11371                                return format(me.getSeconds());
11372                            case "t":
11373                                return ((me.getHours() < 12) ? dtInfo.amDesignator : dtInfo.pmDesignator).substring(0, 1);
11374                            case "tt":
11375                                return (me.getHours() < 12) ? dtInfo.amDesignator : dtInfo.pmDesignator;
11376                            case "f":
11377                            case "ff":
11378                            case "fff":
11379                            case "ffff":
11380                            case "fffff":
11381                            case "ffffff":
11382                            case "fffffff":
11383                                return format(me.getMilliseconds(), match.length, 1, true);
11384                            default:
11385                                return match.substr(1, match.length - 1 - (match.charAt(0) !== "\\"));
11386                        }
11387                    }
11388                );
11389            }
11390
11391            if (ticks.abs().gte(864e9)) {
11392                result += format(ticks.toNumberDivided(864e9), 1) + ".";
11393                ticks = ticks.mod(864e9);
11394            }
11395
11396            result += format(ticks.toNumberDivided(36e9)) + ":";
11397            ticks = ticks.mod(36e9);
11398            result += format(ticks.toNumberDivided(6e8) | 0) + ":";
11399            ticks = ticks.mod(6e8);
11400            result += format(ticks.toNumberDivided(1e7));
11401            ticks = ticks.mod(1e7);
11402
11403            if (ticks.gt(0)) {
11404                result += "." + format(ticks.toNumber(), 7);
11405            }
11406
11407            return (isNeg ? "-" : "") + result;
11408        }
11409    });
11410
11411    H5.Class.addExtend(System.TimeSpan, [System.IComparable$1(System.TimeSpan), System.IEquatable$1(System.TimeSpan)]);
11412
11413    // @source StringBuilder.js
11414
11415    H5.define("System.Text.StringBuilder", {
11416        ctor: function () {
11417            this.$initialize();
11418            this.buffer = [],
11419            this.capacity = 16;
11420
11421            if (arguments.length === 1) {
11422                this.append(arguments[0]);
11423            } else if (arguments.length === 2) {
11424                this.append(arguments[0]);
11425                this.setCapacity(arguments[1]);
11426            } else if (arguments.length >= 3) {
11427                this.append(arguments[0], arguments[1], arguments[2]);
11428                if (arguments.length === 4) {
11429                    this.setCapacity(arguments[3]);
11430                }
11431            }
11432        },
11433
11434        getLength: function () {
11435            if (this.buffer.length < 2) {
11436                return this.buffer[0] ? this.buffer[0].length : 0;
11437            }
11438
11439            var s = this.getString();
11440
11441            return s.length;
11442        },
11443
11444        setLength: function (value) {
11445            if (value === 0) {
11446                this.clear();
11447            } else if (value < 0) {
11448                throw new System.ArgumentOutOfRangeException.$ctor4("value", "Length cannot be less than zero");
11449            } else {
11450                var l = this.getLength();
11451
11452                if (value === l) {
11453                    return;
11454                }
11455
11456                var delta = value - l;
11457
11458                if (delta > 0) {
11459                    this.append("\0", delta);
11460                } else {
11461                    this.remove(l + delta, -delta);
11462                }
11463            }
11464        },
11465
11466        getCapacity: function () {
11467            var length = this.getLength();
11468
11469            return (this.capacity > length) ? this.capacity : length;
11470        },
11471
11472        setCapacity: function (value) {
11473            var length = this.getLength();
11474
11475            if (value > length) {
11476                this.capacity = value;
11477            }
11478        },
11479
11480        toString: function () {
11481            var s = this.getString();
11482
11483            if (arguments.length === 2) {
11484                var startIndex = arguments[0],
11485                    length = arguments[1];
11486
11487                this.checkLimits(s, startIndex, length);
11488
11489                return s.substr(startIndex, length);
11490            }
11491
11492            return s;
11493        },
11494
11495        append: function (value) {
11496            if (value == null) {
11497                return this;
11498            }
11499
11500            if (arguments.length === 2) {
11501                // append a char repeated count times
11502                var count = arguments[1];
11503
11504                if (count === 0) {
11505                    return this;
11506                } else if (count < 0) {
11507                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "cannot be less than zero");
11508                }
11509
11510                value = Array(count + 1).join(value).toString();
11511            } else if (arguments.length === 3) {
11512                // append a (startIndex, count) substring of value
11513                var startIndex = arguments[1],
11514                    count = arguments[2];
11515
11516                if (count === 0) {
11517                    return this;
11518                }
11519
11520                this.checkLimits(value, startIndex, count);
11521                value = value.substr(startIndex, count);
11522            }
11523
11524            this.buffer[this.buffer.length] = value;
11525            this.clearString();
11526
11527            return this;
11528        },
11529
11530        appendFormat: function (format) {
11531            return this.append(System.String.format.apply(System.String, arguments));
11532        },
11533
11534        clear: function () {
11535            this.buffer = [];
11536            this.clearString();
11537
11538            return this;
11539        },
11540
11541        appendLine: function () {
11542            if (arguments.length === 1) {
11543                this.append(arguments[0]);
11544            }
11545
11546            return this.append("\r\n");
11547        },
11548
11549        equals: function (sb) {
11550            if (sb == null) {
11551                return false;
11552            }
11553
11554            if (sb === this) {
11555                return true;
11556            }
11557
11558            return this.toString() === sb.toString();
11559        },
11560
11561        remove: function (startIndex, length) {
11562            var s = this.getString();
11563
11564            this.checkLimits(s, startIndex, length);
11565
11566            if (s.length === length && startIndex === 0) {
11567                // Optimization.  If we are deleting everything
11568                return this.clear();
11569            }
11570
11571            if (length > 0) {
11572                this.buffer = [];
11573                this.buffer[0] = s.substring(0, startIndex);
11574                this.buffer[1] = s.substring(startIndex + length, s.length);
11575                this.clearString();
11576            }
11577
11578            return this;
11579        },
11580
11581        insert: function (index, value) {
11582            if (value == null) {
11583                return this;
11584            }
11585
11586            if (arguments.length === 3) {
11587                // insert value repeated count times
11588                var count = arguments[2];
11589
11590                if (count === 0) {
11591                    return this;
11592                } else if (count < 0) {
11593                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "cannot be less than zero");
11594                }
11595
11596                value = Array(count + 1).join(value).toString();
11597            }
11598
11599            var s = this.getString();
11600
11601            this.buffer = [];
11602
11603            if (index < 1) {
11604                this.buffer[0] = value;
11605                this.buffer[1] = s;
11606            } else if (index >= s.length) {
11607                this.buffer[0] = s;
11608                this.buffer[1] = value;
11609            } else {
11610                this.buffer[0] = s.substring(0, index);
11611                this.buffer[1] = value;
11612                this.buffer[2] = s.substring(index, s.length);
11613            }
11614
11615            this.clearString();
11616
11617            return this;
11618        },
11619
11620        replace: function (oldValue, newValue) {
11621            var r = new RegExp(oldValue, "g"),
11622                s = this.buffer.join("");
11623
11624            this.buffer = [];
11625
11626            if (arguments.length === 4) {
11627                var startIndex = arguments[2],
11628                    count = arguments[3],
11629                    b = s.substr(startIndex, count);
11630
11631                this.checkLimits(s, startIndex, count);
11632
11633                this.buffer[0] = s.substring(0, startIndex);
11634                this.buffer[1] = b.replace(r, newValue);
11635                this.buffer[2] = s.substring(startIndex + count, s.length);
11636            } else {
11637                this.buffer[0] = s.replace(r, newValue);
11638            }
11639
11640            this.clearString();
11641            return this;
11642        },
11643
11644        checkLimits: function (value, startIndex, length) {
11645            if (length < 0) {
11646                throw new System.ArgumentOutOfRangeException.$ctor4("length", "must be non-negative");
11647            }
11648
11649            if (startIndex < 0) {
11650                throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "startIndex cannot be less than zero");
11651            }
11652
11653            if (length > value.length - startIndex) {
11654                throw new System.ArgumentOutOfRangeException.$ctor4("Index and length must refer to a location within the string");
11655            }
11656        },
11657
11658        clearString: function () {
11659            this.$str = null;
11660        },
11661
11662        getString: function () {
11663            if (!this.$str) {
11664                this.$str = this.buffer.join("");
11665                this.buffer = [];
11666                this.buffer[0] = this.$str;
11667            }
11668
11669            return this.$str;
11670        },
11671
11672        getChar: function (index) {
11673            var str = this.getString();
11674
11675            if (index < 0 || index >= str.length) {
11676                throw new System.IndexOutOfRangeException();
11677            }
11678
11679            return str.charCodeAt(index);
11680        },
11681
11682        setChar: function (index, value) {
11683            var str = this.getString();
11684
11685            if (index < 0 || index >= str.length) {
11686                throw new System.ArgumentOutOfRangeException();
11687            }
11688
11689            value = String.fromCharCode(value);
11690            this.buffer = [];
11691            this.buffer[0] = str.substring(0, index);
11692            this.buffer[1] = value;
11693            this.buffer[2] = str.substring(index + 1, str.length);
11694            this.clearString();
11695        }
11696    });
11697
11698    // @source H5Regex.js
11699
11700    (function () {
11701        var specials = [
11702                // order matters for these
11703                  "-"
11704                , "["
11705                , "]"
11706                // order doesn't matter for any of these
11707                , "/"
11708                , "{"
11709                , "}"
11710                , "("
11711                , ")"
11712                , "*"
11713                , "+"
11714                , "?"
11715                , "."
11716                , "\\"
11717                , "^"
11718                , "$"
11719                , "|"
11720        ],
11721
11722        regex = RegExp("[" + specials.join("\\") + "]", "g"),
11723
11724        regexpEscape = function (s) {
11725            return s.replace(regex, "\\$&");
11726        };
11727
11728        H5.regexpEscape = regexpEscape;
11729    })();
11730
11731    // @source DebugAssertException.js
11732
11733    H5.define("System.Diagnostics.Debug.DebugAssertException", {
11734        inherits: [System.Exception],
11735        $kind: "nested class",
11736        ctors: {
11737            ctor: function (message, detailMessage, stackTrace) {
11738                this.$initialize();
11739                System.Exception.ctor.call(this, (message || "") + ("\n" || "") + (detailMessage || "") + ("\n" || "") + (stackTrace || ""));
11740            }
11741        }
11742    });
11743
11744    // @source Debug.js
11745
11746    H5.define("System.Diagnostics.Debug", {
11747        statics: {
11748            fields: {
11749                s_lock: null,
11750                s_indentLevel: 0,
11751                s_indentSize: 0,
11752                s_needIndent: false,
11753                s_indentString: null,
11754                s_ShowAssertDialog: null,
11755                s_WriteCore: null,
11756                s_shouldWriteToStdErr: false
11757            },
11758            props: {
11759                AutoFlush: {
11760                    get: function () {
11761                        return true;
11762                    },
11763                    set: function (value) { }
11764                },
11765                IndentLevel: {
11766                    get: function () {
11767                        return System.Diagnostics.Debug.s_indentLevel;
11768                    },
11769                    set: function (value) {
11770                        System.Diagnostics.Debug.s_indentLevel = value < 0 ? 0 : value;
11771                    }
11772                },
11773                IndentSize: {
11774                    get: function () {
11775                        return System.Diagnostics.Debug.s_indentSize;
11776                    },
11777                    set: function (value) {
11778                        System.Diagnostics.Debug.s_indentSize = value < 0 ? 0 : value;
11779                    }
11780                }
11781            },
11782            ctors: {
11783                init: function () {
11784                    this.s_lock = { };
11785                    this.s_indentSize = 4;
11786                    this.s_ShowAssertDialog = System.Diagnostics.Debug.ShowAssertDialog;
11787                    this.s_WriteCore = System.Diagnostics.Debug.WriteCore;
11788                    this.s_shouldWriteToStdErr = H5.referenceEquals(System.Environment.GetEnvironmentVariable("COMPlus_DebugWriteToStdErr"), "1");
11789                }
11790            },
11791            methods: {
11792                Close: function () { },
11793                Flush: function () { },
11794                Indent: function () {
11795                    System.Diagnostics.Debug.IndentLevel = (System.Diagnostics.Debug.IndentLevel + 1) | 0;
11796                },
11797                Unindent: function () {
11798                    System.Diagnostics.Debug.IndentLevel = (System.Diagnostics.Debug.IndentLevel - 1) | 0;
11799                },
11800                Print: function (message) {
11801                    System.Diagnostics.Debug.Write$2(message);
11802                },
11803                Print$1: function (format, args) {
11804                    if (args === void 0) { args = []; }
11805                    System.Diagnostics.Debug.Write$2(System.String.formatProvider.apply(System.String, [null, format].concat(args)));
11806                },
11807                Assert: function (condition) {
11808                    System.Diagnostics.Debug.Assert$2(condition, "", "");
11809                },
11810                Assert$1: function (condition, message) {
11811                    System.Diagnostics.Debug.Assert$2(condition, message, "");
11812                },
11813                Assert$2: function (condition, message, detailMessage) {
11814                    if (!condition) {
11815                        var stackTrace;
11816
11817                        try {
11818                            throw System.NotImplemented.ByDesign;
11819                        } catch ($e1) {
11820                            $e1 = System.Exception.create($e1);
11821                            stackTrace = "";
11822                        }
11823
11824                        System.Diagnostics.Debug.WriteLine$2(System.Diagnostics.Debug.FormatAssert(stackTrace, message, detailMessage));
11825                        System.Diagnostics.Debug.s_ShowAssertDialog(stackTrace, message, detailMessage);
11826                    }
11827                },
11828                Assert$3: function (condition, message, detailMessageFormat, args) {
11829                    if (args === void 0) { args = []; }
11830                    System.Diagnostics.Debug.Assert$2(condition, message, System.String.format.apply(System.String, [detailMessageFormat].concat(args)));
11831                },
11832                Fail: function (message) {
11833                    System.Diagnostics.Debug.Assert$2(false, message, "");
11834                },
11835                Fail$1: function (message, detailMessage) {
11836                    System.Diagnostics.Debug.Assert$2(false, message, detailMessage);
11837                },
11838                FormatAssert: function (stackTrace, message, detailMessage) {
11839                    var newLine = (System.Diagnostics.Debug.GetIndentStr
11839ing() || "") + ("\n" || "");
11840                    return "---- DEBUG ASSERTION FAILED ----" + (newLine || "") + "---- Assert Short Message ----" + (newLine || "") + (message || "") + (newLine || "") + "---- Assert Long Message ----" + (newLine || "") + (detailMessage || "") + (newLine || "") + (stackTrace || "");
11841                },
11842                WriteLine$2: function (message) {
11843                    System.Diagnostics.Debug.Write$2((message || "") + ("\n" || ""));
11844                },
11845                WriteLine: function (value) {
11846                    System.Diagnostics.Debug.WriteLine$2(value != null ? H5.toString(value) : null);
11847                },
11848                WriteLine$1: function (value, category) {
11849                    System.Diagnostics.Debug.WriteLine$4(value != null ? H5.toString(value) : null, category);
11850                },
11851                WriteLine$3: function (format, args) {
11852                    if (args === void 0) { args = []; }
11853                    System.Diagnostics.Debug.WriteLine$2(System.String.formatProvider.apply(System.String, [null, format].concat(args)));
11854                },
11855                WriteLine$4: function (message, category) {
11856                    if (category == null) {
11857                        System.Diagnostics.Debug.WriteLine$2(message);
11858                    } else {
11859                        System.Diagnostics.Debug.WriteLine$2((category || "") + ":" + (message || ""));
11860                    }
11861                },
11862                Write$2: function (message) {
11863                    System.Diagnostics.Debug.s_lock;
11864                    {
11865                        if (message == null) {
11866                            System.Diagnostics.Debug.s_WriteCore("");
11867                            return;
11868                        }
11869                        if (System.Diagnostics.Debug.s_needIndent) {
11870                            message = (System.Diagnostics.Debug.GetIndentStr
11870ing() || "") + (message || "");
11871                            System.Diagnostics.Debug.s_needIndent = false;
11872                        }
11873                        System.Diagnostics.Debug.s_WriteCore(message);
11874                        if (System.String.endsWith(message, "\n")) {
11875                            System.Diagnostics.Debug.s_needIndent = true;
11876                        }
11877                    }
11878                },
11879                Write: function (value) {
11880                    System.Diagnostics.Debug.Write$2(value != null ? H5.toString(value) : null);
11881                },
11882                Write$3: function (message, category) {
11883                    if (category == null) {
11884                        System.Diagnostics.Debug.Write$2(message);
11885                    } else {
11886                        System.Diagnostics.Debug.Write$2((category || "") + ":" + (message || ""));
11887                    }
11888                },
11889                Write$1: function (value, category) {
11890                    System.Diagnostics.Debug.Write$3(value != null ? H5.toString(value) : null, category);
11891                },
11892                WriteIf$2: function (condition, message) {
11893                    if (condition) {
11894                        System.Diagnostics.Debug.Write$2(message);
11895                    }
11896                },
11897                WriteIf: function (condition, value) {
11898                    if (condition) {
11899                        System.Diagnostics.Debug.Write(value);
11900                    }
11901                },
11902                WriteIf$3: function (condition, message, category) {
11903                    if (condition) {
11904                        System.Diagnostics.Debug.Write$3(message, category);
11905                    }
11906                },
11907                WriteIf$1: function (condition, value, category) {
11908                    if (condition) {
11909                        System.Diagnostics.Debug.Write$1(value, category);
11910                    }
11911                },
11912                WriteLineIf: function (condition, value) {
11913                    if (condition) {
11914                        System.Diagnostics.Debug.WriteLine(value);
11915                    }
11916                },
11917                WriteLineIf$1: function (condition, value, category) {
11918                    if (condition) {
11919                        System.Diagnostics.Debug.WriteLine$1(value, category);
11920                    }
11921                },
11922                WriteLineIf$2: function (condition, message) {
11923                    if (condition) {
11924                        System.Diagnostics.Debug.WriteLine$2(message);
11925                    }
11926                },
11927                WriteLineIf$3: function (condition, message, category) {
11928                    if (condition) {
11929                        System.Diagnostics.Debug.WriteLine$4(message, category);
11930                    }
11931                },
11932                GetIndentString: function () {
11933                    var $t;
11934                    var indentCount = H5.Int.mul(System.Diagnostics.Debug.IndentSize, System.Diagnostics.Debug.IndentLevel);
11935                    if (System.Nullable.eq((System.Diagnostics.Debug.s_indentString != null ? System.Diagnostics.Debug.s_indentString.length : null), indentCount)) {
11936                        return System.Diagnostics.Debug.s_indentString;
11937                    }
11938                    return ($t = System.String.fromCharCount(32, indentCount), System.Diagnostics.Debug.s_indentString = $t, $t);
11939                },
11940                ShowAssertDialog: function (stackTrace, message, detailMessage) {
11941                    if (System.Diagnostics.Debugger.IsAttached) {
11942                        debugger;
11943                    } else {
11944                        var ex = new System.Diagnostics.Debug.DebugAssertException(message, detailMessage, stackTrace);
11945                        System.Environment.FailFast$1(ex.Message, ex);
11946                    }
11947                },
11948                WriteCore: function (message) {
11949                    System.Diagnostics.Debug.WriteToDebugger(message);
11950
11951                    if (System.Diagnostics.Debug.s_shouldWriteToStdErr) {
11952                        System.Diagnostics.Debug.WriteToStderr(message);
11953                    }
11954                },
11955                WriteToDebugger: function (message) {
11956                    if (System.Diagnostics.Debugger.IsLogging()) {
11957                        System.Diagnostics.Debugger.Log(0, null, message);
11958                    } else {
11959                        System.Console.WriteLine(message);
11960
11961                    }
11962                },
11963                WriteToStderr: function (message) {
11964                    System.Console.WriteLine(message);
11965
11966
11967
11968
11969
11970
11971
11972                }
11973            }
11974        }
11975    });
11976
11977    // @source Debugger.js
11978
11979    H5.define("System.Diagnostics.Debugger", {
11980        statics: {
11981            fields: {
11982                DefaultCategory: null
11983            },
11984            props: {
11985                IsAttached: {
11986                    get: function () {
11987                        return true;
11988                    }
11989                }
11990            },
11991            methods: {
11992                IsLogging: function () {
11993                    return true;
11994                },
11995                Launch: function () {
11996                    return true;
11997                },
11998                Log: function (level, category, message) { },
11999                NotifyOfCrossThreadDependency: function () { }
12000            }
12001        }
12002    });
12003
12004    // @source Diagnostics.js
12005
12006    H5.define("System.Diagnostics.Stopwatch", {
12007        ctor: function () {
12008            this.$initialize();
12009            this.reset();
12010        },
12011
12012        start: function () {
12013            if (this.isRunning) {
12014                return;
12015            }
12016
12017            this._startTime = System.Diagnostics.Stopwatch.getTimestamp();
12018            this.isRunning = true;
12019        },
12020
12021        stop: function () {
12022            if (!this.isRunning) {
12023                return;
12024            }
12025
12026            var endTimeStamp = System.Diagnostics.Stopwatch.getTimestamp();
12027            var elapsedThisPeriod = endTimeStamp.sub(this._startTime);
12028            this._elapsed = this._elapsed.add(elapsedThisPeriod);
12029            this.isRunning = false;
12030        },
12031
12032        reset: function () {
12033            this._startTime = System.Int64.Zero;
12034            this._elapsed = System.Int64.Zero;
12035            this.isRunning = false;
12036        },
12037
12038        restart: function () {
12039            this.isRunning = false;
12040            this._elapsed = System.Int64.Zero;
12041            this._startTime = System.Diagnostics.Stopwatch.getTimestamp();
12042            this.start();
12043        },
12044
12045        ticks: function () {
12046            var timeElapsed = this._elapsed;
12047
12048            if (this.isRunning)
12049            {
12050                var currentTimeStamp = System.Diagnostics.Stopwatch.getTimestamp();
12051                var elapsedUntilNow = currentTimeStamp.sub(this._startTime);
12052
12053                timeElapsed = timeElapsed.add(elapsedUntilNow);
12054            }
12055
12056            return timeElapsed;
12057        },
12058
12059        milliseconds: function () {
12060            return this.ticks().mul(1000).div(System.Diagnostics.Stopwatch.frequency);
12061        },
12062
12063        timeSpan: function () {
12064            return new System.TimeSpan(this.milliseconds().mul(10000));
12065        },
12066
12067        statics: {
12068            startNew: function () {
12069                var s = new System.Diagnostics.Stopwatch();
12070                s.start();
12071
12072                return s;
12073            }
12074        }
12075    });
12076
12077if (typeof window !== 'undefined' && window.performance && window.performance.now) {
12078        System.Diagnostics.Stopwatch.frequency = new System.Int64(1e6);
12079        System.Diagnostics.Stopwatch.isHighResolution = true;
12080        System.Diagnostics.Stopwatch.getTimestamp = function () {
12081            return new System.Int64(Math.round(window.performance.now() * 1000));
12082        };
12083    } else if (typeof (process) !== "undefined" && process.hrtime) {
12084        System.Diagnostics.Stopwatch.frequency = new System.Int64(1e9);
12085        System.Diagnostics.Stopwatch.isHighResolution = true;
12086        System.Diagnostics.Stopwatch.getTimestamp = function () {
12087            var hr = process.hrtime();
12088            return new System.Int64(hr[0]).mul(1e9).add(hr[1]);
12089        };
12090    } else {
12091        System.Diagnostics.Stopwatch.frequency = new System.Int64(1e3);
12092        System.Diagnostics.Stopwatch.isHighResolution = false;
12093        System.Diagnostics.Stopwatch.getTimestamp = function () {
12094            return new System.Int64(new Date().valueOf());
12095        };
12096    }
12097
12098    System.Diagnostics.Contracts.Contract = {
12099        reportFailure: function (failureKind, userMessage, condition, innerException, TException) {
12100            var conditionText = condition.toString();
12101
12102            conditionText = conditionText.substring(conditionText.indexOf("return") + 7);
12103            conditionText = conditionText.substr(0, conditionText.lastIndexOf(";"));
12104
12105            var failureMessage = (conditionText) ? "Contract '" + conditionText + "' failed" : "Contract failed",
12106                displayMessage = (userMessage) ? failureMessage + ": " + userMessage : failureMessage;
12107
12108            if (TException) {
12109                throw new TException(conditionText, userMessage);
12110            } else {
12111                throw new System.Diagnostics.Contracts.ContractException(failureKind, displayMessage, userMessage, conditionText, innerException);
12112            }
12113        },
12114        assert: function (failureKind, scope, condition, message) {
12115            if (!condition.call(scope)) {
12116                System.Diagnostics.Contracts.Contract.reportFailure(failureKind, message, condition, null);
12117            }
12118        },
12119        requires: function (TException, scope, condition, message) {
12120            if (!condition.call(scope)) {
12121                System.Diagnostics.Contracts.Contract.reportFailure(0, message, condition, null, TException);
12122            }
12123        },
12124        forAll: function (fromInclusive, toExclusive, predicate) {
12125            if (!predicate) {
12126                throw new System.ArgumentNullException.$ctor1("predicate");
12127            }
12128
12129            for (; fromInclusive < toExclusive; fromInclusive++) {
12130                if (!predicate(fromInclusive)) {
12131                    return false;
12132                }
12133            }
12134
12135            return true;
12136        },
12137        forAll$1: function (collection, predicate) {
12138            if (!collection) {
12139                throw new System.ArgumentNullException.$ctor1("collection");
12140            }
12141
12142            if (!predicate) {
12143                throw new System.ArgumentNullException.$ctor1("predicate");
12144            }
12145
12146            var enumerator = H5.getEnumerator(collection);
12147
12148            try {
12149                while (enumerator.moveNext()) {
12150                    if (!predicate(enumerator.Current)) {
12151                        return false;
12152                    }
12153                }
12154
12155                return true;
12156            } finally {
12157                enumerator.Dispose();
12158            }
12159        },
12160        exists: function (fromInclusive, toExclusive, predicate) {
12161            if (!predicate) {
12162                throw new System.ArgumentNullException.$ctor1("predicate");
12163            }
12164
12165            for (; fromInclusive < toExclusive; fromInclusive++) {
12166                if (predicate(fromInclusive)) {
12167                    return true;
12168                }
12169            }
12170
12171            return false;
12172        },
12173        exists$1: function (collection, predicate) {
12174            if (!collection) {
12175                throw new System.ArgumentNullException.$ctor1("collection");
12176            }
12177
12178            if (!predicate) {
12179                throw new System.ArgumentNullException.$ctor1("predicate");
12180            }
12181
12182            var enumerator = H5.getEnumerator(collection);
12183
12184            try {
12185                while (enumerator.moveNext()) {
12186                    if (predicate(enumerator.Current)) {
12187                        return true;
12188                    }
12189                }
12190
12191                return false;
12192            } finally {
12193                enumerator.Dispose();
12194            }
12195        }
12196    };
12197
12198    H5.define("System.Diagnostics.Contracts.ContractFailureKind", {
12199        $kind: "enum",
12200        $statics: {
12201            precondition: 0,
12202            postcondition: 1,
12203            postconditionOnException: 2,
12204            invarian: 3,
12205            assert: 4,
12206            assume: 5
12207        }
12208    });
12209
12210    H5.define("System.Diagnostics.Contracts.ContractException", {
12211        inherits: [System.Exception],
12212
12213        config: {
12214            properties: {
12215                Kind: {
12216                    get: function () {
12217                        return this._kind;
12218                    }
12219                },
12220
12221                Failure: {
12222                    get: function () {
12223                        return this._failureMessage;
12224                    }
12225                },
12226
12227                UserMessage: {
12228                    get: function () {
12229                        return this._userMessage;
12230                    }
12231                },
12232
12233                Condition: {
12234                    get: function () {
12235                        return this._condition;
12236                    }
12237                }
12238            }
12239        },
12240
12241        ctor: function (failureKind, failureMessage, userMessage, condition, innerException) {
12242            this.$initialize();
12243            System.Exception.ctor.call(this, failureMessage, innerException);
12244            this._kind = failureKind;
12245            this._failureMessage = failureMessage || null;
12246            this._userMessage = userMessage || null;
12247            this._condition = condition || null;
12248        }
12249    });
12250
12251    // @source Array.js
12252
12253    var array = {
12254        toIndex: function (arr, indices) {
12255            if (indices.length !== (arr.$s ? arr.$s.length : 1)) {
12256                throw new System.ArgumentException.$ctor1("Invalid number of indices");
12257            }
12258
12259            if (indices[0] < 0 || indices[0] >= (arr.$s ? arr.$s[0] : arr.length)) {
12260                throw new System.IndexOutOfRangeException.$ctor1("Index 0 out of range");
12261            }
12262
12263            var idx = indices[0],
12264                i;
12265
12266            if (arr.$s) {
12267                for (i = 1; i < arr.$s.length; i++) {
12268                    if (indices[i] < 0 || indices[i] >= arr.$s[i]) {
12269                        throw new System.IndexOutOfRangeException.$ctor1("Index " + i + " out of range");
12270                    }
12271
12272                    idx = idx * arr.$s[i] + indices[i];
12273                }
12274            }
12275
12276            return idx;
12277        },
12278
12279        index: function (index, arr) {
12280            if (index < 0 || index >= arr.length) {
12281                throw new System.IndexOutOfRangeException();
12282            }
12283            return index;
12284        },
12285
12286        $get: function (indices) {
12287            var r = this[System.Array.toIndex(this, indices)];
12288
12289            return typeof r !== "undefined" ? r : this.$v;
12290        },
12291
12292        get: function (arr) {
12293            if (arguments.length < 2) {
12294                throw new System.ArgumentNullException.$ctor1("indices");
12295            }
12296
12297            var idx = Array.prototype.slice.call(arguments, 1);
12298
12299            for (var i = 0; i < idx.length; i++) {
12300                if (!H5.hasValue(idx[i])) {
12301                    throw new System.ArgumentNullException.$ctor1("indices");
12302                }
12303            }
12304
12305            var r = arr[System.Array.toIndex(arr, idx)];
12306
12307            return typeof r !== "undefined" ? r : arr.$v;
12308        },
12309
12310        $set: function (indices, value) {
12311            this[System.Array.toIndex(this, indices)] = value;
12312        },
12313
12314        set: function (arr, value) {
12315            var indices = Array.prototype.slice.call(arguments, 2);
12316
12317            arr[System.Array.toIndex(arr, indices)] = value;
12318        },
12319
12320        getLength: function (arr, dimension) {
12321            if (dimension < 0 || dimension >= (arr.$s ? arr.$s.length : 1)) {
12322                throw new System.IndexOutOfRangeException();
12323            }
12324
12325            return arr.$s ? arr.$s[dimension] : arr.length;
12326        },
12327
12328        getRank: function (arr) {
12329            return arr.$type ? arr.$type.$rank : (arr.$s ? arr.$s.length : 1);
12330        },
12331
12332        getLower: function (arr, d) {
12333            System.Array.getLength(arr, d);
12334
12335            return 0;
12336        },
12337
12338        create: function (defvalue, initValues, T, sizes) {
12339            if (sizes === null) {
12340                throw new System.ArgumentNullException.$ctor1("length");
12341            }
12342
12343            var arr = [],
12344                length = arguments.length > 3 ? 1 : 0,
12345                i, s, v, j,
12346                idx,
12347                indices,
12348                flatIdx;
12349
12350            arr.$v = defvalue;
12351            arr.$s = [];
12352            arr.get = System.Array.$get;
12353            arr.set = System.Array.$set;
12354
12355            if (sizes && H5.isArray(sizes)) {
12356                for (i = 0; i < sizes.length; i++) {
12357                    j = sizes[i];
12358
12359                    if (isNaN(j) || j < 0) {
12360                        throw new System.ArgumentOutOfRangeException.$ctor1("length");
12361                    }
12362
12363                    length *= j;
12364                    arr.$s[i] = j;
12365                }
12366            } else {
12367                for (i = 3; i < arguments.length; i++) {
12368                    j = arguments[i];
12369
12370                    if (isNaN(j) || j < 0) {
12371                        throw new System.ArgumentOutOfRangeException.$ctor1("length");
12372                    }
12373
12374                    length *= j;
12375                    arr.$s[i - 3] = j;
12376                }
12377            }
12378
12379            arr.length = length;
12380            var isFn = H5.isFunction(defvalue);
12381
12382            if (isFn) {
12383                var v = defvalue();
12384
12385                if (!v || (!v.$kind && typeof v !== "object")) {
12386                    isFn = false;
12387                    defvalue = v;
12388                }
12389            }
12390
12391            for (var k = 0; k < length; k++) {
12392                arr[k] = isFn ? defvalue() : defvalue;
12393            }
12394
12395            if (initValues) {
12396                for (i = 0; i < arr.length; i++) {
12397                    indices = [];
12398                    flatIdx = i;
12399
12400                    for (s = arr.$s.length - 1; s >= 0; s--) {
12401                        idx = flatIdx % arr.$s[s];
12402                        indices.unshift(idx);
12403                        flatIdx = H5.Int.div(flatIdx - idx, arr.$s[s]);
12404                    }
12405
12406                    v = initValues;
12407
12408                    for (idx = 0; idx < indices.length; idx++) {
12409                        v = v[indices[idx]];
12410                    }
12411
12412                    arr[i] = v;
12413                }
12414            }
12415
12416            System.Array.init(arr, T, arr.$s.length);
12417
12418            return arr;
12419        },
12420
12421        init: function (length, value, T, addFn) {
12422            if (length == null) {
12423                throw new System.ArgumentNullException.$ctor1("length");
12424            }
12425
12426            if (H5.isArray(length)) {
12427                var elementType = value,
12428                    rank = T || 1;
12429
12430                System.Array.type(elementType, rank, length);
12431
12432                return length;
12433            }
12434
12435            if (isNaN(length) || length < 0) {
12436                throw new System.ArgumentOutOfRangeException.$ctor1("length");
12437            }
12438
12439            var arr = new Array(length),
12440                isFn = addFn !== true && H5.isFunction(value);
12441
12442            if (isFn) {
12443                var v = value();
12444
12445                if (!v || (!v.$kind && typeof v !== "object")) {
12446                    isFn = false;
12447                    value = v;
12448                }
12449            }
12450
12451            for (var i = 0; i < length; i++) {
12452                arr[i] = isFn ? value() : value;
12453            }
12454
12455            return System.Array.init(arr, T, 1);
12456        },
12457
12458        toEnumerable: function (array) {
12459            return new H5.ArrayEnumerable(array);
12460        },
12461
12462        toEnumerator: function (array, T) {
12463            return new H5.ArrayEnumerator(array, T);
12464        },
12465
12466        _typedArrays: {
12467            Float32Array: System.Single,
12468            Float64Array: System.Double,
12469            Int8Array: System.SByte,
12470            Int16Array: System.Int16,
12471            Int32Array: System.Int32,
12472            Uint8Array: System.Byte,
12473            Uint8ClampedArray: System.Byte,
12474            Uint16Array: System.UInt16,
12475            Uint32Array: System.UInt32
12476        },
12477
12478        is: function (obj, type) {
12479            if (obj instanceof H5.ArrayEnumerator) {
12480                if ((obj.constructor === type) || (obj instanceof type) ||
12481                    type === H5.ArrayEnumerator ||
12482                    type.$$name && System.String.startsWith(type.$$name, "System.Collections.IEnumerator") ||
12483                    type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.IEnumerator")) {
12484                    return true;
12485                }
12486
12487                return false;
12488            }
12489
12490            if (!H5.isArray(obj)) {
12491                return false;
12492            }
12493
12494            if (type.$elementType && type.$isArray) {
12495                var et = H5.getType(obj).$elementType;
12496
12497                if (et) {
12498
12499                    if (H5.Reflection.isValueType(et) !== H5.Reflection.isValueType(type.$elementType)) {
12500                        return false;
12501                    }
12502
12503                    return System.Array.getRank(obj) === type.$rank && H5.Reflection.isAssignableFrom(type.$elementType, et);
12504                }
12505
12506                type = Array;
12507            }
12508
12509            if ((obj.constructor === type) || (obj instanceof type)) {
12510                return true;
12511            }
12512
12513            if (type === System.Collections.IEnumerable ||
12514                type === System.Collections.ICollection ||
12515                type === System.ICloneable ||
12516                type === System.Collections.IList ||
12517                type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.IEnumerable$1") ||
12518                type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.ICollection$1") ||
12519                type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.IList$1") ||
12520                type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.IReadOnlyCollection$1") ||
12521                type.$$name && System.String.startsWith(type.$$name, "System.Collections.Generic.IReadOnlyList$1")) {
12522                return true;
12523            }
12524
12525            var isTypedArray = !!System.Array._typedArrays[String.prototype.slice.call(Object.prototype.toString.call(obj), 8, -1)];
12526
12527            if (isTypedArray && !!System.Array._typedArrays[type.name]) {
12528                return obj instanceof type;
12529            }
12530
12531            return isTypedArray;
12532        },
12533
12534        clone: function (arr) {
12535            var newArr;
12536
12537            if (arr.length === 1) {
12538                newArr = [arr[0]];
12539            } else {
12540                newArr = arr.slice(0);
12541            }
12542
12543            newArr.$type = arr.$type;
12544            newArr.$v = arr.$v;
12545            newArr.$s = arr.$s;
12546            newArr.get = System.Array.$get;
12547            newArr.set = System.Array.$set;
12548
12549            return newArr;
12550        },
12551
12552        getCount: function (obj, T) {
12553            var name,
12554                v;
12555
12556            if (H5.isArray(obj)) {
12557                return obj.length;
12558            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$getCount"])) {
12559                return obj[name]();
12560            } else if (H5.isFunction(obj[name = "System$Collections$ICollection$getCount"])) {
12561                return obj[name]();
12562            } else if (T && (v = obj["System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count"]) !== undefined) {
12563                return v;
12564            } else if ((v = obj["System$Collections$ICollection$Count"]) !== undefined) {
12565                return v;
12566            } else if ((v = obj.Count) !== undefined) {
12567                return v;
12568            } else if (H5.isFunction(obj.getCount)) {
12569                return obj.getCount();
12570            }
12571
12572            return 0;
12573        },
12574
12575        getIsReadOnly: function (obj, T) {
12576            var name,
12577                v;
12578
12579            if (H5.isArray(obj)) {
12580                return T ? true : false;
12581            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$getIsReadOnly"])) {
12582                return obj[name]();
12583            } else if (T && (v = obj["System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly"]) !== undefined) {
12584                return v;
12585            } else if (H5.isFunction(obj[name = "System$Collections$IList$getIsReadOnly"])) {
12586                return obj[name]();
12587            } else if ((v = obj["System$Collections$IList$IsReadOnly"]) !== undefined) {
12588                return v;
12589            } else if ((v = obj.IsReadOnly) !== undefined) {
12590                return v;
12591            } else if (H5.isFunction(obj.getIsReadOnly)) {
12592                return obj.getIsReadOnly();
12593            }
12594
12595            return false;
12596        },
12597
12598        checkReadOnly: function (obj, T, msg) {
12599            if (H5.isArray(obj)) {
12600                if (T) {
12601                    throw new System.NotSupportedException.$ctor1(msg || "Collection was of a fixed size.");
12602                }
12603            } else if (System.Array.getIsReadOnly(obj, T)) {
12604                throw new System.NotSupportedException.$ctor1(msg || "Collection is read-only.");
12605            }
12606        },
12607
12608        add: function (obj, item, T) {
12609            var name;
12610
12611            System.Array.checkReadOnly(obj, T);
12612
12613            if (T) {
12614                item = System.Array.checkNewElementType(item, T);
12615            }
12616
12617            if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add"])) {
12618                return obj[name](item);
12619            } else if (H5.isFunction(obj[name = "System$Collections$IList$add"])) {
12620                return obj[name](item);
12621            } else if (H5.isFunction(obj.add)) {
12622                return obj.add(item);
12623            }
12624
12625            return -1;
12626        },
12627
12628        checkNewElementType: function (v, type) {
12629            var unboxed = H5.unbox(v, true);
12630
12631            if (H5.isNumber(unboxed)) {
12632                if (type === System.Decimal) {
12633                    return new System.Decimal(unboxed);
12634                }
12635
12636                if (type === System.Int64) {
12637                    return new System.Int64(unboxed);
12638                }
12639
12640                if (type === System.UInt64) {
12641                    return new System.UInt64(unboxed);
12642                }
12643            }
12644
12645            var is = H5.is(v, type);
12646
12647            if (!is) {
12648                if (v == null && H5.getDefaultValue(type) == null) {
12649                    return null;
12650                }
12651
12652                throw new System.ArgumentException.$ctor1("The value " + unboxed + "is not of type " + H5.getTypeName(type) + " and cannot be used in this generic collection.");
12653            }
12654
12655            return unboxed;
12656        },
12657
12658        clear: function (obj, T) {
12659            var name;
12660
12661            System.Array.checkReadOnly(obj, T, "Collection is read-only.");
12662
12663            if (H5.isArray(obj)) {
12664                System.Array.fill(obj, T ? (T.getDefaultValue || H5.getDefaultValue(T)) : null, 0, obj.length);
12665            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear"])) {
12666                obj[name]();
12667            } else if (H5.isFunction(obj[name = "System$Collections$IList$clear"])) {
12668                obj[name]();
12669            } else if (H5.isFunction(obj.clear)) {
12670                obj.clear();
12671            }
12672        },
12673
12674        fill: function (dst, val, index, count) {
12675            if (!H5.hasValue(dst)) {
12676                throw new System.ArgumentNullException.$ctor1("dst");
12677            }
12678
12679            if (index < 0 || count < 0 || (index + count) > dst.length) {
12680                throw new System.IndexOutOfRangeException();
12681            }
12682
12683            var isFn = H5.isFunction(val);
12684
12685            if (isFn) {
12686                var v = val();
12687
12688                if (!v || (!v.$kind && typeof v !== "object")) {
12689                    isFn = false;
12690                    val = v;
12691                }
12692            }
12693
12694            while (--count >= 0) {
12695                dst[index + count] = isFn ? val() : val;
12696            }
12697        },
12698
12699        copy: function (src, spos, dest, dpos, len) {
12700            if (!dest) {
12701                throw new System.ArgumentNullException.$ctor3("dest", "Value cannot be null");
12702            }
12703
12704            if (!src) {
12705                throw new System.ArgumentNullException.$ctor3("src", "Value cannot be null");
12706            }
12707
12708            if (spos < 0 || dpos < 0 || len < 0) {
12709                throw new System.ArgumentOutOfRangeException.$ctor1("bound", "Number was less than the array's lower bound in the first dimension");
12710            }
12711
12712            if (len > (src.length - spos) || len > (dest.length - dpos)) {
12713                throw new System.ArgumentException.$ctor1("Destination array was not long enough. Check destIndex and length, and the array's lower bounds");
12714            }
12715
12716            if (spos < dpos && src === dest) {
12717                while (--len >= 0) {
12718                    dest[dpos + len] = src[spos + len];
12719                }
12720            } else {
12721                for (var i = 0; i < len; i++) {
12722                    dest[dpos + i] = src[spos + i];
12723                }
12724            }
12725        },
12726
12727        copyTo: function (obj, dest, index, T) {
12728            var name;
12729
12730            if (H5.isArray(obj)) {
12731                System.Array.copy(obj, 0, dest, index, obj ? obj.length : 0);
12732            } else if (H5.isFunction(obj.copyTo)) {
12733                obj.copyTo(dest, index);
12734            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo"])) {
12735                obj[name](dest, index);
12736            } else if (H5.isFunction(obj[name = "System$Collections$ICollection$copyTo"])) {
12737                obj[name](dest, index);
12738            } else {
12739                throw new System.NotImplementedException.$ctor1("copyTo");
12740            }
12741        },
12742
12743        indexOf: function (arr, item, startIndex, count, T) {
12744            var name;
12745
12746            if (H5.isArray(arr)) {
12747                var i,
12748                    el,
12749                    endIndex;
12750
12751                startIndex = startIndex || 0;
12752                count = H5.isNumber(count) ? count : arr.length;
12753                endIndex = startIndex + count;
12754
12755                for (i = startIndex; i < endIndex; i++) {
12756                    el = arr[i];
12757
12758                    if (el === item || System.Collections.Generic.EqualityComparer$1.$default.equals2(el, item)) {
12759                        return i;
12760                    }
12761                }
12762            } else if (T && H5.isFunction(arr[name = "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$indexOf"])) {
12763                return arr[name](item);
12764            } else if (H5.isFunction(arr[name = "System$Collections$IList$indexOf"])) {
12765                return arr[name](item);
12766            } else if (H5.isFunction(arr.indexOf)) {
12767                return arr.indexOf(item);
12768            }
12769
12770            return -1;
12771        },
12772
12773        contains: function (obj, item, T) {
12774            var name;
12775
12776            if (H5.isArray(obj)) {
12777                return System.Array.indexOf(obj, item) > -1;
12778            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains"])) {
12779                return obj[name](item);
12780            } else if (H5.isFunction(obj[name = "System$Collections$IList$contains"])) {
12781                return obj[name](item);
12782            }
12782 else if (H5.isFunction(obj.contains)) {
12783                return obj.contains(item);
12784            }
12785
12786            return false;
12787        },
12788
12789        remove: function (obj, item, T) {
12790            var name;
12791
12792            System.Array.checkReadOnly(obj, T);
12793
12794            if (H5.isArray(obj)) {
12795                var index = System.Array.indexOf(obj, item);
12796
12797                if (index > -1) {
12798                    obj.splice(index, 1);
12799
12800                    return true;
12801                }
12802            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove"])) {
12803                return obj[name](item);
12804            } else if (H5.isFunction(obj[name = "System$Collections$IList$remove"])) {
12805                return obj[name](item);
12806            } else if (H5.isFunction(obj.remove)) {
12807                return obj.remove(item);
12808            }
12809
12810            return false;
12811        },
12812
12813        insert: function (obj, index, item, T) {
12814            var name;
12815
12816            System.Array.checkReadOnly(obj, T);
12817
12818            if (T) {
12819                item = System.Array.checkNewElementType(item, T);
12820            }
12821
12822            if (T && H5.isFunction(obj[name = "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$insert"])) {
12823                obj[name](index, item);
12824            } else if (H5.isFunction(obj[name = "System$Collections$IList$insert"])) {
12825                obj[name](index, item);
12826            } else if (H5.isFunction(obj.insert)) {
12827                obj.insert(index, item);
12828            }
12829        },
12830
12831        removeAt: function (obj, index, T) {
12832            var name;
12833
12834            System.Array.checkReadOnly(obj, T);
12835
12836            if (H5.isArray(obj)) {
12837                obj.splice(index, 1);
12838            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$removeAt"])) {
12839                obj[name](index);
12840            } else if (H5.isFunction(obj[name = "System$Collections$IList$removeAt"])) {
12841                obj[name](index);
12842            } else if (H5.isFunction(obj.removeAt)) {
12843                obj.removeAt(index);
12844            }
12845        },
12846
12847        getItem: function (obj, idx, T) {
12848            var name,
12849                v;
12850
12851            if (H5.isArray(obj)) {
12852                v = obj[idx];
12853                if (T) {
12854                    return v;
12855                }
12856
12857                return (obj.$type && (H5.isNumber(v) || H5.isBoolean(v) || H5.isDate(v))) ? H5.box(v, obj.$type.$elementType) : v;
12858            } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$getItem"])) {
12859                v = obj[name](idx);
12860                return v;
12861            } else if (H5.isFunction(obj.get)) {
12862                v = obj.get(idx);
12863            } else if (H5.isFunction(obj.getItem)) {
12864                v = obj.getItem(idx);
12865            } else if (H5.isFunction(obj[name = "System$Collections$IList$$getItem"])) {
12866                v = obj[name](idx);
12867            } else if (H5.isFunction(obj.get_Item)) {
12868                v = obj.get_Item(idx);
12869            }
12870
12871            return T && H5.getDefaultValue(T) != null ? H5.box(v, T) : v;
12872        },
12873
12874        setItem: function (obj, idx, value, T) {
12875            var name;
12876
12877            if (H5.isArray(obj)) {
12878                if (obj.$type) {
12879                    value = System.Array.checkElementType(value, obj.$type.$elementType);
12880                }
12881
12882                obj[idx] = value;
12883            } else {
12884                if (T) {
12885                    value = System.Array.checkElementType(value, T);
12886                }
12887
12888                if (H5.isFunction(obj.set)) {
12889                    obj.set(idx, value);
12890                } else if (H5.isFunction(obj.setItem)) {
12891                    obj.setItem(idx, value);
12892                } else if (T && H5.isFunction(obj[name = "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$setItem"])) {
12893                    return obj[name](idx, value);
12894                } else if (T && H5.isFunction(obj[name = "System$Collections$IList$setItem"])) {
12895                    return obj[name](idx, value);
12896                } else if (H5.isFunction(obj.set_Item)) {
12897                    obj.set_Item(idx, value);
12898                }
12899            }
12900        },
12901
12902        checkElementType: function (v, type) {
12903            var unboxed = H5.unbox(v, true);
12904
12905            if (H5.isNumber(unboxed)) {
12906                if (type === System.Decimal) {
12907                    return new System.Decimal(unboxed);
12908                }
12909
12910                if (type === System.Int64) {
12911                    return new System.Int64(unboxed);
12912                }
12913
12914                if (type === System.UInt64) {
12915                    return new System.UInt64(unboxed);
12916                }
12917            }
12918
12919            var is = H5.is(v, type);
12920
12921            if (!is) {
12922                if (v == null) {
12923                    return H5.getDefaultValue(type);
12924                }
12925
12926                throw new System.ArgumentException.$ctor1("Cannot widen from source type to target type either because the source type is a not a primitive type or the conversion cannot be accomplished.");
12927            }
12928
12929            return unboxed;
12930        },
12931
12932        resize: function (arr, newSize, val, T) {
12933            if (newSize < 0) {
12934                throw new System.ArgumentOutOfRangeException.$ctor3("newSize", newSize, "newSize cannot be less than 0.");
12935            }
12936
12937            var oldSize = 0,
12938                isFn = H5.isFunction(val),
12939                ref = arr.v;
12940
12941            if (isFn) {
12942                var v = val();
12943
12944                if (!v || (!v.$kind && typeof v !== "object")) {
12945                    isFn = false;
12946                    val = v;
12947                }
12948            }
12949
12950            if (!ref) {
12951                ref = System.Array.init(new Array(newSize), T);
12952            } else {
12953                oldSize = ref.length;
12954                ref.length = newSize;
12955            }
12956
12957            for (var i = oldSize; i < newSize; i++) {
12958                ref[i] = isFn ? val() : val;
12959            }
12960
12961            ref.$s = [ref.length];
12962
12963            arr.v = ref;
12964        },
12965
12966        reverse: function (arr, index, length) {
12967            if (!array) {
12968                throw new System.ArgumentNullException.$ctor1("arr");
12969            }
12970
12971            if (!index && index !== 0) {
12972                index = 0;
12973                length = arr.length;
12974            }
12975
12976            if (index < 0 || length < 0) {
12977                throw new System.ArgumentOutOfRangeException.$ctor4((index < 0 ? "index" : "length"), "Non-negative number required.");
12978            }
12979
12980            if ((array.length - index) < length) {
12981                throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
12982            }
12983
12984            if (System.Array.getRank(arr) !== 1) {
12985                throw new System.Exception("Only single dimension arrays are supported here.");
12986            }
12987
12988            var i = index,
12989                j = index + length - 1;
12990
12991            while (i < j) {
12992                var temp = arr[i];
12993                arr[i] = arr[j];
12994                arr[j] = temp;
12995                i++;
12996                j--;
12997            }
12998        },
12999
13000        binarySearch: function (array, index, length, value, comparer) {
13001            if (!array) {
13002                throw new System.ArgumentNullException.$ctor1("array");
13003            }
13004
13005            var lb = 0;
13006
13007            if (index < lb || length < 0) {
13008                throw new System.ArgumentOutOfRangeException.$ctor4(index < lb ? "index" : "length", "Non-negative number required.");
13009            }
13010
13011            if (array.length - (index - lb) < length) {
13012                throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
13013            }
13014
13015            if (System.Array.getRank(array) !== 1) {
13016                throw new System.RankException.$ctor1("Only single dimensional arrays are supported for the requested action.");
13017            }
13018
13019            if (!comparer) {
13020                comparer = System.Collections.Generic.Comparer$1.$default;
13021            }
13022
13023            var lo = index,
13024                hi = index + length - 1,
13025                i,
13026                c;
13027
13028            while (lo <= hi) {
13029                i = lo + ((hi - lo) >> 1);
13030
13031                try {
13032                    c = System.Collections.Generic.Comparer$1.get(comparer)(array[i], value);
13033                } catch (e) {
13034                    throw new System.InvalidOperationException.$ctor2("Failed to compare two elements in the array.", e);
13035                }
13036
13037                if (c === 0) {
13038                    return i;
13039                }
13040
13041                if (c < 0) {
13042                    lo = i + 1;
13043                } else {
13044                    hi = i - 1;
13045                }
13046            }
13047
13048            return ~lo;
13049        },
13050
13051        sortDict: function (keys, values, index, length, comparer) {
13052            if (!comparer) {
13053                comparer = System.Collections.Generic.Comparer$1.$default;
13054            }
13055
13056            var list = [],
13057                fn = H5.fn.bind(comparer, System.Collections.Generic.Comparer$1.get(comparer));
13058
13059            if (length == null) {
13060                length = keys.length;
13061            }
13062
13063            for (var j = 0; j < keys.length; j++) {
13064                list.push({ key: keys[j], value: values[j] });
13065            }
13066
13067            if (index === 0 && length === list.length) {
13068                list.sort(function (x, y) {
13069                    return fn(x.key, y.key);
13070                });
13071            } else {
13072                var newarray = list.slice(index, index + length);
13073
13074                newarray.sort(function (x, y) {
13075                    return fn(x.key, y.key);
13076                });
13077
13078                for (var i = index; i < (index + length); i++) {
13079                    list[i] = newarray[i - index];
13080                }
13081            }
13082
13083            for (var k = 0; k < list.length; k++) {
13084                keys[k] = list[k].key;
13085                values[k] = list[k].value;
13086            }
13087        },
13088
13089        sort: function (array, index, length, comparer) {
13090            if (!array) {
13091                throw new System.ArgumentNullException.$ctor1("array");
13092            }
13093
13094            if (arguments.length === 2 && typeof index === "function") {
13095                array.sort(index);
13096                return;
13097            }
13098
13099            if (arguments.length === 2 && typeof index === "object") {
13100                comparer = index;
13101                index = null;
13102            }
13103
13104            if (!H5.isNumber(index)) {
13105                index = 0;
13106            }
13107
13108            if (!H5.isNumber(length)) {
13109                length = array.length;
13110            }
13111
13112            if (!comparer) {
13113                comparer = System.Collections.Generic.Comparer$1.$default;
13114            }
13115
13116            if (index === 0 && length === array.length) {
13117                array.sort(H5.fn.bind(comparer, System.Collections.Generic.Comparer$1.get(comparer)));
13118            } else {
13119                var newarray = array.slice(index, index + length);
13120
13121                newarray.sort(H5.fn.bind(comparer, System.Collections.Generic.Comparer$1.get(comparer)));
13122
13123                for (var i = index; i < (index + length) ; i++) {
13124                    array[i] = newarray[i - index];
13125                }
13126            }
13127        },
13128
13129        min: function (arr, minValue) {
13130            var min = arr[0],
13131                len = arr.length;
13132
13133            for (var i = 0; i < len; i++) {
13134                if ((arr[i] < min || min < minValue) && !(arr[i] < minValue)) {
13135                    min = arr[i];
13136                }
13137            }
13138
13139            return min;
13140        },
13141
13142        max: function (arr, maxValue) {
13143            var max = arr[0],
13144                len = arr.length;
13145
13146            for (var i = 0; i < len; i++) {
13147                if ((arr[i] > max || max > maxValue) && !(arr[i] > maxValue)) {
13148                    max = arr[i];
13149                }
13150            }
13151
13152            return max;
13153        },
13154
13155        addRange: function (arr, items) {
13156            if (H5.isArray(items)) {
13157                arr.push.apply(arr, items);
13158            } else {
13159                var e = H5.getEnumerator(items);
13160
13161                try {
13162                    while (e.moveNext()) {
13163                        arr.push(e.Current);
13164                    }
13165                } finally {
13166                    if (H5.is(e, System.IDisposable)) {
13167                        e.Dispose();
13168                    }
13169                }
13170            }
13171        },
13172
13173        convertAll: function (array, converter) {
13174            if (!H5.hasValue(array)) {
13175                throw new System.ArgumentNullException.$ctor1("array");
13176            }
13177
13178            if (!H5.hasValue(converter)) {
13179                throw new System.ArgumentNullException.$ctor1("converter");
13180            }
13181
13182            var array2 = array.map(converter);
13183
13184            return array2;
13185        },
13186
13187        find: function (T, array, match) {
13188            if (!H5.hasValue(array)) {
13189                throw new System.ArgumentNullException.$ctor1("array");
13190            }
13191
13192            if (!H5.hasValue(match)) {
13193                throw new System.ArgumentNullException.$ctor1("match");
13194            }
13195
13196            for (var i = 0; i < array.length; i++) {
13197                if (match(array[i])) {
13198                    return array[i];
13199                }
13200            }
13201
13202            return H5.getDefaultValue(T);
13203        },
13204
13205        findAll: function (array, match) {
13206            if (!H5.hasValue(array)) {
13207                throw new System.ArgumentNullException.$ctor1("array");
13208            }
13209
13210            if (!H5.hasValue(match)) {
13211                throw new System.ArgumentNullException.$ctor1("match");
13212            }
13213
13214            var list = [];
13215
13216            for (var i = 0; i < array.length; i++) {
13217                if (match(array[i])) {
13218                    list.push(array[i]);
13219                }
13220            }
13221
13222            return list;
13223        },
13224
13225        findIndex: function (array, startIndex, count, match) {
13226            if (!H5.hasValue(array)) {
13227                throw new System.ArgumentNullException.$ctor1("array");
13228            }
13229
13230            if (arguments.length === 2) {
13231                match = startIndex;
13232                startIndex = 0;
13233                count = array.length;
13234            } else if (arguments.length === 3) {
13235                match = count;
13236                count = array.length - startIndex;
13237            }
13238
13239            if (startIndex < 0 || startIndex > array.length) {
13240                throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
13241            }
13242
13243            if (count < 0 || startIndex > array.length - count) {
13244                throw new System.ArgumentOutOfRangeException.$ctor1("count");
13245            }
13246
13247            if (!H5.hasValue(match)) {
13248                throw new System.ArgumentNullException.$ctor1("match");
13249            }
13250
13251            var endIndex = startIndex + count;
13252
13253            for (var i = startIndex; i < endIndex; i++) {
13254                if (match(array[i])) {
13255                    return i;
13256                }
13257            }
13258
13259            return -1;
13260        },
13261
13262        findLast: function (T, array, match) {
13263            if (!H5.hasValue(array)) {
13264                throw new System.ArgumentNullException.$ctor1("array");
13265            }
13266
13267            if (!H5.hasValue(match)) {
13268                throw new System.ArgumentNullException.$ctor1("match");
13269            }
13270
13271            for (var i = array.length - 1; i >= 0; i--) {
13272                if (match(array[i])) {
13273                    return array[i];
13274                }
13275            }
13276
13277            return H5.getDefaultValue(T);
13278        },
13279
13280        findLastIndex: function (array, startIndex, count, match) {
13281            if (!H5.hasValue(array)) {
13282                throw new System.ArgumentNullException.$ctor1("array");
13283            }
13284
13285            if (arguments.length === 2) {
13286                match = startIndex;
13287                startIndex = array.length - 1;
13288                count = array.length;
13289            } else if (arguments.length === 3) {
13290                match = count;
13291                count = startIndex + 1;
13292            }
13293
13294            if (!H5.hasValue(match)) {
13295                throw new System.ArgumentNullException.$ctor1("match");
13296            }
13297
13298            if (array.length === 0) {
13299                if (startIndex !== -1) {
13300                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
13301                }
13302            } else {
13303                if (startIndex < 0 || startIndex >= array.length) {
13304                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
13305                }
13306            }
13307
13308            if (count < 0 || startIndex - count + 1 < 0) {
13309                throw new System.ArgumentOutOfRangeException.$ctor1("count");
13310            }
13311
13312            var endIndex = startIndex - count;
13313
13314            for (var i = startIndex; i > endIndex; i--) {
13315                if (match(array[i])) {
13316                    return i;
13317                }
13318            }
13319
13320            return -1;
13321        },
13322
13323        forEach: function (array, action) {
13324            if (!H5.hasValue(array)) {
13325                throw new System.ArgumentNullException.$ctor1("array");
13326            }
13327
13328            if (!H5.hasValue(action)) {
13329                throw new System.ArgumentNullException.$ctor1("action");
13330            }
13331
13332            for (var i = 0; i < array.length; i++) {
13333                action(array[i], i, array);
13334            }
13335        },
13336
13337        indexOfT: function (array, value, startIndex, count) {
13338            if (!H5.hasValue(array)) {
13339                throw new System.ArgumentNullException.$ctor1("array");
13340            }
13341
13342            if (arguments.length === 2) {
13343                startIndex = 0;
13344                count = array.length;
13345            } else if (arguments.length === 3) {
13346                count = array.length - startIndex;
13347            }
13348
13349            if (startIndex < 0 || (startIndex >= array.length && array.length > 0)) {
13350                throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "out of range");
13351            }
13352
13353            if (count < 0 || count > array.length - startIndex) {
13354                throw new System.ArgumentOutOfRangeException.$ctor4("count", "out of range");
13355            }
13356
13357            return System.Array.indexOf(array, value, startIndex, count);
13358        },
13359
13360        isFixedSize: function (array) {
13361            if (H5.isArray(array)) {
13362                return true;
13363            } else if (array["System$Collections$IList$isFixedSize"] != null) {
13364                return array["System$Collections$IList$isFixedSize"];
13365            } else if(array["System$Collections$IList$IsFixedSize"] != null) {
13366                return array["System$Collections$IList$IsFixedSize"];
13367            } else if (array.isFixedSize != null) {
13368                return array.isFixedSize;
13369            } else if (array.IsFixedSize != null) {
13370                return array.IsFixedSize;
13371            }
13372
13373            return true;
13374        },
13375
13376        isSynchronized: function (array) {
13377            return false;
13378        },
13379
13380        lastIndexOfT: function (array, value, startIndex, count) {
13381            if (!H5.hasValue(array)) {
13382                throw new System.ArgumentNullException.$ctor1("array");
13383            }
13384
13385            if (arguments.length === 2) {
13386                startIndex = array.length - 1;
13387                count = array.length;
13388            } else if (arguments.length === 3) {
13389                count = (array.length === 0) ? 0 : (startIndex + 1);
13390            }
13391
13392            if (startIndex < 0 || (startIndex >= array.length && array.length > 0)) {
13393                throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "out of range");
13394            }
13395
13396            if (count < 0 || startIndex - count + 1 < 0) {
13397                throw new System.ArgumentOutOfRangeException.$ctor4("count", "out of range");
13398            }
13399
13400            var endIndex = startIndex - count + 1;
13401
13402            for (var i = startIndex; i >= endIndex; i--) {
13403                var el = array[i];
13404
13405                if (el === value || System.Collections.Generic.EqualityComparer$1.$default.equals2(el, value)) {
13406                    return i;
13407                }
13408            }
13409
13410            return -1;
13411        },
13412
13413        syncRoot: function (array) {
13414            return array;
13415        },
13416
13417        trueForAll: function (array, match) {
13418            if (!H5.hasValue(array)) {
13419                throw new System.ArgumentNullException.$ctor1("array");
13420            }
13421
13422            if (!H5.hasValue(match)) {
13423                throw new System.ArgumentNullException.$ctor1("match");
13424            }
13425
13426            for (var i = 0; i < array.length; i++) {
13427                if (!match(array[i])) {
13428                    return false;
13429                }
13430            }
13431
13432            return true;
13433        },
13434
13435        type: function (t, rank, arr) {
13436            rank = rank || 1;
13437
13438            var typeCache = System.Array.$cache[rank],
13439                result,
13440                name;
13441
13442            if (!typeCache) {
13443                typeCache = [];
13444                System.Array.$cache[rank] = typeCache;
13445            }
13446
13447            for (var i = 0; i < typeCache.length; i++) {
13448                if (typeCache[i].$elementType === t) {
13449                    result = typeCache[i];
13450                    break;
13451                }
13452            }
13453
13454            if (!result) {
13455                name = H5.getTypeName(t) + "[" + System.String.fromCharCount(",".charCodeAt(0), rank - 1) + "]";
13456
13457                var old = H5.Class.staticInitAllow;
13458
13459                result = H5.define(name, {
13460                    $inherits: [System.Array, System.Collections.ICollection, System.ICloneable, System.Collections.Generic.IList$1(t), System.Collections.Generic.IReadOnlyCollection$1(t)],
13461                    $noRegister: true,
13462                    statics: {
13463                        $elementType: t,
13464                        $rank: rank,
13465                        $isArray: true,
13466                        $is: function (obj) {
13467                            return System.Array.is(obj, this);
13468                        },
13469                        getDefaultValue: function () {
13470                            return null;
13471                        },
13472                        createInstance: function () {
13473                            var arr;
13474
13475                            if (this.$rank === 1) {
13476                                arr = [];
13477                            } else {
13478                                var args = [H5.getDefaultValue(this.$elementType), null, this.$elementType];
13479
13480                                for (var j = 0; j < this.$rank; j++) {
13481                                    args.push(0);
13482                                }
13483
13484                                arr = System.Array.create.apply(System.Array, args);
13485                            }
13486
13487                            arr.$type = this;
13488
13489                            return arr;
13490                        }
13491                    }
13492                });
13493
13494                typeCache.push(result);
13495
13496                H5.Class.staticInitAllow = true;
13497
13498                if (result.$staticInit) {
13499                    result.$staticInit();
13500                }
13501
13502                H5.Class.staticInitAllow = old;
13503            }
13504
13505            if (arr) {
13506                arr.$type = result;
13507            }
13508
13509            return arr || result;
13510        },
13511        getLongLength: function (array) {
13512            return System.Int64(array.length);
13513        }
13514    };
13515
13516    H5.define("System.Array", {
13517        statics: array
13518    });
13519
13520    System.Array.$cache = {};
13521
13522    // @source ArraySegment.js
13523
13524    H5.define("System.ArraySegment", {
13525        $kind: "struct",
13526
13527        statics: {
13528            getDefaultValue: function () {
13529                return new System.ArraySegment();
13530            }
13531        },
13532
13533        ctor: function (array, offset, count) {
13534            this.$initialize();
13535
13536            if (arguments.length === 0) {
13537                this.array = null;
13538                this.offset = 0;
13539                this.count = 0;
13540
13541                return;
13542            }
13543
13544            if (array == null) {
13545                throw new System.ArgumentNullException.$ctor1("array");
13546            }
13547
13548            this.array = array;
13549
13550            if (H5.isNumber(offset)) {
13551                if (offset < 0) {
13552                    throw new System.ArgumentOutOfRangeException.$ctor1("offset");
13553                }
13554
13555                this.offset = offset;
13556            } else {
13557                this.offset = 0;
13558            }
13559
13560            if (H5.isNumber(count)) {
13561                if (count < 0) {
13562                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
13563                }
13564
13565                this.count = count;
13566            } else {
13567                this.count = array.length;
13568            }
13569
13570            if (array.length - this.offset < this.count) {
13571                throw new ArgumentException();
13572            }
13573        },
13574
13575        getArray: function () {
13576            return this.array;
13577        },
13578
13579        getCount: function () {
13580            return this.count;
13581        },
13582
13583        getOffset: function () {
13584            return this.offset;
13585        },
13586
13587        getHashCode: function () {
13588            var h = H5.addHash([5322976039, this.array, this.count, this.offset]);
13589
13590            return h;
13591        },
13592
13593        equals: function (o) {
13594            if (!H5.is(o, System.ArraySegment)) {
13595                return false;
13596            }
13597
13598            return H5.equals(this.array, o.array) && H5.equals(this.count, o.count) && H5.equals(this.offset, o.offset);
13599        },
13600
13601        $clone: function (to) { return this; }
13602    });
13603
13604    // @source Interfaces.js
13605
13606    H5.define("System.Collections.IEnumerable", {
13607        $kind: "interface"
13608    });
13609    H5.define("System.Collections.ICollection", {
13610        inherits: [System.Collections.IEnumerable],
13611        $kind: "interface"
13612    });
13613    H5.define("System.Collections.IList", {
13614        inherits: [System.Collections.ICollection],
13615        $kind: "interface"
13616    });
13617    H5.define("System.Collections.IDictionary", {
13618        inherits: [System.Collections.ICollection],
13619        $kind: "interface"
13620    });
13621
13622    H5.define("System.Collections.Generic.IEnumerable$1", function (T) {
13623        return {
13624            inherits: [System.Collections.IEnumerable],
13625            $kind: "interface",
13626            $variance: [1]
13627        };
13628    });
13629
13630    H5.define("System.Collections.Generic.ICollection$1", function (T) {
13631        return {
13632            inherits: [System.Collections.Generic.IEnumerable$1(T)],
13633            $kind: "interface"
13634        };
13635    });
13636
13637    H5.define("System.Collections.Generic.IEqualityComparer$1", function (T) {
13638        return {
13639            $kind: "interface",
13640            $variance: [2]
13641        };
13642    });
13643
13644    H5.define("System.Collections.Generic.IDictionary$2", function (TKey, TValue) {
13645        return {
13646            inherits: [System.Collections.Generic.ICollection$1(System.Collections.Generic.KeyValuePair$2(TKey, TValue))],
13647            $kind: "interface"
13648        };
13649    });
13650
13651    H5.define("System.Collections.Generic.IList$1", function (T) {
13652        return {
13653            inherits: [System.Collections.Generic.ICollection$1(T)],
13654            $kind: "interface"
13655        };
13656    });
13657
13658    H5.define("System.Collections.Generic.ISet$1", function (T) {
13659        return {
13660            inherits: [System.Collections.Generic.ICollection$1(T)],
13661            $kind: "interface"
13662        };
13663    });
13664
13665    H5.define("System.Collections.Generic.IReadOnlyCollection$1", function (T) {
13666        return {
13667            inherits: [System.Collections.Generic.IEnumerable$1(T)],
13668            $kind: "interface"
13669        };
13670    });
13671
13672    H5.define("System.Collections.Generic.IReadOnlyList$1", function (T) {
13673        return {
13674            inherits: [System.Collections.Generic.IReadOnlyCollection$1(T)],
13675            $kind: "interface",
13676            $variance: [1]
13677        };
13678    });
13679
13680    H5.define("System.Collections.Generic.IReadOnlyDictionary$2", function (TKey, TValue) {
13681        return {
13682            inherits: [System.Collections.Generic.IReadOnlyCollection$1(System.Collections.Generic.KeyValuePair$2(TKey, TValue))],
13683            $kind: "interface"
13684        };
13685    });
13686
13687    // @source String.js
13688
13689    H5.define("System.String", {
13690        inherits: [System.IComparable, System.ICloneable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerable$1(System.Char)],
13691
13692        statics: {
13693            $is: function (instance) {
13694                return typeof (instance) === "string";
13695            },
13696
13697            charCodeAt: function (str, idx) {
13698                idx = idx || 0;
13699
13700                var code = str.charCodeAt(idx),
13701                    hi,
13702                    low;
13703
13704                if (0xD800 <= code && code <= 0xDBFF) {
13705                    hi = code;
13706                    low = str.charCodeAt(idx + 1);
13707
13708                    if (isNaN(low)) {
13709                        throw new System.Exception("High surrogate not followed by low surrogate");
13710                    }
13711
13712                    return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
13713                }
13714
13715                if (0xDC00 <= code && code <= 0xDFFF) {
13716                    return false;
13717                }
13718
13719                return code;
13720            },
13721
13722            fromCharCode: function (codePt) {
13723                if (codePt > 0xFFFF) {
13724                    codePt -= 0x10000;
13725
13726                    return String.fromCharCode(0xD800 + (codePt >> 10), 0xDC00 + (codePt & 0x3FF));
13727                }
13728
13729                return String.fromCharCode(codePt);
13730            },
13731
13732            fromCharArray: function (chars, startIndex, length) {
13733                if (chars == null) {
13734                    throw new System.ArgumentNullException.$ctor1("chars");
13735                }
13736
13737                if (startIndex < 0) {
13738                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
13739                }
13740
13741                if (length < 0) {
13742                    throw new System.ArgumentOutOfRangeException.$ctor1("length");
13743                }
13744
13745                if (chars.length - startIndex < length) {
13746                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
13747                }
13748
13749                var result = "";
13750
13751                startIndex = startIndex || 0;
13752                length = H5.isNumber(length) ? length : chars.length;
13753
13754                if ((startIndex + length) > chars.length) {
13755                    length = chars.length - startIndex;
13756                }
13757
13758                for (var i = 0; i < length; i++) {
13759                    var ch = chars[i + startIndex] | 0;
13760
13761                    result += String.fromCharCode(ch);
13762                }
13763
13764                return result;
13765            },
13766
13767            lastIndexOf: function (s, search, startIndex, count) {
13768                var index = s.lastIndexOf(search, startIndex);
13769
13770                return (index < (startIndex - count + 1)) ? -1 : index;
13771            },
13772
13773            lastIndexOfAny: function (s, chars, startIndex, count) {
13774                var length = s.length;
13775
13776                if (!length) {
13777                    return -1;
13778                }
13779
13780                chars = String.fromCharCode.apply(null, chars);
13781                startIndex = startIndex || length - 1;
13782                count = count || length;
13783
13784                var endIndex = startIndex - count + 1;
13785
13786                if (endIndex < 0) {
13787                    endIndex = 0;
13788                }
13789
13790                for (var i = startIndex; i >= endIndex; i--) {
13791                    if (chars.indexOf(s.charAt(i)) >= 0) {
13792                        return i;
13793                    }
13794                }
13795
13796                return -1;
13797            },
13798
13799            isNullOrWhiteSpace: function (s) {
13800                if (!s) {
13801                    return true;
13802                }
13803
13804                return System.Char.isWhiteSpace(s);
13805            },
13806
13807            isNullOrEmpty: function (s) {
13808                return !s;
13809            },
13810
13811            fromCharCount: function (c, count) {
13812                if (count >= 0) {
13813                    return String(Array(count + 1).join(String.fromCharCode(c)));
13814                } else {
13815                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "cannot be less than zero");
13816                }
13817            },
13818
13819            format: function (format, args) {
13820                return System.String._format(System.Globalization.CultureInfo.getCurrentCulture(), format, Array.isArray(args) && arguments.length == 2 ? args : Array.prototype.slice.call(arguments, 1));
13821            },
13822
13823            formatProvider: function (provider, format, args) {
13824                return System.String._format(provider, format, Array.isArray(args) && arguments.length == 3 ? args : Array.prototype.slice.call(arguments, 2));
13825            },
13826
13827            _format: function (provider, format, args) {
13828                if (format == null) {
13829                    throw new System.ArgumentNullException.$ctor1("format");
13830                }
13831
13832                var reverse = function (s) {
13833                    return s.split("").reverse().join("");
13834                };
13835
13836                format = reverse(reverse(format.replace(/\{\{/g, function (m) {
13837                    return String.fromCharCode(1, 1);
13838                })).replace(/\}\}/g, function (m) {
13839                    return String.fromCharCode(2, 2);
13840                }));
13841
13842                var me = this,
13843                    _formatRe = /(\{+)((\d+|[a-zA-Z_$]\w+(?:\.[a-zA-Z_$]\w+|\[\d+\])*)(?:\,(-?\d*))?(?:\:([^\}]*))?)(\}+)|(\{+)|(\}+)/g,
13844                    fn = this.decodeBraceSequence;
13845
13846                format = format.replace(_formatRe, function (m, openBrace, elementContent, index, align, format, closeBrace, repeatOpenBrace, repeatCloseBrace) {
13847                    if (repeatOpenBrace) {
13848                        return fn(repeatOpenBrace);
13849                    }
13850
13851                    if (repeatCloseBrace) {
13852                        return fn(repeatCloseBrace);
13853                    }
13854
13855                    if (openBrace.length % 2 === 0 || closeBrace.length % 2 === 0) {
13856                        return fn(openBrace) + elementContent + fn(closeBrace);
13857                    }
13858
13859                    return fn(openBrace, true) + me.handleElement(provider, index, align, format, args) + fn(closeBrace, true);
13860                });
13861
13862                return format.replace(/(\x01\x01)|(\x02\x02)/g, function (m) {
13863                    if (m == String.fromCharCode(1, 1)) {
13864                        return "{";
13865                    }
13866
13867                    if (m == String.fromCharCode(2, 2)) {
13868                        return "}";
13869                    }
13870                });
13871            },
13872
13873            handleElement: function (provider, index, alignment, formatStr, args) {
13874                var value;
13875
13876                index = parseInt(index, 10);
13877
13878                if (index > args.length - 1) {
13879                    throw new System.FormatException.$ctor1("Input string was not in a correct format.");
13880                }
13881
13882                value = args[index];
13883
13884                if (value == null) {
13885                    value = "";
13886                }
13887
13888                if (formatStr && value.$boxed && value.type.$kind === "enum") {
13889                    value = System.Enum.format(value.type, value.v, formatStr);
13890                } else if (formatStr && value.$boxed && value.type.format) {
13891                    value = value.type.format(H5.unbox(value, true), formatStr, provider);
13892                } else if (formatStr && H5.is(value, System.IFormattable)) {
13893                    value = H5.format(H5.unbox(value, true), formatStr, provider);
13894                } if (H5.isNumber(value)) {
13895                    value = H5.Int.format(value, formatStr, provider);
13896                } else if (H5.isDate(value)) {
13897                    value = System.DateTime.format(value, formatStr, provider);
13898                } else {
13899                    value = "" + H5.toString(value);
13900                }
13901
13902                if (alignment) {
13903                    alignment = parseInt(alignment, 10);
13904
13905                    if (!H5.isNumber(alignment)) {
13906                        alignment = null;
13907                    }
13908                }
13909
13910                return System.String.alignString(H5.toString(value), alignment);
13911            },
13912
13913            decodeBraceSequence: function (braces, remove) {
13914                return braces.substr(0, (braces.length + (remove ? 0 : 1)) / 2);
13915            },
13916
13917            alignString: function (str, alignment, pad, dir, cut) {
13918                if (str == null || !alignment) {
13919                    return str;
13920                }
13921
13922                if (!pad) {
13923                    pad = " ";
13924                }
13925
13926                if (H5.isNumber(pad)) {
13927                    pad = String.fromCharCode(pad);
13928                }
13929
13930                if (!dir) {
13931                    dir = alignment < 0 ? 1 : 2;
13932                }
13933
13934                alignment = Math.abs(alignment);
13935
13936                if (cut && (str.length > alignment)) {
13937                    str = str.substring(0, alignment);
13938                }
13939
13940                if (alignment + 1 >= str.length) {
13941                    switch (dir) {
13942                        case 2:
13943                            str = Array(alignment + 1 - str.length).join(pad) + str;
13944                            break;
13945
13946                        case 3:
13947                            var padlen = alignment - str.length,
13948                                right = Math.ceil(padlen / 2),
13949                                left = padlen - right;
13950
13951                            str = Array(left + 1).join(pad) + str + Array(right + 1).join(pad);
13952                            break;
13953
13954                        case 1:
13955                        default:
13956                            str = str + Array(alignment + 1 - str.length).join(pad);
13957                            break;
13958                    }
13959                }
13960
13961                return str;
13962            },
13963
13964            startsWith: function (str, prefix) {
13965                if (!prefix.length) {
13966                    return true;
13967                }
13968
13969                if (prefix.length > str.length) {
13970                    return false;
13971                }
13972
13973                return System.String.equals(str.slice(0, prefix.length), prefix, arguments[2]);
13974            },
13975
13976            endsWith: function (str, suffix) {
13977                if (!suffix.length) {
13978                    return true;
13979                }
13980
13981                if (suffix.length > str.length) {
13982                    return false;
13983                }
13984
13985                return System.String.equals(str.slice(str.length - suffix.length, str.length), suffix, arguments[2]);
13986            },
13987
13988            contains: function (str, value) {
13989                if (value == null) {
13990                    throw new System.ArgumentNullException();
13991                }
13992
13993                if (str == null) {
13994                    return false;
13995                }
13996
13997                return str.indexOf(value) > -1;
13998            },
13999
14000            indexOfAny: function (str, anyOf) {
14001                if (anyOf == null) {
14002                    throw new System.ArgumentNullException();
14003                }
14004
14005                if (str == null || str === "") {
14006                    return -1;
14007                }
14008
14009                var startIndex = (arguments.length > 2) ? arguments[2] : 0;
14010
14011                if (startIndex < 0) {
14012                    throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "startIndex cannot be less than zero");
14013                }
14014
14015                var length = str.length - startIndex;
14016
14017                if (arguments.length > 3 && arguments[3] != null) {
14018                    length = arguments[3];
14019                }
14020
14021                if (length < 0) {
14022                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "must be non-negative");
14023                }
14024
14025                if (length > str.length - startIndex) {
14026                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index and length must refer to a location within the string");
14027                }
14028
14029                length = startIndex + length;
14030                anyOf = String.fromCharCode.apply(null, anyOf);
14031
14032                for (var i = startIndex; i < length; i++) {
14033                    if (anyOf.indexOf(str.charAt(i)) >= 0) {
14034                        return i;
14035                    }
14036                }
14037
14038                return -1;
14039            },
14040
14041            indexOf: function (str, value) {
14042                if (value == null) {
14043                    throw new System.ArgumentNullException();
14044                }
14045
14046                if (str == null || str === "") {
14047                    return -1;
14048                }
14049
14050                var startIndex = (arguments.length > 2) ? arguments[2] : 0;
14051
14052                if (startIndex < 0 || startIndex > str.length) {
14053                    throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "startIndex cannot be less than zero and must refer to a location within the string");
14054                }
14055
14056                if (value === "") {
14057                    return (arguments.length > 2) ? startIndex : 0;
14058                }
14059
14060                var length = str.length - startIndex;
14061
14062                if (arguments.length > 3 && arguments[3] != null) {
14063                    length = arguments[3];
14064                }
14065
14066                if (length < 0) {
14067                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "must be non-negative");
14068                }
14069
14070                if (length > str.length - startIndex) {
14071                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index and length must refer to a location within the string");
14072                }
14073
14074                var s = str.substr(startIndex, length),
14075                    index = (arguments.length === 5 && arguments[4] % 2 !== 0) ? s.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) : s.indexOf(value);
14076
14077                if (index > -1) {
14078                    if (arguments.length === 5) {
14079                        // StringComparison
14080                        return (System.String.compare(value, s.substr(index, value.length), arguments[4]) === 0) ? index + startIndex : -1;
14081                    } else {
14082                        return index + startIndex;
14083                    }
14084                }
14085
14086                return -1;
14087            },
14088
14089            equals: function () {
14090                return System.String.compare.apply(this, arguments) === 0;
14091            },
14092
14093            swapCase: function (letters) {
14094                return letters.replace(/\w/g, function (c) {
14095                    if (c === c.toLowerCase()) {
14096                        return c.toUpperCase();
14097                    } else {
14098                        return c.toLowerCase();
14099                    }
14100                });
14101            },
14102
14103            compare: function (strA, strB) {
14104                if (strA == null) {
14105                    return (strB == null) ? 0 : -1;
14106                }
14107
14108                if (strB == null) {
14109                    return 1;
14110                }
14111
14112                if (arguments.length >= 3) {
14113                    if (!H5.isBoolean(arguments[2])) {
14114                        // StringComparison
14115                        switch (arguments[2]) {
14116                            case 1: // CurrentCultureIgnoreCase
14117                                return strA.localeCompare(strB, System.Globalization.CultureInfo.getCurrentCulture().name, {
14118                                    sensitivity: "accent"
14119                                });
14120                            case 2: // InvariantCulture
14121                                return strA.localeCompare(strB, System.Globalization.CultureInfo.invariantCulture.name);
14122                            case 3: // InvariantCultureIgnoreCase
14123                                return strA.localeCompare(strB, System.Globalization.CultureInfo.invariantCulture.name, {
14124                                    sensitivity: "accent"
14125                                });
14126                            case 4: // Ordinal
14127                                return (strA === strB) ? 0 : ((strA >
14127 strB) ? 1 : -1);
14128                            case 5: // OrdinalIgnoreCase
14129                                return (strA.toUpperCase() === strB.toUpperCase()) ? 0 : ((strA.toUpperCase() > strB.toUpperCase()) ? 1 : -1);
14130                            case 0: // CurrentCulture
14131                            default:
14132                                break;
14133                        }
14134                    } else {
14135                        // ignoreCase
14136                        if (arguments[2]) {
14137                            strA = strA.toLocaleUpperCase();
14138                            strB = strB.toLocaleUpperCase();
14139                        }
14140
14141                        if (arguments.length === 4) {
14142                            // CultureInfo
14143                            return strA.localeCompare(strB, arguments[3].name);
14144                        }
14145                    }
14146                }
14147
14148                return strA.localeCompare(strB);
14149            },
14150
14151            toCharArray: function (str, startIndex, length) {
14152                if (startIndex < 0 || startIndex > str.length || startIndex > str.length - length) {
14153                    throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "startIndex cannot be less than zero and must refer to a location within the string");
14154                }
14155
14156                if (length < 0) {
14157                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "must be non-negative");
14158                }
14159
14160                if (!H5.hasValue(startIndex)) {
14161                    startIndex = 0;
14162                }
14163
14164                if (!H5.hasValue(length)) {
14165                    length = str.length;
14166                }
14167
14168                var arr = [];
14169
14170                for (var i = startIndex; i < startIndex + length; i++) {
14171                    arr.push(str.charCodeAt(i));
14172                }
14173
14174                return arr;
14175            },
14176
14177            escape: function (str) {
14178                return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
14179            },
14180
14181            replaceAll: function (str, a, b) {
14182                var reg = new RegExp(System.String.escape(a), "g");
14183
14184                return str.replace(reg, b);
14185            },
14186
14187            insert: function (index, strA, strB) {
14188                return index > 0 ? (strA.substring(0, index) + strB + strA.substring(index, strA.length)) : (strB + strA);
14189            },
14190
14191            remove: function (s, index, count) {
14192                if (s == null) {
14193                    throw new System.NullReferenceException();
14194                }
14195
14196                if (index < 0) {
14197                    throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "StartIndex cannot be less than zero");
14198                }
14199
14200                if (count != null) {
14201                    if (count < 0) {
14202                        throw new System.ArgumentOutOfRangeException.$ctor4("count", "Count cannot be less than zero");
14203                    }
14204
14205                    if (count > s.length - index) {
14206                        throw new System.ArgumentOutOfRangeException.$ctor4("count", "Index and count must refer to a location within the string");
14207                    }
14208                } else {
14209                    if (index >= s.length) {
14210                        throw new System.ArgumentOutOfRangeException.$ctor4("startIndex", "startIndex must be less than length of string");
14211                    }
14212                }
14213
14214                if (count == null || ((index + count) > s.length)) {
14215                    return s.substr(0, index);
14216                }
14217
14218                return s.substr(0, index) + s.substr(index + count);
14219            },
14220
14221            split: function (s, strings, limit, options) {
14222                var re = (!H5.hasValue(strings) || strings.length === 0) ? new RegExp("\\s", "g") : new RegExp(strings.map(System.String.escape).join("|"), "g"),
14223                    res = [],
14224                    m,
14225                    i;
14226
14227                for (i = 0; ; i = re.lastIndex) {
14228                    if (m = re.exec(s)) {
14229                        if (options !== 1 || m.index > i) {
14230                            if (res.length === limit - 1) {
14231                                res.push(s.substr(i));
14232
14233                                return res;
14234                            } else {
14235                                res.push(s.substring(i, m.index));
14236                            }
14237                        }
14238                    } else {
14239                        if (options !== 1 || i !== s.length) {
14240                            res.push(s.substr(i));
14241                        }
14242
14243                        return res;
14244                    }
14245                }
14246            },
14247
14248            trimEnd: function (str, chars) {
14249                return str.replace(chars ? new RegExp("[" + System.String.escape(String.fromCharCode.apply(null, chars)) + "]+$") : /\s*$/, "");
14250            },
14251
14252            trimStart: function (str, chars) {
14253                return str.replace(chars ? new RegExp("^[" + System.String.escape(String.fromCharCode.apply(null, chars)) + "]+") : /^\s*/, "");
14254            },
14255
14256            trim: function (str, chars) {
14257                return System.String.trimStart(System.String.trimEnd(str, chars), chars);
14258            },
14259
14260            trimStartZeros: function (str) {
14261                return str.replace(new RegExp("^[ 0+]+(?=.)"), "");
14262            },
14263
14264            concat: function (values) {
14265                var list = (arguments.length == 1 && Array.isArray(values)) ? values : [].slice.call(arguments),
14266                    s = "";
14267
14268                for (var i = 0; i < list.length; i++) {
14269                    s += list[i] == null ? "" : H5.toString(list[i]);
14270                }
14271
14272                return s;
14273            },
14274
14275            copyTo: function (str, sourceIndex, destination, destinationIndex, count) {
14276                if (destination == null) {
14277                    throw new System.ArgumentNullException.$ctor1("destination");
14278                }
14279
14280                if (str == null) {
14281                    throw new System.ArgumentNullException.$ctor1("str");
14282                }
14283
14284                if (count < 0) {
14285                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
14286                }
14287
14288                if (sourceIndex < 0) {
14289                    throw new System.ArgumentOutOfRangeException.$ctor1("sourceIndex");
14290                }
14291
14292                if (count > str.length - sourceIndex) {
14293                    throw new System.ArgumentOutOfRangeException.$ctor1("sourceIndex");
14294                }
14295
14296                if (destinationIndex > destination.length - count || destinationIndex < 0) {
14297                    throw new System.ArgumentOutOfRangeException.$ctor1("destinationIndex");
14298                }
14299
14300                if (count > 0) {
14301                    for (var i = 0; i < count; i++) {
14302                        destination[destinationIndex + i] = str.charCodeAt(sourceIndex + i
14302);
14303                    }
14304                }
14305            }
14306        }
14307    });
14308
14309    H5.Class.addExtend(System.String, [System.IComparable$1(System.String), System.IEquatable$1(System.String)]);
14310
14311    // @source KeyValuePair.js
14312
14313    H5.define("System.Collections.Generic.KeyValuePair$2", function (TKey, TValue) { return {
14314        $kind: "struct",
14315        statics: {
14316            methods: {
14317                getDefaultValue: function () { return new (System.Collections.Generic.KeyValuePair$2(TKey,TValue))(); }
14318            }
14319        },
14320        fields: {
14321            key$1: H5.getDefaultValue(TKey),
14322            value$1: H5.getDefaultValue(TValue)
14323        },
14324        props: {
14325            key: {
14326                get: function () {
14327                    return this.key$1;
14328                }
14329            },
14330            value: {
14331                get: function () {
14332                    return this.value$1;
14333                }
14334            }
14335        },
14336        ctors: {
14337            $ctor1: function (key, value) {
14338                this.$initialize();
14339                this.key$1 = key;
14340                this.value$1 = value;
14341            },
14342            ctor: function () {
14343                this.$initialize();
14344            }
14345        },
14346        methods: {
14347            toString: function () {
14348                var s = System.Text.StringBuilderCache.Acquire();
14349                s.append(String.fromCharCode(91));
14350                if (this.key != null) {
14351                    s.append(H5.toString(this.key));
14352                }
14353                s.append(", ");
14354                if (this.value != null) {
14355                    s.append(H5.toString(this.value));
14356                }
14357                s.append(String.fromCharCode(93));
14358                return System.Text.StringBuilderCache.GetStringAndRelease(s);
14359            },
14360            Deconstruct: function (key, value) {
14361                key.v = this.key;
14362                value.v = this.value;
14363            },
14364            getHashCode: function () {
14365                var h = H5.addHash([5072499452, this.key$1, this.value$1]);
14366                return h;
14367            },
14368            equals: function (o) {
14369                if (!H5.is(o, System.Collections.Generic.KeyValuePair$2(TKey,TValue))) {
14370                    return false;
14371                }
14372                return H5.equals(this.key$1, o.key$1) && H5.equals(this.value$1, o.value$1);
14373            },
14374            $clone: function (to) { return this; }
14375        }
14376    }; });
14377
14378    // @source IEnumerator.js
14379
14380    H5.define("System.Collections.IEnumerator", {
14381        $kind: "interface"
14382    });
14383
14384    // @source IComparer.js
14385
14386    H5.define("System.Collections.IComparer", {
14387        $kind: "interface"
14388    });
14389
14390    // @source IDictionaryEnumerator.js
14391
14392    H5.define("System.Collections.IDictionaryEnumerator", {
14393        inherits: [System.Collections.IEnumerator],
14394        $kind: "interface"
14395    });
14396
14397    // @source IEqualityComparer.js
14398
14399    H5.define("System.Collections.IEqualityComparer", {
14400        $kind: "interface"
14401    });
14402
14403    // @source IStructuralComparable.js
14404
14405    H5.define("System.Collections.IStructuralComparable", {
14406        $kind: "interface"
14407    });
14408
14409    // @source IStructuralEquatable.js
14410
14411    H5.define("System.Collections.IStructuralEquatable", {
14412        $kind: "interface"
14413    });
14414
14415    // @source IEnumerator.js
14416
14417    H5.definei("System.Collections.Generic.IEnumerator$1", function (T) { return {
14418        inherits: [System.IDisposable,System.Collections.IEnumerator],
14419        $kind: "interface",
14420        $variance: [1]
14421    }; });
14422
14423    // @source IComparer.js
14424
14425    H5.definei("System.Collections.Generic.IComparer$1", function (T) { return {
14426        $kind: "interface",
14427        $variance: [2]
14428    }; });
14429
14430    // @source KeyValuePairs.js
14431
14432    H5.define("System.Collections.KeyValuePairs", {
14433        fields: {
14434            key: null,
14435            value: null
14436        },
14437        props: {
14438            Key: {
14439                get: function () {
14440                    return this.key;
14441                }
14442            },
14443            Value: {
14444                get: function () {
14445                    return this.value;
14446                }
14447            }
14448        },
14449        ctors: {
14450            ctor: function (key, value) {
14451                this.$initialize();
14452                this.value = value;
14453                this.key = key;
14454            }
14455        }
14456    });
14457
14458    // @source SortedList.js
14459
14460    H5.define("System.Collections.SortedList", {
14461        inherits: [System.Collections.IDictionary,System.ICloneable],
14462        statics: {
14463            fields: {
14464                emptyArray: null
14465            },
14466            ctors: {
14467                init: function () {
14468                    this.emptyArray = System.Array.init(0, null, System.Object);
14469                }
14470            },
14471            methods: {
14472                Synchronized: function (list) {
14473                    if (list == null) {
14474                        throw new System.ArgumentNullException.$ctor1("list");
14475                    }
14476
14477                    return new System.Collections.SortedList.SyncSortedList(list);
14478                }
14479            }
14480        },
14481        fields: {
14482            keys: null,
14483            values: null,
14484            _size: 0,
14485            version: 0,
14486            comparer: null,
14487            keyList: null,
14488            valueList: null
14489        },
14490        props: {
14491            Capacity: {
14492                get: function () {
14493                    return this.keys.length;
14494                },
14495                set: function (value) {
14496                    if (value < this.Count) {
14497                        throw new System.ArgumentOutOfRangeException.$ctor1("value");
14498                    }
14499
14500                    if (value !== this.keys.length) {
14501                        if (value > 0) {
14502                            var newKeys = System.Array.init(value, null, System.Object);
14503                            var newValues = System.Array.init(value, null, System.Object);
14504                            if (this._size > 0) {
14505                                System.Array.copy(this.keys, 0, newKeys, 0, this._size);
14506                                System.Array.copy(this.values, 0, newValues, 0, this._size);
14507                            }
14508                            this.keys = newKeys;
14509                            this.values = newValues;
14510                        } else {
14511                            this.keys = System.Collections.SortedList.emptyArray;
14512                            this.values = System.Collections.SortedList.emptyArray;
14513                        }
14514                    }
14515                }
14516            },
14517            Count: {
14518                get: function () {
14519                    return this._size;
14520                }
14521            },
14522            Keys: {
14523                get: function () {
14524                    return this.GetKeyList();
14525                }
14526            },
14527            Values: {
14528                get: function () {
14529                    return this.GetValueList();
14530                }
14531            },
14532            IsReadOnly: {
14533                get: function () {
14534                    return false;
14535                }
14536            },
14537            IsFixedSize: {
14538                get: function () {
14539                    return false;
14540                }
14541            },
14542            IsSynchronized: {
14543                get: function () {
14544                    return false;
14545                }
14546            },
14547            SyncRoot: {
14548                get: function () {
14549                    return null;
14550                }
14551            }
14552        },
14553        alias: [
14554            "add", "System$Collections$IDictionary$add",
14555            "Count", "System$Collections$ICollection$Count",
14556            "Keys", "System$Collections$IDictionary$Keys",
14557            "Values", "System$Collections$IDictionary$Values",
14558            "IsReadOnly", "System$Collections$IDictionary$IsReadOnly",
14559            "IsFixedSize", "System$Collections$IDictionary$IsFixedSize",
14560            "IsSynchronized", "System$Collections$ICollection$IsSynchronized",
14561            "SyncRoot", "System$Collections$ICollection$SyncRoot",
14562            "clear", "System$Collections$IDictionary$clear",
14563            "clone", "System$ICloneable$clone",
14564            "contains", "System$Collections$IDictionary$contains",
14565            "copyTo", "System$Collections$ICollection$copyTo",
14566            "GetEnumerator", "System$Collections$IDictionary$GetEnumerator",
14567            "getItem", "System$Collections$IDictionary$getItem",
14568            "setItem", "System$Collections$IDictionary$setItem",
14569            "remove", "System$Collections$IDictionary$remove"
14570        ],
14571        ctors: {
14572            ctor: function () {
14573                this.$initialize();
14574                this.Init();
14575            },
14576            $ctor5: function (initialCapacity) {
14577                this.$initialize();
14578                if (initialCapacity < 0) {
14579                    throw new System.ArgumentOutOfRangeException.$ctor1("initialCapacity");
14580                }
14581
14582                this.keys = System.Array.init(initialCapacity, null, System.Object);
14583                this.values = System.Array.init(initialCapacity, null, System.Object);
14584                this.comparer = new (System.Collections.Generic.Comparer$1(Object))(System.Collections.Generic.Comparer$1.$default.fn);
14585            },
14586            $ctor1: function (comparer) {
14587                System.Collections.SortedList.ctor.call(this);
14588                if (comparer != null) {
14589                    this.comparer = comparer;
14590                }
14591            },
14592            $ctor2: function (comparer, capacity) {
14593                System.Collections.SortedList.$ctor1.call(this, comparer);
14594                this.Capacity = capacity;
14595            },
14596            $ctor3: function (d) {
14597                System.Collections.SortedList.$ctor4.call(this, d, null);
14598            },
14599            $ctor4: function (d, comparer) {
14600                System.Collections.SortedList.$ctor2.call(this, comparer, (d != null ? System.Array.getCount(d) : 0));
14601                if (d == null) {
14602                    throw new System.ArgumentNullException.$ctor1("d");
14603                }
14604
14605                System.Array.copyTo(d.System$Collections$IDictionary$Keys, this.keys, 0);
14606                System.Array.copyTo(d.System$Collections$IDictionary$Values, this.values, 0);
14607                System.Array.sortDict(this.keys, this.values, 0, null, comparer);
14608                this._size = System.Array.getCount(d);
14609            }
14610        },
14611        methods: {
14612            getItem: function (key) {
14613                var i = this.IndexOfKey(key);
14614                if (i >= 0) {
14615                    return this.values[System.Array.index(i, this.values)];
14616                }
14617                return null;
14618            },
14619            setItem: function (key, value) {
14620                if (key == null) {
14621                    throw new System.ArgumentNullException.$ctor1("key");
14622                }
14623
14624                var i = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
14625                if (i >= 0) {
14626                    this.values[System.Array.index(i, this.values)] = value;
14627                    this.version = (this.version + 1) | 0;
14628                    return;
14629                }
14630                this.Insert(~i, key, value);
14631            },
14632            Init: function () {
14633                this.keys = System.Collections.SortedList.emptyArray;
14634                this.values = System.Collections.SortedList.emptyArray;
14635                this._size = 0;
14636                this.comparer = new (System.Collections.Generic.Comparer$1(Object))(System.Collections.Generic.Comparer$1.$default.fn);
14637            },
14638            add: function (key, value) {
14639                if (key == null) {
14640                    throw new System.ArgumentNullException.$ctor1("key");
14641                }
14642
14643                var i = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
14644                if (i >= 0) {
14645                    throw new System.ArgumentException.ctor();
14646                }
14647                this.Insert(~i, key, value);
14648            },
14649            clear: function () {
14650                this.version = (this.version + 1) | 0;
14651                System.Array.fill(this.keys, null, 0, this._size);
14652                System.Array.fill(this.values, null, 0, this._size);
14653                this._size = 0;
14654
14655            },
14656            clone: function () {
14657                var sl = new System.Collections.SortedList.$ctor5(this._size);
14658                System.Array.copy(this.keys, 0, sl.keys, 0, this._size);
14659                System.Array.copy(this.values, 0, sl.values, 0, this._size);
14660                sl._size = this._size;
14661                sl.version = this.version;
14662                sl.comparer = this.comparer;
14663                return sl;
14664            },
14665            contains: function (key) {
14666                return this.IndexOfKey(key) >= 0;
14667            },
14668            ContainsKey: function (key) {
14669                return this.IndexOfKey(key) >= 0;
14670            },
14671            ContainsValue: function (value) {
14672                return this.IndexOfValue(value) >= 0;
14673            },
14674            copyTo: function (array, arrayIndex) {
14675                if (array == null) {
14676                    throw new System.ArgumentNullException.$ctor1("array");
14677                }
14678                if (System.Array.getRank(array) !== 1) {
14679                    throw new System.ArgumentException.ctor();
14680                }
14681                if (arrayIndex < 0) {
14682                    throw new System.ArgumentOutOfRangeException.$ctor1("arrayIndex");
14683                }
14684                if (((array.length - arrayIndex) | 0) < this.Count) {
14685                    throw new System.ArgumentException.ctor();
14686                }
14687                for (var i = 0; i < this.Count; i = (i + 1) | 0) {
14688                    var entry = new System.Collections.DictionaryEntry.$ctor1(this.keys[System.Array.index(i, this.keys)], this.values[System.Array.index(i, this.values)]);
14689                    System.Array.set(array, entry.$clone(), ((i + arrayIndex) | 0));
14690                }
14691            },
14692            ToKeyValuePairsArray: function () {
14693                var array = System.Array.init(this.Count, null, System.Collections.KeyValuePairs);
14694                for (var i = 0; i < this.Count; i = (i + 1) | 0) {
14695                    array[System.Array.index(i, array)] = new System.Collections.KeyValuePairs(this.keys[System.Array.index(i, this.keys)], this.values[System.Array.index(i, this.values)]);
14696                }
14697                return array;
14698            },
14699            EnsureCapacity: function (min) {
14700                var newCapacity = this.keys.length === 0 ? 16 : H5.Int.mul(this.keys.length, 2);
14701
14702                if ((newCapacity >>> 0) > 2146435071) {
14703                    newCapacity = 2146435071;
14704                }
14705                if (newCapacity < min) {
14706                    newCapacity = min;
14707                }
14708                this.Capacity = newCapacity;
14709            },
14710            GetByIndex: function (index) {
14711                if (index < 0 || index >= this.Count) {
14712                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
14713                }
14714
14715                return this.values[System.Array.index(index, this.values)];
14716            },
14717            System$Collections$IEnumerable$GetEnumerator: function () {
14718                return new System.Collections.SortedList.SortedListEnumerator(this, 0, this._size, System.Collections.SortedList.SortedListEnumerator.DictEntry
14718);
14719            },
14720            GetEnumerator: function () {
14721                return new System.Collections.SortedList.SortedListEnumerator(this, 0, this._size, System.Collections.SortedList.SortedListEnumerator.DictEntry);
14722            },
14723            GetKey: function (index) {
14724                if (index < 0 || index >= this.Count) {
14725                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
14726                }
14727                return this.keys[System.Array.index(index, this.keys)];
14728            },
14729            GetKeyList: function () {
14730                if (this.keyList == null) {
14731                    this.keyList = new System.Collections.SortedList.KeyList(this);
14732                }
14733                return this.keyList;
14734            },
14735            GetValueList: function () {
14736                if (this.valueList == null) {
14737                    this.valueList = new System.Collections.SortedList.ValueList(this);
14738                }
14739                return this.valueList;
14740            },
14741            IndexOfKey: function (key) {
14742                if (key == null) {
14743                    throw new System.ArgumentNullException.$ctor1("key");
14744                }
14745
14746                var ret = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
14747                return ret >= 0 ? ret : -1;
14748            },
14749            IndexOfValue: function (value) {
14750                return System.Array.indexOfT(this.values, value, 0, this._size);
14751            },
14752            Insert: function (index, key, value) {
14753                if (this._size === this.keys.length) {
14754                    this.EnsureCapacity(((this._size + 1) | 0));
14755                }
14756                if (index < this._size) {
14757                    System.Array.copy(this.keys, index, this.keys, ((index + 1) | 0), ((this._size - index) | 0));
14758                    System.Array.copy(this.values, index, this.values, ((index + 1) | 0), ((this._size - index) | 0));
14759                }
14760                this.keys[System.Array.index(index, this.keys)] = key;
14761                this.values[System.Array.index(index, this.values)] = value;
14762                this._size = (this._size + 1) | 0;
14763                this.version = (this.version + 1) | 0;
14764            },
14765            RemoveAt: function (index) {
14766                if (index < 0 || index >= this.Count) {
14767                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
14768                }
14769
14770                this._size = (this._size - 1) | 0;
14771                if (index < this._size) {
14772                    System.Array.copy(this.keys, ((index + 1) | 0), this.keys, index, ((this._size - index) | 0));
14773                    System.Array.copy(this.values, ((index + 1) | 0), this.values, index, ((this._size - index) | 0));
14774                }
14775                this.keys[System.Array.index(this._size, this.keys)] = null;
14776                this.values[System.Array.index(this._size, this.values)] = null;
14777                this.version = (this.version + 1) | 0;
14778            },
14779            remove: function (key) {
14780                var i = this.IndexOfKey(key);
14781                if (i >= 0) {
14782                    this.RemoveAt(i);
14783                }
14784            },
14785            SetByIndex: function (index, value) {
14786                if (index < 0 || index >= this.Count) {
14787                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
14788                }
14789
14790                this.values[System.Array.index(index, this.values)] = value;
14791                this.version = (this.version + 1) | 0;
14792            },
14793            TrimToSize: function () {
14794                this.Capacity = this._size;
14795            }
14796        }
14797    });
14798
14799    // @source KeyList.js
14800
14801    H5.define("System.Collections.SortedList.KeyList", {
14802        inherits: [System.Collections.IList],
14803        $kind: "nested class",
14804        fields: {
14805            sortedList: null
14806        },
14807        props: {
14808            Count: {
14809                get: function () {
14810                    return this.sortedList._size;
14811                }
14812            },
14813            IsReadOnly: {
14814                get: function () {
14815                    return true;
14816                }
14817            },
14818            IsFixedSize: {
14819                get: function () {
14820                    return true;
14821                }
14822            },
14823            IsSynchronized: {
14824                get: function () {
14825                    return this.sortedList.IsSynchronized;
14826                }
14827            },
14828            SyncRoot: {
14829                get: function () {
14830                    return this.sortedList.SyncRoot;
14831                }
14832            }
14833        },
14834        alias: [
14835            "Count", "System$Collections$ICollection$Count",
14836            "IsReadOnly", "System$Collections$IList$IsReadOnly",
14837            "IsFixedSize", "System$Collections$IList$IsFixedSize",
14838            "IsSynchronized", "System$Collections$ICollection$IsSynchronized",
14839            "SyncRoot", "System$Collections$ICollection$SyncRoot",
14840            "add", "System$Collections$IList$add",
14841            "clear", "System$Collections$IList$clear",
14842            "contains", "System$Collections$IList$contains",
14843            "copyTo", "System$Collections$ICollection$copyTo",
14844            "insert", "System$Collections$IList$insert",
14845            "getItem", "System$Collections$IList$getItem",
14846            "setItem", "System$Collections$IList$setItem",
14847            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
14848            "indexOf", "System$Collections$IList$indexOf",
14849            "remove", "System$Collections$IList$remove",
14850            "removeAt", "System$Collections$IList$removeAt"
14851        ],
14852        ctors: {
14853            ctor: function (sortedList) {
14854                this.$initialize();
14855                this.sortedList = sortedList;
14856            }
14857        },
14858        methods: {
14859            getItem: function (index) {
14860                return this.sortedList.GetKey(index);
14861            },
14862            setItem: function (index, value) {
14863                throw new System.NotSupportedException.ctor();
14864            },
14865            add: function (key) {
14866                throw new System.NotSupportedException.ctor();
14867            },
14868            clear: function () {
14869                throw new System.NotSupportedException.ctor();
14870            },
14871            contains: function (key) {
14872                return this.sortedList.contains(key);
14873            },
14874            copyTo: function (array, arrayIndex) {
14875                if (array != null && System.Array.getRank(array) !== 1) {
14876                    throw new System.ArgumentException.ctor();
14877                }
14878
14879                System.Array.copy(this.sortedList.keys, 0, array, arrayIndex, this.sortedList.Count);
14880            },
14881            insert: function (index, value) {
14882                throw new System.NotSupportedException.ctor();
14883            },
14884            GetEnumerator: function () {
14885                return new System.Collections.SortedList.SortedListEnumerator(this.sortedList, 0, this.sortedList.Count, System.Collections.SortedList.SortedListEnumerator.Keys);
14886            },
14887            indexOf: function (key) {
14888                if (key == null) {
14889                    throw new System.ArgumentNullException.$ctor1("key");
14890                }
14891
14892                var i = System.Array.binarySearch(this.sortedList.keys, 0, this.sortedList.Count, key, this.sortedList.comparer);
14893                if (i >= 0) {
14894                    return i;
14895                }
14896                return -1;
14897            },
14898            remove: function (key) {
14899                throw new System.NotSupportedException.ctor();
14900            },
14901            removeAt: function (index) {
14902                throw new System.NotSupportedException.ctor();
14903            }
14904        }
14905    });
14906
14907    // @source SortedListDebugView.js
14908
14909    H5.define("System.Collections.SortedList.SortedListDebugView", {
14910        $kind: "nested class",
14911        fields: {
14912            sortedList: null
14913        },
14914        props: {
14915            Items: {
14916                get: function () {
14917                    return this.sortedList.ToKeyValuePairsArray();
14918                }
14919            }
14920        },
14921        ctors: {
14922            ctor: function (sortedList) {
14923                this.$initialize();
14924                if (sortedList == null) {
14925                    throw new System.ArgumentNullException.$ctor1("sortedList");
14926                }
14927
14928                this.sortedList = sortedList;
14929            }
14930        }
14931    });
14932
14933    // @source SortedListEnumerator.js
14934
14935    H5.define("System.Collections.SortedList.SortedListEnumerator", {
14936        inherits: [System.Collections.IDictionaryEnumerator,System.ICloneable],
14937        $kind: "nested class",
14938        statics: {
14939            fields: {
14940                Keys: 0,
14941                Values: 0,
14942                DictEntry: 0
14943            },
14944            ctors: {
14945                init: function () {
14946                    this.Keys = 1;
14947                    this.Values = 2;
14948                    this.DictEntry = 3;
14949                }
14950            }
14951        },
14952        fields: {
14953            sortedList: null,
14954            key: null,
14955            value: null,
14956            index: 0,
14957            startIndex: 0,
14958            endIndex: 0,
14959            version: 0,
14960            current: false,
14961            getObjectRetType: 0
14962        },
14963        props: {
14964            Key: {
14965                get: function () {
14966                    if (this.version !== this.sortedList.version) {
14967                        throw new System.InvalidOperationException.ctor();
14968                    }
14969                    if (this.current === false) {
14970                        throw new System.InvalidOperationException.ctor();
14971                    }
14972                    return this.key;
14973                }
14974            },
14975            Entry: {
14976                get: function () {
14977                    if (this.version !== this.sortedList.version) {
14978                        throw new System.InvalidOperationException.ctor();
14979                    }
14980                    if (this.current === false) {
14981                        throw new System.InvalidOperationException.ctor();
14982                    }
14983                    return new System.Collections.DictionaryEntry.$ctor1(this.key, this.value);
14984                }
14985            },
14986            Current: {
14987                get: function () {
14988                    if (this.current === false) {
14989                        throw new System.InvalidOperationException.ctor();
14990                    }
14991
14992                    if (this.getObjectRetType === System.Collections.SortedList.SortedListEnumerator.Keys) {
14993                        return this.key;
14994                    } else {
14995                        if (this.getObjectRetType === System.Collections.SortedList.SortedListEnumerator.Values) {
14996                            return this.value;
14997                        } else {
14998                            return new System.Collections.DictionaryEntry.$ctor1(this.key, this.value).$clone();
14999                        }
15000                    }
15001                }
15002            },
15003            Value: {
15004                get: function () {
15005                    if (this.version !== this.sortedList.version) {
15006                        throw new System.InvalidOperationException.ctor();
15007                    }
15008                    if (this.current === false) {
15009                        throw new System.InvalidOperationException.ctor();
15010                    }
15011                    return this.value;
15012                }
15013            }
15014        },
15015        alias: [
15016            "clone", "System$ICloneable$clone",
15017            "Key", "System$Collections$IDictionaryEnumerator$Key",
15018            "moveNext", "System$Collections$IEnumerator$moveNext",
15019            "Entry", "System$Collections$IDictionaryEnumerator$Entry",
15020            "Current", "System$Collections$IEnumerator$Current",
15021            "Value", "System$Collections$IDictionaryEnumerator$Value",
15022            "reset", "System$Collections$IEnumerator$reset"
15023        ],
15024        ctors: {
15025            ctor: function (sortedList, index, count, getObjRetType) {
15026                this.$initialize();
15027                this.sortedList = sortedList;
15028                this.index = index;
15029                this.startIndex = index;
15030                this.endIndex = (index + count) | 0;
15031                this.version = sortedList.version;
15032                this.getObjectRetType = getObjRetType;
15033                this.current = false;
15034            }
15035        },
15036        methods: {
15037            clone: function () {
15038                return H5.clone(this);
15039            },
15040            moveNext: function () {
15041                var $t, $t1;
15042                if (this.version !== this.sortedList.version) {
15043                    throw new System.InvalidOperationException.ctor();
15044                }
15045                if (this.index < this.endIndex) {
15046                    this.key = ($t = this.sortedList.keys)[System.Array.index(this.index, $t)];
15047                    this.value = ($t1 = this.sortedList.values)[System.Array.index(this.index, $t1)];
15048                    this.index = (this.index + 1) | 0;
15049                    this.current = true;
15050                    return true;
15051                }
15052                this.key = null;
15053                this.value = null;
15054                this.current = false;
15055                return false;
15056            },
15057            reset: function () {
15058                if (this.version !== this.sortedList.version) {
15059                    throw new System.InvalidOperationException.ctor();
15060                }
15061                this.index = this.startIndex;
15062                this.current = false;
15063                this.key = null;
15064                this.value = null;
15065            }
15066        }
15067    });
15068
15069    // @source SyncSortedList.js
15070
15071    H5.define("System.Collections.SortedList.SyncSortedList", {
15072        inherits: [System.Collections.SortedList],
15073        $kind: "nested class",
15074        fields: {
15075            _list: null,
15076            _root: null
15077        },
15078        props: {
15079            Count: {
15080                get: function () {
15081                    this._root;
15082                    {
15083                        return this._list.Count;
15084                    }
15085                }
15086            },
15087            SyncRoot: {
15088                get: function () {
15089                    return this._root;
15090                }
15091            },
15092            IsReadOnly: {
15093                get: function () {
15094                    return this._list.IsReadOnly;
15095                }
15096            },
15097            IsFixedSize: {
15098                get: function () {
15099                    return this._list.IsFixedSize;
15100                }
15101            },
15102            IsSynchronized: {
15103                get: function () {
15104                    return true;
15105                }
15106            },
15107            Capacity: {
15108                get: function () {
15109                    this._root;
15110                    {
15111                        return this._list.Capacity;
15112                    }
15113                }
15114            }
15115        },
15116        alias: [
15117            "Count", "System$Collections$ICollection$Count",
15118            "SyncRoot", "System$Collections$ICollection$SyncRoot",
15119            "IsReadOnly", "System$Collections$IDictionary$IsReadOnly",
15120            "IsFixedSize", "System$Collections$IDictionary$IsFixedSize",
15121            "IsSynchronized", "System$Collections$ICollection$IsSynchronized",
15122            "getItem", "System$Collections$IDictionary$getItem",
15123            "setItem", "System$Collections$IDictionary$setItem",
15124            "add", "System$Collections$IDictionary$add",
15125            "clear", "System$Collections$IDictionary$clear",
15126            "clone", "System$ICloneable$clone",
15127            "contains", "System$Collections$IDictionary$contains",
15128            "copyTo", "System$Collections$ICollection$copyTo",
15129            "GetEnumerator", "System$Collections$IDictionary$GetEnumerator",
15130            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
15131            "remove", "System$Collections$IDictionary$remove"
15132        ],
15133        ctors: {
15134            ctor: function (list) {
15135                this.$initialize();
15136                System.Collections.SortedList.ctor.call(this);
15137                this._list = list;
15138                this._root = list.SyncRoot;
15139            }
15140        },
15141        methods: {
15142            getItem: function (key) {
15143                this._root;
15144                {
15145                    return this._list.getItem(key);
15146                }
15147            },
15148            setItem: function (key, value) {
15149                this._root;
15150                {
15151                    this._list.setItem(key, value);
15152                }
15153            },
15154            add: function (key, value) {
15155                this._root;
15156                {
15157                    this._list.add(key, value);
15158                }
15159            },
15160            clear: function () {
15161                this._root;
15162                {
15163                    this._list.clear();
15164                }
15165            },
15166            clone: function () {
15167                this._root;
15168                {
15169                    return this._list.clone();
15170                }
15171            },
15172            contains: function (key) {
15173                this._root;
15174                {
15175                    return this._list.contains(key);
15176                }
15177            },
15178            ContainsKey: function (key) {
15179                this._root;
15180                {
15181                    return this._list.ContainsKey(key);
15182                }
15183            },
15184            ContainsValue: function (key) {
15185                this._root;
15186                {
15187                    return this._list.ContainsValue(key);
15188                }
15189            },
15190            copyTo: function (array, index) {
15191                this._root;
15192                {
15193                    this._list.copyTo(array, index);
15194                }
15195            },
15196            GetByIndex: function (index) {
15197                this._root;
15198                {
15199                    return this._list.GetByIndex(index);
15200                }
15201            },
15202            GetEnumerator: function () {
15203                this._root;
15204                {
15205                    return this._list.GetEnumerator();
15206                }
15207            },
15208            GetKey: function (index) {
15209                this._root;
15210                {
15211                    return this._list.GetKey(index);
15212                }
15213            },
15214            GetKeyList: function () {
15215                this._root;
15216                {
15217                    return this._list.GetKeyList();
15218                }
15219            },
15220            GetValueList: function () {
15221                this._root;
15222                {
15223                    return this._list.GetValueList();
15224                }
15225            },
15226            IndexOfKey: function (key) {
15227                if (key == null) {
15228                    throw new System.ArgumentNullException.$ctor1("key");
15229                }
15230
15231                return this._list.IndexOfKey(key);
15232            },
15233            IndexOfValue: function (value) {
15234                this._root;
15235                {
15236                    return this._list.IndexOfValue(value);
15237                }
15238            },
15239            RemoveAt: function (index) {
15240                this._root;
15241                {
15242                    this._list.RemoveAt(index);
15243                }
15244            },
15245            remove: function (key) {
15246                this._root;
15247                {
15248                    this._list.remove(key);
15249                }
15250            },
15251            SetByIndex: function (index, value) {
15252                this._root;
15253                {
15254                    this._list.SetByIndex(index, value);
15255                }
15256            },
15257            ToKeyValuePairsArray: function () {
15258                return this._list.ToKeyValuePairsArray();
15259            },
15260            TrimToSize: function () {
15261                this._root;
15262                {
15263                    this._list.TrimToSize();
15264                }
15265            }
15266        }
15267    });
15268
15269    // @source ValueList.js
15270
15271    H5.define("System.Collections.SortedList.ValueList", {
15272        inherits: [System.Collections.IList],
15273        $kind: "nested class",
15274        fields: {
15275            sortedList: null
15276        },
15277        props: {
15278            Count: {
15279                get: function () {
15280                    return this.sortedList._size;
15281                }
15282            },
15283            IsReadOnly: {
15284                get: function () {
15285                    return true;
15286                }
15287            },
15288            IsFixedSize: {
15289                get: function () {
15290                    return true;
15291                }
15292            },
15293            IsSynchronized: {
15294                get: function () {
15295                    return this.sortedList.IsSynchronized;
15296                }
15297            },
15298            SyncRoot: {
15299                get: function () {
15300                    return this.sortedList.SyncRoot;
15301                }
15302            }
15303        },
15304        alias: [
15305            "Count", "System$Collections$ICollection$Count",
15306            "IsReadOnly", "System$Collections$IList$IsReadOnly",
15307            "IsFixedSize", "System$Collections$IList$IsFixedSize",
15308            "IsSynchronized", "System$Collections$ICollection$IsSynchronized",
15309            "SyncRoot", "System$Collections$ICollection$SyncRoot",
15310            "add", "System$Collections$IList$add",
15311            "clear", "System$Collections$IList$clear",
15312            "contains", "System$Collections$IList$contains",
15313            "copyTo", "System$Collections$ICollection$copyTo",
15314            "insert", "System$Collections$IList$insert",
15315            "getItem", "System$Collections$IList$getItem",
15316            "setItem", "System$Collections$IList$setItem",
15317            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
15318            "indexOf", "System$Collections$IList$indexOf",
15319            "remove", "System$Collections$IList$remove",
15320            "removeAt", "System$Collections$IList$removeAt"
15321        ],
15322        ctors: {
15323            ctor: function (sortedList) {
15324                this.$initialize();
15325                this.sortedList = sortedList;
15326            }
15327        },
15328        methods: {
15329            getItem: function (index) {
15330                return this.sortedList.GetByIndex(index);
15331            },
15332            setItem: function (index, value) {
15333                throw new System.NotSupportedException.ctor();
15334            },
15335            add: function (key) {
15336                throw new System.NotSupportedException.ctor();
15337            },
15338            clear: function () {
15339                throw new System.NotSupportedException.ctor();
15340            },
15341            contains: function (value) {
15342                return this.sortedList.ContainsValue(value);
15343            },
15344            copyTo: function (array, arrayIndex) {
15345                if (array != null && System.Array.getRank(array) !== 1) {
15346                    throw new System.ArgumentException.ctor();
15347                }
15348
15349                System.Array.copy(this.sortedList.values, 0, array, arrayIndex, this.sortedList.Count);
15350            },
15351            insert: function (index, value) {
15352                throw new System.NotSupportedException.ctor();
15353            },
15354            GetEnumerator: function () {
15355                return new System.Collections.SortedList.SortedListEnumerator(this.sortedList, 0, this.sortedList.Count, System.Collections.SortedList.SortedListEnumerator.Values);
15356            },
15357            indexOf: function (value) {
15358                return System.Array.indexOfT(this.sortedList.values, value, 0, this.sortedList.Count);
15359            },
15360            remove: function (value) {
15361                throw new System.NotSupportedException.ctor();
15362            },
15363            removeAt: function (index) {
15364                throw new System.NotSupportedException.ctor();
15365            }
15366        }
15367    });
15368
15369    // @source SortedList.js
15370
15371    H5.define("System.Collections.Generic.SortedList$2", function (TKey, TValue) { return {
15372        inherits: [System.Collections.Generic.IDictionary$2(TKey,TValue),System.Collections.IDictionary,System.Collections.Generic.IReadOnlyDictionary$2(TKey,TValue)],
15373        statics: {
15374            fields: {
15375                _defaultCapacity: 0,
15376                MaxArrayLength: 0,
15377                emptyKeys: null,
15378                emptyValues: null
15379            },
15380            ctors: {
15381                init: function () {
15382                    this._defaultCapacity = 4;
15383                    this.MaxArrayLength = 2146435071;
15384                    this.emptyKeys = System.Array.init(0, function (){
15385                        return H5.getDefaultValue(TKey);
15386                    }, TKey);
15387                    this.emptyValues = System.Array.init(0, function (){
15388                        return H5.getDefaultValue(TValue);
15389                    }, TValue);
15390                }
15391            },
15392            methods: {
15393                IsCompatibleKey: function (key) {
15394                    if (key == null) {
15395                        System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15396                    }
15397
15398                    return (H5.is(key, TKey));
15399                }
15400            }
15401        },
15402        fields: {
15403            keys: null,
15404            values: null,
15405            _size: 0,
15406            version: 0,
15407            comparer: null,
15408            keyList: null,
15409            valueList: null
15410        },
15411        props: {
15412            Capacity: {
15413                get: function () {
15414                    return this.keys.length;
15415                },
15416                set: function (value) {
15417                    if (value !== this.keys.length) {
15418                        if (value < this._size) {
15419                            System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.
15419ExceptionArgument.value, System.ExceptionResource.ArgumentOutOfRange_SmallCapacity);
15420                        }
15421
15422                        if (value > 0) {
15423                            var newKeys = System.Array.init(value, function (){
15424                                return H5.getDefaultValue(TKey);
15425                            }, TKey);
15426                            var newValues = System.Array.init(value, function (){
15427                                return H5.getDefaultValue(TValue);
15428                            }, TValue);
15429                            if (this._size > 0) {
15430                                System.Array.copy(this.keys, 0, newKeys, 0, this._size);
15431                                System.Array.copy(this.values, 0, newValues, 0, this._size);
15432                            }
15433                            this.keys = newKeys;
15434                            this.values = newValues;
15435                        } else {
15436                            this.keys = System.Collections.Generic.SortedList$2(TKey,TValue).emptyKeys;
15437                            this.values = System.Collections.Generic.SortedList$2(TKey,TValue).emptyValues;
15438                        }
15439                    }
15440                }
15441            },
15442            Comparer: {
15443                get: function () {
15444                    return this.comparer;
15445                }
15446            },
15447            Count: {
15448                get: function () {
15449                    return this._size;
15450                }
15451            },
15452            Keys: {
15453                get: function () {
15454                    return this.GetKeyListHelper();
15455                }
15456            },
15457            System$Collections$Generic$IDictionary$2$Keys: {
15458                get: function () {
15459                    return this.GetKeyListHelper();
15460                }
15461            },
15462            System$Collections$IDictionary$Keys: {
15463                get: function () {
15464                    return this.GetKeyListHelper();
15465                }
15466            },
15467            System$Collections$Generic$IReadOnlyDictionary$2$Keys: {
15468                get: function () {
15469                    return this.GetKeyListHelper();
15470                }
15471            },
15472            Values: {
15473                get: function () {
15474                    return this.GetValueListHelper();
15475                }
15476            },
15477            System$Collections$Generic$IDictionary$2$Values: {
15478                get: function () {
15479                    return this.GetValueListHelper();
15480                }
15481            },
15482            System$Collections$IDictionary$Values: {
15483                get: function () {
15484                    return this.GetValueListHelper();
15485                }
15486            },
15487            System$Collections$Generic$IReadOnlyDictionary$2$Values: {
15488                get: function () {
15489                    return this.GetValueListHelper();
15490                }
15491            },
15492            System$Collections$Generic$ICollection$1$IsReadOnly: {
15493                get: function () {
15494                    return false;
15495                }
15496            },
15497            System$Collections$IDictionary$IsReadOnly: {
15498                get: function () {
15499                    return false;
15500                }
15501            },
15502            System$Collections$IDictionary$IsFixedSize: {
15503                get: function () {
15504                    return false;
15505                }
15506            },
15507            System$Collections$ICollection$IsSynchronized: {
15508                get: function () {
15509                    return false;
15510                }
15511            },
15512            System$Collections$ICollection$SyncRoot: {
15513                get: function () {
15514                    return null;
15515                }
15516            }
15517        },
15518        alias: [
15519            "add", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
15520            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
15521            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$contains",
15522            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove",
15523            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
15524            "Count", "System$Collections$ICollection$Count",
15525            "Count", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count",
15526            "System$Collections$Generic$IDictionary$2$Keys", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
15527            "System$Collections$Generic$IReadOnlyDictionary$2$Keys", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
15528            "System$Collections$Generic$IDictionary$2$Values", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values",
15529            "System$Collections$Generic$IReadOnlyDictionary$2$Values", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values",
15530            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$IsReadOnly", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
15531            "clear", "System$Collections$IDictionary$clear",
15532            "clear", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$clear",
15533            "containsKey", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
15534            "containsKey", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
15535            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$copyTo",
15536            "System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$GetEnumerator", "System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$GetEnumerator",
15537            "getItem", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
15538            "setItem", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$setItem",
15539            "getItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
15540            "setItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$setItem",
15541            "getItem$1", "System$Collections$IDictionary$getItem",
15542            "setItem$1", "System$Collections$IDictionary$setItem",
15543            "tryGetValue", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
15544            "tryGetValue", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
15545            "remove", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove"
15546        ],
15547        ctors: {
15548            ctor: function () {
15549                this.$initialize();
15550                this.keys = System.Collections.Generic.SortedList$2(TKey,TValue).emptyKeys;
15551                this.values = System.Collections.Generic.SortedList$2(TKey,TValue).emptyValues;
15552                this._size = 0;
15553                this.comparer = new (System.Collections.Generic.Comparer$1(TKey))(System.Collections.Generic.Comparer$1.$default.fn);
15554            },
15555            $ctor4: function (capacity) {
15556                this.$initialize();
15557                if (capacity < 0) {
15558                    System.ThrowHelper.ThrowArgumentOutOfRangeException$1(System.ExceptionArgument.capacity);
15559                }
15560                this.keys = System.Array.init(capacity, function (){
15561                    return H5.getDefaultValue(TKey);
15562                }, TKey);
15563                this.values = System.Array.init(capacity, function (){
15564                    return H5.getDefaultValue(TValue);
15565                }, TValue);
15566                this.comparer = new (System.Collections.Generic.Comparer$1(TKey))(System.Collections.Generic.Comparer$1.$default.fn);
15567            },
15568            $ctor1: function (comparer) {
15569                System.Collections.Generic.SortedList$2(TKey,TValue).ctor.call(this);
15570                if (comparer != null) {
15571                    this.comparer = comparer;
15572                }
15573            },
15574            $ctor5: function (capacity, comparer) {
15575                System.Collections.Generic.SortedList$2(TKey,TValue).$ctor1.call(this, comparer);
15576                this.Capacity = capacity;
15577            },
15578            $ctor2: function (dictionary) {
15579                System.Collections.Generic.SortedList$2(TKey,TValue).$ctor3.call(this, dictionary, null);
15580            },
15581            $ctor3: function (dictionary, comparer) {
15582                System.Collections.Generic.SortedList$2(TKey,TValue).$ctor5.call(this, (dictionary != null ? System.Array.getCount(dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue)) : 0), comparer);
15583                if (dictionary == null) {
15584                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.dictionary);
15585                }
15586
15587                System.Array.copyTo(dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys"], this.keys, 0, TKey);
15588                System.Array.copyTo(dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values"], this.values, 0, TValue);
15589                System.Array.sortDict(this.keys, this.values, 0, null, this.comparer);
15590                this._size = System.Array.getCount(dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
15591            }
15592        },
15593        methods: {
15594            getItem: function (key) {
15595                var i = this.IndexOfKey(key);
15596                if (i >= 0) {
15597                    return this.values[System.Array.index(i, this.values)];
15598                }
15599
15600                throw new System.Collections.Generic.KeyNotFoundException.ctor();
15601            },
15602            setItem: function (key, value) {
15603                if (key == null) {
15604                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15605                }
15606                var i = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
15607                if (i >= 0) {
15608                    this.values[System.Array.index(i, this.values)] = value;
15609                    this.version = (this.version + 1) | 0;
15610                    return;
15611                }
15612                this.Insert(~i, key, value);
15613            },
15614            getItem$1: function (key) {
15615                if (System.Collections.Generic.SortedList$2(TKey,TValue).IsCompatibleKey(key)) {
15616                    var i = this.IndexOfKey(H5.cast(H5.unbox(key, TKey), TKey));
15617                    if (i >= 0) {
15618                        return this.values[System.Array.index(i, this.values)];
15619                    }
15620                }
15621
15622                return null;
15623            },
15624            setItem$1: function (key, value) {
15625                if (!System.Collections.Generic.SortedList$2(TKey,TValue).IsCompatibleKey(key)) {
15626                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15627                }
15628
15629                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(TValue, value, System.ExceptionArgument.value);
15630
15631                try {
15632                    var tempKey = H5.cast(H5.unbox(key, TKey), TKey);
15633                    try {
15634                        this.setItem(tempKey, H5.cast(H5.unbox(value, TValue), TValue));
15635                    } catch ($e1) {
15636                        $e1 = System.Exception.create($e1);
15637                        if (H5.is($e1, System.InvalidCastException)) {
15638                            System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, TValue);
15639                        } else {
15640                            throw $e1;
15641                        }
15642                    }
15643                } catch ($e2) {
15644                    $e2 = System.Exception.create($e2);
15645                    if (H5.is($e2, System.InvalidCastException)) {
15646                        System.ThrowHelper.ThrowWrongKeyTypeArgumentException(System.Object, key, TKey);
15647                    } else {
15648                        throw $e2;
15649                    }
15650                }
15651            },
15652            add: function (key, value) {
15653                if (key == null) {
15654                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15655                }
15656                var i = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
15657                if (i >= 0) {
15658                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_AddingDuplicate);
15659                }
15660                this.Insert(~i, key, value);
15661            },
15662            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add: function (keyValuePair) {
15663                this.add(keyValuePair.key, keyValuePair.value);
15664            },
15665            System$Collections$IDictionary$add: function (key, value) {
15666                if (key == null) {
15667                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15668                }
15669
15670                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(TValue, value, System.ExceptionArgument.value);
15671
15672                try {
15673                    var tempKey = H5.cast(H5.unbox(key, TKey), TKey);
15674
15675                    try {
15676                        this.add(tempKey, H5.cast(H5.unbox(value, TValue), TValue));
15677                    } catch ($e1) {
15678                        $e1 = System.Exception.create($e1);
15679                        if (H5.is($e1, System.InvalidCastException)) {
15680                            System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, TValue);
15681                        } else {
15682                            throw $e1;
15683                        }
15684                    }
15685                } catch ($e2) {
15686                    $e2 = System.Exception.create($e2);
15687                    if (H5.is($e2, System.InvalidCastException)) {
15688                        System.ThrowHelper.ThrowWrongKeyTypeArgumentException(System.Object, key, TKey);
15689                    } else {
15690                        throw $e2;
15691                    }
15692                }
15693            },
15694            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains: function (keyValuePair) {
15695                var index = this.IndexOfKey(keyValuePair.key);
15696                if (index >= 0 && System.Collections.Generic.EqualityComparer$1(TValue).def.equals2(this.values[System.Array.index(index, this.values)], keyValuePair.value)) {
15697                    return true;
15698                }
15699                return false;
15700            },
15701            System$Collections$IDictionary$contains: function (key) {
15702                if (System.Collections.Generic.SortedList$2(TKey,TValue).IsCompatibleKey(key)) {
15703                    return this.containsKey(H5.cast(H5.unbox(key, TKey), TKey));
15704                }
15705                return false;
15706            },
15707            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove: function (keyValuePair) {
15708                var index = this.IndexOfKey(keyValuePair.key);
15709                if (index >= 0 && System.Collections.Generic.EqualityComparer$1(TValue).def.equals2(this.values[System.Array.index(index, this.values)], keyValuePair.value)) {
15710                    this.RemoveAt(index);
15711                    return true;
15712                }
15713                return false;
15714            },
15715            remove: function (key) {
15716                var i = this.IndexOfKey(key);
15717                if (i >= 0) {
15718                    this.RemoveAt(i);
15719                }
15720                return i >= 0;
15721            },
15722            System$Collections$IDictionary$remove: function (key) {
15723                if (System.Collections.Generic.SortedList$2(TKey,TValue).IsCompatibleKey(key)) {
15724                    this.remove(H5.cast(H5.unbox(key, TKey), TKey));
15725                }
15726            },
15727            GetKeyListHelper: function () {
15728                if (this.keyList == null) {
15729                    this.keyList = new (System.Collections.Generic.SortedList$2.KeyList(TKey,TValue))(this);
15730                }
15731                return this.keyList;
15732            },
15733            GetValueListHelper: function () {
15734                if (this.valueList == null) {
15735                    this.valueList = new (System.Collections.Generic.SortedList$2.ValueList(TKey,TValue))(this);
15736                }
15737                return this.valueList;
15738            },
15739            clear: function () {
15740                this.version = (this.version + 1) | 0;
15741                System.Array.fill(this.keys, function () {
15742                    return H5.getDefaultValue(TKey);
15743                }, 0, this._size);
15744                System.Array.fill(this.values, function () {
15745                    return H5.getDefaultValue(TValue);
15746                }, 0, this._size);
15747                this._size = 0;
15748            },
15749            containsKey: function (key) {
15750                return this.IndexOfKey(key) >= 0;
15751            },
15752            ContainsValue: function (value) {
15753                return this.IndexOfValue(value) >= 0;
15754            },
15755            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo: function (array, arrayIndex) {
15756                if (array == null) {
15757                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
15758                }
15759
15760                if (arrayIndex < 0 || arrayIndex > array.length) {
15761                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.arrayIndex, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
15762                }
15763
15764                if (((array.length - arrayIndex) | 0) < this.Count) {
15765                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
15766                }
15767
15768                for (var i = 0; i < this.Count; i = (i + 1) | 0) {
15769                    var entry = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.keys[System.Array.index(i, this.keys)], this.values[System.Array.index(i, this.values)]);
15770                    array[System.Array.index(((arrayIndex + i) | 0), array)] = entry;
15771                }
15772            },
15773            System$Collections$ICollection$copyTo: function (array, arrayIndex) {
15774                if (array == null) {
15775                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
15776                }
15777
15778                if (System.Array.getRank(array) !== 1) {
15779                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
15780                }
15781
15782                if (System.Array.getLower(array, 0) !== 0) {
15783                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
15784                }
15785
15786                if (arrayIndex < 0 || arrayIndex > array.length) {
15787                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.
15787ExceptionArgument.arrayIndex, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
15788                }
15789
15790                if (((array.length - arrayIndex) | 0) < this.Count) {
15791                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
15792                }
15793                var keyValuePairArray;
15794                if (((keyValuePairArray = H5.as(array, System.Array.type(System.Collections.Generic.KeyValuePair$2(TKey,TValue))))) != null) {
15795                    for (var i = 0; i < this.Count; i = (i + 1) | 0) {
15796                        keyValuePairArray[System.Array.index(((i + arrayIndex) | 0), keyValuePairArray)] = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.keys[System.Array.index(i, this.keys)], this.values[System.Array.index(i, this.values)]);
15797                    }
15798                } else {
15799                    var objects = H5.as(array, System.Array.type(System.Object));
15800                    if (objects == null) {
15801                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
15802                    }
15803
15804                    try {
15805                        for (var i1 = 0; i1 < this.Count; i1 = (i1 + 1) | 0) {
15806                            objects[System.Array.index(((i1 + arrayIndex) | 0), objects)] = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.keys[System.Array.index(i1, this.keys)], this.values[System.Array.index(i1, this.values)]);
15807                        }
15808                    } catch ($e1) {
15809                        $e1 = System.Exception.create($e1);
15810                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
15811                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
15812                        } else {
15813                            throw $e1;
15814                        }
15815                    }
15816
15817                }
15818            },
15819            EnsureCapacity: function (min) {
15820                var newCapacity = this.keys.length === 0 ? System.Collections.Generic.SortedList$2(TKey,TValue)._defaultCapacity : H5.Int.mul(this.keys.length, 2);
15821                if ((newCapacity >>> 0) > System.Collections.Generic.SortedList$2(TKey,TValue).MaxArrayLength) {
15822                    newCapacity = System.Collections.Generic.SortedList$2(TKey,TValue).MaxArrayLength;
15823                }
15824                if (newCapacity < min) {
15825                    newCapacity = min;
15826                }
15827                this.Capacity = newCapacity;
15828            },
15829            GetByIndex: function (index) {
15830                if (index < 0 || index >= this._size) {
15831                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_Index);
15832                }
15833                return this.values[System.Array.index(index, this.values)];
15834            },
15835            GetEnumerator: function () {
15836                return new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue).KeyValuePair).$clone();
15837            },
15838            System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$GetEnumerator: function () {
15839                return new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue).KeyValuePair).$clone();
15840            },
15841            System$Collections$IDictionary$GetEnumerator: function () {
15842                return new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue).DictEntry).$clone();
15843            },
15844            System$Collections$IEnumerable$GetEnumerator: function () {
15845                return new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue).KeyValuePair).$clone();
15846            },
15847            GetKey: function (index) {
15848                if (index < 0 || index >= this._size) {
15849                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.
15849ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_Index);
15850                }
15851                return this.keys[System.Array.index(index, this.keys)];
15852            },
15853            IndexOfKey: function (key) {
15854                if (key == null) {
15855                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
15856                }
15857                var ret = System.Array.binarySearch(this.keys, 0, this._size, key, this.comparer);
15858                return ret >= 0 ? ret : -1;
15859            },
15860            IndexOfValue: function (value) {
15861                return System.Array.indexOfT(this.values, value, 0, this._size);
15862            },
15863            Insert: function (index, key, value) {
15864                if (this._size === this.keys.length) {
15865                    this.EnsureCapacity(((this._size + 1) | 0));
15866                }
15867                if (index < this._size) {
15868                    System.Array.copy(this.keys, index, this.keys, ((index + 1) | 0), ((this._size - index) | 0));
15869                    System.Array.copy(this.values, index, this.values, ((index + 1) | 0), ((this._size - index) | 0));
15870                }
15871                this.keys[System.Array.index(index, this.keys)] = key;
15872                this.values[System.Array.index(index, this.values)] = value;
15873                this._size = (this._size + 1) | 0;
15874                this.version = (this.version + 1) | 0;
15875            },
15876            tryGetValue: function (key, value) {
15877                var i = this.IndexOfKey(key);
15878                if (i >= 0) {
15879                    value.v = this.values[System.Array.index(i, this.values)];
15880                    return true;
15881                }
15882
15883                value.v = H5.getDefaultValue(TValue);
15884                return false;
15885            },
15886            RemoveAt: function (index) {
15887                if (index < 0 || index >= this._size) {
15888                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_Index);
15889                }
15890                this._size = (this._size - 1) | 0;
15891                if (index < this._size) {
15892                    System.Array.copy(this.keys, ((index + 1) | 0), this.keys, index, ((this._size - index) | 0));
15893                    System.Array.copy(this.values, ((index + 1) | 0), this.values, index, ((this._size - index) | 0));
15894                }
15895                this.keys[System.Array.index(this._size, this.keys)] = H5.getDefaultValue(TKey);
15896                this.values[System.Array.index(this._size, this.values)] = H5.getDefaultValue(TValue);
15897                this.version = (this.version + 1) | 0;
15898            },
15899            TrimExcess: function () {
15900                var threshold = H5.Int.clip32(this.keys.length * 0.9);
15901                if (this._size < threshold) {
15902                    this.Capacity = this._size;
15903                }
15904            }
15905        }
15906    }; });
15907
15908    // @source Enumerator.js
15909
15910    H5.define("System.Collections.Generic.SortedList$2.Enumerator", function (TKey, TValue) { return {
15911        inherits: [System.Collections.Generic.IEnumerator$1(System.Collections.Generic.KeyValuePair$2(TKey,TValue)),System.Collections.IDictionaryEnumerator],
15912        $kind: "nested struct",
15913        statics: {
15914            fields: {
15915                KeyValuePair: 0,
15916                DictEntry: 0
15917            },
15918            ctors: {
15919                init: function () {
15920                    this.KeyValuePair = 1;
15921                    this.DictEntry = 2;
15922                }
15923            },
15924            methods: {
15925                getDefaultValue: function () { return new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue))(); }
15926            }
15927        },
15928        fields: {
15929            _sortedList: null,
15930            key: H5.getDefaultValue(TKey),
15931            value: H5.getDefaultValue(TValue),
15932            index: 0,
15933            version: 0,
15934            getEnumeratorRetType: 0
15935        },
15936        props: {
15937            System$Collections$IDictionaryEnumerator$Key: {
15938                get: function () {
15939                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
15940                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
15941                    }
15942
15943                    return this.key;
15944                }
15945            },
15946            System$Collections$IDictionaryEnumerator$Entry: {
15947                get: function () {
15948                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
15949                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
15950                    }
15951
15952                    return new System.Collections.DictionaryEntry.$ctor1(this.key, this.value);
15953                }
15954            },
15955            Current: {
15956                get: function () {
15957                    return new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.key, this.value);
15958                }
15959            },
15960            System$Collections$IEnumerator$Current: {
15961                get: function () {
15962                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
15963                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
15964                    }
15965
15966                    if (this.getEnumeratorRetType === System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue).DictEntry
15966) {
15967                        return new System.Collections.DictionaryEntry.$ctor1(this.key, this.value).$clone();
15968                    } else {
15969                        return new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.key, this.value);
15970                    }
15971                }
15972            },
15973            System$Collections$IDictionaryEnumerator$Value: {
15974                get: function () {
15975                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
15976                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
15977                    }
15978
15979                    return this.value;
15980                }
15981            }
15982        },
15983        alias: [
15984            "Dispose", "System$IDisposable$Dispose",
15985            "moveNext", "System$Collections$IEnumerator$moveNext",
15986            "Current", ["System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
15987        ],
15988        ctors: {
15989            $ctor1: function (sortedList, getEnumeratorRetType) {
15990                this.$initialize();
15991                this._sortedList = sortedList;
15992                this.index = 0;
15993                this.version = this._sortedList.version;
15994                this.getEnumeratorRetType = getEnumeratorRetType;
15995                this.key = H5.getDefaultValue(TKey);
15996                this.value = H5.getDefaultValue(TValue);
15997            },
15998            ctor: function () {
15999                this.$initialize();
16000            }
16001        },
16002        methods: {
16003            Dispose: function () {
16004                this.index = 0;
16005                this.key = H5.getDefaultValue(TKey);
16006                this.value = H5.getDefaultValue(TValue);
16007            },
16008            moveNext: function () {
16009                var $t, $t1;
16010                if (this.version !== this._sortedList.version) {
16011                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16012                }
16013
16014                if ((this.index >>> 0) < ((this._sortedList.Count) >>> 0)) {
16015                    this.key = ($t = this._sortedList.keys)[System.Array.index(this.index, $t)];
16016                    this.value = ($t1 = this._sortedList.values)[System.Array.index(this.index, $t1)];
16017                    this.index = (this.index + 1) | 0;
16018                    return true;
16019                }
16020
16021                this.index = (this._sortedList.Count + 1) | 0;
16022                this.key = H5.getDefaultValue(TKey);
16023                this.value = H5.getDefaultValue(TValue);
16024                return false;
16025            },
16026            System$Collections$IEnumerator$reset: function () {
16027                if (this.version !== this._sortedList.version) {
16028                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16029                }
16030
16031                this.index = 0;
16032                this.key = H5.getDefaultValue(TKey);
16033                this.value = H5.getDefaultValue(TValue);
16034            },
16035            getHashCode: function () {
16036                var h = H5.addHash([3788985113, this._sortedList, this.key, this.value, this.index, this.version, this.getEnumeratorRetType]);
16037                return h;
16038            },
16039            equals: function (o) {
16040                if (!H5.is(o, System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue))) {
16041                    return false;
16042                }
16043                return H5.equals(this._sortedList, o._sortedList) && H5.equals(this.key, o.key) && H5.equals(this.value, o.value) && H5.equals(this.index, o.index) && H5.equals(this.version, o.version) && H5.equals(this.getEnumeratorRetType, o.getEnumeratorRetType);
16044            },
16045            $clone: function (to) {
16046                var s = to || new (System.Collections.Generic.SortedList$2.Enumerator(TKey,TValue))();
16047                s._sortedList = this._sortedList;
16048                s.key = this.key;
16049                s.value = this.value;
16050                s.index = this.index;
16051                s.version = this.version;
16052                s.getEnumeratorRetType = this.getEnumeratorRetType;
16053                return s;
16054            }
16055        }
16056    }; });
16057
16058    // @source KeyList.js
16059
16060    H5.define("System.Collections.Generic.SortedList$2.KeyList", function (TKey, TValue) { return {
16061        inherits: [System.Collections.Generic.IList$1(TKey),System.Collections.ICollection],
16062        $kind: "nested class",
16063        fields: {
16064            _dict: null
16065        },
16066        props: {
16067            Count: {
16068                get: function () {
16069                    return this._dict._size;
16070                }
16071            },
16072            IsReadOnly: {
16073                get: function () {
16074                    return true;
16075                }
16076            },
16077            System$Collections$ICollection$IsSynchronized: {
16078                get: function () {
16079                    return false;
16080                }
16081            },
16082            System$Collections$ICollection$SyncRoot: {
16083                get: function () {
16084                    return H5.cast(this._dict, System.Collections.ICollection).System$Collections$ICollection$SyncRoot;
16085                }
16086            }
16087        },
16088        alias: [
16089            "Count", "System$Collections$ICollection$Count",
16090            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$Count",
16091            "IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$IsReadOnly",
16092            "add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$add",
16093            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$clear",
16094            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$contains",
16095            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$copyTo",
16096            "insert", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TKey) + "$insert",
16097            "getItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TKey) + "$getItem",
16098            "setItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TKey) + "$setItem",
16099            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TKey) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"],
16100            "indexOf", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TKey) + "$indexOf",
16101            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$remove",
16102            "removeAt", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TKey) + "$removeAt"
16103        ],
16104        ctors: {
16105            ctor: function (dictionary) {
16106                this.$initialize();
16107                this._dict = dictionary;
16108            }
16109        },
16110        methods: {
16111            getItem: function (index) {
16112                return this._dict.GetKey(index);
16113            },
16114            setItem: function (index, value) {
16115                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_KeyCollectionSet);
16116            },
16117            add: function (key) {
16118                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16119            },
16120            clear: function () {
16121                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16122            },
16123            contains: function (key) {
16124                return this._dict.containsKey(key);
16125            },
16126            copyTo: function (array, arrayIndex) {
16127                System.Array.copy(this._dict.keys, 0, array, arrayIndex, this._dict.Count);
16128            },
16129            System$Collections$ICollection$copyTo: function (array, arrayIndex) {
16130                if (array != null && System.Array.getRank(array) !== 1) {
16131                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
16132                }
16133
16134                try {
16135                    System.Array.copy(this._dict.keys, 0, array, arrayIndex, this._dict.Count);
16136                } catch ($e1) {
16137                    $e1 = System.Exception.create($e1);
16138                    if (H5.is($e1, System.ArrayTypeMismatchException)) {
16139                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
16140                    } else {
16141                        throw $e1;
16142                    }
16143                }
16144            },
16145            insert: function (index, value) {
16146                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16147            },
16148            GetEnumerator: function () {
16149                return new (System.Collections.Generic.SortedList$2.SortedListKeyEnumerator(TKey,TValue))(this._dict);
16150            },
16151            System$Collections$IEnumerable$GetEnumerator: function () {
16152                return new (System.Collections.Generic.SortedList$2.SortedListKeyEnumerator(TKey,TValue))(this._dict);
16153            },
16154            indexOf: function (key) {
16155                if (key == null) {
16156                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
16157                }
16158
16159                var i = System.Array.binarySearch(this._dict.keys, 0, this._dict.Count, key, this._dict.comparer);
16160                if (i >= 0) {
16161                    return i;
16162                }
16163                return -1;
16164            },
16165            remove: function (key) {
16166                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16167                return false;
16168            },
16169            removeAt: function (index) {
16170                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16171            }
16172        }
16173    }; });
16174
16175    // @source SortedListKeyEnumerator.js
16176
16177    H5.define("System.Collections.Generic.SortedList$2.SortedListKeyEnumerator", function (TKey, TValue) { return {
16178        inherits: [System.Collections.Generic.IEnumerator$1(TKey),System.Collections.IEnumerator],
16179        $kind: "nested class",
16180        fields: {
16181            _sortedList: null,
16182            index: 0,
16183            version: 0,
16184            currentKey: H5.getDefaultValue(TKey)
16185        },
16186        props: {
16187            Current: {
16188                get: function () {
16189                    return this.currentKey;
16190                }
16191            },
16192            System$Collections$IEnumerator$Current: {
16193                get: function () {
16194                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
16195                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
16196                    }
16197
16198                    return this.currentKey;
16199                }
16200            }
16201        },
16202        alias: [
16203            "Dispose", "System$IDisposable$Dispose",
16204            "moveNext", "System$Collections$IEnumerator$moveNext",
16205            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(TKey) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
16206        ],
16207        ctors: {
16208            ctor: function (sortedList) {
16209                this.$initialize();
16210                this._sortedList = sortedList;
16211                this.version = sortedList.version;
16212            }
16213        },
16214        methods: {
16215            Dispose: function () {
16216                this.index = 0;
16217                this.currentKey = H5.getDefaultValue(TKey);
16218            },
16219            moveNext: function () {
16220                var $t;
16221                if (this.version !== this._sortedList.version) {
16222                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16223                }
16224
16225                if ((this.index >>> 0) < ((this._sortedList.Count) >>> 0)) {
16226                    this.currentKey = ($t = this._sortedList.keys)[System.Array.index(this.index, $t)];
16227                    this.index = (this.index + 1) | 0;
16228                    return true;
16229                }
16230
16231                this.index = (this._sortedList.Count + 1) | 0;
16232                this.currentKey = H5.getDefaultValue(TKey);
16233                return false;
16234            },
16235            System$Collections$IEnumerator$reset: function () {
16236                if (this.version !== this._sortedList.version) {
16237                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16238                }
16239                this.index = 0;
16240                this.currentKey = H5.getDefaultValue(TKey);
16241            }
16242        }
16243    }; });
16244
16245    // @source SortedListValueEnumerator.js
16246
16247    H5.define("System.Collections.Generic.SortedList$2.SortedListValueEnumerator", function (TKey, TValue) { return {
16248        inherits: [System.Collections.Generic.IEnumerator$1(TValue),System.Collections.IEnumerator],
16249        $kind: "nested class",
16250        fields: {
16251            _sortedList: null,
16252            index: 0,
16253            version: 0,
16254            currentValue: H5.getDefaultValue(TValue)
16255        },
16256        props: {
16257            Current: {
16258                get: function () {
16259                    return this.currentValue;
16260                }
16261            },
16262            System$Collections$IEnumerator$Current: {
16263                get: function () {
16264                    if (this.index === 0 || (this.index === ((this._sortedList.Count + 1) | 0))) {
16265                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
16266                    }
16267
16268                    return this.currentValue;
16269                }
16270            }
16271        },
16272        alias: [
16273            "Dispose", "System$IDisposable$Dispose",
16274            "moveNext", "System$Collections$IEnumerator$moveNext",
16275            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
16276        ],
16277        ctors: {
16278            ctor: function (sortedList) {
16279                this.$initialize();
16280                this._sortedList = sortedList;
16281                this.version = sortedList.version;
16282            }
16283        },
16284        methods: {
16285            Dispose: function () {
16286                this.index = 0;
16287                this.currentValue = H5.getDefaultValue(TValue);
16288            },
16289            moveNext: function () {
16290                var $t;
16291                if (this.version !== this._sortedList.version) {
16292                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16293                }
16294
16295                if ((this.index >>> 0) < ((this._sortedList.Count) >>> 0)) {
16296                    this.currentValue = ($t = this._sortedList.values)[System.Array.index(this.index, $t)];
16297                    this.index = (this.index + 1) | 0;
16298                    return true;
16299                }
16300
16301                this.index = (this._sortedList.Count + 1) | 0;
16302                this.currentValue = H5.getDefaultValue(TValue);
16303                return false;
16304            },
16305            System$Collections$IEnumerator$reset: function () {
16306                if (this.version !== this._sortedList.version) {
16307                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
16308                }
16309                this.index = 0;
16310                this.currentValue = H5.getDefaultValue(TValue);
16311            }
16312        }
16313    }; });
16314
16315    // @source ValueList.js
16316
16317    H5.define("System.Collections.Generic.SortedList$2.ValueList", function (TKey, TValue) { return {
16318        inherits: [System.Collections.Generic.IList$1(TValue),System.Collections.ICollection],
16319        $kind: "nested class",
16320        fields: {
16321            _dict: null
16322        },
16323        props: {
16324            Count: {
16325                get: function () {
16326                    return this._dict._size;
16327                }
16328            },
16329            IsReadOnly: {
16330                get: function () {
16331                    return true;
16332                }
16333            },
16334            System$Collections$ICollection$IsSynchronized: {
16335                get: function () {
16336                    return false;
16337                }
16338            },
16339            System$Collections$ICollection$SyncRoot: {
16340                get: function () {
16341                    return H5.cast(this._dict, System.Collections.ICollection).System$Collections$ICollection$SyncRoot;
16342                }
16343            }
16344        },
16345        alias: [
16346            "Count", "System$Collections$ICollection$Count",
16347            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$Count",
16348            "IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
16349            "add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$add",
16350            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$clear",
16351            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$contains",
16352            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$copyTo",
16353            "insert", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TValue) + "$insert",
16354            "getItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TValue) + "$getItem",
16355            "setItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TValue) + "$setItem",
16356            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TValue) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"],
16357            "indexOf", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TValue) + "$indexOf",
16358            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$remove",
16359            "removeAt", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(TValue) + "$removeAt"
16360        ],
16361        ctors: {
16362            ctor: function (dictionary) {
16363                this.$initialize();
16364                this._dict = dictionary;
16365            }
16366        },
16367        methods: {
16368            getItem: function (index) {
16369                return this._dict.GetByIndex(index);
16370            },
16371            setItem: function (index, value) {
16372                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16373            },
16374            add: function (key) {
16375                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16376            },
16377            clear: function () {
16378                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16379            },
16380            contains: function (value) {
16381                return this._dict.ContainsValue(value);
16382            },
16383            copyTo: function (array, arrayIndex) {
16384                System.Array.copy(this._dict.values, 0, array, arrayIndex, this._dict.Count);
16385            },
16386            System$Collections$ICollection$copyTo: function (array, arrayIndex) {
16387                if (array != null && System.Array.getRank(array) !== 1) {
16388                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
16389                }
16390
16391                try {
16392                    System.Array.copy(this._dict.values, 0, array, arrayIndex, this._dict.Count);
16393                } catch ($e1) {
16394                    $e1 = System.Exception.create($e1);
16395                    if (H5.is($e1, System.ArrayTypeMismatchException)) {
16396                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
16397                    } else {
16398                        throw $e1;
16399                    }
16400                }
16401            },
16402            insert: function (index, value) {
16403                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16404            },
16405            GetEnumerator: function () {
16406                return new (System.Collections.Generic.SortedList$2.SortedListValueEnumerator(TKey,TValue))(this._dict);
16407            },
16408            System$Collections$IEnumerable$GetEnumerator: function () {
16409                return new (System.Collections.Generic.SortedList$2.SortedListValueEnumerator(TKey,TValue))(this._dict);
16410            },
16411            indexOf: function (value) {
16412                return System.Array.indexOfT(this._dict.values, value, 0, this._dict.Count);
16413            },
16414            remove: function (value) {
16415                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16416                return false;
16417            },
16418            removeAt: function (index) {
16419                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_SortedListNestedWrite);
16420            }
16421        }
16422    }; });
16423
16424    // @source SortedSet.js
16425
16426    H5.define("System.Collections.Generic.SortedSet$1", function (T) { return {
16427        inherits: [System.Collections.Generic.ISet$1(T),System.Collections.Generic.ICollection$1(T),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(T)],
16428        statics: {
16429            fields: {
16430                ComparerName: null,
16431                CountName: null,
16432                ItemsName: null,
16433                VersionName: null,
16434                TreeName: null,
16435                NodeValueName: null,
16436                EnumStartName: null,
16437                ReverseName: null,
16438                EnumVersionName: null,
16439                minName: null,
16440                maxName: null,
16441                lBoundActiveName: null,
16442                uBoundActiveName: null,
16443                StackAllocThreshold: 0
16444            },
16445            ctors: {
16446                init: function () {
16447                    this.ComparerName = "Comparer";
16448                    this.CountName = "Count";
16449                    this.ItemsName = "Items";
16450                    this.VersionName = "Version";
16451                    this.TreeName = "Tree";
16452                    this.NodeValueName = "Item";
16453                    this.EnumStartName = "EnumStarted";
16454                    this.ReverseName = "Reverse";
16455                    this.EnumVersionName = "EnumVersion";
16456                    this.minName = "Min";
16457                    this.maxName = "Max";
16458                    this.lBoundActiveName = "lBoundActive";
16459                    this.uBoundActiveName = "uBoundActive";
16460                    this.StackAllocThreshold = 100;
16461                }
16462            },
16463            methods: {
16464                GetSibling: function (node, parent) {
16465                    if (H5.referenceEquals(parent.Left, node)) {
16466                        return parent.Right;
16467                    }
16468                    return parent.Left;
16469                },
16470                Is2Node: function (node) {
16471                    return System.Collections.Generic.SortedSet$1(T).IsBlack(node) && System.Collections.Generic.SortedSet$1(T).IsNullOrBlack(node.Left) && System.Collections.Generic.SortedSet$1(T).IsNullOrBlack(node.Right);
16472                },
16473                Is4Node: function (node) {
16474                    return System.Collections.Generic.SortedSet$1(T).IsRed(node.Left) && System.Collections.Generic.SortedSet$1(T).IsRed(node.Right);
16475                },
16476                IsBlack: function (node) {
16477                    return (node != null && !node.IsRed);
16478                },
16479                IsNullOrBlack: function (node) {
16480                    return (node == null || !node.IsRed);
16481                },
16482                IsRed: function (node) {
16483                    return (node != null && node.IsRed);
16484                },
16485                Merge2Nodes: function (parent, child1, child2) {
16486                    parent.IsRed = false;
16487                    child1.IsRed = true;
16488                    child2.IsRed = true;
16489                },
16490                RotateLeft: function (node) {
16491                    var x = node.Right;
16492                    node.Right = x.Left;
16493                    x.Left = node;
16494                    return x;
16495                },
16496                RotateLeftRight: function (node) {
16497                    var child = node.Left;
16498                    var grandChild = child.Right;
16499
16500                    node.Left = grandChild.Right;
16501                    grandChild.Right = node;
16502                    child.Right = grandChild.Left;
16503                    grandChild.Left = child;
16504                    return grandChild;
16505                },
16506                RotateRight: function (node) {
16507                    var x = node.Left;
16508                    node.Left = x.Right;
16509                    x.Right = node;
16510                    return x;
16511                },
16512                RotateRightLeft: function (node) {
16513                    var child = node.Right;
16514                    var grandChild = child.Left;
16515
16516                    node.Right = grandChild.Left;
16517                    grandChild.Left = node;
16518                    child.Left = grandChild.Right;
16519                    grandChild.Right = child;
16520                    return grandChild;
16521                },
16522                RotationNeeded: function (parent, current, sibling) {
16523                    if (System.Collections.Generic.SortedSet$1(T).IsRed(sibling.Left)) {
16524                        if (H5.referenceEquals(parent.Left, current)) {
16525                            return System.Collections.Generic.TreeRotation.RightLeftRotation;
16526                        }
16527                        return System.Collections.Generic.TreeRotation.RightRotation;
16528                    } else {
16529                        if (H5.referenceEquals(parent.Left, current)) {
16530                            return System.Collections.Generic.TreeRotation.LeftRotation;
16531                        }
16532                        return System.Collections.Generic.TreeRotation.LeftRightRotation;
16533                    }
16534                },
16535                CreateSetComparer: function () {
16536                    return new (System.Collections.Generic.SortedSetEqualityComparer$1(T)).ctor();
16537                },
16538                CreateSetComparer$1: function (memberEqualityComparer) {
16539                    return new (System.Collections.Generic.SortedSetEqualityComparer$1(T)).$ctor3(memberEqualityComparer);
16540                },
16541                SortedSetEquals: function (set1, set2, comparer) {
16542                    var $t, $t1;
16543                    if (set1 == null) {
16544                        return (set2 == null);
16545                    } else if (set2 == null) {
16546                        return false;
16547                    }
16548
16549                    if (System.Collections.Generic.SortedSet$1(T).AreComparersEqual(set1, set2)) {
16550                        if (set1.Count !== set2.Count) {
16551                            return false;
16552                        }
16553
16554                        return set1.setEquals(set2);
16555                    } else {
16556                        var found = false;
16557                        $t = H5.getEnumerator(set1);
16558                        try {
16559                            while ($t.moveNext()) {
16560                                var item1 = $t.Current;
16561                                found = false;
16562                                $t1 = H5.getEnumerator(set2);
16563                                try {
16564                                    while ($t1.moveNext()) {
16565                                        var item2 = $t1.Current;
16566                                        if (comparer[H5.geti(comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item1, item2) === 0) {
16567                                            found = true;
16568                                            break;
16569                                        }
16570                                    }
16571                                } finally {
16572                                    if (H5.is($t1, System.IDisposable)) {
16573                                        $t1.System$IDisposable$Dispose();
16574                                    }
16575                                }
16576                                if (!found) {
16577                                    return false;
16578                                }
16579                            }
16580                        } finally {
16581                            if (H5.is($t, System.IDisposable)) {
16582                                $t.System$IDisposable$Dispose();
16583                            }
16584                        }
16585                        return true;
16586                    }
16587
16588                },
16589                AreComparersEqual: function (set1, set2) {
16590                    return H5.equals(set1.Comparer, set2.Comparer);
16591                },
16592                Split4Node: function (node) {
16593                    node.IsRed = true;
16594                    node.Left.IsRed = false;
16595                    node.Right.IsRed = false;
16596                },
16597                ConstructRootFromSortedArray: function (arr, startIndex, endIndex, redNode) {
16598
16599
16600
16601
16602
16603                    var size = (((endIndex - startIndex) | 0) + 1) | 0;
16604                    if (size === 0) {
16605                        return null;
16606                    }
16607                    var root = null;
16608                    if (size === 1) {
16609                        root = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(startIndex, arr)], false);
16610                        if (redNode != null) {
16611                            root.Left = redNode;
16612                        }
16613                    } else if (size === 2) {
16614                        root = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(startIndex, arr)], false);
16615                        root.Right = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(endIndex, arr)], false);
16616                        root.Right.IsRed = true;
16617                        if (redNode != null) {
16618                            root.Left = redNode;
16619                        }
16620                    } else if (size === 3) {
16621                        root = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(((startIndex + 1) | 0), arr)], false);
16622                        root.Left = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(startIndex, arr)], false);
16623                        root.Right = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(endIndex, arr)], false);
16624                        if (redNode != null) {
16625                            root.Left.Left = redNode;
16626
16627                        }
16628                    } else {
16629                        var midpt = (((H5.Int.div((((startIndex + endIndex) | 0)), 2)) | 0));
16630                        root = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(midpt, arr)], false);
16631                        root.Left = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(arr, startIndex, ((m
16631idpt - 1) | 0), redNode);
16632                        if (size % 2 === 0) {
16633                            root.Right = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(arr, ((midpt + 2) | 0), endIndex, new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(arr[System.Array.index(((midpt + 1) | 0), arr)], true));
16634                        } else {
16635                            root.Right = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(arr, ((midpt + 1) | 0), endIndex, null);
16636                        }
16637                    }
16638                    return root;
16639
16640                },
16641                log2: function (value) {
16642                    var c = 0;
16643                    while (value > 0) {
16644                        c = (c + 1) | 0;
16645                        value = value >> 1;
16646                    }
16647                    return c;
16648                }
16649            }
16650        },
16651        fields: {
16652            root: null,
16653            comparer: null,
16654            count: 0,
16655            version: 0
16656        },
16657        props: {
16658            Count: {
16659                get: function () {
16660                    this.VersionCheck();
16661                    return this.count;
16662                }
16663            },
16664            Comparer: {
16665                get: function () {
16666                    return this.comparer;
16667                }
16668            },
16669            System$Collections$Generic$ICollection$1$IsReadOnly: {
16670                get: function () {
16671                    return false;
16672                }
16673            },
16674            System$Collections$ICollection$IsSynchronized: {
16675                get: function () {
16676                    return false;
16677                }
16678            },
16679            System$Collections$ICollection$SyncRoot: {
16680                get: function () {
16681                    return null;
16682                }
16683            },
16684            Min: {
16685                get: function () {
16686                    var ret = H5.getDefaultValue(T);
16687                    this.InOrderTreeWalk(function (n) {
16688                        ret = n.Item;
16689                        return false;
16690                    });
16691                    return ret;
16692                }
16693            },
16694            Max: {
16695                get: function () {
16696                    var ret = H5.getDefaultValue(T);
16697                    this.InOrderTreeWalk$1(function (n) {
16698                        ret = n.Item;
16699                        return false;
16700                    }, true);
16701                    return ret;
16702                }
16703            }
16704        },
16705        alias: [
16706            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
16707            "Count", "System$Collections$ICollection$Count",
16708            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
16709            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly",
16710            "add", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$add",
16711            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
16712            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove",
16713            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
16714            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
16715            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
16716            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator",
16717            "unionWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$unionWith",
16718            "intersectWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$intersectWith",
16719            "exceptWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$exceptWith",
16720            "symmetricExceptWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$symmetricExceptWith",
16721            "isSubsetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isSubsetOf",
16722            "isProperSubsetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isProperSubsetOf",
16723            "isSupersetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isSupersetOf",
16724            "isProperSupersetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isProperSupersetOf",
16725            "setEquals", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$setEquals",
16726            "overlaps", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$overlaps"
16727        ],
16728        ctors: {
16729            ctor: function () {
16730                this.$initialize();
16731                this.comparer = new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn);
16732
16733            },
16734            $ctor1: function (comparer) {
16735                this.$initialize();
16736                if (comparer == null) {
16737                    this.comparer = new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn);
16738                } else {
16739                    this.comparer = comparer;
16740                }
16741            },
16742            $ctor2: function (collection) {
16743                System.Collections.Generic.SortedSet$1(T).$ctor3.call(this, collection, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn));
16744            },
16745            $ctor3: function (collection, comparer) {
16746                System.Collections.Generic.SortedSet$1(T).$ctor1.call(this, comparer);
16747                if (collection == null) {
16748                    throw new System.ArgumentNullException.$ctor1("collection");
16749                }
16750
16751                var baseTreeSubSet = H5.as(collection, System.Collections.Generic.SortedSet$1.TreeSubSet(T));
16752                var baseSortedSet;
16753                if (((baseSortedSet = H5.as(collection, System.Collections.Generic.SortedSet$1(T)))) != null && baseTreeSubSet == null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, baseSortedSet)) {
16754                    if (baseSortedSet.Count === 0) {
16755                        this.count = 0;
16756                        this.version = 0;
16757                        this.root = null;
16758                        return;
16759                    }
16760
16761
16762                    var theirStack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(((H5.Int.mul(2, System.Collections.Generic.SortedSet$1(T).log2(baseSortedSet.Count)) + 2) | 0));
16763                    var myStack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(((H5.Int.mul(2, System.Collections.Generic.SortedSet$1(T).log2(baseSortedSet.Count)) + 2) | 0));
16764                    var theirCurrent = baseSortedSet.root;
16765                    var myCurrent = (theirCurrent != null ? new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(theirCurrent.Item, the
16765irCurrent.IsRed) : null);
16766                    this.root = myCurrent;
16767                    while (theirCurrent != null) {
16768                        theirStack.Push(theirCurrent);
16769                        myStack.Push(myCurrent);
16770                        myCurrent.Left = (theirCurrent.Left != null ? new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(theirCurrent.Left.Item, theirCurrent.Left.IsRed) : null);
16771                        theirCurrent = theirCurrent.Left;
16772                        myCurrent = myCurrent.Left;
16773                    }
16774                    while (theirStack.Count !== 0) {
16775                        theirCurrent = theirStack.Pop();
16776                        myCurrent = myStack.Pop();
16777                        var theirRight = theirCurrent.Right;
16778                        var myRight = null;
16779                        if (theirRight != null) {
16780                            myRight = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(theirRight.Item, theirRight.IsRed);
16781                        }
16782                        myCurrent.Right = myRight;
16783
16784                        while (theirRight != null) {
16785                            theirStack.Push(theirRight);
16786                            myStack.Push(myRight);
16787                            myRight.Left = (theirRight.Left != null ? new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(theirRight.Left.Item, theirRight.Left.IsRed) : null);
16788                            theirRight = theirRight.Left;
16789                            myRight = myRight.Left;
16790                        }
16791                    }
16792                    this.count = baseSortedSet.count;
16793                    this.version = 0;
16794                } else {
16795
16796                    var els = new (System.Collections.Generic.List$1(T)).$ctor1(collection);
16797                    els.Sort$1(this.comparer);
16798                    for (var i = 1; i < els.Count; i = (i + 1) | 0) {
16799                        if (this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](els.getItem(i), els.getItem(((i - 1) | 0))) === 0) {
16800                            els.removeAt(i);
16801                            i = (i - 1) | 0;
16802                        }
16803                    }
16804                    this.root = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(els.ToArray(), 0, ((els.Count - 1) | 0), null);
16805                    this.count = els.Count;
16806                    this.version = 0;
16807                }
16808            }
16809        },
16810        methods: {
16811            AddAllElements: function (collection) {
16812                var $t;
16813
16814                $t = H5.getEnumerator(collection, T);
16815                try {
16816                    while ($t.moveNext()) {
16817                        var item = $t.Current;
16818                        if (!this.contains(item)) {
16819                            this.add(item);
16820                        }
16821                    }
16822                } finally {
16823                    if (H5.is($t, System.IDisposable)) {
16824                        $t.System$IDisposable$Dispose();
16825                    }
16826                }
16827            },
16828            RemoveAllElements: function (collection) {
16829                var $t;
16830                var min = this.Min;
16831                var max = this.Max;
16832                $t = H5.getEnumerator(collection, T);
16833                try {
16834                    while ($t.moveNext()) {
16835                        var item = $t.Current;
16836                        if (!(this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, min) < 0 || this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, max) > 0) && this.contains(item)) {
16837                            this.remove(item);
16838                        }
16839                    }
16840                } finally {
16841                    if (H5.is($t, System.IDisposable)) {
16842                        $t.System$IDisposable$Dispose();
16843                    }
16844                }
16845            },
16846            ContainsAllElements: function (collection) {
16847                var $t;
16848                $t = H5.getEnumerator(collection, T);
16849                try {
16850                    while ($t.moveNext()) {
16851                        var item = $t.Current;
16852                        if (!this.contains(item)) {
16853                            return false;
16854                        }
16855                    }
16856                } finally {
16857                    if (H5.is($t, System.IDisposable)) {
16858                        $t.System$IDisposable$Dispose();
16859                    }
16860                }
16861                return true;
16862            },
16863            InOrderTreeWalk: function (action) {
16864                return this.InOrderTreeWalk$1(action, false);
16865            },
16866            InOrderTreeWalk$1: function (action, reverse) {
16867                if (this.root == null) {
16868                    return true;
16869                }
16870
16871                var stack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(H5.Int.mul(2, (System.Collections.Generic.SortedSet$1(T).log2(((this.Count + 1) | 0)))));
16872                var current = this.root;
16873                while (current != null) {
16874                    stack.Push(current);
16875                    current = (reverse ? current.Right : current.Left);
16876                }
16877                while (stack.Count !== 0) {
16878                    current = stack.Pop();
16879                    if (!action(current)) {
16880                        return false;
16881                    }
16882
16883                    var node = (reverse ? current.Left : current.Right);
16884                    while (node != null) {
16885                        stack.Push(node);
16886                        node = (reverse ? node.Right : node.Left);
16887                    }
16888                }
16889                return true;
16890            },
16891            BreadthFirstTreeWalk: function (action) {
16892                if (this.root == null) {
16893                    return true;
16894                }
16895
16896                var processQueue = new (System.Collections.Generic.List$1(System.Collections.Generic.SortedSet$1.Node(T))).ctor();
16897                processQueue.add(this.root);
16898                var current;
16899
16900                while (processQueue.Count !== 0) {
16901                    current = processQueue.getItem(0);
16902                    processQueue.removeAt(0);
16903                    if (!action(current)) {
16904                        return false;
16905                    }
16906                    if (current.Left != null) {
16907                        processQueue.add(current.Left);
16908                    }
16909                    if (current.Right != null) {
16910                        processQueue.add(current.Right);
16911                    }
16912                }
16913                return true;
16914            },
16915            VersionCheck: function () { },
16916            IsWithinRange: function (item) {
16917                return true;
16918
16919            },
16920            add: function (item) {
16921                return this.AddIfNotPresent(item);
16922            },
16923            System$Collections$Generic$ICollection$1$add: function (item) {
16924                this.AddIfNotPresent(item);
16925            },
16926            AddIfNotPresent: function (item) {
16927                if (this.root == null) {
16928                    this.root = new (System.Collections.Generic.SortedSet$1.Node(T)).$ctor1(item, false);
16929                    this.count = 1;
16930                    this.version = (this.version + 1) | 0;
16931                    return true;
16932                }
16933
16934                var current = this.root;
16935                var parent = { v : null };
16936                var grandParent = null;
16937                var greatGrandParent = null;
16938
16939                this.version = (this.version + 1) | 0;
16940
16941
16942                var order = 0;
16943                while (current != null) {
16944                    order = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, current.Item);
16945                    if (order === 0) {
16946                        this.root.IsRed = false;
16947                        return false;
16948                    }
16949
16950                    if (System.Collections.Generic.SortedSet$1(T).Is4Node(current)) {
16951                        System.Collections.Generic.SortedSet$1(T).Split4Node(current);
16952                        if (System.Collections.Generic.SortedSet$1(T).IsRed(parent.v)) {
16953                            this.InsertionBalance(current, parent, grandParent, greatGrandParent);
16954                        }
16955                    }
16956                    greatGrandParent = grandParent;
16957                    grandParent = parent.v;
16958                    parent.v = current;
16959                    current = (order < 0) ? current.Left : current.Right;
16960                }
16961
16962                var node = new (System.Collections.Generic.SortedSet$1.Node(T)).ctor(item);
16963                if (order > 0) {
16964                    parent.v.Right = node;
16965                } else {
16966                    parent.v.Left = node;
16967                }
16968
16969                if (parent.v.IsRed) {
16970                    this.InsertionBalance(node, parent, grandParent, greatGrandParent);
16971                }
16972
16973                this.root.IsRed = false;
16974                this.count = (this.count + 1) | 0;
16975                return true;
16976            },
16977            remove: function (item) {
16978                return this.DoRemove(item);
16979            },
16980            DoRemove: function (item) {
16981
16982                if (this.root == null) {
16983                    return false;
16984                }
16985
16986
16987
16988                this.version = (this.version + 1) | 0;
16989
16990                var current = this.root;
16991                var parent = null;
16992                var grandParent = null;
16993                var match = null;
16994                var parentOfMatch = null;
16995                var foundMatch = false;
16996                while (current != null) {
16997                    if (System.Collections.Generic.SortedSet$1(T).Is2Node(current)) {
16998                        if (parent == null) {
16999                            current.IsRed = true;
17000                        } else {
17001                            var sibling = System.Collections.Generic.SortedSet$1(T).GetSibling(current, parent);
17002                            if (sibling.IsRed) {
17003                                if (H5.referenceEquals(parent.Right, sibling)) {
17004                                    System.Collections.Generic.SortedSet$1(T).RotateLeft(parent);
17005                                } else {
17006                                    System.Collections.Generic.SortedSet$1(T).RotateRight(parent);
17007                                }
17008
17009                                parent.IsRed = true;
17010                                sibling.IsRed = false;
17011                                this.ReplaceChildOfNodeOrRoot(grandParent, parent, sibling);
17012                                grandParent = sibling;
17013                                if (H5.referenceEquals(parent, match)) {
17014                                    parentOfMatch = sibling;
17015                                }
17016
17017                                sibling = (H5.referenceEquals(parent.Left, current)) ? parent.Right : parent.Left;
17018                            }
17019
17020                            if (System.Collections.Generic.SortedSet$1(T).Is2Node(sibling)) {
17021                                System.Collections.Generic.SortedSet$1(T).Merge2Nodes(parent, current, sibling);
17022                            } else {
17023                                var rotation = System.Collections.Generic.SortedSet$1(T).RotationNeeded(parent, current, sibling);
17024                                var newGrandParent = null;
17025                                switch (rotation) {
17026                                    case System.Collections.Generic.TreeRotation.RightRotation: 
17027                                        sibling.Left.IsRed = false;
17028                                        newGrandParent = System.Collections.Generic.SortedSet$1(T).RotateRight(parent);
17029                                        break;
17030                                    case System.Collections.Generic.TreeRotation.LeftRotation: 
17031                                        sibling.Right.IsRed = false;
17032                                        newGrandParent = System.Collections.Generic.SortedSet$1(T).RotateLeft(parent);
17033                                        break;
17034                                    case System.Collections.Generic.TreeRotation.RightLeftRotation: 
17035                                        newGrandParent = System.Collections.Generic.SortedSet$1(T).RotateRightLeft(parent);
17036                                        break;
17037                                    case System.Collections.Generic.TreeRotation.LeftRightRotation: 
17038                                        newGrandParent = System.Collections.Generic.SortedSet$1(T).RotateLeftRight(parent);
17039                                        break;
17040                                }
17041
17042                                newGrandParent.IsRed = parent.IsRed;
17043                                parent.IsRed = false;
17044                                current.IsRed = true;
17045                                this.ReplaceChildOfNodeOrRoot(grandParent, parent, newGrandParent);
17046                                if (H5.referenceEquals(parent, match)) {
17047                                    parentOfMatch = newGrandParent;
17048                                }
17049                                grandParent = newGrandParent;
17050                            }
17051                        }
17052                    }
17053
17054                    var order = foundMatch ? -1 : this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, current.Item);
17055                    if (order === 0) {
17056                        foundMatch = true;
17057                        match = current;
17058                        parentOfMatch = parent;
17059                    }
17060
17061                    grandParent = parent;
17062                    parent = current;
17063
17064                    if (order < 0) {
17065                        current = current.Left;
17066                    } else {
17067                        current = current.Right;
17068                    }
17069                }
17070
17071                if (match != null) {
17072                    this.ReplaceNode(match, parentOfMatch, parent, grandParent);
17073                    this.count = (this.count - 1) | 0;
17074                }
17075
17076                if (this.root != null) {
17077                    this.root.IsRed = false;
17078                }
17079                return foundMatch;
17080            },
17081            clear: function () {
17082                this.root = null;
17083                this.count = 0;
17084                this.version = (this.version + 1) | 0;
17085            },
17086            contains: function (item) {
17087
17088                return this.FindNode(item) != null;
17089            },
17090            CopyTo: function (array) {
17091                this.CopyTo$1(array, 0, this.Count);
17092            },
17093            copyTo: function (array, index) {
17094                this.CopyTo$1(array, index, this.Count);
17095            },
17096            CopyTo$1: function (array, index, count) {
17097                if (array == null) {
17098                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
17099                }
17100
17101                if (index < 0) {
17102                    System.ThrowHelper.ThrowArgumentOutOfRangeException$1(System.ExceptionArgument.index);
17103                }
17104
17105                if (count < 0) {
17106                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
17107                }
17108
17109                if (index > array.length || count > ((array.length - index) | 0)) {
17110                    throw new System.ArgumentException.ctor();
17111                }
17112                count = (count + index) | 0;
17113
17114                this.InOrderTreeWalk(function (node) {
17115                    if (index >= count) {
17116                        return false;
17117                    } else {
17118                        array[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), array)] = node.Item;
17119                        return true;
17120                    }
17121                });
17122            },
17123            System$Collections$ICollection$copyTo: function (array, index) {
17124                if (array == null) {
17125                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
17126                }
17127
17128                if (System.Array.getRank(array) !== 1) {
17129                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
17130                }
17131
17132                if (System.Array.getLower(array, 0) !== 0) {
17133                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
17134                }
17135
17136                if (index < 0) {
17137                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.arrayIndex, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
17138                }
17139
17140                if (((array.length - index) | 0) < this.Count) {
17141                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
17142                }
17143                var tarray;
17144                if (((tarray = H5.as(array, System.Array.type(T)))) != null) {
17145                    this.copyTo(tarray, index);
17146                } else {
17147                    var objects = H5.as(array, System.Array.type(System.Object));
17148                    if (objects == null) {
17149                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
17150                    }
17151
17152                    try {
17153                        this.InOrderTreeWalk(function (node) {
17154                            objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = node.Item;
17155                            return true;
17156                        });
17157                    } catch ($e1) {
17158                        $e1 = System.Exception.create($e1);
17159                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
17160                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
17161                        } else {
17162                            throw $e1;
17163                        }
17164                    }
17165                }
17166            },
17167            GetEnumerator: function () {
17168                return new (System.Collections.Generic.SortedSet$1.Enumerator(T)).$ctor1(this);
17169            },
17170            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
17171                return new (System.Collections.Generic.SortedSet$1.Enumerator(T)).$ctor1(this).$clone();
17172            },
17173            System$Collections$IEnumerable$GetEnumerator: function () {
17174                return new (System.Collections.Generic.SortedSet$1.Enumerator(T)).$ctor1(this).$clone();
17175            },
17176            InsertionBalance: function (current, parent, grandParent, greatGrandParent) {
17177                var parentIsOnRight = (H5.referenceEquals(grandParent.Right, parent.v));
17178                var currentIsOnRight = (H5.referenceEquals(parent.v.Right, current));
17179
17180                var newChildOfGreatGrandParent;
17181                if (parentIsOnRight === currentIsOnRight) {
17182                    newChildOfGreatGrandParent = currentIsOnRight ? System.Collections.Generic.SortedSet$1(T).RotateLeft(grandParent) : System.Collections.Generic.SortedSet$1(T).RotateRight(grandParent);
17183                } else {
17184                    newChildOfGreatGrandParent = currentIsOnRight ? System.Collections.Generic.SortedSet$1(T).RotateLeftRight(grandParent) : System.Collections.Generic.SortedSet$1(T).RotateRightLeft(grandParent);
17185                    parent.v = greatGrandParent;
17186                }
17187                grandParent.IsRed = true;
17188                newChildOfGreatGrandParent.IsRed = false;
17189
17190                this.ReplaceChildOfNodeOrRoot(greatGrandParent, grandParent, newChildOfGreatGrandParent);
17191            },
17192            ReplaceChildOfNodeOrRoot: function (parent, child, newChild) {
17193                if (parent != null) {
17194                    if (H5.referenceEquals(parent.Left, child)) {
17195                        parent.Left = newChild;
17196                    } else {
17197                        parent.Right = newChild;
17198                    }
17199                } else {
17200                    this.root = newChild;
17201                }
17202            },
17203            ReplaceNode: function (match, parentOfMatch, succesor, parentOfSuccesor) {
17204                if (H5.referenceEquals(succesor, match)) {
17205                    succesor = match.Left;
17206                } else {
17207                    if (succesor.Right != null) {
17208                        succesor.Right.IsRed = false;
17209                    }
17210
17211                    if (!H5.referenceEquals(parentOfSuccesor, match)) {
17212                        parentOfSuccesor.Left = succesor.Right;
17213                        succesor.Right = match.Right;
17214                    }
17215
17216                    succesor.Left = match.Left;
17217                }
17218
17219                if (succesor != null) {
17220                    succesor.IsRed = match.IsRed;
17221                }
17222
17223                this.ReplaceChildOfNodeOrRoot(parentOfMatch, match, succesor);
17224
17225            },
17226            FindNode: function (item) {
17227                var current = this.root;
17228                while (current != null) {
17229                    var order = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, current.Item);
17230                    if (order === 0) {
17231                        return current;
17232                    } else {
17233                        current = (order < 0) ? current.Left : current.Right;
17234                    }
17235                }
17236
17237                return null;
17238            },
17239            InternalIndexOf: function (item) {
17240                var current = this.root;
17241                var count = 0;
17242                while (current != null) {
17243                    var order = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, current.Item);
17244                    if (order === 0) {
17245                        return count;
17246                    } else {
17247                        current = (order < 0) ? current.Left : current.Right;
17248                        count = (order < 0) ? (((H5.Int.mul(2, count) + 1) | 0)) : (((H5.Int.mul(2, count) + 2) | 0));
17249                    }
17250                }
17251                return -1;
17252            },
17253            FindRange: function (from, to) {
17254                return this.FindRange$1(from, to, true, true);
17255            },
17256            FindRange$1: function (from, to, lowerBoundActive, upperBoundActive) {
17257                var current = this.root;
17258                while (current != null) {
17259                    if (lowerBoundActive && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](from, current.Item) > 0) {
17260                        current = current.Right;
17261                    } else {
17262                        if (upperBoundActive && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](to, current.Item) < 0) {
17263                            current = current.Left;
17264                        } else {
17265                            return current;
17266                        }
17267                    }
17268                }
17269
17270                return null;
17271            },
17272            UpdateVersion: function () {
17273                this.version = (this.version + 1) | 0;
17274            },
17275            ToArray: function () {
17276                var newArray = System.Array.init(this.Count, function (){
17277                    return H5.getDefaultValue(T);
17278                }, T);
17279                this.CopyTo(newArray);
17280                return newArray;
17281            },
17282            unionWith: function (other) {
17283                var $t;
17284                if (other == null) {
17285                    throw new System.ArgumentNullException.$ctor1("other");
17286                }
17287
17288                var s = H5.as(other, System.Collections.Generic.SortedSet$1(T));
17289                var t = H5.as(this, System.Collections.Generic.SortedSet$1.TreeSubSet(T));
17290
17291                if (t != null) {
17292                    this.VersionCheck();
17293                }
17294
17295                if (s != null && t == null && this.count === 0) {
17296                    var dummy = new (System.Collections.Generic.SortedSet$1(T)).$ctor3(s, this.comparer);
17297                    this.root = dummy.root;
17298                    this.count = dummy.count;
17299                    this.version = (this.version + 1) | 0;
17300                    return;
17301                }
17302
17303
17304                if (s != null && t == null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, s) && (s.Count > ((H5.Int.div(this.Count, 2)) | 0))) {
17305                    var merged = System.Array.init(((s.Count + this.Count) | 0), function (){
17306                        return H5.getDefaultValue(T);
17307                    }, T);
17308                    var c = 0;
17309                    var mine = this.GetEnumerator();
17310                    var theirs = s.GetEnumerator();
17311                    var mineEnded = !mine.moveNext(), theirsEnded = !theirs.moveNext();
17312                    while (!mineEnded && !theirsEnded) {
17313                        var comp = ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](mine.Current, theirs.Current);
17314                        if (comp < 0) {
17315                            merged[System.Array.index(H5.identity(c, ((c = (c + 1) | 0))), merged)] = mine.Current;
17316                            mineEnded = !mine.moveNext();
17317                        } else if (comp === 0) {
17318                            merged[System.Array.index(H5.identity(c, ((c = (c + 1) | 0))), merged)] = theirs.Current;
17319                            mineEnded = !mine.moveNext();
17320                            theirsEnded = !theirs.moveNext();
17321                        } else {
17322                            merged[System.Array.index(H5.identity(c, ((c = (c + 1) | 0))), merged)] = theirs.Current;
17323                            theirsEnded = !theirs.moveNext();
17324                        }
17325                    }
17326
17327                    if (!mineEnded || !theirsEnded) {
17328                        var remaining = (mineEnded ? theirs : mine);
17329                        do {
17330                            merged[System.Array.index(H5.identity(c, ((c = (c + 1) | 0))), merged)] = remaining.Current;
17331                        } while (remaining.moveNext());
17332                    }
17333
17334
17335                    this.root = null;
17336
17337
17338                    this.root = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(merged, 0, ((c - 1) | 0), null);
17339                    this.count = c;
17340                    this.version = (this.version + 1) | 0;
17341                } else {
17342                    this.AddAllElements(other);
17343                }
17344            },
17345            intersectWith: function (other) {
17346                var $t, $t1;
17347                if (other == null) {
17348                    throw new System.ArgumentNullException.$ctor1("other");
17349                }
17350
17351                if (this.Count === 0) {
17352                    return;
17353                }
17354
17355
17356                var t = H5.as(this, System.Collections.Generic.SortedSet$1.TreeSubSet(T));
17357                if (t != null) {
17358                    this.VersionCheck();
17359                }
17360                var s;
17361                if (((s = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && t == null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, s)) {
17362
17363
17364                    var merged = System.Array.init(this.Count, function (){
17365                        return H5.getDefaultValue(T);
17366                    }, T);
17367                    var c = 0;
17368                    var mine = this.GetEnumerator();
17369                    var theirs = s.GetEnumerator();
17370                    var mineEnded = !mine.moveNext(), theirsEnded = !theirs.moveNext();
17371                    var max = this.Max;
17372                    var min = this.Min;
17373
17374                    while (!mineEnded && !theirsEnded && ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](theirs.Current, max) <= 0) {
17375                        var comp = ($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](mine.Current, theirs.Current);
17376                        if (comp < 0) {
17377                            mineEnded = !mine.moveNext();
17378                        } else if (comp === 0) {
17379                            merged[System.Array.index(H5.identity(c, ((c = (c + 1) | 0))), merged)] = theirs.Current;
17380                            mineEnded = !mine.moveNext();
17381                            theirsEnded = !theirs.moveNext();
17382                        } else {
17383                            theirsEnded = !theirs.moveNext();
17384                        }
17385                    }
17386
17387
17388                    this.root = null;
17389
17390                    this.root = System.Collections.Generic.SortedSet$1(T).ConstructRootFromSortedArray(merged, 0, ((c - 1) | 0), null);
17391                    this.count = c;
17392                    this.version = (this.version + 1) | 0;
17393                } else {
17394                    this.IntersectWithEnumerable(other);
17395                }
17396            },
17397            IntersectWithEnumerable: function (other) {
17398                var $t;
17399                var toSave = new (System.Collections.Generic.List$1(T)).$ctor2(this.Count);
17400                $t = H5.getEnumerator(other, T);
17401                try {
17402                    while ($t.moveNext()) {
17403                        var item = $t.Current;
17404                        if (this.contains(item)) {
17405                            toSave.add(item);
17406                            this.remove(item);
17407                        }
17408                    }
17409                } finally {
17410                    if (H5.is($t, System.IDisposable)) {
17411                        $t.System$IDisposable$Dispose();
17412                    }
17413                }
17414                this.clear();
17415                this.AddAllElements(toSave);
17416
17417            },
17418            exceptWith: function (other) {
17419                var $t;
17420                if (other == null) {
17421                    throw new System.ArgumentNullException.$ctor1("other");
17422                }
17423
17424                if (this.count === 0) {
17425                    return;
17426                }
17427
17428                if (H5.referenceEquals(other, this)) {
17429                    this.clear();
17430                    return;
17431                }
17432                var asSorted;
17433
17434                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17435                    if (!(this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](asSorted.Max, this.Min) < 0 || this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](asSorted.Min, this.Max) > 0)) {
17436                        var min = this.Min;
17437                        var max = this.Max;
17438                        $t = H5.getEnumerator(other, T);
17439                        try {
17440                            while ($t.moveNext()) {
17441                                var item = $t.Current;
17442                                if (this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, min) < 0) {
17443                                    continue;
17444                                }
17445                                if (this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, max) > 0) {
17446                                    break;
17447                                }
17448                                this.remove(item);
17449                            }
17450                        } finally {
17451                            if (H5.is($t, System.IDisposable)) {
17452                                $t.System$IDisposable$Dispose();
17453                            }
17454                        }
17455                    }
17456
17457                } else {
17458                    this.RemoveAllElements(other);
17459                }
17460            },
17461            symmetricExceptWith: function (other) {
17462                if (other == null) {
17463                    throw new System.ArgumentNullException.$ctor1("other");
17464                }
17465
17466                if (this.Count === 0) {
17467                    this.unionWith(other);
17468                    return;
17469                }
17470
17471                if (H5.referenceEquals(other, this)) {
17472                    this.clear();
17473                    return;
17474                }
17475                var asSorted;
17476                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17477                    this.SymmetricExceptWithSameEC$1(asSorted);
17478                } else {
17479                    var asHash;
17480                    if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17481                        this.SymmetricExceptWithSameEC$1(asHash);
17482                    } else {
17483                        var elements = (new (System.Collections.Generic.List$1(T)).$ctor1(other)).ToArray();
17484                        System.Array.sort(elements, this.Comparer);
17485                        this.SymmetricExceptWithSameEC(elements);
17486                    }
17487                }
17488            },
17489            SymmetricExceptWithSameEC$1: function (other) {
17490                var $t;
17491                $t = H5.getEnumerator(other, T);
17492                try {
17493                    while ($t.moveNext()) {
17494                        var item = $t.Current;
17495                        if (this.contains(item)) {
17496                            this.remove(item);
17497                        } else {
17498                            this.add(item);
17499                        }
17500                    }
17501                } finally {
17502                    if (H5.is($t, System.IDisposable)) {
17503                        $t.System$IDisposable$Dispose();
17504                    }
17505                }
17506            },
17507            SymmetricExceptWithSameEC: function (other) {
17508                if (other.length === 0) {
17509                    return;
17510                }
17511                var last = other[System.Array.index(0, other)];
17512                for (var i = 0; i < other.length; i = (i + 1) | 0) {
17513                    while (i < other.length && i !== 0 && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](other[System.Array.index(i, other)], last) === 0) {
17514                        i = (i + 1) | 0;
17515                    }
17516                    if (i >= other.length) {
17517                        break;
17518                    }
17519                    if (this.contains(other[System.Array.index(i, other)])) {
17520                        this.remove(other[System.Array.index(i, other)]);
17521                    } else {
17522                        this.add(other[System.Array.index(i, other)]);
17523                    }
17524                    last = other[System.Array.index(i, other)];
17525                }
17526            },
17527            isSubsetOf: function (other) {
17528                if (other == null) {
17529                    throw new System.ArgumentNullException.$ctor1("other");
17530                }
17531
17532                if (this.Count === 0) {
17533                    return true;
17534                }
17535                var asSorted;
17536
17537                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17538                    if (this.Count > asSorted.Count) {
17539                        return false;
17540                    }
17541                    return this.IsSubsetOfSortedSetWithSameEC(asSorted);
17542                } else {
17543
17544                    var result = this.CheckUniqueAndUnfoundElements(other, false);
17545                    return (result.uniqueCount === this.Count && result.unfoundCount >= 0);
17546                }
17547            },
17548            IsSubsetOfSortedSetWithSameEC: function (asSorted) {
17549                var $t;
17550                var prunedOther = asSorted.GetViewBetween(this.Min, this.Max);
17551                $t = H5.getEnumerator(this);
17552                try {
17553                    while ($t.moveNext()) {
17554                        var item = $t.Current;
17555                        if (!prunedOther.contains(item)) {
17556                            return false;
17557                        }
17558                    }
17559                } finally {
17560                    if (H5.is($t, System.IDisposable)) {
17561                        $t.System$IDisposable$Dispose();
17562                    }
17563                }
17564                return true;
17565
17566            },
17567            isProperSubsetOf: function (other) {
17568                if (other == null) {
17569                    throw new System.ArgumentNullException.$ctor1("other");
17570                }
17571
17572                if ((H5.as(other, System.Collections.ICollection)) != null) {
17573                    if (this.Count === 0) {
17574                        return System.Array.getCount((H5.as(other, System.Collections.ICollection))) > 0;
17575                    }
17576                }
17577                var asHash;
17578
17579
17580                if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17581                    return asHash.isProperSupersetOf(this);
17582                }
17583                var asSorted;
17584                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17585                    if (this.Count >= asSorted.Count) {
17586                        return false;
17587                    }
17588                    return this.IsSubsetOfSortedSetWithSameEC(asSorted);
17589                }
17590
17591
17592                var result = this.CheckUniqueAndUnfoundElements(other, false);
17593                return (result.uniqueCount === this.Count && result.unfoundCount > 0);
17594            },
17595            isSupersetOf: function (other) {
17596                var $t;
17597                if (other == null) {
17598                    throw new System.ArgumentNullException.$ctor1("other");
17599                }
17600
17601                if ((H5.as(other, System.Collections.ICollection)) != null && System.Array.getCount((H5.as(other, System.Collections.ICollection))) === 0) {
17602                    return true;
17603                }
17604                var asHash;
17605
17606                if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17607                    return asHash.isSubsetOf(this);
17608                }
17609                var asSorted;
17610                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17611                    if (this.Count < asSorted.Count) {
17612                        return false;
17613                    }
17614                    var pruned = this.GetViewBetween(asSorted.Min, asSorted.Max);
17615                    $t = H5.getEnumerator(asSorted);
17616                    try {
17617                        while ($t.moveNext()) {
17618                            var item = $t.Current;
17619                            if (!pruned.contains(item)) {
17620                                return false;
17621                            }
17622                        }
17623                    } finally {
17624                        if (H5.is($t, System.IDisposable)) {
17625                            $t.System$IDisposable$Dispose();
17626                        }
17627                    }
17628                    return true;
17629                }
17630                return this.ContainsAllElements(other);
17631            },
17632            isProperSupersetOf: function (other) {
17633                var $t;
17634                if (other == null) {
17635                    throw new System.ArgumentNullException.$ctor1("other");
17636                }
17637
17638                if (this.Count === 0) {
17639                    return false;
17640                }
17641
17642                if ((H5.as(other, System.Collections.ICollection)) != null && System.Array.getCount((H5.as(other, System.Collections.ICollection))) === 0) {
17643                    return true;
17644                }
17645                var asHash;
17646
17647
17648                if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17649                    return asHash.isProperSubsetOf(this);
17650                }
17651                var asSorted;
17652                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(asSorted, this)) {
17653                    if (asSorted.Count >= this.Count) {
17654                        return false;
17655                    }
17656                    var pruned = this.GetViewBetween(asSorted.Min, asSorted.Max);
17657                    $t = H5.getEnumerator(asSorted);
17658                    try {
17659                        while ($t.moveNext()) {
17660                            var item = $t.Current;
17661                            if (!pruned.contains(item)) {
17662                                return false;
17663                            }
17664                        }
17665                    } finally {
17666                        if (H5.is($t, System.IDisposable)) {
17667                            $t.System$IDisposable$Dispose();
17668                        }
17669                    }
17670                    return true;
17671                }
17672
17673
17674                var result = this.CheckUniqueAndUnfoundElements(other, true);
17675                return (result.uniqueCount < this.Count && result.unfoundCount === 0);
17676            },
17677            setEquals: function (other) {
17678                var $t;
17679                if (other == null) {
17680                    throw new System.ArgumentNullException.$ctor1("other");
17681                }
17682                var asHash;
17683                if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17684                    return asHash.setEquals(this);
17685                }
17686                var asSorted;
17687                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted)) {
17688                    var mine = this.GetEnumerator().$clone();
17689                    var theirs = asSorted.GetEnumerator().$clone();
17690                    var mineEnded = !mine.System$Collections$IEnumerator$moveNext();
17691                    var theirsEnded = !theirs.System$Collections$IEnumerator$moveNext();
17692                    while (!mineEnded && !theirsEnded) {
17693                        if (($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](mine[H5.geti(mine, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")], theirs[H5.geti(theirs, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")]) !== 0) {
17694                            return false;
17695                        }
17696                        mineEnded = !mine.System$Collections$IEnumerator$moveNext();
17697                        theirsEnded = !theirs.System$Collections$IEnumerator$moveNext();
17698                    }
17699                    return mineEnded && theirsEnded;
17700                }
17701
17702                var result = this.CheckUniqueAndUnfoundElements(other, true);
17703                return (result.uniqueCount === this.Count && result.unfoundCount === 0);
17704            },
17705            overlaps: function (other) {
17706                var $t;
17707                if (other == null) {
17708                    throw new System.ArgumentNullException.$ctor1("other");
17709                }
17710
17711                if (this.Count === 0) {
17712                    return false;
17713                }
17714
17715                if ((H5.as(other, System.Collections.Generic.ICollection$1(T)) != null) && System.Array.getCount((H5.as(other, System.Collections.Generic.ICollection$1(T))), T) === 0) {
17716                    return false;
17717                }
17718                var asSorted;
17719                if (((asSorted = H5.as(other, System.Collections.Generic.SortedSet$1(T)))) != null && System.Collections.Generic.SortedSet$1(T).AreComparersEqual(this, asSorted) && (this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.Min, asSorted.Max) > 0 || this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.Max, asSorted.Min) < 0)) {
17720                    return false;
17721                }
17722                var asHash;
17723                if (((asHash = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && H5.equals(this.comparer, new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn)) && H5.equals(asHash.Comparer, System.Collections.Generic.EqualityComparer$1(T).def)) {
17724                    return asHash.overlaps(this);
17725                }
17726
17727                $t = H5.getEnumerator(other, T);
17728                try {
17729                    while ($t.moveNext()) {
17730                        var item = $t.Current;
17731                        if (this.contains(item)) {
17732                            return true;
17733                        }
17734                    }
17735                } finally {
17736                    if (H5.is($t, System.IDisposable)) {
17737                        $t.System$IDisposable$Dispose();
17738                    }
17739                }
17740                return false;
17741            },
17742            CheckUniqueAndUnfoundElements: function (other, returnIfUnfound) {
17743                var $t, $t1;
17744                var result = new (System.Collections.Generic.SortedSet$1.ElementCount(T))();
17745
17746                if (this.Count === 0) {
17747                    var numElementsInOther = 0;
17748                    $t = H5.getEnumerator(other, T);
17749                    try {
17750                        while ($t.moveNext()) {
17751                            var item = $t.Current;
17752                            numElementsInOther = (numElementsInOther + 1) | 0;
17753                            break;
17754                        }
17755                    } finally {
17756                        if (H5.is($t, System.IDisposable)) {
17757                            $t.System$IDisposable$Dispose();
17758                        }
17759                    }
17760                    result.uniqueCount = 0;
17761                    result.unfoundCount = numElementsInOther;
17762                    return result.$clone();
17763                }
17764
17765
17766                var originalLastIndex = this.Count;
17767                var intArrayLength = System.Collections.Generic.BitHelper.ToIntArrayLength(originalLastIndex);
17768
17769                var bitHelper;
17770                var bitArray = System.Array.init(intArrayLength, 0, System.Int32);
17771                bitHelper = new System.Collections.Generic.BitHelper(bitArray, intArrayLength);
17772
17773                var unfoundCount = 0;
17774                var uniqueFoundCount = 0;
17775
17776                $t1 = H5.getEnumerator(other, T);
17777                try {
17778                    while ($t1.moveNext()) {
17779                        var item1 = $t1.Current;
17780                        var index = this.InternalIndexOf(item1);
17781                        if (index >= 0) {
17782                            if (!bitHelper.IsMarked(index)) {
17783                                bitHelper.MarkBit(index);
17784                                uniqueFoundCount = (uniqueFoundCount + 1) | 0;
17785                            }
17786                        } else {
17787                            unfoundCount = (unfoundCount + 1) | 0;
17788                            if (returnIfUnfound) {
17789                                break;
17790                            }
17791                        }
17792                    }
17793                } finally {
17794                    if (H5.is($t1, System.IDisposable)) {
17795                        $t1.System$IDisposable$Dispose();
17796                    }
17797                }
17798
17799                result.uniqueCount = uniqueFoundCount;
17800                result.unfoundCount = unfoundCount;
17801                return result.$clone();
17802            },
17803            RemoveWhere: function (match) {
17804                if (H5.staticEquals(match, null)) {
17805                    throw new System.ArgumentNullException.$ctor1("match");
17806                }
17807                var matches = new (System.Collections.Generic.List$1(T)).$ctor2(this.Count);
17808
17809                this.BreadthFirstTreeWalk(function (n) {
17810                    if (match(n.Item)) {
17811                        matches.add(n.Item);
17812                    }
17813                    return true;
17814                });
17815                var actuallyRemoved = 0;
17816                for (var i = (matches.Count - 1) | 0; i >= 0; i = (i - 1) | 0) {
17817                    if (this.remove(matches.getItem(i))) {
17818                        actuallyRemoved = (actuallyRemoved + 1) | 0;
17819                    }
17820                }
17821
17822                return actuallyRemoved;
17823
17824            },
17825            Reverse: function () {
17826                return new (H5.GeneratorEnumerable$1(T))(H5.fn.bind(this, function ()  {
17827                    var $s = 0,
17828                        $jff,
17829                        $rv,
17830                        e,
17831                        $ae;
17832
17833                    var $en = new (H5.GeneratorEnumerator$1(T))(H5.fn.bind(this, function () {
17834                        try {
17835                            for (;;) {
17836                                switch ($s) {
17837                                    case 0: {
17838                                        e = new (System.Collections.Generic.SortedSet$1.Enumerator(T)).$ctor2(this, true);
17839                                        $s = 1;
17840                                        continue;
17841                                    }
17842                                    case 1: {
17843                                        if ( e.moveNext() ) {
17844                                                $s = 2;
17845                                                continue;
17846                                            } 
17847                                            $s = 4;
17848                                            continue;
17849                                    }
17850                                    case 2: {
17851                                        $en.current = e.Current;
17852                                            $s = 3;
17853                                            return true;
17854                                    }
17855                                    case 3: {
17856                                        
17857                                            $s = 1;
17858                                            continue;
17859                                    }
17860                                    case 4: {
17861
17862                                    }
17863                                    default: {
17864                                        return false;
17865                                    }
17866                                }
17867                            }
17868                        } catch($ae1) {
17869                            $ae = System.Exception.create($ae1);
17870                            throw $ae;
17871                        }
17872                    }));
17873                    return $en;
17874                }));
17875            },
17876            GetViewBetween: function (lowerValue, upperValue) {
17877                var $t;
17878                if (($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](lowerValue, upperValue) > 0) {
17879                    throw new System.ArgumentException.$ctor1("lowerBound is greater than upperBound");
17880                }
17881                return new (System.Collections.Generic.SortedSet$1.TreeSubSet(T)).$ctor1(this, lowerValue, upperValue, true, true);
17882            },
17883            TryGetValue: function (equalValue, actualValue) {
17884                var node = this.FindNode(equalValue);
17885                if (node != null) {
17886                    actualValue.v = node.Item;
17887                    return true;
17888                }
17889                actualValue.v = H5.getDefaultValue(T);
17890                return false;
17891            }
17892        }
17893    }; });
17894
17895    // @source SortedSetEqualityComparer.js
17896
17897    H5.define("System.Collections.Generic.SortedSetEqualityComparer$1", function (T) { return {
17898        inherits: [System.Collections.Generic.IEqualityComparer$1(System.Collections.Generic.SortedSet$1(T))],
17899        fields: {
17900            comparer: null,
17901            e_comparer: null
17902        },
17903        alias: [
17904            "equals2", ["System$Collections$Generic$IEqualityComparer$1$System$Collections$Generic$SortedSet$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2"],
17905            "getHashCode2", ["System$Collections$Generic$IEqualityComparer$1$System$Collections$Generic$SortedSet$1$" + H5.getTypeAlias(T) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2"]
17906        ],
17907        ctors: {
17908            ctor: function () {
17909                System.Collections.Generic.SortedSetEqualityComparer$1(T).$ctor2.call(this, null, null);
17910            },
17911            $ctor1: function (comparer) {
17912                System.Collections.Generic.SortedSetEqualityComparer$1(T).$ctor2.call(this, comparer, null);
17913            },
17914            $ctor3: function (memberEqualityComparer) {
17915                System.Collections.Generic.SortedSetEqualityComparer$1(T).$ctor2.call(this, null, memberEqualityComparer);
17916            },
17917            $ctor2: function (comparer, memberEqualityComparer) {
17918                this.$initialize();
17919                if (comparer == null) {
17920                    this.comparer = new (System.Collections.Generic.Comparer$1(T))(System.Collections.Generic.Comparer$1.$default.fn);
17921                } else {
17922                    this.comparer = comparer;
17923                }
17924                if (memberEqualityComparer == null) {
17925                    this.e_comparer = System.Collections.Generic.EqualityComparer$1(T).def;
17926                } else {
17927                    this.e_comparer = memberEqualityComparer;
17928                }
17929            }
17930        },
17931        methods: {
17932            equals2: function (x, y) {
17933                return System.Collections.Generic.SortedSet$1(T).SortedSetEquals(x, y, this.comparer);
17934            },
17935            equals: function (obj) {
17936                var comparer;
17937                if (!(((comparer = H5.as(obj, System.Collections.Generic.SortedSetEqualityComparer$1(T)))) != null)) {
17938                    return false;
17939                }
17940                return (H5.referenceEquals(this.comparer, comparer.comparer));
17941            },
17942            getHashCode2: function (obj) {
17943                var $t;
17944                var hashCode = 0;
17945                if (obj != null) {
17946                    $t = H5.getEnumerator(obj);
17947                    try {
17948                        while ($t.moveNext()) {
17949                            var t = $t.Current;
17950                            hashCode = hashCode ^ (this.e_comparer[H5.geti(this.e_comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](t) & 2147483647);
17951                        }
17952                    } finally {
17953                        if (H5.is($t, System.IDisposable)) {
17954                            $t.System$IDisposable$Dispose();
17955                        }
17956                    }
17957                }
17958                return hashCode;
17959            },
17960            getHashCode: function () {
17961                return H5.getHashCode(this.comparer) ^ H5.getHashCode(this.e_comparer);
17962            }
17963        }
17964    }; });
17965
17966    // @source ElementCount.js
17967
17968    H5.define("System.Collections.Generic.SortedSet$1.ElementCount", function (T) { return {
17969        $kind: "nested struct",
17970        statics: {
17971            methods: {
17972                getDefaultValue: function () { return new (System.Collections.Generic.SortedSet$1.ElementCount(T))(); }
17973            }
17974        },
17975        fields: {
17976            uniqueCount: 0,
17977            unfoundCount: 0
17978        },
17979        ctors: {
17980            ctor: function () {
17981                this.$initialize();
17982            }
17983        },
17984        methods: {
17985            getHashCode: function () {
17986                var h = H5.addHash([4920463385, this.uniqueCount, this.unfoundCount]);
17987                return h;
17988            },
17989            equals: function (o) {
17990                if (!H5.is(o, System.Collections.Generic.SortedSet$1.ElementCount(T))) {
17991                    return false;
17992                }
17993                return H5.equals(this.uniqueCount, o.uniqueCount) && H5.equals(this.unfoundCount, o.unfoundCount);
17994            },
17995            $clone: function (to) {
17996                var s = to || new (System.Collections.Generic.SortedSet$1.ElementCount(T))();
17997                s.uniqueCount = this.uniqueCount;
17998                s.unfoundCount = this.unfoundCount;
17999                return s;
18000            }
18001        }
18002    }; });
18003
18004    // @source Enumerator.js
18005
18006    H5.define("System.Collections.Generic.SortedSet$1.Enumerator", function (T) { return {
18007        inherits: [System.Collections.Generic.IEnumerator$1(T),System.Collections.IEnumerator],
18008        $kind: "nested struct",
18009        statics: {
18010            fields: {
18011                dummyNode: null
18012            },
18013            ctors: {
18014                init: function () {
18015                    this.dummyNode = new (System.Collections.Generic.SortedSet$1.Node(T)).ctor(H5.getDefaultValue(T));
18016                }
18017            },
18018            methods: {
18019                getDefaultValue: function () { return new (System.Collections.Generic.SortedSet$1.Enumerator(T))(); }
18020            }
18021        },
18022        fields: {
18023            tree: null,
18024            version: 0,
18025            stack: null,
18026            current: null,
18027            reverse: false
18028        },
18029        props: {
18030            Current: {
18031                get: function () {
18032                    if (this.current != null) {
18033                        return this.current.Item;
18034                    }
18035                    return H5.getDefaultValue(T);
18036                }
18037            },
18038            System$Collections$IEnumerator$Current: {
18039                get: function () {
18040                    if (this.current == null) {
18041                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
18042                    }
18043
18044                    return this.current.Item;
18045                }
18046            },
18047            NotStartedOrEnded: {
18048                get: function () {
18049                    return this.current == null;
18050                }
18051            }
18052        },
18053        alias: [
18054            "moveNext", "System$Collections$IEnumerator$moveNext",
18055            "Dispose", "System$IDisposable$Dispose",
18056            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
18057        ],
18058        ctors: {
18059            $ctor1: function (set) {
18060                this.$initialize();
18061                this.tree = set;
18062                this.tree.VersionCheck();
18063
18064                this.version = this.tree.version;
18065
18066                this.stack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(H5.Int.mul(2, System.Collections.Generic.SortedSet$1(T).log2(((set.Count + 1) | 0))));
18067                this.current = null;
18068                this.reverse = false;
18069
18070                this.Intialize();
18071            },
18072            $ctor2: function (set, reverse) {
18073                this.$initialize();
18074                this.tree = set;
18075                this.tree.VersionCheck();
18076                this.version = this.tree.version;
18077
18078                this.stack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(H5.Int.mul(2, System.Collections.Generic.SortedSet$1(T).log2(((set.Count + 1) | 0))));
18079                this.current = null;
18080                this.reverse = reverse;
18081
18082                this.Intialize();
18083
18084            },
18085            ctor: function () {
18086                this.$initialize();
18087            }
18088        },
18089        methods: {
18090            Intialize: function () {
18091
18092                this.current = null;
18093                var node = this.tree.root;
18094                var next = null, other = null;
18095                while (node != null) {
18096                    next = (this.reverse ? node.Right : node.Left);
18097                    other = (this.reverse ? node.Left : node.Right);
18098                    if (this.tree.IsWithinRange(node.Item)) {
18099                        this.stack.Push(node);
18100                        node = next;
18101                    } else if (next == null || !this.tree.IsWithinRange(next.Item)) {
18102                        node = other;
18103                    } else {
18104                        node = next;
18105                    }
18106                }
18107            },
18108            moveNext: function () {
18109
18110                this.tree.VersionCheck();
18111
18112                if (this.version !== this.tree.version) {
18113                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
18114                }
18115
18116                if (this.stack.Count === 0) {
18117                    this.current = null;
18118                    return false;
18119                }
18120
18121                this.current = this.stack.Pop();
18122                var node = (this.reverse ? this.current.Left : this.current.Right);
18123                var next = null, other = null;
18124                while (node != null) {
18125                    next = (this.reverse ? node.Right : node.Left);
18126                    other = (this.reverse ? node.Left : node.Right);
18127                    if (this.tree.IsWithinRange(node.Item)) {
18128                        this.stack.Push(node);
18129                        node = next;
18130                    } else if (other == null || !this.tree.IsWithinRange(other.Item)) {
18131                        node = next;
18132                    } else {
18133                        node = other;
18134                    }
18135                }
18136                return true;
18137            },
18138            Dispose: function () { },
18139            Reset: function () {
18140                if (this.version !== this.tree.version) {
18141                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
18142                }
18143
18144                this.stack.Clear();
18145                this.Intialize();
18146            },
18147            System$Collections$IEnumerator$reset: function () {
18148                this.Reset();
18149            },
18150            getHashCode: function () {
18151                var h = H5.addHash([3788985113, this.tree, this.version, this.stack, this.current, this.reverse]);
18152                return h;
18153            },
18154            equals: function (o) {
18155                if (!H5.is(o, System.Collections.Generic.SortedSet$1.Enumerator(T))) {
18156                    return false;
18157                }
18158                return H5.equals(this.tree, o.tree) && H5.equals(this.version, o.version) && H5.equals(this.stack, o.stack) && H5.equals(this.current, o.current) && H5.equals(this.reverse, o.reverse);
18159            },
18160            $clone: function (to) {
18161                var s = to || new (System.Collections.Generic.SortedSet$1.Enumerator(T))();
18162                s.tree = this.tree;
18163                s.version = this.version;
18164                s.stack = this.stack;
18165                s.current = this.current;
18166                s.reverse = this.reverse;
18167                return s;
18168            }
18169        }
18170    }; });
18171
18172    // @source Node.js
18173
18174    H5.define("System.Collections.Generic.SortedSet$1.Node", function (T) { return {
18175        $kind: "nested class",
18176        fields: {
18177            IsRed: false,
18178            Item: H5.getDefaultValue(T),
18179            Left: null,
18180            Right: null
18181        },
18182        ctors: {
18183            ctor: function (item) {
18184                this.$initialize();
18185                this.Item = item;
18186                this.IsRed = true;
18187            },
18188            $ctor1: function (item, isRed) {
18189                this.$initialize();
18190                this.Item = item;
18191                this.IsRed = isRed;
18192            }
18193        }
18194    }; });
18195
18196    // @source TreeSubSet.js
18197
18198    H5.define("System.Collections.Generic.SortedSet$1.TreeSubSet", function (T) { return {
18199        inherits: [System.Collections.Generic.SortedSet$1(T)],
18200        $kind: "nested class",
18201        fields: {
18202            underlying: null,
18203            min: H5.getDefaultValue(T),
18204            max: H5.getDefaultValue(T),
18205            lBoundActive: false,
18206            uBoundActive: false
18207        },
18208        alias: [
18209            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
18210            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear"
18211        ],
18212        ctors: {
18213            $ctor1: function (Underlying, Min, Max, lowerBoundActive, upperBoundActive) {
18214                this.$initialize();
18215                System.Collections.Generic.SortedSet$1(T).$ctor1.call(this, Underlying.Comparer);
18216                this.underlying = Underlying;
18217                this.min = Min;
18218                this.max = Max;
18219                this.lBoundActive = lowerBoundActive;
18220                this.uBoundActive = upperBoundActive;
18221                this.root = this.underlying.FindRange$1(this.min, this.max, this.lBoundActive, this.uBoundActive);
18222                this.count = 0;
18223                this.version = -1;
18224                this.VersionCheckImpl();
18225            },
18226            ctor: function () {
18227                this.$initialize();
18228                System.Collections.Generic.SortedSet$1(T).ctor.call(this);
18229                this.comparer = null;
18230            }
18231        },
18232        methods: {
18233            AddIfNotPresent: function (item) {
18234
18235                if (!this.IsWithinRange(item)) {
18236                    System.ThrowHelper.ThrowArgumentOutOfRangeException$1(System.ExceptionArgument.collection);
18237                }
18238
18239                var ret = this.underlying.AddIfNotPresent(item);
18240                this.VersionCheck();
18241
18242                return ret;
18243            },
18244            contains: function (item) {
18245                this.VersionCheck();
18246                return System.Collections.Generic.SortedSet$1(T).prototype.contains.call(this, item);
18247            },
18248            DoRemove: function (item) {
18249
18250                if (!this.IsWithinRange(item)) {
18251                    return false;
18252                }
18253
18254                var ret = this.underlying.remove(item);
18255                this.VersionCheck();
18256                return ret;
18257            },
18258            clear: function () {
18259
18260
18261                if (this.count === 0) {
18262                    return;
18263                }
18264
18265                var toRemove = new (System.Collections.Generic.List$1(T)).ctor();
18266                this.BreadthFirstTreeWalk(function (n) {
18267                    toRemove.add(n.Item);
18268                    return true;
18269                });
18270                while (toRemove.Count !== 0) {
18271                    this.underlying.remove(toRemove.getItem(((toRemove.Count - 1) | 0)));
18272                    toRemove.removeAt(((toRemove.Count - 1) | 0));
18273                }
18274                this.root = null;
18275                this.count = 0;
18276                this.version = this.underlying.version;
18277            },
18278            IsWithinRange: function (item) {
18279                var $t, $t1;
18280
18281                var comp = (this.lBoundActive ? ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.min, item) : -1);
18282                if (comp > 0) {
18283                    return false;
18284                }
18285                comp = (this.uBoundActive ? ($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.max, item) : 1);
18286                if (comp < 0) {
18287                    return false;
18288                }
18289                return true;
18290            },
18291            InOrderTreeWalk$1: function (action, reverse) {
18292                var $t, $t1;
18293                this.VersionCheck();
18294
18295                if (this.root == null) {
18296                    return true;
18297                }
18298
18299                var stack = new (System.Collections.Generic.Stack$1(System.Collections.Generic.SortedSet$1.Node(T))).$ctor2(H5.Int.mul(2, System.Collections.Generic.SortedSet$1(T).log2(((this.count + 1) | 0))));
18300                var current = this.root;
18301                while (current != null) {
18302                    if (this.IsWithinRange(current.Item)) {
18303                        stack.Push(current);
18304                        current = (reverse ? current.Right : current.Left);
18305                    } else if (this.lBoundActive && ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.min, current.Item) > 0) {
18306                        current = current.Right;
18307                    } else {
18308                        current = current.Left;
18309                    }
18310                }
18311
18312                while (stack.Count !== 0) {
18313                    current = stack.Pop();
18314                    if (!action(current)) {
18315                        return false;
18316                    }
18317
18318                    var node = (reverse ? current.Left : current.Right);
18319                    while (node != null) {
18320                        if (this.IsWithinRange(node.Item)) {
18321                            stack.Push(node);
18322                            node = (reverse ? node.Right : node.Left);
18323                        } else if (this.lBoundActive && ($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.min, node.Item) > 0) {
18324                            node = node.Right;
18325                        } else {
18326                            node = node.Left;
18327                        }
18328                    }
18329                }
18330                return true;
18331            },
18332            BreadthFirstTreeWalk: function (action) {
18333                var $t, $t1;
18334                this.VersionCheck();
18335
18336                if (this.root == null) {
18337                    return true;
18338                }
18339
18340                var processQueue = new (System.Collections.Generic.List$1(System.Collections.Generic.SortedSet$1.Node(T))).ctor();
18341                processQueue.add(this.root);
18342                var current;
18343
18344                while (processQueue.Count !== 0) {
18345                    current = processQueue.getItem(0);
18346                    processQueue.removeAt(0);
18347                    if (this.IsWithinRange(current.Item) && !action(current)) {
18348                        return false;
18349                    }
18350                    if (current.Left != null && (!this.lBoundActive || ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.min, current.Item) < 0)) {
18351                        processQueue.add(current.Left);
18352                    }
18353                    if (current.Right != null && (!this.uBoundActive || ($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.max, current.Item) > 0)) {
18354                        processQueue.add(current.Right);
18355                    }
18356
18357                }
18358                return true;
18359            },
18360            FindNode: function (item) {
18361
18362                if (!this.IsWithinRange(item)) {
18363                    return null;
18364                }
18365                this.VersionCheck();
18366                return System.Collections.Generic.SortedSet$1(T).prototype.FindNode.call(this, item);
18367            },
18368            InternalIndexOf: function (item) {
18369                var $t, $t1;
18370                var count = -1;
18371                $t = H5.getEnumerator(this);
18372                try {
18373                    while ($t.moveNext()) {
18374                        var i = $t.Current;
18375                        count = (count + 1) | 0;
18376                        if (($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](item, i) === 0) {
18377                            return count;
18378                        }
18379                    }
18380                } finally {
18381                    if (H5.is($t, System.IDisposable)) {
18382                        $t.System$IDisposable$Dispose();
18383                    }
18384                }
18385                return -1;
18386            },
18387            VersionCheck: function () {
18388                this.VersionCheckImpl();
18389            },
18390            VersionCheckImpl: function () {
18391                if (this.version !== this.underlying.version) {
18392                    this.root = this.underlying.FindRange$1(this.min, this.max, this.lBoundActive, this.uBoundActive);
18393                    this.version = this.underlying.version;
18394                    this.count = 0;
18395                    this.InOrderTreeWalk(H5.fn.bind(this, $asm.$.System.Collections.Generic.SortedSet$1.TreeSubSet.f1));
18396                }
18397            },
18398            GetViewBetween: function (lowerValue, upperValue) {
18399                var $t, $t1;
18400
18401                if (this.lBoundActive && ($t = this.Comparer)[H5.geti($t, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.min, lowerValue) > 0) {
18402                    throw new System.ArgumentOutOfRangeException.$ctor1("lowerValue");
18403                }
18404                if (this.uBoundActive && ($t1 = this.Comparer)[H5.geti($t1, "System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare", "System$Collections$Generic$IComparer$1$compare")](this.max, upperValue) < 0) {
18405                    throw new System.ArgumentOutOfRangeException.$ctor1("upperValue");
18406                }
18407                var ret = H5.cast(this.underlying.GetViewBetween(lowerValue, upperValue), System.Collections.Generic.SortedSet$1.TreeSubSet(T));
18408                return ret;
18409            },
18410            IntersectWithEnumerable: function (other) {
18411                var $t;
18412
18413                var toSave = new (System.Collections.Generic.List$1(T)).$ctor2(this.Count);
18414                $t = H5.getEnumerator(other, T);
18415                try {
18416                    while ($t.moveNext()) {
18417                        var item = $t.Current;
18418                        if (this.contains(item)) {
18419                            toSave.add(item);
18420                            this.remove(item);
18421                        }
18422                    }
18423                } finally {
18424                    if (H5.is($t, System.IDisposable)) {
18425                        $t.System$IDisposable$Dispose();
18426                    }
18427                }
18428                this.clear();
18429                this.AddAllElements(toSave);
18430            }
18431        }
18432    }; });
18433
18434    H5.ns("System.Collections.Generic.SortedSet$1.TreeSubSet", $asm.$);
18435
18436    H5.apply($asm.$.System.Collections.Generic.SortedSet$1.TreeSubSet, {
18437        f1: function (n) {
18438            this.count = (this.count + 1) | 0;
18439            return true;
18440        }
18441    });
18442
18443    // @source LinkedList.js
18444
18445    H5.define("System.Collections.Generic.LinkedList$1", function (T) { return {
18446        inherits: [System.Collections.Generic.ICollection$1(T),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(T)],
18447        statics: {
18448            fields: {
18449                VersionName: null,
18450                CountName: null,
18451                ValuesName: null
18452            },
18453            ctors: {
18454                init: function () {
18455                    this.VersionName = "Version";
18456                    this.CountName = "Count";
18457                    this.ValuesName = "Data";
18458                }
18459            }
18460        },
18461        fields: {
18462            head: null,
18463            count: 0,
18464            version: 0
18465        },
18466        props: {
18467            Count: {
18468                get: function () {
18469                    return this.count;
18470                }
18471            },
18472            First: {
18473                get: function () {
18474                    return this.head;
18475                }
18476            },
18477            Last: {
18478                get: function () {
18479                    return this.head == null ? null : this.head.prev;
18480                }
18481            },
18482            System$Collections$Generic$ICollection$1$IsReadOnly: {
18483                get: function () {
18484                    return false;
18485                }
18486            },
18487            System$Collections$ICollection$IsSynchronized: {
18488                get: function () {
18489                    return false;
18490                }
18491            },
18492            System$Collections$ICollection$SyncRoot: {
18493                get: function () {
18494                    return null;
18495                }
18496            }
18497        },
18498        alias: [
18499            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
18500            "Count", "System$Collections$ICollection$Count",
18501            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
18502            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly",
18503            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
18504            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
18505            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
18506            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
18507            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator",
18508            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove"
18509        ],
18510        ctors: {
18511            ctor: function () {
18512                this.$initialize();
18513            },
18514            $ctor1: function (collection) {
18515                var $t;
18516                this.$initialize();
18517                if (collection == null) {
18518                    throw new System.ArgumentNullException.$ctor1("collection");
18519                }
18520
18521                $t = H5.getEnumerator(collection, T);
18522                try {
18523                    while ($t.moveNext()) {
18524                        var item = $t.Current;
18525                        this.AddLast(item);
18526                    }
18527                } finally {
18528                    if (H5.is($t, System.IDisposable)) {
18529                        $t.System$IDisposable$Dispose();
18530                    }
18531                }
18532            }
18533        },
18534        methods: {
18535            System$Collections$Generic$ICollection$1$add: function (value) {
18536                this.AddLast(value);
18537            },
18538            AddAfter: function (node, value) {
18539                this.ValidateNode(node);
18540                var result = new (System.Collections.Generic.LinkedListNode$1(T)).$ctor1(node.list, value);
18541                this.InternalInsertNodeBefore(node.next, result);
18542                return result;
18543            },
18544            AddAfter$1: function (node, newNode) {
18545                this.ValidateNode(node);
18546                this.ValidateNewNode(newNode);
18547                this.InternalInsertNodeBefore(node.next, newNode);
18548                newNode.list = this;
18549            },
18550            AddBefore: function (node, value) {
18551                this.ValidateNode(node);
18552                var result = new (System.Collections.Generic.LinkedListNode$1(T)).$ctor1(node.list, value);
18553                this.InternalInsertNodeBefore(node, result);
18554                if (H5.referenceEquals(node, this.head)) {
18555                    this.head = result;
18556                }
18557                return result;
18558            },
18559            AddBefore$1: function (node, newNode) {
18560                this.ValidateNode(node);
18561                this.ValidateNewNode(newNode);
18562                this.InternalInsertNodeBefore(node, newNode);
18563                newNode.list = this;
18564                if (H5.referenceEquals(node, this.head)) {
18565                    this.head = newNode;
18566                }
18567            },
18568            AddFirst: function (value) {
18569                var result = new (System.Collections.Generic.LinkedListNode$1(T)).$ctor1(this, value);
18570                if (this.head == null) {
18571                    this.InternalInsertNodeToEmptyList(result);
18572                } else {
18573                    this.InternalInsertNodeBefore(this.head, result);
18574                    this.head = result;
18575                }
18576                return result;
18577            },
18578            AddFirst$1: function (node) {
18579                this.ValidateNewNode(node);
18580
18581                if (this.head == null) {
18582                    this.InternalInsertNodeToEmptyList(node);
18583                } else {
18584                    this.InternalInsertNodeBefore(this.head, node);
18585                    this.head = node;
18586                }
18587                node.list = this;
18588            },
18589            AddLast: function (value) {
18590                var result = new (System.Collections.Generic.LinkedListNode$1(T)).$ctor1(this, value);
18591                if (this.head == null) {
18592                    this.InternalInsertNodeToEmptyList(result);
18593                } else {
18594                    this.InternalInsertNodeBefore(this.head, result);
18595                }
18596                return result;
18597            },
18598            AddLast$1: function (node) {
18599                this.ValidateNewNode(node);
18600
18601                if (this.head == null) {
18602                    this.InternalInsertNodeToEmptyList(node);
18603                } else {
18604                    this.InternalInsertNodeBefore(this.head, node);
18605                }
18606                node.list = this;
18607            },
18608            clear: function () {
18609                var current = this.head;
18610                while (current != null) {
18611                    var temp = current;
18612                    current = current.Next;
18613                    temp.Invalidate();
18614                }
18615
18616                this.head = null;
18617                this.count = 0;
18618                this.version = (this.version + 1) | 0;
18619            },
18620            contains: function (value) {
18621                return this.Find(value) != null;
18622            },
18623            copyTo: function (array, index) {
18624                if (array == null) {
18625                    throw new System.ArgumentNullException.$ctor1("array");
18626                }
18627
18628                if (index < 0 || index > array.length) {
18629                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
18630                }
18631
18632                if (((array.length - index) | 0) < this.Count) {
18633                    throw new System.ArgumentException.ctor();
18634                }
18635
18636                var node = this.head;
18637                if (node != null) {
18638                    do {
18639                        array[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), array)] = node.item;
18640                        node = node.next;
18641                    } while (!H5.referenceEquals(node, this.head));
18642                }
18643            },
18644            System$Collections$ICollection$copyTo: function (array, index) {
18645                if (array == null) {
18646                    throw new System.ArgumentNullException.$ctor1("array");
18647                }
18648
18649                if (System.Array.getRank(array) !== 1) {
18650                    throw new System.ArgumentException.ctor();
18651                }
18652
18653                if (System.Array.getLower(array, 0) !== 0) {
18654                    throw new System.ArgumentException.ctor();
18655                }
18656
18657                if (index < 0) {
18658                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
18659                }
18660
18661                if (((array.length - index) | 0) < this.Count) {
18662                    throw new System.ArgumentException.ctor();
18663                }
18664                var tArray;
18665                if (((tArray = H5.as(array, System.Array.type(T)))
18665) != null) {
18666                    this.copyTo(tArray, index);
18667                } else {
18668                    var targetType = (H5.getType(array).$elementType || null);
18669                    var sourceType = T;
18670                    if (!(H5.Reflection.isAssignableFrom(targetType, sourceType) || H5.Reflection.isAssignableFrom(sourceType, targetType))) {
18671                        throw new System.ArgumentException.ctor();
18672                    }
18673                    var objects;
18674                    if (!(((objects = H5.as(array, System.Array.type(System.Object)))) != null)) {
18675                        throw new System.ArgumentException.ctor();
18676                    }
18677                    var node = this.head;
18678                    try {
18679                        if (node != null) {
18680                            do {
18681                                objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = node.item;
18682                                node = node.next;
18683                            } while (!H5.referenceEquals(node, this.head));
18684                        }
18685                    } catch ($e1) {
18686                        $e1 = System.Exception.create($e1);
18687                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
18688                            throw new System.ArgumentException.ctor();
18689                        } else {
18690                            throw $e1;
18691                        }
18692                    }
18693                }
18694            },
18695            Find: function (value) {
18696                var node = this.head;
18697                var c = System.Collections.Generic.EqualityComparer$1(T).def;
18698                if (node != null) {
18699                    if (value != null) {
18700                        do {
18701                            if (c.equals2(node.item, value)) {
18702                                return node;
18703                            }
18704                            node = node.next;
18705                        } while (!H5.referenceEquals(node, this.head));
18706                    } else {
18707                        do {
18708                            if (node.item == null) {
18709                                return node;
18710                            }
18711                            node = node.next;
18712                        } while (!H5.referenceEquals(node, this.head));
18713                    }
18714                }
18715                return null;
18716            },
18717            FindLast: function (value) {
18718                if (this.head == null) {
18719                    return null;
18720                }
18721
18722                var last = this.head.prev;
18723                var node = last;
18724                var c = System.Collections.Generic.EqualityComparer$1(T).def;
18725                if (node != null) {
18726                    if (value != null) {
18727                        do {
18728                            if (c.equals2(node.item, value)) {
18729                                return node;
18730                            }
18731
18732                            node = node.prev;
18733                        } while (!H5.referenceEquals(node, last));
18734                    } else {
18735                        do {
18736                            if (node.item == null) {
18737                                return node;
18738                            }
18739                            node = node.prev;
18740                        } while (!H5.referenceEquals(node, last));
18741                    }
18742                }
18743                return null;
18744            },
18745            GetEnumerator: function () {
18746                return new (System.Collections.Generic.LinkedList$1.Enumerator(T)).$ctor1(this);
18747            },
18748            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
18749                return this.GetEnumerator().$clone();
18750            },
18751            System$Collections$IEnumerable$GetEnumerator: function () {
18752                return this.GetEnumerator().$clone();
18753            },
18754            remove: function (value) {
18755                var node = this.Find(value);
18756                if (node != null) {
18757                    this.InternalRemoveNode(node);
18758                    return true;
18759                }
18760                return false;
18761            },
18762            Remove: function (node) {
18763                this.ValidateNode(node);
18764                this.InternalRemoveNode(node);
18765            },
18766            RemoveFirst: function () {
18767                if (this.head == null) {
18768                    throw new System.InvalidOperationException.ctor();
18769                }
18770                this.InternalRemoveNode(this.head);
18771            },
18772            RemoveLast: function () {
18773                if (this.head == null) {
18774                    throw new System.InvalidOperationException.ctor();
18775                }
18776                this.InternalRemoveNode(this.head.prev);
18777            },
18778            InternalInsertNodeBefore: function (node, newNode) {
18779                newNode.next = node;
18780                newNode.prev = node.prev;
18781                node.prev.next = newNode;
18782                node.prev = newNode;
18783                this.version = (this.version + 1) | 0;
18784                this.count = (this.count + 1) | 0;
18785            },
18786            InternalInsertNodeToEmptyList: function (newNode) {
18787                newNode.next = newNode;
18788                newNode.prev = newNode;
18789                this.head = newNode;
18790                this.version = (this.version + 1) | 0;
18791                this.count = (this.count + 1) | 0;
18792            },
18793            InternalRemoveNode: function (node) {
18794                if (H5.referenceEquals(node.next, node)) {
18795                    this.head = null;
18796                } else {
18797                    node.next.prev = node.prev;
18798                    node.prev.next = node.next;
18799                    if (H5.referenceEquals(this.head, node)) {
18800                        this.head = node.next;
18801                    }
18802                }
18803                node.Invalidate();
18804                this.count = (this.count - 1) | 0;
18805                this.version = (this.version + 1) | 0;
18806            },
18807            ValidateNewNode: function (node) {
18808                if (node == null) {
18809                    throw new System.ArgumentNullException.$ctor1("node");
18810                }
18811
18812                if (node.list != null) {
18813                    throw new System.InvalidOperationException.ctor();
18814                }
18815            },
18816            ValidateNode: function (node) {
18817                if (node == null) {
18818                    throw new System.ArgumentNullException.$ctor1("node");
18819                }
18820
18821                if (!H5.referenceEquals(node.list, this)) {
18822                    throw new System.InvalidOperationException.ctor();
18823                }
18824            }
18825        }
18826    }; });
18827
18828    // @source LinkedListNode.js
18829
18830    H5.define("System.Collections.Generic.LinkedListNode$1", function (T) { return {
18831        fields: {
18832            list: null,
18833            next: null,
18834            prev: null,
18835            item: H5.getDefaultValue(T)
18836        },
18837        props: {
18838            List: {
18839                get: function () {
18840                    return this.list;
18841                }
18842            },
18843            Next: {
18844                get: function () {
18845                    return this.next == null || H5.referenceEquals(this.next, this.list.head) ? null : this.next;
18846                }
18847            },
18848            Previous: {
18849                get: function () {
18850                    return this.prev == null || H5.referenceEquals(this, this.list.head) ? null : this.prev;
18851                }
18852            },
18853            Value: {
18854                get: function () {
18855                    return this.item;
18856                },
18857                set: function (value) {
18858                    this.item = value;
18859                }
18860            }
18861        },
18862        ctors: {
18863            ctor: function (value) {
18864                this.$initialize();
18865                this.item = value;
18866            },
18867            $ctor1: function (list, value) {
18868                this.$initialize();
18869                this.list = list;
18870                this.item = value;
18871            }
18872        },
18873        methods: {
18874            Invalidate: function () {
18875                this.list = null;
18876                this.next = null;
18877                this.prev = null;
18878            }
18879        }
18880    }; });
18881
18882    // @source Enumerator.js
18883
18884    H5.define("System.Collections.Generic.LinkedList$1.Enumerator", function (T) { return {
18885        inherits: [System.Collections.Generic.IEnumerator$1(T),System.Collections.IEnumerator],
18886        $kind: "nested struct",
18887        statics: {
18888            fields: {
18889                LinkedListName: null,
18890                CurrentValueName: null,
18891                VersionName: null,
18892                IndexName: null
18893            },
18894            ctors: {
18895                init: function () {
18896                    this.LinkedListName = "LinkedList";
18897                    this.CurrentValueName = "Current";
18898                    this.VersionName = "Version";
18899                    this.IndexName = "Index";
18900                }
18901            },
18902            methods: {
18903                getDefaultValue: function () { return new (System.Collections.Generic.LinkedList$1.Enumerator(T))(); }
18904            }
18905        },
18906        fields: {
18907            list: null,
18908            node: null,
18909            version: 0,
18910            current: H5.getDefaultValue(T),
18911            index: 0
18912        },
18913        props: {
18914            Current: {
18915                get: function () {
18916                    return this.current;
18917                }
18918            },
18919            System$Collections$IEnumerator$Current: {
18920                get: function () {
18921                    if (this.index === 0 || (this.index === ((this.list.Count + 1) | 0))) {
18922                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
18923                    }
18924
18925                    return this.current;
18926                }
18927            }
18928        },
18929        alias: [
18930            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"],
18931            "moveNext", "System$Collections$IEnumerator$moveNext",
18932            "Dispose", "System$IDisposable$Dispose"
18933        ],
18934        ctors: {
18935            $ctor1: function (list) {
18936                this.$initialize();
18937                this.list = list;
18938                this.version = list.version;
18939                this.node = list.head;
18940                this.current = H5.getDefaultValue(T);
18941                this.index = 0;
18942            },
18943            ctor: function () {
18944                this.$initialize();
18945            }
18946        },
18947        methods: {
18948            moveNext: function () {
18949                if (this.version !== this.list.version) {
18950                    throw new System.InvalidOperationException.ctor();
18951                }
18952
18953                if (this.node == null) {
18954                    this.index = (this.list.Count + 1) | 0;
18955                    return false;
18956                }
18957
18958                this.index = (this.index + 1) | 0;
18959                this.current = this.node.item;
18960                this.node = this.node.next;
18961                if (H5.referenceEquals(this.node, this.list.head)) {
18962                    this.node = null;
18963                }
18964                return true;
18965            },
18966            System$Collections$IEnumerator$reset: function () {
18967                if (this.version !== this.list.version) {
18968                    throw new System.InvalidOperationException.ctor();
18969                }
18970
18971                this.current = H5.getDefaultValue(T);
18972                this.node = this.list.head;
18973                this.index = 0;
18974            },
18975            Dispose: function () { },
18976            getHashCode: function () {
18977                var h = H5.addHash([3788985113, this.list, this.node, this.version, this.current, this.index]);
18978                return h;
18979            },
18980            equals: function (o) {
18981                if (!H5.is(o, System.Collections.Generic.LinkedList$1.Enumerator(T))) {
18982                    return false;
18983                }
18984                return H5.equals(this.list, o.list) && H5.equals(this.node, o.node) && H5.equals(this.version, o.version) && H5.equals(this.current, o.current) && H5.equals(this.index, o.index);
18985            },
18986            $clone: function (to) {
18987                var s = to || new (System.Collections.Generic.LinkedList$1.Enumerator(T))();
18988                s.list = this.list;
18989                s.node = this.node;
18990                s.version = this.version;
18991                s.current = this.current;
18992                s.index = this.index;
18993                return s;
18994            }
18995        }
18996    }; });
18997
18998    // @source TreeRotation.js
18999
19000    H5.define("System.Collections.Generic.TreeRotation", {
19001        $kind: "enum",
19002        statics: {
19003            fields: {
19004                LeftRotation: 1,
19005                RightRotation: 2,
19006                RightLeftRotation: 3,
19007                LeftRightRotation: 4
19008            }
19009        }
19010    });
19011
19012    // @source Dictionary.js
19013
19014    H5.define("System.Collections.Generic.Dictionary$2", function (TKey, TValue) { return {
19015        inherits: [System.Collections.Generic.IDictionary$2(TKey,TValue),System.Collections.IDictionary,System.Collections.Generic.IReadOnlyDictionary$2(TKey,TValue)],
19016        statics: {
19017            fields: {
19018                VersionName: null,
19019                HashSizeName: null,
19020                KeyValuePairsName: null,
19021                ComparerName: null
19022            },
19023            ctors: {
19024                init: function () {
19025                    this.VersionName = "Version";
19026                    this.HashSizeName = "HashSize";
19027                    this.KeyValuePairsName = "KeyValuePairs";
19028                    this.ComparerName = "Comparer";
19029                }
19030            },
19031            methods: {
19032                IsCompatibleKey: function (key) {
19033                    if (key == null) {
19034                        System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19035                    }
19036                    return (H5.is(key, TKey));
19037                }
19038            }
19039        },
19040        fields: {
19041            buckets: null,
19042            simpleBuckets: null,
19043            entries: null,
19044            count: 0,
19045            version: 0,
19046            freeList: 0,
19047            freeCount: 0,
19048            comparer: null,
19049            keys: null,
19050            values: null,
19051            isSimpleKey: false
19052        },
19053        props: {
19054            Comparer: {
19055                get: function () {
19056                    return this.comparer;
19057                }
19058            },
19059            Count: {
19060                get: function () {
19061                    return ((this.count - this.freeCount) | 0);
19062                }
19063            },
19064            Keys: {
19065                get: function () {
19066                    if (this.keys == null) {
19067                        this.keys = new (System.Collections.Generic.Dictionary$2.KeyCollection(TKey,TValue))(this);
19068                    }
19069                    return this.keys;
19070                }
19071            },
19072            System$Collections$Generic$IDictionary$2$Keys: {
19073                get: function () {
19074                    if (this.keys == null) {
19075                        this.keys = new (System.Collections.Generic.Dictionary$2.KeyCollection(TKey,TValue))(this);
19076                    }
19077                    return this.keys;
19078                }
19079            },
19080            System$Collections$Generic$IReadOnlyDictionary$2$Keys: {
19081                get: function () {
19082                    if (this.keys == null) {
19083                        this.keys = new (System.Collections.Generic.Dictionary$2.KeyCollection(TKey,TValue))(this);
19084                    }
19085                    return this.keys;
19086                }
19087            },
19088            Values: {
19089                get: function () {
19090                    if (this.values == null) {
19091                        this.values = new (System.Collections.Generic.Dictionary$2.ValueCollection(TKey,TValue))(this);
19092                    }
19093                    return this.values;
19094                }
19095            },
19096            System$Collections$Generic$IDictionary$2$Values: {
19097                get: function () {
19098                    if (this.values == null) {
19099                        this.values = new (System.Collections.Generic.Dictionary$2.ValueCollection(TKey,TValue))(this);
19100                    }
19101                    return this.values;
19102                }
19103            },
19104            System$Collections$Generic$IReadOnlyDictionary$2$Values: {
19105                get: function () {
19106                    if (this.values == null) {
19107                        this.values = new (System.Collections.Generic.Dictionary$2.ValueCollection(TKey,TValue))(this);
19108                    }
19109                    return this.values;
19110                }
19111            },
19112            System$Collections$Generic$ICollection$1$IsReadOnly: {
19113                get: function () {
19114                    return false;
19115                }
19116            },
19117            System$Collections$ICollection$IsSynchronized: {
19118                get: function () {
19119                    return false;
19120                }
19121            },
19122            System$Collections$ICollection$SyncRoot: {
19123                get: function () {
19124                    return null;
19125                }
19126            },
19127            System$Collections$IDictionary$IsFixedSize: {
19128                get: function () {
19129                    return false;
19130                }
19131            },
19132            System$Collections$IDictionary$IsReadOnly: {
19133                get: function () {
19134                    return false;
19135                }
19136            },
19137            System$Collections$IDictionary$Keys: {
19138                get: function () {
19139                    return H5.cast(this.Keys, System.Collections.ICollection);
19140                }
19141            },
19142            System$Collections$IDictionary$Values: {
19143                get: function () {
19144                    return H5.cast(this.Values, System.Collections.ICollection);
19145                }
19146            }
19147        },
19148        alias: [
19149            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
19150            "Count", "System$Collections$ICollection$Count",
19151            "Count", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count",
19152            "System$Collections$Generic$IDictionary$2$Keys", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
19153            "System$Collections$Generic$IReadOnlyDictionary$2$Keys", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
19154            "System$Collections$Generic$IDictionary$2$Values", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values",
19155            "System$Collections$Generic$IReadOnlyDictionary$2$Values", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values",
19156            "getItem", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
19157            "setItem", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$setItem",
19158            "getItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
19159            "setItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$setItem",
19160            "add", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
19161            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
19162            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$contains",
19163            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove",
19164            "clear", "System$Collections$IDictionary$clear",
19165            "clear", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$clear",
19166            "containsKey", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
19167            "containsKey", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
19168            "System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$GetEnumerator", "System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$GetEnumerator",
19169            "remove", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove",
19170            "tryGetValue", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
19171            "tryGetValue", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
19172            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$IsReadOnly", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
19173            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$copyTo"
19174        ],
19175        ctors: {
19176            ctor: function () {
19177                System.Collections.Generic.Dictionary$2(TKey,TValue).$ctor5.call(this, 0, null);
19178            },
19179            $ctor4: function (capacity) {
19180                System.Collections.Generic.Dictionary$2(TKey,TValue).$ctor5.call(this, capacity, null);
19181            },
19182            $ctor3: function (comparer) {
19183                System.Collections.Generic.Dictionary$2(TKey,TValue).$ctor5.call(this, 0, comparer);
19184            },
19185            $ctor5: function (capacity, comparer) {
19186                this.$initialize();
19187                if (capacity < 0) {
19188                    System.ThrowHelper.ThrowArgumentOutOfRangeException$1(System.ExceptionArgument.capacity);
19189                }
19190                if (capacity > 0) {
19191                    this.Initialize(capacity);
19192                }
19193                this.comparer = comparer || System.Collections.Generic.EqualityComparer$1(TKey).def;
19194
19195                this.isSimpleKey = ((H5.referenceEquals(TKey, System.String)) || (TKey.$number === true && !H5.referenceEquals(TKey, System.Int64) && !H5.referenceEquals(TKey, System.UInt64)) || (H5.referenceEquals(TKey, System.Char))) && (H5.referenceEquals(this.comparer, System.Collections.Generic.EqualityComparer$1(TKey).def));
19196            },
19197            $ctor1: function (dictionary) {
19198                System.Collections.Generic.Dictionary$2(TKey,TValue).$ctor2.call(this, dictionary, null);
19199            },
19200            $ctor2: function (dictionary, comparer) {
19201                var $t;
19202                System.Collections.Generic.Dictionary$2(TKey,TValue).$ctor5.call(this, dictionary != null ? System.Array.getCount(dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue)) : 0, comparer);
19203
19204                if (dictionary == null) {
19205                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.dictionary);
19206                }
19207
19208                $t = H5.getEnumerator(dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
19209                try {
19210                    while ($t.moveNext()) {
19211                        var pair = $t.Current;
19212                        this.add(pair.key, pair.value);
19213                    }
19214                } finally {
19215                    if (H5.is($t, System.IDisposable)) {
19216                        $t.System$IDisposable$Dispose();
19217                    }
19218                }
19219            }
19220        },
19221        methods: {
19222            getItem: function (key) {
19223                var i = this.FindEntry(key);
19224                if (i >= 0) {
19225                    return this.entries[System.Array.index(i, this.entries)].value;
19226                }
19227                throw new System.Collections.Generic.KeyNotFoundException.ctor();
19228            },
19229            setItem: function (key, value) {
19230                this.Insert(key, value, false);
19231            },
19232            System$Collections$IDictionary$getItem: function (key) {
19233                if (System.Collections.Generic.Dictionary$2(TKey,TValue).IsCompatibleKey(key)) {
19234                    var i = this.FindEntry(H5.cast(H5.unbox(key, TKey), TKey));
19235                    if (i >= 0) {
19236                        return this.entries[System.Array.index(i, this.entries)].value;
19237                    }
19238                }
19239                return null;
19240            },
19241            System$Collections$IDictionary$setItem: function (key, value) {
19242                if (key == null) {
19243                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19244                }
19245                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(TValue, value, System.ExceptionArgument.value);
19246
19247                try {
19248                    var tempKey = H5.cast(H5.unbox(key, TKey), TKey);
19249                    try {
19250                        this.setItem(tempKey, H5.cast(H5.unbox(value, TValue), TValue));
19251                    } catch ($e1) {
19252                        $e1 = System.Exception.create($e1);
19253                        if (H5.is($e1, System.InvalidCastException)) {
19254                            System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, TValue);
19255                        } else {
19256                            throw $e1;
19257                        }
19258                    }
19259                } catch ($e2) {
19260                    $e2 = System.Exception.create($e2);
19261                    if (H5.is($e2, System.InvalidCastException)) {
19262                        System.ThrowHelper.ThrowWrongKeyTypeArgumentException(System.Object, key, TKey);
19263                    } else {
19264                        throw $e2;
19265                    }
19266                }
19267            },
19268            add: function (key, value) {
19269                this.Insert(key, value, true);
19270            },
19271            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add: function (keyValuePair) {
19272                this.add(keyValuePair.key, keyValuePair.value);
19273            },
19274            System$Collections$IDictionary$add: function (key, value) {
19275                if (key == null) {
19276                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19277                }
19278                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(TValue, value, System.ExceptionArgument.value);
19279
19280                try {
19281                    var tempKey = H5.cast(H5.unbox(key, TKey), TKey);
19282
19283                    try {
19284                        this.add(tempKey, H5.cast(H5.unbox(value, TValue), TValue));
19285                    } catch ($e1) {
19286                        $e1 = System.Exception.create($e1);
19287                        if (H5.is($e1, System.InvalidCastException)) {
19288                            System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, TValue);
19289                        } else {
19290                            throw $e1;
19291                        }
19292                    }
19293                } catch ($e2) {
19294                    $e2 = System.Exception.create($e2);
19295                    if (H5.is($e2, System.InvalidCastException)) {
19296                        System.ThrowHelper.ThrowWrongKeyTypeArgumentException(System.Object, key, TKey);
19297                    } else {
19298                        throw $e2;
19299                    }
19300                }
19301            },
19302            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains: function (keyValuePair) {
19303                var i = this.FindEntry(keyValuePair.key);
19304                if (i >= 0 && System.Collections.Generic.EqualityComparer$1(TValue).def.equals2(this.entries[System.Array.index(i, this.entries)].value, keyValuePair.value)) {
19305                    return true;
19306                }
19307                return false;
19308            },
19309            System$Collections$IDictionary$contains: function (key) {
19310                if (System.Collections.Generic.Dictionary$2(TKey,TValue).IsCompatibleKey(key)) {
19311                    return this.containsKey(H5.cast(H5.unbox(key, TKey), TKey));
19312                }
19313
19314                return false;
19315            },
19316            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove: function (keyValuePair) {
19317                var i = this.FindEntry(keyValuePair.key);
19318                if (i >= 0 && System.Collections.Generic.EqualityComparer$1(TValue).def.equals2(this.entries[System.Array.index(i, this.entries)].value, keyValuePair.value)) {
19319                    this.remove(keyValuePair.key);
19320                    return true;
19321                }
19322                return false;
19323            },
19324            remove: function (key) {
19325                if (key == null) {
19326                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19327                }
19328
19329                if (this.isSimpleKey) {
19330                    if (this.simpleBuckets != null) {
19331                        if (this.simpleBuckets.hasOwnProperty(key)) {
19332                            var i = this.simpleBuckets[key];
19333                            delete this.simpleBuckets[key];
19334                            this.entries[System.Array.index(i, this.entries)].hashCode = -1;
19335                            this.entries[System.Array.index(i, this.entries)].next = this.freeList;
19336                            this.entries[System.Array.index(i, this.entries)].key = H5.getDefaultValue(TKey);
19337                            this.entries[System.Array.index(i, this.entries)].value = H5.getDefaultValue(TValue);
19338                            this.freeList = i;
19339                            this.freeCount = (this.freeCount + 1) | 0;
19340                            this.version = (this.version + 1) | 0;
19341                            return true;
19342                        }
19343                    }
19344                } else if (this.buckets != null) {
19345                    var hashCode = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](key) & 2147483647;
19346                    var bucket = hashCode % this.buckets.length;
19347                    var last = -1;
19348                    for (var i1 = this.buckets[System.Array.index(bucket, this.buckets)]; i1 >= 0; last = i1, i1 = this.entries[System.Array.index(i1, this.entries)].next) {
19349                        if (this.entries[System.Array.index(i1, this.entries)].hashCode === hashCode && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this.entries[System.Array.index(i1, this.entries)].key, key)) {
19350                            if (last < 0) {
19351                                this.buckets[System.Array.index(bucket, this.buckets)] = this.entries[System.Array.index(i1, this.entries)].next;
19352                            } else {
19353                                this.entries[System.Array.index(last, this.entries)].next = this.entries[System.Array.index(i1, this.entries)].next;
19354                            }
19355                            this.entries[System.Array.index(i1, this.entries)].hashCode = -1;
19356                            this.entries[System.Array.index(i1, this.entries)].next = this.freeList;
19357                            this.entries[System.Array.index(i1, this.entries)].key = H5.getDefaultValue(TKey);
19358                            this.entries[System.Array.index(i1, this.entries)].value = H5.getDefaultValue(TValue);
19359                            this.freeList = i1;
19360                            this.freeCount = (this.freeCount + 1) | 0;
19361                            this.version = (this.version + 1) | 0;
19362                            return true;
19363                        }
19364                    }
19365                }
19366                return false;
19367            },
19368            System$Collections$IDictionary$remove: function (key) {
19369                if (System.Collections.Generic.Dictionary$2(TKey,TValue).IsCompatibleKey(key)) {
19370                    this.remove(H5.cast(H5.unbox(key, TKey), TKey));
19371                }
19372            },
19373            clear: function () {
19374                if (this.count > 0) {
19375                    for (var i = 0; i < this.buckets.length; i = (i + 1) | 0) {
19376                        this.buckets[System.Array.index(i, this.buckets)] = -1;
19377                    }
19378                    if (this.isSimpleKey) {
19379                        this.simpleBuckets = { };
19380                    }
19381                    System.Array.fill(this.entries, function () {
19382                        return H5.getDefaultValue(System.Collections.Generic.Dictionary$2.Entry(TKey,TValue));
19383                    }, 0, this.count);
19384                    this.freeList = -1;
19385                    this.count = 0;
19386                    this.freeCount = 0;
19387                    this.version = (this.version + 1) | 0;
19388                }
19389            },
19390            containsKey: function (key) {
19391                return this.FindEntry(key) >= 0;
19392            },
19393            ContainsValue: function (value) {
19394                if (value == null) {
19395                    for (var i = 0; i < this.count; i = (i + 1) | 0) {
19396                        if (this.entries[System.Array.index(i, this.entries)].hashCode >= 0 && this.entries[System.Array.index(i, this.entries)].value == null) {
19397                            return true;
19398                        }
19399                    }
19400                } else {
19401                    var c = System.Collections.Generic.EqualityComparer$1(TValue).def;
19402                    for (var i1 = 0; i1 < this.count; i1 = (i1 + 1) | 0) {
19403                        if (this.entries[System.Array.index(i1, this.entries)].hashCode >= 0 && c.equals2(this.entries[System.Array.index(i1, this.entries)].value, value)) {
19404                            return true;
19405                        }
19406                    }
19407                }
19408                return false;
19409            },
19410            CopyTo: function (array, index) {
19411                if (array == null) {
19412                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
19413                }
19414
19415                if (index < 0 || index > array.length) {
19416                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
19417                }
19418
19419                if (((array.length - index) | 0) < this.Count) {
19420                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
19421                }
19422
19423                var count = this.count;
19424                var entries = this.entries;
19425                for (var i = 0; i < count; i = (i + 1) | 0) {
19426                    if (entries[System.Array.index(i, entries)].hashCode >= 0) {
19427                        array[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), array)] = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(entries[System.Array.index(i, entries)].key, entries[System.Array.index(i, entries)].value);
19428                    }
19429                }
19430            },
19431            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo: function (array, index) {
19432                this.CopyTo(array, index);
19433            },
19434            System$Collections$ICollection$copyTo: function (array, index) {
19435                if (array == null) {
19436                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
19437                }
19438
19439                if (System.Array.getRank(array) !== 1) {
19440                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
19441                }
19442
19443                if (System.Array.getLower(array, 0) !== 0) {
19444                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
19445                }
19446
19447                if (index < 0 || index > array.length) {
19448                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
19449                }
19450
19451                if (((array.length - index) | 0) < this.Count) {
19452                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
19453                }
19454                var pairs;
19455                if (((pairs = H5.as(array, System.Array.type(System.Collections.Generic.KeyValuePair$2(TKey,TValue))))) != null) {
19456                    this.CopyTo(pairs, index);
19457                } else if (H5.is(array, System.Array.type(System.Collections.DictionaryEntry))) {
19458                    var dictEntryArray = H5.as(array, System.Array.type(System.Collections.DictionaryEntry));
19459                    var entries = this.entries;
19460                    for (var i = 0; i < this.count; i = (i + 1) | 0) {
19461                        if (entries[System.Array.index(i, entries)].hashCode >= 0) {
19462                            dictEntryArray[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), dictEntryArray)] = new System.Collections.DictionaryEntry.$ctor1(entries[System.Array.index(i, entries)].key, entries[System.Array.index(i, entries)].value);
19463                        }
19464                    }
19465                } else {
19466                    var objects = H5.as(array, System.Array.type(System.Object));
19467                    if (objects == null) {
19468                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
19469                    }
19470
19471                    try {
19472                        var count = this.count;
19473                        var entries1 = this.entries;
19474                        for (var i1 = 0; i1 < count; i1 = (i1 + 1) | 0) {
19475                            if (entries1[System.Array.index(i1, entries1)].hashCode >= 0) {
19476                                objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(entries1[System.Array.index(i1, entries1)].key, entries1[System.Array.index(i1, entries1)].value);
19477                            }
19478                        }
19479                    } catch ($e1) {
19480                        $e1 = System.Exception.create($e1);
19481                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
19482                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
19483                        } else {
19484                            throw $e1;
19485                        }
19486                    }
19487                }
19488            },
19489            GetEnumerator: function () {
19490                return new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue).KeyValuePair);
19491            },
19492            System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$GetEnumerator: function () {
19493                return new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue).KeyValuePair).$clone();
19494            },
19495            System$Collections$IEnumerable$GetEnumerator: function () {
19496                return new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue).KeyValuePair).$clone();
19497            },
19498            System$Collections$IDictionary$GetEnumerator: function () {
19499                return new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue)).$ctor1(this, System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue).DictEntry
19499).$clone();
19500            },
19501            FindEntry: function (key) {
19502                if (key == null) {
19503                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19504                }
19505
19506                if (this.isSimpleKey) {
19507                    if (this.simpleBuckets != null && this.simpleBuckets.hasOwnProperty(key)) {
19508                        return this.simpleBuckets[key];
19509                    }
19510                } else if (this.buckets != null) {
19511                    var hashCode = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](key) & 2147483647;
19512                    for (var i = this.buckets[System.Array.index(hashCode % this.buckets.length, this.buckets)]; i >= 0; i = this.entries[System.Array.index(i, this.entries)].next) {
19513                        if (this.entries[System.Array.index(i, this.entries)].hashCode === hashCode && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this.entries[System.Array.index(i, this.entries)].key, key)) {
19514                            return i;
19515                        }
19516                    }
19517                }
19518                return -1;
19519            },
19520            Initialize: function (capacity) {
19521                var size = System.Collections.HashHelpers.GetPrime(capacity);
19522                this.buckets = System.Array.init(size, 0, System.Int32);
19523                for (var i = 0; i < this.buckets.length; i = (i + 1) | 0) {
19524                    this.buckets[System.Array.index(i, this.buckets)] = -1;
19525                }
19526                this.entries = System.Array.init(size, function (){
19527                    return new (System.Collections.Generic.Dictionary$2.Entry(TKey,TValue))();
19528                }, System.Collections.Generic.Dictionary$2.Entry(TKey,TValue));
19529                this.freeList = -1;
19530                this.simpleBuckets = { };
19531            },
19532            Insert: function (key, value, add) {
19533
19534                if (key == null) {
19535                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.key);
19536                }
19537
19538                if (this.buckets == null) {
19539                    this.Initialize(0);
19540                }
19541
19542                if (this.isSimpleKey) {
19543                    if (this.simpleBuckets.hasOwnProperty(key)) {
19544                        if (add) {
19545                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_AddingDuplicate);
19546                        }
19547
19548                        this.entries[System.Array.index(this.simpleBuckets[key], this.entries)].value = value;
19549                        this.version = (this.version + 1) | 0;
19550                        return;
19551                    }
19552
19553                    var simpleIndex;
19554                    if (this.freeCount > 0) {
19555                        simpleIndex = this.freeList;
19556                        this.freeList = this.entries[System.Array.index(simpleIndex, this.entries)].next;
19557                        this.freeCount = (this.freeCount - 1) | 0;
19558                    } else {
19559                        if (this.count === this.entries.length) {
19560                            this.Resize();
19561                        }
19562                        simpleIndex = this.count;
19563                        this.count = (this.count + 1) | 0;
19564                    }
19565
19566                    this.entries[System.Array.index(simpleIndex, this.entries)].hashCode = 1;
19567                    this.entries[System.Array.index(simpleIndex, this.entries)].next = -1;
19568                    this.entries[System.Array.index(simpleIndex, this.entries)].key = key;
19569                    this.entries[System.Array.index(simpleIndex, this.entries)].value = value;
19570
19571                    this.simpleBuckets[key] = simpleIndex;
19572                    this.version = (this.version + 1) | 0;
19573
19574                    return;
19575                }
19576
19577                var hashCode = this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](key) & 2147483647;
19578                var targetBucket = hashCode % this.buckets.length;
19579
19580                for (var i = this.buckets[System.Array.index(targetBucket, this.buckets)]; i >= 0; i = this.entries[System.Array.index(i, this.entries)].next) {
19581                    if (this.entries[System.Array.index(i, this.entries)].hashCode === hashCode && this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this.entries[System.Array.index(i, this.entries)].key, 
19581key)) {
19582                        if (add) {
19583                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_AddingDuplicate);
19584                        }
19585                        this.entries[System.Array.index(i, this.entries)].value = value;
19586                        this.version = (this.version + 1) | 0;
19587                        return;
19588                    }
19589                }
19590                var index;
19591                if (this.freeCount > 0) {
19592                    index = this.freeList;
19593                    this.freeList = this.entries[System.Array.index(index, this.entries)].next;
19594                    this.freeCount = (this.freeCount - 1) | 0;
19595                } else {
19596                    if (this.count === this.entries.length) {
19597                        this.Resize();
19598                        targetBucket = hashCode % this.buckets.length;
19599                    }
19600                    index = this.count;
19601                    this.count = (this.count + 1) | 0;
19602                }
19603
19604                this.entries[System.Array.index(index, this.entries)].hashCode = hashCode;
19605                this.entries[System.Array.index(index, this.entries)].next = this.buckets[System.Array.index(targetBucket, this.buckets)];
19606                this.entries[System.Array.index(index, this.entries)].key = key;
19607                this.entries[System.Array.index(index, this.entries)].value = value;
19608                this.buckets[System.Array.index(targetBucket, this.buckets)] = index;
19609                this.version = (this.version + 1) | 0;
19610            },
19611            Resize: function () {
19612                this.Resize$1(System.Collections.HashHelpers.ExpandPrime(this.count), false);
19613            },
19614            Resize$1: function (newSize, forceNewHashCodes) {
19615                var newBuckets = System.Array.init(newSize, 0, System.Int32);
19616                for (var i = 0; i < newBuckets.length; i = (i + 1) | 0) {
19617                    newBuckets[System.Array.index(i, newBuckets)] = -1;
19618                }
19619                if (this.isSimpleKey) {
19620                    this.simpleBuckets = { };
19621                }
19622                var newEntries = System.Array.init(newSize, function (){
19623                    return new (System.Collections.Generic.Dictionary$2.Entry(TKey,TValue))();
19624                }, System.Collections.Generic.Dictionary$2.Entry(TKey,TValue));
19625                System.Array.copy(this.entries, 0, newEntries, 0, this.count);
19626                if (forceNewHashCodes) {
19627                    for (var i1 = 0; i1 < this.count; i1 = (i1 + 1) | 0) {
19628                        if (newEntries[System.Array.index(i1, newEntries)].hashCode !== -1) {
19629                            newEntries[System.Array.index(i1, newEntries)].hashCode = (this.comparer[H5.geti(this.comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(TKey) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](newEntries[System.Array.index(i1, newEntries)].key) & 2147483647);
19630                        }
19631                    }
19632                }
19633                for (var i2 = 0; i2 < this.count; i2 = (i2 + 1) | 0) {
19634                    if (newEntries[System.Array.index(i2, newEntries)].hashCode >= 0) {
19635                        if (this.isSimpleKey) {
19636                            newEntries[System.Array.index(i2, newEntries)].next = -1;
19637                            this.simpleBuckets[newEntries[System.Array.index(i2, newEntries)].key] = i2;
19638                        } else {
19639                            var bucket = newEntries[System.Array.index(i2, newEntries)].hashCode % newSize;
19640                            newEntries[System.Array.index(i2, newEntries)].next = newBuckets[System.Array.index(bucket, newBuckets)];
19641                            newBuckets[System.Array.index(bucket, newBuckets)] = i2;
19642                        }
19643                    }
19644                }
19645                this.buckets = newBuckets;
19646                this.entries = newEntries;
19647            },
19648            tryGetValue: function (key, value) {
19649                var i = this.FindEntry(key);
19650                if (i >= 0) {
19651                    value.v = this.entries[System.Array.index(i, this.entries)].value;
19652                    return true;
19653                }
19654                value.v = H5.getDefaultValue(TValue);
19655                return false;
19656            },
19657            GetValueOrDefault: function (key) {
19658                var i = this.FindEntry(key);
19659                if (i >= 0) {
19660                    return this.entries[System.Array.index(i, this.entries)].value;
19661                }
19662                return H5.getDefaultValue(TValue);
19663            }
19664        }
19665    }; });
19666
19667    // @source Entry.js
19668
19669    H5.define("System.Collections.Generic.Dictionary$2.Entry", function (TKey, TValue) { return {
19670        $kind: "nested struct",
19671        statics: {
19672            methods: {
19673                getDefaultValue: function () { return new (System.Collections.Generic.Dictionary$2.Entry(TKey,TValue))(); }
19674            }
19675        },
19676        fields: {
19677            hashCode: 0,
19678            next: 0,
19679            key: H5.getDefaultValue(TKey),
19680            value: H5.getDefaultValue(TValue)
19681        },
19682        ctors: {
19683            ctor: function () {
19684                this.$initialize();
19685            }
19686        },
19687        methods: {
19688            getHashCode: function () {
19689                var h = H5.addHash([1920233150, this.hashCode, this.next, this.key, this.value]);
19690                return h;
19691            },
19692            equals: function (o) {
19693                if (!H5.is(o, System.Collections.Generic.Dictionary$2.Entry(TKey,TValue))) {
19694                    return false;
19695                }
19696                return H5.equals(this.hashCode, o.hashCode) && H5.equals(this.next, o.next) && H5.equals(this.key, o.key) && H5.equals(this.value, o.value);
19697            },
19698            $clone: function (to) {
19699                var s = to || new (System.Collections.Generic.Dictionary$2.Entry(TKey,TValue))();
19700                s.hashCode = this.hashCode;
19701                s.next = this.next;
19702                s.key = this.key;
19703                s.value = this.value;
19704                return s;
19705            }
19706        }
19707    }; });
19708
19709    // @source Enumerator.js
19710
19711    H5.define("System.Collections.Generic.Dictionary$2.Enumerator", function (TKey, TValue) { return {
19712        inherits: [System.Collections.Generic.IEnumerator$1(System.Collections.Generic.KeyValuePair$2(TKey,TValue)),System.Collections.IDictionaryEnumerator],
19713        $kind: "nested struct",
19714        statics: {
19715            fields: {
19716                DictEntry: 0,
19717                KeyValuePair: 0
19718            },
19719            ctors: {
19720                init: function () {
19721                    this.DictEntry = 1;
19722                    this.KeyValuePair = 2;
19723                }
19724            },
19725            methods: {
19726                getDefaultValue: function () { return new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue))(); }
19727            }
19728        },
19729        fields: {
19730            dictionary: null,
19731            version: 0,
19732            index: 0,
19733            current: null,
19734            getEnumeratorRetType: 0
19735        },
19736        props: {
19737            Current: {
19738                get: function () {
19739                    return this.current;
19740                }
19741            },
19742            System$Collections$IEnumerator$Current: {
19743                get: function () {
19744                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
19745                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
19746                    }
19747
19748                    if (this.getEnumeratorRetType === System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue).DictEntry) {
19749                        return new System.Collections.DictionaryEntry.$ctor1(this.current.key, this.current.value).$clone();
19750                    } else {
19751                        return new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(this.current.key, this.current.value);
19752                    }
19753                }
19754            },
19755            System$Collections$IDictionaryEnumerator$Entry: {
19756                get: function () {
19757                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
19758                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
19759                    }
19760
19761                    return new System.Collections.DictionaryEntry.$ctor1(this.current.key, this.current.value);
19762                }
19763            },
19764            System$Collections$IDictionaryEnumerator$Key: {
19765                get: function () {
19766                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
19767                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
19768                    }
19769
19770                    return this.current.key;
19771                }
19772            },
19773            System$Collections$IDictionaryEnumerator$Value: {
19774                get: function () {
19775                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
19776                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
19777                    }
19778
19779                    return this.current.value;
19780                }
19781            }
19782        },
19783        alias: [
19784            "moveNext", "System$Collections$IEnumerator$moveNext",
19785            "Current", ["System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"],
19786            "Dispose", "System$IDisposable$Dispose"
19787        ],
19788        ctors: {
19789            init: function () {
19790                this.current = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue))();
19791            },
19792            $ctor1: function (dictionary, getEnumeratorRetType) {
19793                this.$initialize();
19794                this.dictionary = dictionary;
19795                this.version = dictionary.version;
19796                this.index = 0;
19797                this.getEnumeratorRetType = getEnumeratorRetType;
19798                this.current = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).ctor();
19799            },
19800            ctor: function () {
19801                this.$initialize();
19802            }
19803        },
19804        methods: {
19805            moveNext: function () {
19806                var $t, $t1, $t2;
19807                if (this.version !== this.dictionary.version) {
19808                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
19809                }
19810
19811                while ((this.index >>> 0) < ((this.dictionary.count) >>> 0)) {
19812                    if (($t = this.dictionary.entries)[System.Array.index(this.index, $t)].hashCode >= 0) {
19813                        this.current = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(($t1 = this.dictionary.entries)[System.Array.index(this.index, $t1)].key, ($t2 = this.dictionary.entries)[System.Array.index(this.index, $t2)].value);
19814                        this.index = (this.index + 1) | 0;
19815                        return true;
19816                    }
19817                    this.index = (this.index + 1) | 0;
19818                }
19819
19820                this.index = (this.dictionary.count + 1) | 0;
19821                this.current = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).ctor();
19822                return false;
19823            },
19824            Dispose: function () { },
19825            System$Collections$IEnumerator$reset: function () {
19826                if (this.version !== this.dictionary.version) {
19827                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
19828                }
19829
19830                this.index = 0;
19831                this.current = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).ctor();
19832            },
19833            getHashCode: function () {
19834                var h = H5.addHash([3788985113, this.dictionary, this.version, this.index, this.current, this.getEnumeratorRetType]);
19835                return h;
19836            },
19837            equals: function (o) {
19838                if (!H5.is(o, System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue))) {
19839                    return false;
19840                }
19841                return H5.equals(this.dictionary, o.dictionary) && H5.equals(this.version, o.version) && H5.equals(this.index, o.index) && H5.equals(this.current, o.current) && H5.equals(this.getEnumeratorRetType, o.getEnumeratorRetType);
19842            },
19843            $clone: function (to) {
19844                var s = to || new (System.Collections.Generic.Dictionary$2.Enumerator(TKey,TValue))();
19845                s.dictionary = this.dictionary;
19846                s.version = this.version;
19847                s.index = this.index;
19848                s.current = this.current;
19849                s.getEnumeratorRetType = this.getEnumeratorRetType;
19850                return s;
19851            }
19852        }
19853    }; });
19854
19855    // @source KeyCollection.js
19856
19857    H5.define("System.Collections.Generic.Dictionary$2.KeyCollection", function (TKey, TValue) { return {
19858        inherits: [System.Collections.Generic.ICollection$1(TKey),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(TKey)],
19859        $kind: "nested class",
19860        fields: {
19861            dictionary: null
19862        },
19863        props: {
19864            Count: {
19865                get: function () {
19866                    return this.dictionary.Count;
19867                }
19868            },
19869            System$Collections$Generic$ICollection$1$IsReadOnly: {
19870                get: function () {
19871                    return true;
19872                }
19873            },
19874            System$Collections$ICollection$IsSynchronized: {
19875                get: function () {
19876                    return false;
19877                }
19878            },
19879            System$Collections$ICollection$SyncRoot: {
19880                get: function () {
19881                    return H5.cast(this.dictionary, System.Collections.ICollection).System$Collections$ICollection$SyncRoot;
19882                }
19883            }
19884        },
19885        alias: [
19886            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$copyTo",
19887            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(TKey) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
19888            "Count", "System$Collections$ICollection$Count",
19889            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$Count",
19890            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$IsReadOnly",
19891            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$add",
19892            "System$Collections$Generic$ICollection$1$clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$clear",
19893            "System$Collections$Generic$ICollection$1$contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$contains",
19894            "System$Collections$Generic$ICollection$1$remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$remove",
19895            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TKey) + "$GetEnumerator"
19896        ],
19897        ctors: {
19898            ctor: function (dictionary) {
19899                this.$initialize();
19900                if (dictionary == null) {
19901                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.dictionary);
19902                }
19903                this.dictionary = dictionary;
19904            }
19905        },
19906        methods: {
19907            GetEnumerator: function () {
19908                return new (System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary);
19909            },
19910            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
19911                return new (System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary).$clone();
19912            },
19913            System$Collections$IEnumerable$GetEnumerator: function () {
19914                return new (System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary).$clone();
19915            },
19916            copyTo: function (array, index) {
19917                if (array == null) {
19918                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
19919                }
19920
19921                if (index < 0 || index > array.length) {
19922                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.
19922ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
19923                }
19924
19925                if (((array.length - index) | 0) < this.dictionary.Count) {
19926                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
19927                }
19928
19929                var count = this.dictionary.count;
19930                var entries = this.dictionary.entries;
19931                for (var i = 0; i < count; i = (i + 1) | 0) {
19932                    if (entries[System.Array.index(i, entries)].hashCode >= 0) {
19933                        array[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), array)] = entries[System.Array.index(i, entries)].key;
19934                    }
19935                }
19936            },
19937            System$Collections$ICollection$copyTo: function (array, index) {
19938                if (array == null) {
19939                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
19940                }
19941
19942                if (System.Array.getRank(array) !== 1) {
19943                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
19944                }
19945
19946                if (System.Array.getLower(array, 0) !== 0) {
19947                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
19948                }
19949
19950                if (index < 0 || index > array.length) {
19951                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
19952                }
19953
19954                if (((array.length - index) | 0) < this.dictionary.Count) {
19955                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
19956                }
19957                var keys;
19958                if (((keys = H5.as(array, System.Array.type(TKey)))) != null) {
19959                    this.copyTo(keys, index);
19960                } else {
19961                    var objects = H5.as(array, System.Array.type(System.Object));
19962                    if (objects == null) {
19963                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
19964                    }
19965
19966                    var count = this.dictionary.count;
19967                    var entries = this.dictionary.entries;
19968                    try {
19969                        for (var i = 0; i < count; i = (i + 1) | 0) {
19970                            if (entries[System.Array.index(i, entries)].hashCode >= 0) {
19971                                objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = entries[System.Array.index(i, entries)].key;
19972                            }
19973                        }
19974                    } catch ($e1) {
19975                        $e1 = System.Exception.create($e1);
19976                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
19977                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
19978                        } else {
19979                            throw $e1;
19980                        }
19981                    }
19982                }
19983            },
19984            System$Collections$Generic$ICollection$1$add: function (item) {
19985                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_KeyCollectionSet);
19986            },
19987            System$Collections$Generic$ICollection$1$clear: function () {
19988                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_KeyCollectionSet);
19989            },
19990            System$Collections$Generic$ICollection$1$contains: function (item) {
19991                return this.dictionary.containsKey(item);
19992            },
19993            System$Collections$Generic$ICollection$1$remove: function (item) {
19994                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_KeyCollectionSet);
19995                return false;
19996            }
19997        }
19998    }; });
19999
20000    // @source Enumerator.js
20001
20002    H5.define("System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator", function (TKey, TValue) { return {
20003        inherits: [System.Collections.Generic.IEnumerator$1(TKey),System.Collections.IEnumerator],
20004        $kind: "nested struct",
20005        statics: {
20006            methods: {
20007                getDefaultValue: function () { return new (System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue))(); }
20008            }
20009        },
20010        fields: {
20011            dictionary: null,
20012            index: 0,
20013            version: 0,
20014            currentKey: H5.getDefaultValue(TKey)
20015        },
20016        props: {
20017            Current: {
20018                get: function () {
20019                    return this.currentKey;
20020                }
20021            },
20022            System$Collections$IEnumerator$Current: {
20023                get: function () {
20024                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
20025                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
20026                    }
20027
20028                    return this.currentKey;
20029                }
20030            }
20031        },
20032        alias: [
20033            "Dispose", "System$IDisposable$Dispose",
20034            "moveNext", "System$Collections$IEnumerator$moveNext",
20035            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(TKey) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
20036        ],
20037        ctors: {
20038            $ctor1: function (dictionary) {
20039                this.$initialize();
20040                this.dictionary = dictionary;
20041                this.version = dictionary.version;
20042                this.index = 0;
20043                this.currentKey = H5.getDefaultValue(TKey);
20044            },
20045            ctor: function () {
20046                this.$initialize();
20047            }
20048        },
20049        methods: {
20050            Dispose: function () { },
20051            moveNext: function () {
20052                var $t, $t1;
20053                if (this.version !== this.dictionary.version) {
20054                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
20055                }
20056
20057                while ((this.index >>> 0) < ((this.dictionary.count) >>> 0)) {
20058                    if (($t = this.dictionary.entries)[System.Array.index(this.index, $t)].hashCode >= 0) {
20059                        this.currentKey = ($t1 = this.dictionary.entries)[System.Array.index(this.index, $t1)].key;
20060                        this.index = (this.index + 1) | 0;
20061                        return true;
20062                    }
20063                    this.index = (this.index + 1) | 0;
20064                }
20065
20066                this.index = (this.dictionary.count + 1) | 0;
20067                this.currentKey = H5.getDefaultValue(TKey);
20068                return false;
20069            },
20070            System$Collections$IEnumerator$reset: function () {
20071                if (this.version !== this.dictionary.version) {
20072                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
20073                }
20074
20075                this.index = 0;
20076                this.currentKey = H5.getDefaultValue(TKey);
20077            },
20078            getHashCode: function () {
20079                var h = H5.addHash([3788985113, this.dictionary, this.index, this.version, this.currentKey]);
20080                return h;
20081            },
20082            equals: function (o) {
20083                if (!H5.is(o, System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue))) {
20084                    return false;
20085                }
20086                return H5.equals(this.dictionary, o.dictionary) && H5.equals(this.index, o.index) && H5.equals(this.version, o.version) && H5.equals(this.currentKey, o.currentKey);
20087            },
20088            $clone: function (to) {
20089                var s = to || new (System.Collections.Generic.Dictionary$2.KeyCollection.Enumerator(TKey,TValue))();
20090                s.dictionary = this.dictionary;
20091                s.index = this.index;
20092                s.version = this.version;
20093                s.currentKey = this.currentKey;
20094                return s;
20095            }
20096        }
20097    }; });
20098
20099    // @source ValueCollection.js
20100
20101    H5.define("System.Collections.Generic.Dictionary$2.ValueCollection", function (TKey, TValue) { return {
20102        inherits: [System.Collections.Generic.ICollection$1(TValue),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(TValue)],
20103        $kind: "nested class",
20104        fields: {
20105            dictionary: null
20106        },
20107        props: {
20108            Count: {
20109                get: function () {
20110                    return this.dictionary.Count;
20111                }
20112            },
20113            System$Collections$Generic$ICollection$1$IsReadOnly: {
20114                get: function () {
20115                    return true;
20116                }
20117            },
20118            System$Collections$ICollection$IsSynchronized: {
20119                get: function () {
20120                    return false;
20121                }
20122            },
20123            System$Collections$ICollection$SyncRoot: {
20124                get: function () {
20125                    return H5.cast(this.dictionary, System.Collections.ICollection).System$Collections$ICollection$SyncRoot;
20126                }
20127            }
20128        },
20129        alias: [
20130            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$copyTo",
20131            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(TValue) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
20132            "Count", "System$Collections$ICollection$Count",
20133            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$Count",
20134            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
20135            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$add",
20136            "System$Collections$Generic$ICollection$1$remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$remove",
20137            "System$Collections$Generic$ICollection$1$clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$clear",
20138            "System$Collections$Generic$ICollection$1$contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$contains",
20139            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TValue) + "$GetEnumerator"
20140        ],
20141        ctors: {
20142            ctor: function (dictionary) {
20143                this.$initialize();
20144                if (dictionary == null) {
20145                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.dictionary);
20146                }
20147                this.dictionary = dictionary;
20148            }
20149        },
20150        methods: {
20151            GetEnumerator: function () {
20152                return new (System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary);
20153            },
20154            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
20155                return new (System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary).$clone();
20156            },
20157            System$Collections$IEnumerable$GetEnumerator: function () {
20158                return new (System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue)).$ctor1(this.dictionary).$clone();
20159            },
20160            copyTo: function (array, index) {
20161                if (array == null) {
20162                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
20163                }
20164
20165                if (index < 0 || index > array.length) {
20166                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.
20166ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
20167                }
20168
20169                if (((array.length - index) | 0) < this.dictionary.Count) {
20170                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
20171                }
20172
20173                var count = this.dictionary.count;
20174                var entries = this.dictionary.entries;
20175                for (var i = 0; i < count; i = (i + 1) | 0) {
20176                    if (entries[System.Array.index(i, entries)].hashCode >= 0) {
20177                        array[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), array)] = entries[System.Array.index(i, entries)].value;
20178                    }
20179                }
20180            },
20181            System$Collections$ICollection$copyTo: function (array, index) {
20182                if (array == null) {
20183                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
20184                }
20185
20186                if (System.Array.getRank(array) !== 1) {
20187                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
20188                }
20189
20190                if (System.Array.getLower(array, 0) !== 0) {
20191                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
20192                }
20193
20194                if (index < 0 || index > array.length) {
20195                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
20196                }
20197
20198                if (((array.length - index) | 0) < this.dictionary.Count) {
20199                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
20200                }
20201                var values;
20202                if (((values = H5.as(array, System.Array.type(TValue)))) != null) {
20203                    this.copyTo(values, index);
20204                } else {
20205                    var objects = H5.as(array, System.Array.type(System.Object));
20206                    if (objects == null) {
20207                        System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
20208                    }
20209
20210                    var count = this.dictionary.count;
20211                    var entries = this.dictionary.entries;
20212                    try {
20213                        for (var i = 0; i < count; i = (i + 1) | 0) {
20214                            if (entries[System.Array.index(i, entries)].hashCode >= 0) {
20215                                objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = entries[System.Array.index(i, entries)].value;
20216                            }
20217                        }
20218                    } catch ($e1) {
20219                        $e1 = System.Exception.create($e1);
20220                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
20221                            System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
20222                        } else {
20223                            throw $e1;
20224                        }
20225                    }
20226                }
20227            },
20228            System$Collections$Generic$ICollection$1$add: function (item) {
20229                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ValueCollectionSet);
20230            },
20231            System$Collections$Generic$ICollection$1$remove: function (item) {
20232                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ValueCollectionSet);
20233                return false;
20234            },
20235            System$Collections$Generic$ICollection$1$clear: function () {
20236                System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ValueCollectionSet);
20237            },
20238            System$Collections$Generic$ICollection$1$contains: function (item) {
20239                return this.dictionary.ContainsValue(item);
20240            }
20241        }
20242    }; });
20243
20244    // @source Enumerator.js
20245
20246    H5.define("System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator", function (TKey, TValue) { return {
20247        inherits: [System.Collections.Generic.IEnumerator$1(TValue),System.Collections.IEnumerator],
20248        $kind: "nested struct",
20249        statics: {
20250            methods: {
20251                getDefaultValue: function () { return new (System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue))(); }
20252            }
20253        },
20254        fields: {
20255            dictionary: null,
20256            index: 0,
20257            version: 0,
20258            currentValue: H5.getDefaultValue(TValue)
20259        },
20260        props: {
20261            Current: {
20262                get: function () {
20263                    return this.currentValue;
20264                }
20265            },
20266            System$Collections$IEnumerator$Current: {
20267                get: function () {
20268                    if (this.index === 0 || (this.index === ((this.dictionary.count + 1) | 0))) {
20269                        System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
20270                    }
20271
20272                    return this.currentValue;
20273                }
20274            }
20275        },
20276        alias: [
20277            "Dispose", "System$IDisposable$Dispose",
20278            "moveNext", "System$Collections$IEnumerator$moveNext",
20279            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
20280        ],
20281        ctors: {
20282            $ctor1: function (dictionary) {
20283                this.$initialize();
20284                this.dictionary = dictionary;
20285                this.version = dictionary.version;
20286                this.index = 0;
20287                this.currentValue = H5.getDefaultValue(TValue);
20288            },
20289            ctor: function () {
20290                this.$initialize();
20291            }
20292        },
20293        methods: {
20294            Dispose: function () { },
20295            moveNext: function () {
20296                var $t, $t1;
20297                if (this.version !== this.dictionary.version) {
20298                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
20299                }
20300
20301                while ((this.index >>> 0) < ((this.dictionary.count) >>> 0)) {
20302                    if (($t = this.dictionary.entries)[System.Array.index(this.index, $t)].hashCode >= 0) {
20303                        this.currentValue = ($t1 = this.dictionary.entries)[System.Array.index(this.index, $t1)].value;
20304                        this.index = (this.index + 1) | 0;
20305                        return true;
20306                    }
20307                    this.index = (this.index + 1) | 0;
20308                }
20309                this.index = (this.dictionary.count + 1) | 0;
20310                this.currentValue = H5.getDefaultValue(TValue);
20311                return false;
20312            },
20313            System$Collections$IEnumerator$reset: function () {
20314                if (this.version !== this.dictionary.version) {
20315                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
20316                }
20317                this.index = 0;
20318                this.currentValue = H5.getDefaultValue(TValue);
20319            },
20320            getHashCode: function () {
20321                var h = H5.addHash([3788985113, this.dictionary, this.index, this.version, this.currentValue]);
20322                return h;
20323            },
20324            equals: function (o) {
20325                if (!H5.is(o, System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue))) {
20326                    return false;
20327                }
20328                return H5.equals(this.dictionary, o.dictionary) && H5.equals(this.index, o.index) && H5.equals(this.version, o.version) && H5.equals(this.currentValue, o.currentValue);
20329            },
20330            $clone: function (to) {
20331                var s = to || new (System.Collections.Generic.Dictionary$2.ValueCollection.Enumerator(TKey,TValue))();
20332                s.dictionary = this.dictionary;
20333                s.index = this.index;
20334                s.version = this.version;
20335                s.currentValue = this.currentValue;
20336                return s;
20337            }
20338        }
20339    }; });
20340
20341    // @source ReadOnlyDictionary.js
20342
20343    H5.define("System.Collections.ObjectModel.ReadOnlyDictionary$2", function (TKey, TValue) { return {
20344        inherits: [System.Collections.Generic.IDictionary$2(TKey,TValue),System.Collections.IDictionary,System.Collections.Generic.IReadOnlyDictionary$2(TKey,TValue)],
20345        statics: {
20346            fields: {
20347                NotSupported_ReadOnlyCollection: null
20348            },
20349            ctors: {
20350                init: function () {
20351                    this.NotSupported_ReadOnlyCollection = "Collection is read-only.";
20352                }
20353            },
20354            methods: {
20355                IsCompatibleKey: function (key) {
20356                    if (key == null) {
20357                        throw new System.ArgumentNullException.$ctor1("key");
20358                    }
20359                    return H5.is(key, TKey);
20360                }
20361            }
20362        },
20363        fields: {
20364            m_dictionary: null,
20365            _keys: null,
20366            _values: null
20367        },
20368        props: {
20369            Dictionary: {
20370                get: function () {
20371                    return this.m_dictionary;
20372                }
20373            },
20374            Keys: {
20375                get: function () {
20376                    if (this._keys == null) {
20377                        this._keys = new (System.Collections.ObjectModel.ReadOnlyDictionary$2.KeyCollection(TKey,TValue))(this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys"]);
20378                    }
20379                    return this._keys;
20380                }
20381            },
20382            Values: {
20383                get: function () {
20384                    if (this._values == null) {
20385                        this._values = new (System.Collections.ObjectModel.ReadOnlyDictionary$2.ValueCollection(TKey,TValue))(this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values"]);
20386                    }
20387                    return this._values;
20388                }
20389            },
20390            System$Collections$Generic$IDictionary$2$Keys: {
20391                get: function () {
20392                    return this.Keys;
20393                }
20394            },
20395            System$Collections$Generic$IDictionary$2$Values: {
20396                get: function () {
20397                    return this.Values;
20398                }
20399            },
20400            Count: {
20401                get: function () {
20402                    return System.Array.getCount(this.m_dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20403                }
20404            },
20405            System$Collections$Generic$ICollection$1$IsReadOnly: {
20406                get: function () {
20407                    return true;
20408                }
20409            },
20410            System$Collections$IDictionary$IsFixedSize: {
20411                get: function () {
20412                    return true;
20413                }
20414            },
20415            System$Collections$IDictionary$IsReadOnly: {
20416                get: function () {
20417                    return true;
20418                }
20419            },
20420            System$Collections$IDictionary$Keys: {
20421                get: function () {
20422                    return this.Keys;
20423                }
20424            },
20425            System$Collections$IDictionary$Values: {
20426                get: function () {
20427                    return this.Values;
20428                }
20429            },
20430            System$Collections$ICollection$IsSynchronized: {
20431                get: function () {
20432                    return false;
20433                }
20434            },
20435            System$Collections$ICollection$SyncRoot: {
20436                get: function () {
20437                    return null;
20438                }
20439            },
20440            System$Collections$Generic$IReadOnlyDictionary$2$Keys: {
20441                get: function () {
20442                    return this.Keys;
20443                }
20444            },
20445            System$Collections$Generic$IReadOnlyDictionary$2$Values: {
20446                get: function () {
20447                    return this.Values;
20448                }
20449            }
20450        },
20451        alias: [
20452            "containsKey", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
20453            "containsKey", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey",
20454            "System$Collections$Generic$IDictionary$2$Keys", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
20455            "tryGetValue", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
20456            "tryGetValue", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue",
20457            "System$Collections$Generic$IDictionary$2$Values", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values",
20458            "getItem", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
20459            "System$Collections$Generic$IDictionary$2$add", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
20460            "System$Collections$Generic$IDictionary$2$remove", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove",
20461            "System$Collections$Generic$IDictionary$2$getItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem",
20462            "System$Collections$Generic$IDictionary$2$setItem", "System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$setItem",
20463            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
20464            "Count", "System$Collections$ICollection$Count",
20465            "Count", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Count",
20466            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$contains",
20467            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$copyTo",
20468            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$IsReadOnly", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
20469            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add",
20470            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$clear", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$clear",
20471            "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove", "System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove",
20472            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"],
20473            "System$Collections$Generic$IReadOnlyDictionary$2$Keys", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Keys",
20474            "System$Collections$Generic$IReadOnlyDictionary$2$Values", "System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Values"
20475        ],
20476        ctors: {
20477            ctor: function (dictionary) {
20478                this.$initialize();
20479                if (dictionary == null) {
20480                    throw new System.ArgumentNullException.$ctor1("dictionary");
20481                }
20482                this.m_dictionary = dictionary;
20483            }
20484        },
20485        methods: {
20486            getItem: function (key) {
20487                return this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem"](key);
20488            },
20489            System$Collections$Generic$IDictionary$2$getItem: function (key) {
20490                return this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$getItem"](key);
20491            },
20492            System$Collections$Generic$IDictionary$2$setItem: function (key, value) {
20493                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20494            },
20495            System$Collections$IDictionary$getItem: function (key) {
20496                if (System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).IsCompatibleKey(key)) {
20497                    return this.getItem(H5.cast(H5.unbox(key, TKey), TKey));
20498                }
20499                return null;
20500            },
20501            System$Collections$IDictionary$setItem: function (key, value) {
20502                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20503            },
20504            containsKey: function (key) {
20505                return this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey"](key);
20506            },
20507            tryGetValue: function (key, value) {
20508                return this.m_dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue"](key, value);
20509            },
20510            System$Collections$Generic$IDictionary$2$add: function (key, value) {
20511                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20512            },
20513            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$add: function (item) {
20514                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20515            },
20516            System$Collections$IDictionary$add: function (key, value) {
20517                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20518            },
20519            System$Collections$Generic$IDictionary$2$remove: function (key) {
20520                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20521            },
20522            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$remove: function (item) {
20523                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20524            },
20525            System$Collections$IDictionary$remove: function (key) {
20526                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20527            },
20528            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$contains: function (item) {
20529                return System.Array.contains(this.m_dictionary, item, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20530            },
20531            System$Collections$IDictionary$contains: function (key) {
20532                return System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).IsCompatibleKey(key) && this.containsKey(H5.cast(H5.unbox(key, TKey), TKey));
20533            },
20534            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$copyTo: function (array, arrayIndex) {
20535                System.Array.copyTo(this.m_dictionary, array, arrayIndex, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20536            },
20537            System$Collections$ICollection$copyTo: function (array, index) {
20538                var $t, $t1;
20539                if (array == null) {
20540                    throw new System.ArgumentNullException.$ctor1("array");
20541                }
20542
20543                if (System.Array.getRank(array) !== 1) {
20544                    throw new System.ArgumentException.$ctor1("Only single dimensional arrays are supported for the requested action.");
20545                }
20546
20547                if (System.Array.getLower(array, 0) !== 0) {
20548                    throw new System.ArgumentException.$ctor1("The lower bound of target array must be zero.");
20549                }
20550
20551                if (index < 0 || index > array.length) {
20552                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "Non-negative number required.");
20553                }
20554
20555                if (((array.length - index) | 0) < this.Count) {
20556                    throw new System.ArgumentException.$ctor1("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
20557                }
20558                var pairs;
20559                if (((pairs = H5.as(array, System.Array.type(System.Collections.Generic.KeyValuePair$2(TKey,TValue))))) != null) {
20560                    System.Array.copyTo(this.m_dictionary, pairs, index, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20561                } else {
20562                    var dictEntryArray;
20563                    if (((dictEntryArray = H5.as(array, System.Array.type(System.Collections.DictionaryEntry)))) != null) {
20564                        $t = H5.getEnumerator(this.m_dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20565                        try {
20566                            while ($t.moveNext()) {
20567                                var item = $t.Current;
20568                                dictEntryArray[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), dictEntryArray)] = new System.Collections.DictionaryEntry.$ctor1(item.key, item.value);
20569                            }
20570                        } finally {
20571                            if (H5.is($t, System.IDisposable)) {
20572                                $t.System$IDisposable$Dispose();
20573                            }
20574                        }
20575                    } else {
20576                        var objects;
20577                        if (!(((objects = H5.as(array, System.Array.type(System.Object)))) != null)) {
20578                            throw new System.ArgumentException.$ctor1("Target array type is not compatible with the type of items in the collection.");
20579                        }
20580
20581                        try {
20582                            $t1 = H5.getEnumerator(this.m_dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20583                            try {
20584                                while ($t1.moveNext()) {
20585                                    var item1 = $t1.Current;
20586                                    objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = new (System.Collections.Generic.KeyValuePair$2(TKey,TValue)).$ctor1(item1.key, item1.value);
20587                                }
20588                            } finally {
20589                                if (H5.is($t1, System.IDisposable)) {
20590                                    $t1.System$IDisposable$Dispose();
20591                                }
20592                            }
20593                        } catch ($e1) {
20594                            $e1 = System.Exception.create($e1);
20595                            if (H5.is($e1, System.ArrayTypeMismatchException)) {
20596                                throw new System.ArgumentException.$ctor1("Target array type is not compatible with the type of items in the collection.");
20597                            } else {
20598                                throw $e1;
20599                            }
20600                        }
20601                    }
20602                }
20603            },
20604            System$Collections$Generic$ICollection$1$System$Collections$Generic$KeyValuePair$2$clear: function () {
20605                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20606            },
20607            System$Collections$IDictionary$clear: function () {
20608                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20609            },
20610            GetEnumerator: function () {
20611                return H5.getEnumerator(this.m_dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20612            },
20613            System$Collections$IEnumerable$GetEnumerator: function () {
20614                return H5.getEnumerator(H5.cast(this.m_dictionary, System.Collections.IEnumerable));
20615            },
20616            System$Collections$IDictionary$GetEnumerator: function () {
20617                var d;
20618                if (((d = H5.as(this.m_dictionary, System.Collections.IDictionary))) != null) {
20619                    return d.System$Collections$IDictionary$GetEnumerator();
20620                }
20621                return new (System.Collections.ObjectModel.ReadOnlyDictionary$2.DictionaryEnumerator(TKey,TValue)).$ctor1(this.m_dictionary).$clone();
20622            }
20623        }
20624    }; });
20625
20626    // @source DictionaryEnumerator.js
20627
20628    H5.define("System.Collections.ObjectModel.ReadOnlyDictionary$2.DictionaryEnumerator", function (TKey, TValue) { return {
20629        inherits: [System.Collections.IDictionaryEnumerator],
20630        $kind: "nested struct",
20631        statics: {
20632            methods: {
20633                getDefaultValue: function () { return new (System.Collections.ObjectModel.ReadOnlyDictionary$2.DictionaryEnumerator(TKey,TValue))(); }
20634            }
20635        },
20636        fields: {
20637            _dictionary: null,
20638            _enumerator: null
20639        },
20640        props: {
20641            Entry: {
20642                get: function () {
20643                    return new System.Collections.DictionaryEntry.$ctor1(this._enumerator[H5.geti(this._enumerator, "System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")].
20643key, this._enumerator[H5.geti(this._enumerator, "System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")].value);
20644                }
20645            },
20646            Key: {
20647                get: function () {
20648                    return this._enumerator[H5.geti(this._enumerator, "System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")].key;
20649                }
20650            },
20651            Value: {
20652                get: function () {
20653                    return this._enumerator[H5.geti(this._enumerator, "System$Collections$Generic$IEnumerator$1$System$Collections$Generic$KeyValuePair$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")].value;
20654                }
20655            },
20656            Current: {
20657                get: function () {
20658                    return this.Entry.$clone();
20659                }
20660            }
20661        },
20662        alias: [
20663            "Entry", "System$Collections$IDictionaryEnumerator$Entry",
20664            "Key", "System$Collections$IDictionaryEnumerator$Key",
20665            "Value", "System$Collections$IDictionaryEnumerator$Value",
20666            "Current", "System$Collections$IEnumerator$Current",
20667            "moveNext", "System$Collections$IEnumerator$moveNext",
20668            "reset", "System$Collections$IEnumerator$reset"
20669        ],
20670        ctors: {
20671            $ctor1: function (dictionary) {
20672                this.$initialize();
20673                this._dictionary = dictionary;
20674                this._enumerator = H5.getEnumerator(this._dictionary, System.Collections.Generic.KeyValuePair$2(TKey,TValue));
20675            },
20676            ctor: function () {
20677                this.$initialize();
20678            }
20679        },
20680        methods: {
20681            moveNext: function () {
20682                return this._enumerator.System$Collections$IEnumerator$moveNext();
20683            },
20684            reset: function () {
20685                this._enumerator.System$Collections$IEnumerator$reset();
20686            },
20687            getHashCode: function () {
20688                var h = H5.addHash([9276503029, this._dictionary, this._enumerator]);
20689                return h;
20690            },
20691            equals: function (o) {
20692                if (!H5.is(o, System.Collections.ObjectModel.ReadOnlyDictionary$2.DictionaryEnumerator(TKey,TValue))) {
20693                    return false;
20694                }
20695                return H5.equals(this._dictionary, o._dictionary) && H5.equals(this._enumerator, o._enumerator);
20696            },
20697            $clone: function (to) {
20698                var s = to || new (System.Collections.ObjectModel.ReadOnlyDictionary$2.DictionaryEnumerator(TKey,TValue))();
20699                s._dictionary = this._dictionary;
20700                s._enumerator = this._enumerator;
20701                return s;
20702            }
20703        }
20704    }; });
20705
20706    // @source KeyCollection.js
20707
20708    H5.define("System.Collections.ObjectModel.ReadOnlyDictionary$2.KeyCollection", function (TKey, TValue) { return {
20709        inherits: [System.Collections.Generic.ICollection$1(TKey),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(TKey)],
20710        $kind: "nested class",
20711        fields: {
20712            _collection: null
20713        },
20714        props: {
20715            Count: {
20716                get: function () {
20717                    return System.Array.getCount(this._collection, TKey);
20718                }
20719            },
20720            System$Collections$Generic$ICollection$1$IsReadOnly: {
20721                get: function () {
20722                    return true;
20723                }
20724            },
20725            System$Collections$ICollection$IsSynchronized: {
20726                get: function () {
20727                    return false;
20728                }
20729            },
20730            System$Collections$ICollection$SyncRoot: {
20731                get: function () {
20732                    return null;
20733                }
20734            }
20735        },
20736        alias: [
20737            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$add",
20738            "System$Collections$Generic$ICollection$1$clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$clear",
20739            "System$Collections$Generic$ICollection$1$contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$contains",
20740            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$copyTo",
20741            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(TKey) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
20742            "Count", "System$Collections$ICollection$Count",
20743            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$Count",
20744            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$IsReadOnly",
20745            "System$Collections$Generic$ICollection$1$remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TKey) + "$remove",
20746            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TKey) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"]
20747        ],
20748        ctors: {
20749            ctor: function (collection) {
20750                this.$initialize();
20751                if (collection == null) {
20752                    throw new System.ArgumentNullException.$ctor1("collection");
20753                }
20754                this._collection = collection;
20755            }
20756        },
20757        methods: {
20758            System$Collections$Generic$ICollection$1$add: function (item) {
20759                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20760            },
20761            System$Collections$Generic$ICollection$1$clear: function () {
20762                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20763            },
20764            System$Collections$Generic$ICollection$1$contains: function (item) {
20765                return System.Array.contains(this._collection, item, TKey);
20766            },
20767            copyTo: function (array, arrayIndex) {
20768                System.Array.copyTo(this._collection, array, arrayIndex, TKey);
20769            },
20770            System$Collections$ICollection$copyTo: function (array, index) {
20771                System.Collections.ObjectModel.ReadOnlyDictionaryHelpers.CopyToNonGenericICollectionHelper(TKey, this._collection, array, index);
20772            },
20773            System$Collections$Generic$ICollection$1$remove: function (item) {
20774                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20775            },
20776            GetEnumerator: function () {
20777                return H5.getEnumerator(this._collection, TKey);
20778            },
20779            System$Collections$IEnumerable$GetEnumerator: function () {
20780                return H5.getEnumerator(H5.cast(this._collection, System.Collections.IEnumerable));
20781            }
20782        }
20783    }; });
20784
20785    // @source ValueCollection.js
20786
20787    H5.define("System.Collections.ObjectModel.ReadOnlyDictionary$2.ValueCollection", function (TKey, TValue) { return {
20788        inherits: [System.Collections.Generic.ICollection$1(TValue),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(TValue)],
20789        $kind: "nested class",
20790        fields: {
20791            _collection: null
20792        },
20793        props: {
20794            Count: {
20795                get: function () {
20796                    return System.Array.getCount(this._collection, TValue);
20797                }
20798            },
20799            System$Collections$Generic$ICollection$1$IsReadOnly: {
20800                get: function () {
20801                    return true;
20802                }
20803            },
20804            System$Collections$ICollection$IsSynchronized: {
20805                get: function () {
20806                    return false;
20807                }
20808            },
20809            System$Collections$ICollection$SyncRoot: {
20810                get: function () {
20811                    return null;
20812                }
20813            }
20814        },
20815        alias: [
20816            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$add",
20817            "System$Collections$Generic$ICollection$1$clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$clear",
20818            "System$Collections$Generic$ICollection$1$contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$contains",
20819            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$copyTo",
20820            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(TValue) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
20821            "Count", "System$Collections$ICollection$Count",
20822            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$Count",
20823            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$IsReadOnly",
20824            "System$Collections$Generic$ICollection$1$remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(TValue) + "$remove",
20825            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TValue) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"]
20826        ],
20827        ctors: {
20828            ctor: function (collection) {
20829                this.$initialize();
20830                if (collection == null) {
20831                    throw new System.ArgumentNullException.$ctor1("collection");
20832                }
20833                this._collection = collection;
20834            }
20835        },
20836        methods: {
20837            System$Collections$Generic$ICollection$1$add: function (item) {
20838                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20839            },
20840            System$Collections$Generic$ICollection$1$clear: function () {
20841                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20842            },
20843            System$Collections$Generic$ICollection$1$contains: function (item) {
20844                return System.Array.contains(this._collection, item, TValue);
20845            },
20846            copyTo: function (array, arrayIndex) {
20847                System.Array.copyTo(this._collection, array, arrayIndex, TValue);
20848            },
20849            System$Collections$ICollection$copyTo: function (array, index) {
20850                System.Collections.ObjectModel.ReadOnlyDictionaryHelpers.CopyToNonGenericICollectionHelper(TValue, this._collection, array, index);
20851            },
20852            System$Collections$Generic$ICollection$1$remove: function (item) {
20853                throw new System.NotSupportedException.$ctor1(System.Collections.ObjectModel.ReadOnlyDictionary$2(TKey,TValue).NotSupported_ReadOnlyCollection);
20854            },
20855            GetEnumerator: function () {
20856                return H5.getEnumerator(this._collection, TValue);
20857            },
20858            System$Collections$IEnumerable$GetEnumerator: function () {
20859                return H5.getEnumerator(H5.cast(this._collection, System.Collections.IEnumerable));
20860            }
20861        }
20862    }; });
20863
20864    // @source ReadOnlyDictionaryHelpers.js
20865
20866    H5.define("System.Collections.ObjectModel.ReadOnlyDictionaryHelpers", {
20867        statics: {
20868            methods: {
20869                CopyToNonGenericICollectionHelper: function (T, collection, array, index) {
20870                    var $t;
20871                    if (array == null) {
20872                        throw new System.ArgumentNullException.$ctor1("array");
20873                    }
20874
20875                    if (System.Array.getRank(array) !== 1) {
20876                        throw new System.ArgumentException.$ctor1("Only single dimensional arrays are supported for the requested action.");
20877                    }
20878
20879                    if (System.Array.getLower(array, 0) !== 0) {
20880                        throw new System.ArgumentException.$ctor1("The lower bound of target array must be zero.");
20881                    }
20882
20883                    if (index < 0) {
20884                        throw new System.ArgumentOutOfRangeException.$ctor4("index", "Index is less than zero.");
20885                    }
20886
20887                    if (((array.length - index) | 0) < System.Array.getCount(collection, T)) {
20888                        throw new System.ArgumentException.$ctor1("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
20889                    }
20890                    var nonGenericCollection;
20891                    if (((nonGenericCollection = H5.as(collection, System.Collections.ICollection))) != null) {
20892                        System.Array.copyTo(nonGenericCollection, array, index);
20893                        return;
20894                    }
20895                    var items;
20896                    if (((items = H5.as(array, System.Array.type(T)))
20896) != null) {
20897                        System.Array.copyTo(collection, items, index, T);
20898                    } else {
20899                        var objects; /* 
20900                        FxOverRh: Type.IsAssignableNot() not an api on that platform.
20901
20902                        //
20903                        // Catch the obvious case assignment will fail.
20904                        // We can found all possible problems by doing the check though.
20905                        // For example, if the element type of the Array is derived from T,
20906                        // we can't figure out if we can successfully copy the element beforehand.
20907                        //
20908                        Type targetType = array.GetType().GetElementType();
20909                        Type sourceType = typeof(T);
20910                        if (!(targetType.IsAssignableFrom(sourceType) || sourceType.IsAssignableFrom(targetType))) {
20911                        throw new ArgumentException(SR.Argument_InvalidArrayType);
20912                        }
20913                        */
20914
20915                        if (!(((objects = H5.as(array, System.Array.type(System.Object)))) != null)) {
20916                            throw new System.ArgumentException.$ctor1("Target array type is not compatible with the type of items in the collection.");
20917                        }
20918
20919                        try {
20920                            $t = H5.getEnumerator(collection, T);
20921                            try {
20922                                while ($t.moveNext()) {
20923                                    var item = $t.Current;
20924                                    objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = item;
20925                                }
20926                            } finally {
20927                                if (H5.is($t, System.IDisposable)) {
20928                                    $t.System$IDisposable$Dispose();
20929                                }
20930                            }
20931                        } catch ($e1) {
20932                            $e1 = System.Exception.create($e1);
20933                            if (H5.is($e1, System.ArrayTypeMismatchException)) {
20934                                throw new System.ArgumentException.$ctor1("Target array type is not compatible with the type of items in the collection.");
20935                            } else {
20936                                throw $e1;
20937                            }
20938                        }
20939                    }
20940                }
20941            }
20942        }
20943    });
20944
20945    // @source CollectionExtensions.js
20946
20947    H5.define("System.Collections.Generic.CollectionExtensions", {
20948        statics: {
20949            methods: {
20950                GetValueOrDefault$1: function (TKey, TValue, dictionary, key) {
20951                    return System.Collections.Generic.CollectionExtensions.GetValueOrDefault(TKey, TValue, dictionary, key, H5.getDefaultValue(TValue));
20952                },
20953                GetValueOrDefault: function (TKey, TValue, dictionary, key, defaultValue) {
20954                    if (dictionary == null) {
20955                        throw new System.ArgumentNullException.$ctor1("dictionary");
20956                    }
20957
20958                    var value = { };
20959                    return dictionary["System$Collections$Generic$IReadOnlyDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue"](key, value) ? value.v : defaultValue;
20960                },
20961                TryAdd: function (TKey, TValue, dictionary, key, value) {
20962                    if (dictionary == null) {
20963                        throw new System.ArgumentNullException.$ctor1("dictionary");
20964                    }
20965
20966                    if (!dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$containsKey"](key)) {
20967                        dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$add"](key, value);
20968                        return true;
20969                    }
20970
20971                    return false;
20972                },
20973                Remove: function (TKey, TValue, dictionary, key, value) {
20974                    if (dictionary == null) {
20975                        throw new System.ArgumentNullException.$ctor1("dictionary");
20976                    }
20977
20978                    if (dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$tryGetValue"](key, value)) {
20979                        dictionary["System$Collections$Generic$IDictionary$2$" + H5.getTypeAlias(TKey) + "$" + H5.getTypeAlias(TValue) + "$remove"](key);
20980                        return true;
20981                    }
20982
20983                    value.v = H5.getDefaultValue(TValue);
20984                    return false;
20985                }
20986            }
20987        }
20988    });
20989
20990    // @source StringComparer.js
20991
20992    H5.define("System.StringComparer", {
20993        inherits: [System.Collections.Generic.IComparer$1(System.String),System.Collections.Generic.IEqualityComparer$1(System.String)],
20994        statics: {
20995            fields: {
20996                _ordinal: null,
20997                _ordinalIgnoreCase: null
20998            },
20999            props: {
21000                Ordinal: {
21001                    get: function () {
21002                        return System.StringComparer._ordinal;
21003                    }
21004                },
21005                OrdinalIgnoreCase: {
21006                    get: function () {
21007                        return System.StringComparer._ordinalIgnoreCase;
21008                    }
21009                }
21010            },
21011            ctors: {
21012                init: function () {
21013                    this._ordinal = new System.OrdinalComparer(false);
21014                    this._ordinalIgnoreCase = new System.OrdinalComparer(true);
21015                }
21016            }
21017        },
21018        methods: {
21019            Compare: function (x, y) {
21020                if (H5.referenceEquals(x, y)) {
21021                    return 0;
21022                }
21023                if (x == null) {
21024                    return -1;
21025                }
21026                if (y == null) {
21027                    return 1;
21028                }
21029                var sa;
21030                if (((sa = H5.as(x, System.String))) != null) {
21031                    var sb;
21032                    if (((sb = H5.as(y, System.String))) != null) {
21033                        return this.compare(sa, sb);
21034                    }
21035                }
21036                var ia;
21037                if (((ia = H5.as(x, System.IComparable))) != null) {
21038                    return H5.compare(ia, y);
21039                }
21040
21041                throw new System.ArgumentException.$ctor1("At least one object must implement IComparable.");
21042            },
21043            Equals: function (x, y) {
21044                if (H5.referenceEquals(x, y)) {
21045                    return true;
21046                }
21047                if (x == null || y == null) {
21048                    return false;
21049                }
21050                var sa;
21051                if (((sa = H5.as(x, System.String))) != null) {
21052                    var sb;
21053                    if (((sb = H5.as(y, System.String))) != null) {
21054                        return this.equals2(sa, sb);
21055                    }
21056                }
21057                return H5.equals(x, y);
21058            },
21059            GetHashCode: function (obj) {
21060                if (obj == null) {
21061                    throw new System.ArgumentNullException.$ctor1("obj");
21062                }
21063                var s;
21064                if (((s = H5.as(obj, System.String))) != null) {
21065                    return this.getHashCode2(s);
21066                }
21067                return H5.getHashCode(obj);
21068            }
21069        }
21070    });
21071
21072    // @source OrdinalComparer.js
21073
21074    H5.define("System.OrdinalComparer", {
21075        inherits: [System.StringComparer],
21076        fields: {
21077            _ignoreCase: false
21078        },
21079        alias: [
21080            "compare", ["System$Collections$Generic$IComparer$1$System$String$compare", "System$Collections$Generic$IComparer$1$compare"],
21081            "equals2", ["System$Collections$Generic$IEqualityComparer$1$System$String$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2"],
21082            "getHashCode2", ["System$Collections$Generic$IEqualityComparer$1$System$String$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2"]
21083        ],
21084        ctors: {
21085            ctor: function (ignoreCase) {
21086                this.$initialize();
21087                System.StringComparer.ctor.call(this);
21088                this._ignoreCase = ignoreCase;
21089            }
21090        },
21091        methods: {
21092            compare: function (x, y) {
21093                if (H5.referenceEquals(x, y)) {
21094                    return 0;
21095                }
21096                if (x == null) {
21097                    return -1;
21098                }
21099                if (y == null) {
21100                    return 1;
21101                }
21102
21103                if (this._ignoreCase) {
21104                    return System.String.compare(x, y, 5);
21105                }
21106
21107                return System.String.compare(x, y, false);
21108            },
21109            equals2: function (x, y) {
21110                if (H5.referenceEquals(x, y)) {
21111                    return true;
21112                }
21113                if (x == null || y == null) {
21114                    return false;
21115                }
21116
21117                if (this._ignoreCase) {
21118                    if (x.length !== y.length) {
21119                        return false;
21120                    }
21121                    return (System.String.compare(x, y, 5) === 0);
21122                }
21123                return System.String.equals(x, y);
21124            },
21125            equals: function (obj) {
21126                var comparer;
21127                if (!(((comparer = H5.as(obj, System.OrdinalComparer))) != null)) {
21128                    return false;
21129                }
21130                return (this._ignoreCase === comparer._ignoreCase);
21131            },
21132            getHashCode2: function (obj) {
21133                if (obj == null) {
21134                    throw new System.ArgumentNullException.$ctor1("obj");
21135                }
21136
21137                if (this._ignoreCase && obj != null) {
21138                    return H5.getHashCode(obj.toLowerCase());
21139                }
21140
21141                return H5.getHashCode(obj);
21142            },
21143            getHashCode: function () {
21144                var name = "OrdinalComparer";
21145                var hashCode = H5.getHashCode(name);
21146                return this._ignoreCase ? (~hashCode) : hashCode;
21147            }
21148        }
21149    });
21150
21151    // @source CustomEnumerator.js
21152
21153    H5.define("H5.CustomEnumerator", {
21154        inherits: [System.Collections.IEnumerator, System.IDisposable],
21155
21156        config: {
21157            properties: {
21158                Current: {
21159                    get: function () {
21160                        return this.getCurrent();
21161                    }
21162                },
21163
21164                Current$1: {
21165                    get: function () {
21166                        return this.getCurrent();
21167                    }
21168                }
21169            },
21170
21171            alias: [
21172                "getCurrent", "System$Collections$IEnumerator$getCurrent",
21173                "moveNext", "System$Collections$IEnumerator$moveNext",
21174                "reset", "System$Collections$IEnumerator$reset",
21175                "Dispose", "System$IDisposable$Dispose",
21176                "Current", "System$Collections$IEnumerator$Current"
21177            ]
21178        },
21179
21180        ctor: function (moveNext, getCurrent, reset, dispose, scope, T) {
21181            this.$initialize();
21182            this.$moveNext = moveNext;
21183            this.$getCurrent = getCurrent;
21184            this.$Dispose = dispose;
21185            this.$reset = reset;
21186            this.scope = scope;
21187
21188            if (T) {
21189                this["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$getCurrent$1"] = this.getCurrent;
21190                this["System$Collections$Generic$IEnumerator$1$getCurrent$1"] = this.getCurrent;
21191
21192                Object.defineProperty(this, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", {
21193                    get: this.getCurrent,
21194                    enumerable: true
21195                });
21196
21197                Object.defineProperty(this, "System$Collections$Generic$IEnumerator$1$Current$1", {
21198                    get: this.getCurrent,
21199                    enumerable: true
21200                });
21201            }
21202        },
21203
21204        moveNext: function () {
21205            try {
21206                return this.$moveNext.call(this.scope);
21207            }
21208            catch (ex) {
21209                this.Dispose.call(this.scope);
21210
21211                throw ex;
21212            }
21213        },
21214
21215        getCurrent: function () {
21216            return this.$getCurrent.call(this.scope);
21217        },
21218
21219        getCurrent$1: function () {
21220            return this.$getCurrent.call(this.scope);
21221        },
21222
21223        reset: function () {
21224            if (this.$reset) {
21225                this.$reset.call(this.scope);
21226            }
21227        },
21228
21229        Dispose: function () {
21230            if (this.$Dispose) {
21231                this.$Dispose.call(this.scope);
21232            }
21233        }
21234    });
21235
21236    // @source ArrayEnumerator.js
21237
21238    H5.define("H5.ArrayEnumerator", {
21239        inherits: [System.Collections.IEnumerator, System.IDisposable],
21240
21241        statics: {
21242            $isArrayEnumerator: true
21243        },
21244
21245        config: {
21246            properties: {
21247                Current: {
21248                    get: function () {
21249                        return this.getCurrent();
21250                    }
21251                },
21252
21253                Current$1: {
21254                    get: function () {
21255                        return this.getCurrent();
21256                    }
21257                }
21258            },
21259
21260            alias: [
21261                "getCurrent", "System$Collections$IEnumerator$getCurrent",
21262                "moveNext", "System$Collections$IEnumerator$moveNext",
21263                "reset", "System$Collections$IEnumerator$reset",
21264                "Dispose", "System$IDisposable$Dispose",
21265                "Current", "System$Collections$IEnumerator$Current"
21266            ]
21267        },
21268
21269        ctor: function (array, T) {
21270            this.$initialize();
21271            this.array = array;
21272            this.reset();
21273
21274            if (T) {
21275                this["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$getCurrent$1"] = this.getCurrent;
21276                this["System$Collections$Generic$IEnumerator$1$getCurrent$1"] = this.getCurrent;
21277
21278                Object.defineProperty(this, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", {
21279                    get: this.getCurrent,
21280                    enumerable: true
21281                });
21282
21283                Object.defineProperty(this, "System$Collections$Generic$IEnumerator$1$Current$1", {
21284                    get: this.getCurrent,
21285                    enumerable: true
21286                });
21287            }
21288        },
21289
21290        moveNext: function () {
21291            this.index++;
21292
21293            return this.index < this.array.length;
21294        },
21295
21296        getCurrent: function () {
21297            return this.array[this.index];
21298        },
21299
21300        getCurrent$1: function () {
21301            return this.array[this.index];
21302        },
21303
21304        reset: function () {
21305            this.index = -1;
21306        },
21307
21308        Dispose: H5.emptyFn
21309    });
21310
21311    H5.define("H5.ArrayEnumerable", {
21312        inherits: [System.Collections.IEnumerable],
21313
21314        config: {
21315            alias: [
21316                "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator"
21317            ]
21318        },
21319
21320        ctor: function (array) {
21321            this.$initialize();
21322            this.array = array;
21323        },
21324
21325        GetEnumerator: function () {
21326            return new H5.ArrayEnumerator(this.array);
21327        }
21328    });
21329
21330    // @source EqualityComparer.js
21331
21332    H5.define("System.Collections.Generic.EqualityComparer$1", function (T) {
21333        return {
21334            inherits: [System.Collections.Generic.IEqualityComparer$1(T)],
21335
21336            statics: {
21337                config: {
21338                    init: function () {
21339                        this.def = new (System.Collections.Generic.EqualityComparer$1(T))();
21340                    }
21341                }
21342            },
21343
21344            config: {
21345                alias: [
21346                    "equals2", ["System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2"],
21347                    "getHashCode2", ["System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2"]
21348                ]
21349            },
21350
21351            equals2: function (x, y) {
21352                if (!H5.isDefined(x, true)) {
21353                    return !H5.isDefined(y, true);
21354                } else if (H5.isDefined(y, true)) {
21355                    var isH5 = x && x.$$name;
21356
21357                    if (H5.isFunction(x) && H5.isFunction(y)) {
21358                        return H5.fn.equals.call(x, y);
21359                    } else if (!isH5 || x && x.$boxed || y && y.$boxed) {
21360                        return H5.equals(x, y);
21361                    } else if (H5.isFunction(x.equalsT)) {
21362                        return H5.equalsT(x, y);
21363                    } else if (H5.isFunction(x.equals)) {
21364                        return H5.equals(x, y);
21365                    }
21366
21367                    return x === y;
21368                }
21369
21370                return false;
21371            },
21372
21373            getHashCode2: function (obj) {
21374                return H5.isDefined(obj, true) ? H5.getHashCode(obj) : 0;
21375            }
21376        };
21377    });
21378
21379    System.Collections.Generic.EqualityComparer$1.$default = new (System.Collections.Generic.EqualityComparer$1(System.Object))();
21380
21381    // @source Comparer.js
21382
21383    H5.define("System.Collections.Generic.Comparer$1", function (T) {
21384        return {
21385            inherits: [System.Collections.Generic.IComparer$1(T)],
21386
21387            ctor: function (fn) {
21388                this.$initialize();
21389                this.fn = fn;
21390                this.compare = fn;
21391                this["System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare"] = fn;
21392                this["System$Collections$Generic$IComparer$1$compare"] = fn;
21393            }
21394        }
21395    });
21396
21397    System.Collections.Generic.Comparer$1.$default = new (System.Collections.Generic.Comparer$1(System.Object))(function (x, y) {
21398        if (!H5.hasValue(x)) {
21399            return !H5.hasValue(y) ? 0 : -1;
21400        } else if (!H5.hasValue(y)) {
21401            return 1;
21402        }
21403
21404        return H5.compare(x, y);
21405    });
21406
21407    System.Collections.Generic.Comparer$1.get = function (obj, T) {
21408        var m;
21409
21410        if (T && (m = obj["System$Collections$Generic$IComparer$1$" + H5.getTypeAlias(T) + "$compare"])) {
21411            return m.bind(obj);
21412        }
21413
21414        if (m = obj["System$Collections$Generic$IComparer$1$compare"]) {
21415            return m.bind(obj);
21416        }
21417
21418        return obj.compare.bind(obj);
21419    };
21420
21421    // @source Dictionary.js
21422
21423    System.Collections.Generic.Dictionary$2.getTypeParameters = function (type) {
21424        var interfaceType;
21425
21426        if (System.String.startsWith(type.$$name, "System.Collections.Generic.IDictionary")) {
21427            interfaceType = type;
21428        } else {
21429            var interfaces = H5.Reflection.getInterfaces(type);
21430
21431            for (var j = 0; j < interfaces.length; j++) {
21432                if (System.String.startsWith(interfaces[j].$$name, "System.Collections.Generic.IDictionary")) {
21433                    interfaceType = interfaces[j];
21434
21435                    break;
21436                }
21437            }
21438        }
21439
21440        var typesGeneric = interfaceType ? H5.Reflection.getGenericArguments(interfaceType) : null;
21441        var typeKey = typesGeneric ? typesGeneric[0] : null;
21442        var typeValue = typesGeneric ? typesGeneric[1] : null;
21443
21444        return [typeKey, typeValue];
21445    };
21446    // @source List.js
21447
21448    H5.define("System.Collections.Generic.List$1", function (T) { return {
21449        inherits: [System.Collections.Generic.IList$1(T),System.Collections.IList,System.Collections.Generic.IReadOnlyList$1(T)],
21450        statics: {
21451            fields: {
21452                _defaultCapacity: 0,
21453                _emptyArray: null
21454            },
21455            ctors: {
21456                init: function () {
21457                    this._defaultCapacity = 4;
21458                    this._emptyArray = System.Array.init(0, function (){
21459                        return H5.getDefaultValue(T);
21460                    }, T);
21461                }
21462            },
21463            methods: {
21464                IsCompatibleObject: function (value) {
21465                    return ((H5.is(value, T)) || (value == null && H5.getDefaultValue(T) == null));
21466                }
21467            }
21468        },
21469        fields: {
21470            _items: null,
21471            _size: 0,
21472            _version: 0
21473        },
21474        props: {
21475            Capacity: {
21476                get: function () {
21477                    return this._items.length;
21478                },
21479                set: function (value) {
21480                    if (value < this._size) {
21481                        throw new System.ArgumentOutOfRangeException.$ctor1("value");
21482                    }
21483
21484                    if (value !== this._items.length) {
21485                        if (value > 0) {
21486                            var newItems = System.Array.init(value, function (){
21487                                return H5.getDefaultValue(T);
21488                            }, T);
21489                            if (this._size > 0) {
21490                                System.Array.copy(this._items, 0, newItems, 0, this._size);
21491                            }
21492                            this._items = newItems;
21493                        } else {
21494                            this._items = System.Collections.Generic.List$1(T)._emptyArray;
21495                        }
21496                    }
21497                }
21498            },
21499            Count: {
21500                get: function () {
21501                    return this._size;
21502                }
21503            },
21504            System$Collections$IList$IsFixedSize: {
21505                get: function () {
21506                    return false;
21507                }
21508            },
21509            System$Collections$Generic$ICollection$1$IsReadOnly: {
21510                get: function () {
21511                    return false;
21512                }
21513            },
21514            System$Collections$IList$IsReadOnly: {
21515                get: function () {
21516                    return false;
21517                }
21518            },
21519            System$Collections$ICollection$IsSynchronized: {
21520                get: function () {
21521                    return false;
21522                }
21523            },
21524            System$Collections$ICollection$SyncRoot: {
21525                get: function () {
21526                    return this;
21527                }
21528            }
21529        },
21530        alias: [
21531            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
21532            "Count", "System$Collections$ICollection$Count",
21533            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
21534            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly",
21535            "getItem", ["System$Collections$Generic$IReadOnlyList$1$" + H5.getTypeAlias(T) + "$getItem", "System$Collections$Generic$IReadOnlyList$1$getItem"],
21536            "setItem", ["System$Collections$Generic$IReadOnlyList$1$" + H5.getTypeAlias(T) + "$setItem", "System$Collections$Generic$IReadOnlyList$1$setItem"],
21537            "getItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$getItem",
21538            "setItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$setItem",
21539            "add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
21540            "clear", "System$Collections$IList$clear",
21541            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
21542            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
21543            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
21544            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator",
21545            "indexOf", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$indexOf",
21546            "insert", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$insert",
21547            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove",
21548            "removeAt", "System$Collections$IList$removeAt",
21549            "removeAt", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$removeAt"
21550        ],
21551        ctors: {
21552            ctor: function () {
21553                this.$initialize();
21554                this._items = System.Collections.Generic.List$1(T)._emptyArray;
21555            },
21556            $ctor2: function (capacity) {
21557                this.$initialize();
21558                if (capacity < 0) {
21559                    throw new System.ArgumentOutOfRangeException.$ctor1("capacity");
21560                }
21561
21562                if (capacity === 0) {
21563                    this._items = System.Collections.Generic.List$1(T)._emptyArray;
21564                } else {
21565                    this._items = System.Array.init(capacity, function (){
21566                        return H5.getDefaultValue(T);
21567                    }, T);
21568                }
21569            },
21570            $ctor1: function (collection) {
21571                this.$initialize();
21572                if (collection == null) {
21573                    throw new System.ArgumentNullException.$ctor1("collection");
21574                }
21575                var c;
21576                if (((c = H5.as(collection, System.Collections.Generic.ICollection$1(T)))) != null) {
21577                    var count = System.Array.getCount(c, T);
21578                    if (count === 0) {
21579                        this._items = System.Collections.Generic.List$1(T)._emptyArray;
21580                    } else {
21581                        this._items = System.Array.init(count, function (){
21582                            return H5.getDefaultValue(T);
21583                        }, T);
21584                        System.Array.copyTo(c, this._items, 0, T);
21585                        this._size = count;
21586                    }
21587                } else {
21588                    this._size = 0;
21589                    this._items = System.Collections.Generic.List$1(T)._emptyArray;
21590
21591                    var en = H5.getEnumerator(collection, T);
21592                    try {
21593                        while (en.System$Collections$IEnumerator$moveNext()) {
21594                            this.add(en[H5.geti(en, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")]);
21595                        }
21596                    }
21597                    finally {
21598                        if (H5.hasValue(en)) {
21599                            en.System$IDisposable$Dispose();
21600                        }
21601                    }
21602                }
21603            }
21604        },
21605        methods: {
21606            getItem: function (index) {
21607                if ((index >>> 0) >= (this._size >>> 0)) {
21608                    throw new System.ArgumentOutOfRangeException.ctor();
21609                }
21610                return this._items[System.Array.index(index, this._items)];
21611            },
21612            setItem: function (index, value) {
21613                if ((index >>> 0) >= (this._size >>> 0)) {
21614                    throw new System.ArgumentOutOfRangeException.ctor();
21615                }
21616                this._items[System.Array.index(index, this._items)] = value;
21617                this._version = (this._version + 1) | 0;
21618            },
21619            System$Collections$IList$getItem: function (index) {
21620                return this.getItem(index);
21621            },
21622            System$Collections$IList$setItem: function (index, value) {
21623                if (value == null && !(H5.getDefaultValue(T) == null)) {
21624                    throw new System.ArgumentNullException.$ctor1("value");
21625                }
21626
21627                try {
21628                    this.setItem(index, H5.cast(H5.unbox(value, T), T));
21629                } catch ($e1) {
21630                    $e1 = System.Exception.create($e1);
21631                    if (H5.is($e1, System.InvalidCastException)) {
21632                        throw new System.ArgumentException.$ctor1("value");
21633                    } else {
21634                        throw $e1;
21635                    }
21636                }
21637            },
21638            add: function (item) {
21639                if (this._size === this._items.length) {
21640                    this.EnsureCapacity(((this._size + 1) | 0));
21641                }
21642                this._items[System.Array.index(H5.identity(this._size, 
21642((this._size = (this._size + 1) | 0))), this._items)] = item;
21643                this._version = (this._version + 1) | 0;
21644            },
21645            System$Collections$IList$add: function (item) {
21646                if (item == null && !(H5.getDefaultValue(T) == null)) {
21647                    throw new System.ArgumentNullException.$ctor1("item");
21648                }
21649
21650                try {
21651                    this.add(H5.cast(H5.unbox(item, T), T));
21652                } catch ($e1) {
21653                    $e1 = System.Exception.create($e1);
21654                    if (H5.is($e1, System.InvalidCastException)) {
21655                        throw new System.ArgumentException.$ctor1("item");
21656                    } else {
21657                        throw $e1;
21658                    }
21659                }
21660
21661                return ((this.Count - 1) | 0);
21662            },
21663            AddRange: function (collection) {
21664                this.InsertRange(this._size, collection);
21665            },
21666            AsReadOnly: function () {
21667                return new (System.Collections.ObjectModel.ReadOnlyCollection$1(T))(this);
21668            },
21669            BinarySearch$2: function (index, count, item, comparer) {
21670                if (index < 0) {
21671                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21672                }
21673                if (count < 0) {
21674                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
21675                }
21676                if (((this._size - index) | 0) < count) {
21677                    throw new System.ArgumentException.ctor();
21678                }
21679
21680                return System.Array.binarySearch(this._items, index, count, item, comparer);
21681            },
21682            BinarySearch: function (item) {
21683                return this.BinarySearch$2(0, this.Count, item, null);
21684            },
21685            BinarySearch$1: function (item, comparer) {
21686                return this.BinarySearch$2(0, this.Count, item, comparer);
21687            },
21688            clear: function () {
21689                if (this._size > 0) {
21690                    System.Array.fill(this._items, function () {
21691                        return H5.getDefaultValue(T);
21692                    }, 0, this._size);
21693                    this._size = 0;
21694                }
21695                this._version = (this._version + 1) | 0;
21696            },
21697            contains: function (item) {
21698                if (item == null) {
21699                    for (var i = 0; i < this._size; i = (i + 1) | 0) {
21700                        if (this._items[System.Array.index(i, this._items)] == null) {
21701                            return true;
21702                        }
21703                    }
21704                    return false;
21705                } else {
21706                    var c = System.Collections.Generic.EqualityComparer$1(T).def;
21707                    for (var i1 = 0; i1 < this._size; i1 = (i1 + 1) | 0) {
21708                        if (c.equals2(this._items[System.Array.index(i1, this._items)], item)) {
21709                            return true;
21710                        }
21711                    }
21712                    return false;
21713                }
21714            },
21715            System$Collections$IList$contains: function (item) {
21716                if (System.Collections.Generic.List$1(T).IsCompatibleObject(item)) {
21717                    return this.contains(H5.cast(H5.unbox(item, T), T));
21718                }
21719                return false;
21720            },
21721            ConvertAll: function (TOutput, converter) {
21722                if (H5.staticEquals(converter, null)) {
21723                    throw new System.ArgumentNullException.$ctor1("converter");
21724                }
21725
21726                var list = new (System.Collections.Generic.List$1(TOutput)).$ctor2(this._size);
21727                for (var i = 0; i < this._size; i = (i + 1) | 0) {
21728                    list._items[System.Array.index(i, list._items)] = converter(this._items[System.Array.index(i, this._items)]);
21729                }
21730                list._size = this._size;
21731                return list;
21732            },
21733            CopyTo: function (array) {
21734                this.copyTo(array, 0);
21735            },
21736            System$Collections$ICollection$copyTo: function (array, arrayIndex) {
21737                if ((array != null) && (System.Array.getRank(array) !== 1)) {
21738                    throw new System.ArgumentException.$ctor1("array");
21739                }
21740
21741                System.Array.copy(this._items, 0, array, arrayIndex, this._size);
21742            },
21743            CopyTo$1: function (index, array, arrayIndex, count) {
21744                if (((this._size - index) | 0) < count) {
21745                    throw new System.ArgumentException.ctor();
21746                }
21747
21748                System.Array.copy(this._items, index, array, arrayIndex, count);
21749            },
21750            copyTo: function (array, arrayIndex) {
21751                System.Array.copy(this._items, 0, array, arrayIndex, this._size);
21752            },
21753            EnsureCapacity: function (min) {
21754                if (this._items.length < min) {
21755                    var newCapacity = this._items.length === 0 ? System.Collections.Generic.List$1(T)._defaultCapacity : H5.Int.mul(this._items.length, 2);
21756                    if ((newCapacity >>> 0) > 2146435071) {
21757                        newCapacity = 2146435071;
21758                    }
21759                    if (newCapacity < min) {
21760                        newCapacity = min;
21761                    }
21762                    this.Capacity = newCapacity;
21763                }
21764            },
21765            Exists: function (match) {
21766                return this.FindIndex$2(match) !== -1;
21767            },
21768            Find: function (match) {
21769                if (H5.staticEquals(match, null)) {
21770                    throw new System.ArgumentNullException.$ctor1("match");
21771                }
21772
21773                for (var i = 0; i < this._size; i = (i + 1) | 0) {
21774                    if (match(this._items[System.Array.index(i, this._items)])) {
21775                        return this._items[System.Array.index(i, this._items)];
21776                    }
21777                }
21778                return H5.getDefaultValue(T);
21779            },
21780            FindAll: function (match) {
21781                if (H5.staticEquals(match, null)) {
21782                    throw new System.ArgumentNullException.$ctor1("match");
21783                }
21784
21785                var list = new (System.Collections.Generic.List$1(T)).ctor();
21786                for (var i = 0; i < this._size; i = (i + 1) | 0) {
21787                    if (match(this._items[System.Array.index(i, this._items)])) {
21788                        list.add(this._items[System.Array.index(i, this._items)]);
21789                    }
21790                }
21791                return list;
21792            },
21793            FindIndex$2: function (match) {
21794                return this.FindIndex(0, this._size, match);
21795            },
21796            FindIndex$1: function (startIndex, match) {
21797                return this.FindIndex(startIndex, ((this._size - startIndex) | 0), match);
21798            },
21799            FindIndex: function (startIndex, count, match) {
21800                if ((startIndex >>> 0) > (this._size >>> 0)) {
21801                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
21802                }
21803
21804                if (count < 0 || startIndex > ((this._size - count) | 0)) {
21805                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
21806                }
21807
21808                if (H5.staticEquals(match, null)) {
21809                    throw new System.ArgumentNullException.$ctor1("match");
21810                }
21811
21812                var endIndex = (startIndex + count) | 0;
21813                for (var i = startIndex; i < endIndex; i = (i + 1) | 0) {
21814                    if (match(this._items[System.Array.index(i, this._items)])) {
21815                        return i;
21816                    }
21817                }
21818                return -1;
21819            },
21820            FindLast: function (match) {
21821                if (H5.staticEquals(match, null)) {
21822                    throw new System.ArgumentNullException.$ctor1("match");
21823                }
21824
21825                for (var i = (this._size - 1) | 0; i >= 0; i = (i - 1) | 0) {
21826                    if (match(this._items[System.Array.index(i, this._items)])) {
21827                        return this._items[System.Array.index(i, this._items)];
21828                    }
21829                }
21830                return H5.getDefaultValue(T);
21831            },
21832            FindLastIndex$2: function (match) {
21833                return this.FindLastIndex(((this._size - 1) | 0), this._size, match);
21834            },
21835            FindLastIndex$1: function (startIndex, match) {
21836                return this.FindLastIndex(startIndex, ((startIndex + 1) | 0), match);
21837            },
21838            FindLastIndex: function (startIndex, count, match) {
21839                if (H5.staticEquals(match, null)) {
21840                    throw new System.ArgumentNullException.$ctor1("match");
21841                }
21842
21843                if (this._size === 0) {
21844                    if (startIndex !== -1) {
21845                        throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
21846                    }
21847                } else {
21848                    if ((startIndex >>> 0) >= (this._size >>> 0)) {
21849                        throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
21850                    }
21851                }
21852
21853                if (count < 0 || ((((startIndex - count) | 0) + 1) | 0) < 0) {
21854                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
21855                }
21856
21857                var endIndex = (startIndex - count) | 0;
21858                for (var i = startIndex; i > endIndex; i = (i - 1) | 0) {
21859                    if (match(this._items[System.Array.index(i, this._items)])) {
21860                        return i;
21861                    }
21862                }
21863                return -1;
21864            },
21865            ForEach: function (action) {
21866                if (H5.staticEquals(action, null)) {
21867                    throw new System.ArgumentNullException.$ctor1("match");
21868                }
21869
21870                var version = this._version;
21871
21872                for (var i = 0; i < this._size; i = (i + 1) | 0) {
21873                    if (version !== this._version) {
21874                        break;
21875                    }
21876                    action(this._items[System.Array.index(i, this._items)]);
21877                }
21878
21879                if (version !== this._version) {
21880                    throw new System.InvalidOperationException.ctor();
21881                }
21882            },
21883            GetEnumerator: function () {
21884                return new (System.Collections.Generic.List$1.Enumerator(T)).$ctor1(this);
21885            },
21886            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
21887                return new (System.Collections.Generic.List$1.Enumerator(T)).$ctor1(this).$clone();
21888            },
21889            System$Collections$IEnumerable$GetEnumerator: function () {
21890                return new (System.Collections.Generic.List$1.Enumerator(T)).$ctor1(this).$clone();
21891            },
21892            GetRange: function (index, count) {
21893                if (index < 0) {
21894                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21895                }
21896
21897                if (count < 0) {
21898                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
21899                }
21900
21901                if (((this._size - index) | 0) < count) {
21902                    throw new System.ArgumentException.ctor();
21903                }
21904
21905                var list = new (System.Collections.Generic.List$1(T)).$ctor2(count);
21906                System.Array.copy(this._items, index, list._items, 0, count);
21907                list._size = count;
21908                return list;
21909            },
21910            indexOf: function (item) {
21911                return System.Array.indexOfT(this._items, item, 0, this._size);
21912            },
21913            System$Collections$IList$indexOf: function (item) {
21914                if (System.Collections.Generic.List$1(T).IsCompatibleObject(item)) {
21915                    return this.indexOf(H5.cast(H5.unbox(item, T), T));
21916                }
21917                return -1;
21918            },
21919            IndexOf: function (item, index) {
21920                if (index > this._size) {
21921                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21922                }
21923                return System.Array.indexOfT(this._items, item, index, ((this._size - index) | 0));
21924            },
21925            IndexOf$1: function (item, index, count) {
21926                if (index > this._size) {
21927                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21928                }
21929
21930                if (count < 0 || index > ((this._size - count) | 0)) {
21931                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
21932                }
21933
21934                return System.Array.indexOfT(this._items, item, index, count);
21935            },
21936            insert: function (index, item) {
21937                if ((index >>> 0) > (this._size >>> 0)) {
21938                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21939                }
21940                if (this._size === this._items.length) {
21941                    this.EnsureCapacity(((this._size + 1) | 0));
21942                }
21943                if (index < this._size) {
21944                    System.Array.copy(this._items, index, this._items, ((index + 1) | 0), ((this._size - index) | 0));
21945                }
21946                this._items[System.Array.index(index, this._items)] = item;
21947                this._size = (this._size + 1) | 0;
21948                this._version = (this._version + 1) | 0;
21949            },
21950            System$Collections$IList$insert: function (index, item) {
21951                if (item == null && !(H5.getDefaultValue(T) == null)) {
21952                    throw new System.ArgumentNullException.$ctor1("item");
21953                }
21954
21955                try {
21956                    this.insert(index, H5.cast(H5.unbox(item, T), T));
21957                } catch ($e1) {
21958                    $e1 = System.Exception.create($e1);
21959                    if (H5.is($e1, System.InvalidCastException)) {
21960                        throw new System.ArgumentException.$ctor1("item");
21961                    } else {
21962                        throw $e1;
21963                    }
21964                }
21965            },
21966            InsertRange: function (index, collection) {
21967                if (collection == null) {
21968                    throw new System.ArgumentNullException.$ctor1("collection");
21969                }
21970
21971                if ((index >>> 0) > (this._size >>> 0)) {
21972                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
21973                }
21974                var c;
21975                if (((c = H5.as(collection, System.Collections.Generic.ICollection$1(T)))) != null) {
21976                    var count = System.Array.getCount(c, T);
21977                    if (count > 0) {
21978                        this.EnsureCapacity(((this._size + count) | 0));
21979                        if (index < this._size) {
21980                            System.Array.copy(this._items, index, this._items, ((index + count) | 0), ((this._size - index) | 0));
21981                        }
21982
21983                        if (H5.referenceEquals(this, c)) {
21984                            System.Array.copy(this._items, 0, this._items, index, index);
21985                            System.Array.copy(this._items, ((index + count) | 0), this._items, H5.Int.mul(index, 2), ((this._size - index) | 0));
21986                        } else {
21987                            var itemsToInsert = System.Array.init(count, function (){
21988                                return H5.getDefaultValue(T);
21989                            }, T);
21990                            System.Array.copyTo(c, itemsToInsert, 0, T);
21991                            System.Array.copy(itemsToInsert, 0, this._items, index, itemsToInsert.length);
21992                        }
21993                        this._size = (this._size + count) | 0;
21994                    }
21995                } else {
21996                    var en = H5.getEnumerator(collection, T);
21997                    try {
21998                        while (en.System$Collections$IEnumerator$moveNext()) {
21999                            this.insert(H5.identity(index, ((index = (index + 1) | 0))), en[H5.geti(en, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")]);
22000                        }
22001                    }
22002                    finally {
22003                        if (H5.hasValue(en)) {
22004                            en.System$IDisposable$Dispose();
22005                        }
22006                    }
22007                }
22008                this._version = (this._version + 1) | 0;
22009            },
22010            LastIndexOf: function (item) {
22011                if (this._size === 0) {
22012                    return -1;
22013                } else {
22014                    return this.LastIndexOf$2(item, ((this._size - 1) | 0), this._size);
22015                }
22016            },
22017            LastIndexOf$1: function (item, index) {
22018                if (index >= this._size) {
22019                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22020                }
22021                return this.LastIndexOf$2(item, index, ((index + 1) | 0));
22022            },
22023            LastIndexOf$2: function (item, index, count) {
22024                if ((this.Count !== 0) && (index < 0)) {
22025                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22026                }
22027
22028                if ((this.Count !== 0) && (count < 0)) {
22029                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
22030                }
22031
22032                if (this._size === 0) {
22033                    return -1;
22034                }
22035
22036                if (index >= this._size) {
22037                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22038                }
22039
22040                if (count > ((index + 1) | 0)) {
22041                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
22042                }
22043
22044                return System.Array.lastIndexOfT(this._items, item, index, count);
22045            },
22046            remove: function (item) {
22047                var index = this.indexOf(item);
22048                if (index >= 0) {
22049                    this.removeAt(index);
22050                    return true;
22051                }
22052
22053                return false;
22054            },
22055            System$Collections$IList$remove: function (item) {
22056                if (System.Collections.Generic.List$1(T).IsCompatibleObject(item)) {
22057                    this.remove(H5.cast(H5.unbox(item, T), T));
22058                }
22059            },
22060            RemoveAll: function (match) {
22061                if (H5.staticEquals(match, null)) {
22062                    throw new System.ArgumentNullException.$ctor1("match");
22063                }
22064
22065                var freeIndex = 0;
22066
22067                while (freeIndex < this._size && !match(this._items[System.Array.index(freeIndex, this._items)])) {
22068                    freeIndex = (freeIndex + 1) | 0;
22069                }
22070                if (freeIndex >= this._size) {
22071                    return 0;
22072                }
22073
22074                var current = (freeIndex + 1) | 0;
22075                while (current < this._size) {
22076                    while (current < this._size && match(this._items[System.Array.index(current, this._items)])) {
22077                        current = (current + 1) | 0;
22078                    }
22079
22080                    if (current < this._size) {
22081                        this._items[System.Array.index(H5.identity(freeIndex, ((freeIndex = (freeIndex + 1) | 0))), this._items)] = this._items[System.Array.index(H5.identity(current, ((current = (current + 1) | 0))), this._items)];
22082                    }
22083                }
22084
22085                System.Array.fill(this._items, function () {
22086                    return H5.getDefaultValue(T);
22087                }, freeIndex, ((this._size - freeIndex) | 0));
22088                var result = (this._size - freeIndex) | 0;
22089                this._size = freeIndex;
22090                this._version = (this._version + 1) | 0;
22091                return result;
22092            },
22093            removeAt: function (index) {
22094                if ((index >>> 0) >= (this._size >>> 0)) {
22095                    throw new System.ArgumentOutOfRangeException.ctor();
22096                }
22097                this._size = (this._size - 1) | 0;
22098                if (index < this._size) {
22099                    System.Array.copy(this._items, ((index + 1) | 0), this._items, index, ((this._size - index) | 0));
22100                }
22101                this._items[System.Array.index(this._size, this._items)] = H5.getDefaultValue(T);
22102                this._version = (this._version + 1) | 0;
22103            },
22104            RemoveRange: function (index, count) {
22105                if (index < 0) {
22106                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22107                }
22108
22109                if (count < 0) {
22110                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
22111                }
22112
22113                if (((this._size - index) | 0) < count) {
22114                    throw new System.ArgumentException.ctor();
22115                }
22116
22117                if (count > 0) {
22118                    var i = this._size;
22119                    this._size = (this._size - count) | 0;
22120                    if (index < this._size) {
22121                        System.Array.copy(this._items, ((index + count) | 0), this._items, index, ((this._size - index) | 0));
22122                    }
22123                    System.Array.fill(this._items, function () {
22124                        return H5.getDefaultValue(T);
22125                    }, this._size, count);
22126                    this._version = (this._version + 1) | 0;
22127                }
22128            },
22129            Reverse: function () {
22130                this.Reverse$1(0, this.Count);
22131            },
22132            Reverse$1: function (index, count) {
22133                if (index < 0) {
22134                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22135                }
22136
22137                if (count < 0) {
22138                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
22139                }
22140
22141                if (((this._size - index) | 0) < count) {
22142                    throw new System.ArgumentException.ctor();
22143                }
22144                System.Array.reverse(this._items, index, count);
22145                this._version = (this._version + 1) | 0;
22146            },
22147            Sort: function () {
22148                this.Sort$3(0, this.Count, null);
22149            },
22150            Sort$1: function (comparer) {
22151                this.Sort$3(0, this.Count, comparer);
22152            },
22153            Sort$3: function (index, count, comparer) {
22154                if (index < 0) {
22155                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
22156                }
22157
22158                if (count < 0) {
22159                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
22160                }
22161
22162                if (((this._size - index) | 0) < count) {
22163                    throw new System.ArgumentException.ctor();
22164                }
22165
22166                System.Array.sort(this._items, index, count, comparer);
22167                this._version = (this._version + 1) | 0;
22168            },
22169            Sort$2: function (comparison) {
22170                if (H5.staticEquals(comparison, null)) {
22171                    throw new System.ArgumentNullException.$ctor1("comparison");
22172                }
22173
22174                if (this._size > 0) {
22175                    if (this._items.length === this._size) {
22176                        System.Array.sort(this._items, comparison);
22177                    } else {
22178                        var newItems = System.Array.init(this._size, function (){
22179                            return H5.getDefaultValue(T);
22180                        }, T);
22181                        System.Array.copy(this._items, 0, newItems, 0, this._size);
22182                        System.Array.sort(newItems, comparison);
22183                        System.Array.copy(newItems, 0, this._items, 0, this._size);
22184                    }
22185                }
22186            },
22187            ToArray: function () {
22188
22189                var array = System.Array.init(this._size, function (){
22190                    return H5.getDefaultValue(T);
22191                }, T);
22192                System.Array.copy(this._items, 0, array, 0, this._size);
22193                return array;
22194            },
22195            TrimExcess: function () {
22196                var threshold = H5.Int.clip32(this._items.length * 0.9);
22197                if (this._size < threshold) {
22198                    this.Capacity = this._size;
22199                }
22200            },
22201            TrueForAll: function (match) {
22202                if (H5.staticEquals(match, null)) {
22203                    throw new System.ArgumentNullException.$ctor1("match");
22204                }
22205
22206                for (var i = 0; i < this._size; i = (i + 1) | 0) {
22207                    if (!match(this._items[System.Array.index(i, this._items)])) {
22208                        return false;
22209                    }
22210                }
22211                return true;
22212            },
22213            toJSON: function () {
22214                var newItems = System.Array.init(this._size, function (){
22215                    return H5.getDefaultValue(T);
22216                }, T);
22217                if (this._size > 0) {
22218                    System.Array.copy(this._items, 0, newItems, 0, this._size);
22219                }
22220
22221                return newItems;
22222            }
22223        }
22224    }; });
22225
22226    // @source KeyNotFoundException.js
22227
22228    H5.define("System.Collections.Generic.KeyNotFoundException", {
22229        inherits: [System.SystemException],
22230        ctors: {
22231            ctor: function () {
22232                this.$initialize();
22233                System.SystemException.$ctor1.call(this, "The given key was not present in the dictionary.");
22234                this.HResult = -2146232969;
22235            },
22236            $ctor1: function (message) {
22237                this.$initialize();
22238                System.SystemException.$ctor1.call(this, message);
22239                this.HResult = -2146232969;
22240            },
22241            $ctor2: function (message, innerException) {
22242                this.$initialize();
22243                System.SystemException.$ctor2.call(this, message, innerException);
22244                this.HResult = -2146232969;
22245            }
22246        }
22247    });
22248
22249    // @source List.js
22250
22251    System.Collections.Generic.List$1.getElementType = function (type) {
22252        var interfaceType;
22253
22254        if (System.String.startsWith(type.$$name, "System.Collections.Generic.IList")) {
22255            interfaceType = type;
22256        } else {
22257            var interfaces = H5.Reflection.getInterfaces(type);
22258
22259            for (var j = 0; j < interfaces.length; j++) {
22260                if (System.String.startsWith(interfaces[j].$$name, "System.Collections.Generic.IList")) {
22261                    interfaceType = interfaces[j];
22262
22263                    break;
22264                }
22265            }
22266        }
22267
22268        return interfaceType ? H5.Reflection.getGenericArguments(interfaceType)[0] : null;
22269    };
22270
22271    // @source CharEnumerator.js
22272
22273    H5.define("System.CharEnumerator", {
22274        inherits: [System.Collections.IEnumerator,System.Collections.Generic.IEnumerator$1(System.Char),System.IDisposable,System.ICloneable],
22275        fields: {
22276            _str: null,
22277            _index: 0,
22278            _currentElement: 0
22279        },
22280        props: {
22281            System$Collections$IEnumerator$Current: {
22282                get: function () {
22283                    return H5.box(this.Current, System.Char, String.fromCharCode, System.Char.getHashCode);
22284                }
22285            },
22286            Current: {
22287                get: function () {
22288                    if (this._index === -1) {
22289                        throw new System.InvalidOperationException.$ctor1("Enumeration has not started. Call MoveNext.");
22290                    }
22291                    if (this._index >= this._str.length) {
22292                        throw new System.InvalidOperationException.$ctor1("Enumeration already finished.");
22293                    }
22294                    return this._currentElement;
22295                }
22296            }
22297        },
22298        alias: [
22299            "clone", "System$ICloneable$clone",
22300            "moveNext", "System$Collections$IEnumerator$moveNext",
22301            "Dispose", "System$IDisposable$Dispose",
22302            "Current", ["System$Collections$Generic$IEnumerator$1$System$Char$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"],
22303            "reset", "System$Collections$IEnumerator$reset"
22304        ],
22305        ctors: {
22306            ctor: function (str) {
22307                this.$initialize();
22308                this._str = str;
22309                this._index = -1;
22310            }
22311        },
22312        methods: {
22313            clone: function () {
22314                return H5.clone(this);
22315            },
22316            moveNext: function () {
22317                if (this._index < (((this._str.length - 1) | 0))) {
22318                    this._index = (this._index + 1) | 0;
22319                    this._currentElement = this._str.charCodeAt(this._index);
22320                    return true;
22321                } else {
22322                    this._index = this._str.length;
22323                }
22324                return false;
22325            },
22326            Dispose: function () {
22327                if (this._str != null) {
22328                    this._index = this._str.length;
22329                }
22330                this._str = null;
22331            },
22332            reset: function () {
22333                this._currentElement = 0;
22334                this._index = -1;
22335            }
22336        }
22337    });
22338
22339    // @source Task.js
22340
22341    H5.define("System.Threading.Tasks.Task", {
22342        inherits: [System.IDisposable, System.IAsyncResult],
22343
22344        config: {
22345            alias: [
22346                "dispose", "System$IDisposable$Dispose",
22347                "AsyncState", "System$IAsyncResult$AsyncState",
22348                "CompletedSynchronously", "System$IAsyncResult$CompletedSynchronously",
22349                "IsCompleted", "System$IAsyncResult$IsCompleted"
22350            ],
22351
22352            properties: {
22353                IsCompleted: {
22354                    get: function () {
22355                        return this.isCompleted();
22356                    }
22357                }
22358            }
22359        },
22360
22361        ctor: function (action, state) {
22362            this.$initialize();
22363            this.action = action;
22364            this.state = state;
22365            this.AsyncState = state;
22366            this.CompletedSynchronously = false;
22367            this.exception = null;
22368            this.status = System.Threading.Tasks.TaskStatus.created;
22369            this.callbacks = [];
22370            this.result = null;
22371        },
22372
22373        statics: {
22374            queue: [],
22375
22376            runQueue: function () {
22377                var queue = System.Threading.Tasks.Task.queue.slice(0);
22378                System.Threading.Tasks.Task.queue = [];
22379
22380                for (var i = 0; i < queue.length; i++) {
22381                    queue[i]();
22382                }
22383            },
22384
22385            schedule: function (fn) {
22386                System.Threading.Tasks.Task.queue.push(fn);
22387                H5.setImmediate(System.Threading.Tasks.Task.runQueue);
22388            },
22389
22390            delay: function (delay, state) {
22391                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22392                    token,
22393                    cancelCallback = false;
22394
22395                if (H5.is(state, System.Threading.CancellationToken)) {
22396                    token = state;
22397                    state = undefined;
22398                }
22399
22400                if (token) {
22401                    token.cancelWasRequested = function () {
22402                        if (!cancelCallback) {
22403                            cancelCallback = true;
22404                            clearTimeout(clear);
22405
22406                            tcs.setCanceled();
22407                        }
22408                    };
22409                }
22410
22411                var ms = delay;
22412                if (H5.is(delay, System.TimeSpan)) {
22413                    ms = delay.getTotalMilliseconds();
22414                }
22415
22416                var clear = setTimeout(function () {
22417                    if (!cancelCallback) {
22418                        cancelCallback = true;
22419                        tcs.setResult(state);
22420                    }
22421                }, ms);
22422
22423                if (token && token.getIsCancellationRequested()) {
22424                    H5.setImmediate(token.cancelWasRequested);
22425                }
22426
22427                return tcs.task;
22428            },
22429
22430            fromResult: function (result, T) {
22431                var t = new (System.Threading.Tasks.Task$1(T || System.Object))();
22432
22433                t.status = System.Threading.Tasks.TaskStatus.ranToCompletion;
22434                t.result = result;
22435
22436                return t;
22437            },
22438
22439            run: function (fn) {
22440                var tcs = new System.Threading.Tasks.TaskCompletionSource();
22441
22442                System.Threading.Tasks.Task.schedule(function () {
22443                    try {
22444                        var result = fn();
22445
22446                        if (H5.is(result, System.Threading.Tasks.Task)) {
22447                            result.continueWith(function () {
22448                                if (result.isFaulted() || result.isCanceled()) {
22449                                    tcs.setException(result.exception.innerExceptions.Count > 0 ? result.exception.innerExceptions.getItem(0) : result.exception);
22450                                } else {
22451                                    tcs.setResult(result.getAwaitedResult());
22452                                }
22453                            });
22454                        } else {
22455                            tcs.setResult(result);
22456                        }
22457                    } catch (e) {
22458                        tcs.setException(System.Exception.create(e));
22459                    }
22460                });
22461
22462                return tcs.task;
22463            },
22464
22465            whenAll: function (tasks) {
22466                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22467                    result,
22468                    executing,
22469                    cancelled = false,
22470                    exceptions = [],
22471                    i;
22472
22473                if (H5.is(tasks, System.Collections.IEnumerable)) {
22474                    tasks = H5.toArray(tasks);
22475                } else if (!H5.isArray(tasks)) {
22476                    tasks = Array.prototype.slice.call(arguments, 0);
22477                }
22478
22479                if (tasks.length === 0) {
22480                    tcs.setResult([]);
22481
22482                    return tcs.task;
22483                }
22484
22485                executing = tasks.length;
22486                result = new Array(tasks.length);
22487
22488                for (i = 0; i < tasks.length; i++) {
22489                    (function (i) {
22490                        tasks[i].continueWith(function (t) {
22491                            switch (t.status) {
22492                                case System.Threading.Tasks.TaskStatus.ranToCompletion:
22493                                    result[i] = t.getResult();
22494                                    break;
22495                                case System.Threading.Tasks.TaskStatus.canceled:
22496                                    cancelled = true;
22497                                    break;
22498                                case System.Threading.Tasks.TaskStatus.faulted:
22499                                    System.Array.addRange(exceptions, t.exception.innerExceptions);
22500                                    break;
22501                                default:
22502                                    throw new System.InvalidOperationException.$ctor1("Invalid task status: " + t.status);
22503                            }
22504
22505                            if (--executing === 0) {
22506                                if (exceptions.length > 0) {
22507                                    tcs.setException(exceptions);
22508                                } else if (cancelled) {
22509                                    tcs.setCanceled();
22510                                } else {
22511                                    tcs.setResult(result);
22512                                }
22513                            }
22514                        });
22515                    })(i);
22516                }
22517
22518                return tcs.task;
22519            },
22520
22521            whenAny: function (tasks) {
22522                if (H5.is(tasks, System.Collections.IEnumerable)) {
22523                    tasks = H5.toArray(tasks);
22524                } else if (!H5.isArray(tasks)) {
22525                    tasks = Array.prototype.slice.call(arguments, 0);
22526                }
22527
22528                if (!tasks.length) {
22529                    throw new System.ArgumentException.$ctor1("At least one task is required");
22530                }
22531
22532                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22533                    i;
22534
22535                for (i = 0; i < tasks.length; i++) {
22536                    tasks[i].continueWith(function (t) {
22537                        switch (t.status) {
22538                            case System.Threading.Tasks.TaskStatus.ranToCompletion:
22539                                tcs.trySetResult(t);
22540                                break;
22541                            case System.Threading.Tasks.TaskStatus.canceled:
22542                            case System.Threading.Tasks.TaskStatus.faulted:
22543                                tcs.trySetException(t.exception.innerExceptions);
22544                                break;
22545                            default:
22546                                throw new System.InvalidOperationException.$ctor1("Invalid task status: " + t.status);
22547                        }
22548                    });
22549                }
22550
22551                return tcs.task;
22552            },
22553
22554            fromCallback: function (target, method) {
22555                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22556                    args = Array.prototype.slice.call(arguments, 2),
22557                    callback;
22558
22559                callback = function (value) {
22560                    tcs.setResult(value);
22561                };
22562
22563                args.push(callback);
22564
22565                target[method].apply(target, args);
22566
22567                return tcs.task;
22568            },
22569
22570            fromCallbackResult: function (target, method, resultHandler) {
22571                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22572                    args = Array.prototype.slice.call(arguments, 3),
22573                    callback;
22574
22575                callback = function (value) {
22576                    tcs.setResult(value);
22577                };
22578
22579                resultHandler(args, callback);
22580
22581                target[method].apply(target, args);
22582
22583                return tcs.task;
22584            },
22585
22586            fromCallbackOptions: function (target, method, name) {
22587                var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22588                    args = Array.prototype.slice.call(arguments, 3),
22589                    callback;
22590
22591                callback = function (value) {
22592                    tcs.setResult(value);
22593                };
22594
22595                args[0] = args[0] || {};
22596                args[0][name] = callback;
22597
22598                target[method].apply(target, args);
22599
22600                return tcs.task;
22601            },
22602
22603            fromPromise: function (promise, handler, errorHandler, progressHandler) {
22604                var tcs = new System.Threading.Tasks.TaskCompletionSource();
22605
22606                if (!promise.then) {
22607                    promise = promise.promise();
22608                }
22609
22610                if (typeof (handler) === 'number') {
22611                    handler = (function (i) {
22612                        return function () {
22613                            return arguments[i >= 0 ? i : (arguments.length + i)];
22614                        };
22615                    })(handler);
22616                } else if (typeof (handler) !== 'function') {
22617                    handler = function () {
22618                        return Array.prototype.slice.call(arguments, 0);
22619                    };
22620                }
22621
22622                promise.then(function () {
22623                    tcs.setResult(handler ? handler.apply(null, arguments) : Array.prototype.slice.call(arguments, 0));
22624                }, function () {
22625                    tcs.setException(errorHandler ? errorHandler.apply(null, arguments) : new H5.PromiseException(Array.prototype.slice.call(arguments, 0)));
22626                }, progressHandler);
22627
22628                return tcs.task;
22629            }
22630        },
22631
22632        getException: function () {
22633            return this.isCanceled() ? null : this.exception;
22634        },
22635
22636        waitt: function (timeout, token) {
22637            var ms = timeout,
22638                tcs = new System.Threading.Tasks.TaskCompletionSource(),
22639                cancelCallback = false;
22640
22641            if (token) {
22642                token.cancelWasRequested = function () {
22643                    if (!cancelCallback) {
22644                        cancelCallback = true;
22645                        clearTimeout(clear);
22646                        tcs.setException(new System.OperationCanceledException.$ctor1(token));
22647                    }
22648                };
22649            }
22650
22651            if (H5.is(timeout, System.TimeSpan)) {
22652                ms = timeout.getTotalMilliseconds();
22653            }
22654
22655            var clear = setTimeout(function () {
22656                cancelCallback = true;
22657                tcs.setResult(false);
22658            }, ms);
22659
22660            this.continueWith(function () {
22661                clearTimeout(clear);
22662                if (!cancelCallback) {
22663                    cancelCallback = true;
22664                    tcs.setResult(true);
22665                }
22666            })
22667
22668            return tcs.task;
22669        },
22670
22671        wait: function (token) {
22672            var me = this,
22673                tcs = new System.Threading.Tasks.TaskCompletionSource(),
22674                complete = false;
22675
22676            if (token) {
22677                token.cancelWasRequested = function () {
22678                    if (!complete) {
22679                        complete = true;
22680                        tcs.setException(new System.OperationCanceledException.$ctor1(token));
22681                    }
22682                };
22683            }
22684
22685            this.continueWith(function () {
22686                if (!complete) {
22687                    complete = true;
22688                    if (me.isFaulted() || me.isCanceled()) {
22689                        tcs.setException(me.exception);
22690                    } else {
22691                        tcs.setResult();
22692                    }
22693                }
22694            })
22695
22696            return tcs.task;
22697        },
22698
22699        c: function (continuationAction) {
22700            if (this.isCompleted()) {
22701                System.Threading.Tasks.Task.queue.push(continuationAction);
22702                System.Threading.Tasks.Task.runQueue();
22703            } else {
22704                this.callbacks.push(continuationAction);
22705            }
22706        },
22707
22708        continue: function (continuationAction) {
22709            if (this.isCompleted()) {
22710                System.Threading.Tasks.Task.queue.push(continuationAction);
22711                System.Threading.Tasks.Task.runQueue();
22712            } else {
22713                this.callbacks.push(continuationAction);
22714            }
22715        },
22716
22717        continueWith: function (continuationAction, raise) {
22718            var tcs = new System.Threading.Tasks.TaskCompletionSource(),
22719                me = this,
22720                fn = raise ? function () {
22721                    tcs.setResult(continuationAction(me));
22722                } : function () {
22723                    try {
22724                        tcs.setResult(continuationAction(me));
22725                    } catch (e) {
22726                        tcs.setException(System.Exception.create(e));
22727                    }
22728                };
22729
22730            if (this.isCompleted()) {
22731                //System.Threading.Tasks.Task.schedule(fn);
22732                System.Threading.Tasks.Task.queue.push(fn);
22733                System.Threading.Tasks.Task.runQueue();
22734            } else {
22735                this.callbacks.push(fn);
22736            }
22737
22738            return tcs.task;
22739        },
22740
22741        start: function () {
22742            if (this.status !== System.Threading.Tasks.TaskStatus.created) {
22743                throw new System.InvalidOperationException.$ctor1("Task was already started.");
22744            }
22745
22746            var me = this;
22747
22748            this.status = System.Threading.Tasks.TaskStatus.running;
22749
22750            System.Threading.Tasks.Task.schedule(function () {
22751                try {
22752                    var result = me.action(me.state);
22753
22754                    delete me.action;
22755                    delete me.state;
22756
22757                    me.complete(result);
22758                } catch (e) {
22759                    me.fail(new System.AggregateException(null, [System.Exception.create(e)]));
22760                }
22761            });
22762        },
22763
22764        runCallbacks: function () {
22765            var me = this;
22766
22767            for (var i = 0; i < me.callbacks.length; i++) {
22768                me.callbacks[i](me);
22769            }
22770
22771            delete me.callbacks;
22772        },
22773
22774        complete: function (result) {
22775            if (this.isCompleted()) {
22776                return false;
22777            }
22778
22779            this.result = result;
22780            this.status = System.Threading.Tasks.TaskStatus.ranToCompletion;
22781            this.runCallbacks();
22782
22783            return true;
22784        },
22785
22786        fail: function (error) {
22787            if (this.isCompleted()) {
22788                return false;
22789            }
22790
22791            this.exception = error;
22792            this.status = this.exception.hasTaskCanceledException && this.exception.hasTaskCanceledException() ? System.Threading.Tasks.TaskStatus.canceled : System.Threading.Tasks.TaskStatus.faulted;
22793            this.runCallbacks();
22794
22795            return true;
22796        },
22797
22798        cancel: function (error) {
22799            if (this.isCompleted()) {
22800                return false;
22801            }
22802
22803            this.exception = error || new System.AggregateException(null, [new System.Threading.Tasks.TaskCanceledException.$ctor3(this)]);
22804            this.status = System.Threading.Tasks.TaskStatus.canceled;
22805            this.runCallbacks();
22806
22807            return true;
22808        },
22809
22810        isCanceled: function () {
22811            return this.status === System.Threading.Tasks.TaskStatus.canceled;
22812        },
22813
22814        isCompleted: function () {
22815            return this.status === System.Threading.Tasks.TaskStatus.ranToCompletion || this.status === System.Threading.Tasks.TaskStatus.canceled || this.status === System.Threading.Tasks.TaskStatus.faulted;
22816        },
22817
22818        isC: function () {
22819            return this.status === System.Threading.Tasks.TaskStatus.ranToCompletion || this.status === System.Threading.Tasks.TaskStatus.canceled || this.status === System.Threading.Tasks.TaskStatus.faulted;
22820        },
22821
22822        isFaulted: function () {
22823            return this.status === System.Threading.Tasks.TaskStatus.faulted;
22824        },
22825
22826        _getResult: function (awaiting) {
22827            switch (this.status) {
22828                case System.Threading.Tasks.TaskStatus.ranToCompletion:
22829                    return this.result;
22830                case System.Threading.Tasks.TaskStatus.canceled:
22831                    if (this.exception && this.exception.innerExceptions) {
22832                        throw awaiting ? (this.exception.innerExceptions.Count > 0 ? this.exception.innerExceptions.getItem(0) : null) : this.exception;
22833                    }
22834
22835                    var ex = new System.Threading.Tasks.TaskCanceledException.$ctor3(this);
22836                    throw awaiting ? ex : new System.AggregateException(null, [ex]);
22837                case System.Threading.Tasks.TaskStatus.faulted:
22838                    throw awaiting ? (this.exception.innerExceptions.Count > 0 ? this.exception.innerExceptions.getItem(0) : null) : this.exception;
22839                default:
22840                    throw new System.InvalidOperationException.$ctor1("Task is not yet completed.");
22841            }
22842        },
22843
22844        getResult: function () {
22845            return this._getResult(false);
22846        },
22847
22848        dispose: function () {},
22849
22850        getAwaiter: function () {
22851            return this;
22852        },
22853
22854        getAwaitedResult: function () {
22855            return this._getResult(true);
22856        },
22857
22858        gAR: function () {
22859            return this._getResult(true);
22860        }
22861
22862    });
22863
22864    H5.define("System.Threading.Tasks.Task$1", function (T) {
22865        return {
22866            inherits: [System.Threading.Tasks.Task],
22867            ctor: function (action, state) {
22868                this.$initialize();
22869                System.Threading.Tasks.Task.ctor.call(this, action, state);
22870            }
22871        };
22872    });
22873
22874    H5.define("System.Threading.Tasks.TaskStatus", {
22875        $kind: "enum",
22876        $statics: {
22877            created: 0,
22878            waitingForActivation: 1,
22879            waitingToRun: 2,
22880            running: 3,
22881            waitingForChildrenToComplete: 4,
22882            ranToCompletion: 5,
22883            canceled: 6,
22884            faulted: 7
22885        }
22886    });
22887
22888    H5.define("System.Threading.Tasks.TaskCompletionSource", {
22889        ctor: function (state) {
22890            this.$initialize();
22891            this.task = new System.Threading.Tasks.Task(null, state);
22892            this.task.status = System.Threading.Tasks.TaskStatus.running;
22893        },
22894
22895        setCanceled: function () {
22896            if (!this.task.cancel()) {
22897                throw new System.InvalidOperationException.$ctor1("Task was already completed.");
22898            }
22899        },
22900
22901        sR: function (result) {
22902            if (!this.task.complete(result)) {
22903                throw new System.InvalidOperationException.$ctor1("Task was already completed.");
22904            }
22905        },
22906
22907        setResult: function (result) {
22908            if (!this.task.complete(result)) {
22909                throw new System.InvalidOperationException.$ctor1("Task was already completed.");
22910            }
22911        },
22912
22913        setException: function (exception) {
22914            if (!this.trySetException(exception)) {
22915                throw new System.InvalidOperationException.$ctor1("Task was already completed.");
22916            }
22917        },
22918
22919        sE: function (exception) {
22920            if (!this.trySetException(exception)) {
22921                throw new System.InvalidOperationException.$ctor1("Task was already completed.");
22922            }
22923        },
22924
22925        trySetCanceled: function () {
22926            return this.task.cancel();
22927        },
22928
22929        trySetResult: function (result) {
22930            return this.task.complete(result);
22931        },
22932
22933        trySetException: function (exception) {
22934            if (H5.is(exception, System.Exception)) {
22935                exception = [exception];
22936            }
22937
22938            exception = new System.AggregateException(null, exception);
22939
22940            if (exception.hasTaskCanceledException()) {
22941                return this.task.cancel(exception);
22942            }
22943
22944            return this.task.fail(exception);
22945        }
22946    });
22947
22948    H5.define("System.Threading.CancellationTokenSource", {
22949        inherits: [System.IDisposable],
22950
22951        config: {
22952            alias: [
22953                "dispose", "System$IDisposable$Dispose"
22954            ]
22955        },
22956
22957        ctor: function (delay) {
22958            this.$initialize();
22959            this.timeout = typeof delay === "number" && delay >= 0 ? setTimeout(H5.fn.bind(this, this.cancel), delay, -1) : null;
22960            this.isCancellationRequested = false;
22961            this.token = new System.Threading.CancellationToken(this);
22962            this.handlers = [];
22963        },
22964
22965        cancel: function (throwFirst) {
22966            if (this.isCancellationRequested) {
22967                return;
22968            }
22969
22970            this.isCancellationRequested = true;
22971
22972            var x = [],
22973                h = this.handlers;
22974
22975            this.clean();
22976            this.token.cancelWasRequested();
22977
22978            for (var i = 0; i < h.length; i++) {
22979                try {
22980                    h[i].f(h[i].s);
22981                } catch (ex) {
22982                    if (throwFirst && throwFirst !== -1) {
22983                        throw ex;
22984                    }
22985
22986                    x.push(ex);
22987                }
22988            }
22989
22990            if (x.length > 0 && throwFirst !== -1) {
22991                throw new System.AggregateException(null, x);
22992            }
22993        },
22994
22995        cancelAfter: function (delay) {
22996            if (this.isCancellationRequested) {
22997                return;
22998            }
22999
23000            if (this.timeout) {
23001                clearTimeout(this.timeout);
23002            }
23003
23004            this.timeout = setTimeout(H5.fn.bind(this, this.cancel), delay, -1);
23005        },
23006
23007        register: function (f, s) {
23008            if (this.isCancellationRequested) {
23009                f(s);
23010
23011                return new System.Threading.CancellationTokenRegistration();
23012            } else {
23013                var o = {
23014                    f: f,
23015                    s: s
23016                };
23017
23018                this.handlers.push(o);
23019
23020                return new System.Threading.CancellationTokenRegistration(this, o);
23021            }
23022        },
23023
23024        deregister: function (o) {
23025            var ix = this.handlers.indexOf(o);
23026
23027            if (ix >= 0) {
23028                this.handlers.splice(ix, 1);
23029            }
23030        },
23031
23032        dispose: function () {
23033            this.clean();
23034        },
23035
23036        clean: function () {
23037            if (this.timeout) {
23038                clearTimeout(this.timeout);
23039            }
23040
23041            this.timeout = null;
23042            this.handlers = [];
23043
23044            if (this.links) {
23045                for (var i = 0; i < this.links.length; i++) {
23046                    this.links[i].dispose();
23047                }
23048
23049                this.links = null;
23050            }
23051        },
23052
23053        statics: {
23054            createLinked: function () {
23055                var cts = new System.Threading.CancellationTokenSource();
23056
23057                cts.links = [];
23058
23059                var d = H5.fn.bind(cts, cts.cancel);
23060
23061                for (var i = 0; i < arguments.length; i++) {
23062                    cts.links.push(arguments[i].register(d));
23063                }
23064
23065                return cts;
23066            }
23067        }
23068    });
23069
23070    H5.define("System.Threading.CancellationToken", {
23071         $kind: "struct",
23072
23073        ctor: function (source) {
23074            this.$initialize();
23075
23076            if (!H5.is(source, System.Threading.CancellationTokenSource)) {
23077                source = source ? System.Threading.CancellationToken.sourceTrue : System.Threading.CancellationToken.sourceFalse;
23078            }
23079
23080            this.source = source;
23081        },
23082
23083        cancelWasRequested: function () {
23084
23085        },
23086
23087        getCanBeCanceled: function () {
23088            return !this.source.uncancellable;
23089        },
23090
23091        getIsCancellationRequested: function () {
23092            return this.source.isCancellationRequested;
23093        },
23094
23095        throwIfCancellationRequested: function () {
23096            if (this.source.isCancellationRequested) {
23097                throw new System.OperationCanceledException.$ctor1(this);
23098            }
23099        },
23100
23101        register: function (cb, s) {
23102            return this.source.register(cb, s);
23103        },
23104
23105        getHashCode: function () {
23106            return H5.getHashCode(this.source);
23107        },
23108
23109        equals: function (other) {
23110            return other.source === this.source;
23111        },
23112
23113        equalsT: function (other) {
23114            return other.source === this.source;
23115        },
23116
23117        statics: {
23118            sourceTrue: {
23119                isCancellationRequested: true,
23120                register: function (f, s) {
23121                    f(s);
23122
23123                    return new System.Threading.CancellationTokenRegistration();
23124                }
23125            },
23126            sourceFalse: {
23127                uncancellable: true,
23128                isCancellationRequested: false,
23129                register: function () {
23130                    return new System.Threading.CancellationTokenRegistration();
23131                }
23132            },
23133            getDefaultValue: function () {
23134                return new System.Threading.CancellationToken();
23135            }
23136        }
23137    });
23138
23139    System.Threading.CancellationToken.none = new System.Threading.CancellationToken();
23140
23141    H5.define("System.Threading.CancellationTokenRegistration", {
23142        inherits: function () {
23143            return [System.IDisposable, System.IEquatable$1(System.Threading.CancellationTokenRegistration)];
23144        },
23145
23146        $kind: "struct",
23147
23148        config: {
23149            alias: [
23150                "dispose", "System$IDisposable$Dispose"
23151            ]
23152        },
23153
23154        ctor: function (cts, o) {
23155            this.$initialize();
23156            this.cts = cts;
23157            this.o = o;
23158        },
23159
23160        dispose: function () {
23161            if (this.cts) {
23162                this.cts.deregister(this.o);
23163                this.cts = this.o = null;
23164            }
23165        },
23166
23167        equalsT: function (o) {
23168            return this === o;
23169        },
23170
23171        equals: function (o) {
23172            return this === o;
23173        },
23174
23175        statics: {
23176            getDefaultValue: function () {
23177                return new System.Threading.CancellationTokenRegistration();
23178            }
23179        }
23180    });
23181
23182    // @source Validation.js
23183
23184    var validation = {
23185        isNull: function (value) {
23186            return !H5.isDefined(value, true);
23187        },
23188
23189        isEmpty: function (value) {
23190            return value == null || value.length === 0 || H5.is(value, System.Collections.ICollection) ? value.getCount() === 0 : false;
23191        },
23192
23193        isNotEmptyOrWhitespace: function (value) {
23194            return H5.isDefined(value, true) && !(/^$|\s+/.test(value));
23195        },
23196
23197        isNotNull: function (value) {
23198            return H5.isDefined(value, true);
23199        },
23200
23201        isNotEmpty: function (value) {
23202            return !H5.Validation.isEmpty(value);
23203        },
23204
23205        email: function (value) {
23206            var re = /^(")?(?:[^\."])(?:(?:[\.])?(?:[\w\-!#$%&'*+/=?^_`{|}~]))*\1@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/;
23207
23208            return re.test(value);
23209        },
23210
23211        url: function (value) {
23212            var re = /(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:\.\d{1,3}){3})(?!(?:\.\d{1,3}){2})(?!\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/;
23213
23214            return re.test(value);
23215        },
23216
23217        alpha: function (value) {
23218            var re = /^[a-zA-Z_]+$/;
23219
23220            return re.test(value);
23221        },
23222
23223        alphaNum: function (value) {
23224            var re = /^[a-zA-Z_]+$/;
23225
23226            return re.test(value);
23227        },
23228
23229        creditCard: function (value, type) {
23230            var re,
23231                checksum,
23232                i,
23233                digit,
23234                notype = false;
23235
23236            if (type === "Visa") {
23237                // Visa: length 16, prefix 4, dashes optional.
23238                re = /^4\d{3}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/;
23239            } else if (type === "MasterCard") {
23240                // Mastercard: length 16, prefix 51-55, dashes optional.
23241                re = /^5[1-5]\d{2}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/;
23242            } else if (type === "Discover") {
23243                // Discover: length 16, prefix 6011, dashes optional.
23244                re = /^6011[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/;
23245            } else if (type === "AmericanExpress") {
23246                // American Express: length 15, prefix 34 or 37.
23247                re = /^3[4,7]\d{13}$/;
23248            } else if (type === "DinersClub") {
23249                // Diners: length 14, prefix 30, 36, or 38.
23250                re = /^(3[0,6,8]\d{12})|(5[45]\d{14})$/;
23251            } else {
23252                // Basing min and max length on
23253                // http://developer.ean.com/general_info/Valid_Credit_Card_Types
23254                if (!value || value.length < 13 || value.length > 19) {
23255                    return false;
23256                }
23257
23258                re = /[^0-9 \-]+/;
23259                notype = true;
23260            }
23261
23262            if (!re.test(value)) {
23263                return false;
23264            }
23265
23266            // Remove all dashes for the checksum checks to eliminate negative numbers
23267            value = value.split(notype ? "-" : /[- ]/).join("");
23268
23269            // Checksum ("Mod 10")
23270            // Add even digits in even length strings or odd digits in odd length strings.
23271            checksum = 0;
23272
23273            for (i = (2 - (value.length % 2)); i <= value.length; i += 2) {
23274                checksum += parseInt(value.charAt(i - 1));
23275            }
23276
23277            // Analyze odd digits in even length strings or even digits in odd length strings.
23278            for (i = (value.length % 2) + 1; i < value.length; i += 2) {
23279                digit = parseInt(value.charAt(i - 1)) * 2;
23280
23281                if (digit < 10) {
23282                    checksum += digit;
23283                } else {
23284                    checksum += (digit - 9);
23285                }
23286            }
23287
23288            return (checksum % 10) === 0;
23289        }
23290    };
23291
23292    H5.Validation = validation;
23293
23294    // @source Attribute.js
23295
23296    H5.define("System.Attribute", {
23297        statics: {
23298            getCustomAttributes: function (o, t, b) {
23299                if (o == null) {
23300                    throw new System.ArgumentNullException.$ctor1("element");
23301                }
23302
23303                if (t == null) {
23304                    throw new System.ArgumentNullException.$ctor1("attributeType");
23305                }
23306
23307                var r = o.at || [];
23308
23309                if (o.ov === true) {
23310                    var baseType = H5.Reflection.getBaseType(o.td),
23311                        baseAttrs = [],
23312                        baseMember = null;
23313
23314                    while (baseType != null && baseMember == null) {
23315                        baseMember = H5.Reflection.getMembers(baseType, 31, 28, o.n);
23316
23317                        if (baseMember.length == 0) {
23318                            var newBaseType = H5.Reflection.getBaseType(baseType);
23319
23320                            if (newBaseType != baseType) {
23321                                baseType = newBaseType;
23322                            }
23323
23324                            baseMember = null;
23325                        } else {
23326                            baseMember = baseMember[0];
23327                        }
23328                    }
23329
23330                    if (baseMember != null) {
23331                        baseAttrs = System.Attribute.getCustomAttributes(baseMember, t);
23332                    }
23333
23334                    for (var i = 0; i < baseAttrs.length; i++) {
23335                        var baseAttr = baseAttrs[i],
23336                            attrType = H5.getType(baseAttr),
23337                            meta = H5.getMetadata(attrType);
23338
23339                        if (meta && meta.am || !r.some(function (a) { return H5.is(a, t); })) {
23340                            r.push(baseAttr);
23341                        }
23342                    }
23343                }
23344
23345                if (!t) {
23346                    return r;
23347                }
23348
23349                return r.filter(function (a) { return H5.is(a, t); });
23350            },
23351
23352            getCustomAttributes$1: function (a, t, b) {
23353                if (a == null) {
23354                    throw new System.ArgumentNullException.$ctor1("element");
23355                }
23356
23357                if (t == null) {
23358                    throw new System.ArgumentNullException.$ctor1("attributeType");
23359                }
23360
23361                return a.getCustomAttributes(t || b);
23362            },
23363
23364            isDefined: function (o, t, b) {
23365                var attrs = System.Attribute.getCustomAttributes(o, t, b);
23366
23367                return attrs.length > 0;
23368            }
23369        }
23370    });
23371
23372    // @source SerializableAttribute.js
23373
23374    H5.define("System.SerializableAttribute", {
23375        inherits: [System.Attribute],
23376        ctors: {
23377            ctor: function () {
23378                this.$initialize();
23379                System.Attribute.ctor.call(this);
23380            }
23381        }
23382    });
23383
23384    // @source INotifyPropertyChanged.js
23385
23386    H5.define("System.ComponentModel.INotifyPropertyChanged", {
23387        $kind: "interface"
23388    });
23389
23390    H5.define("System.ComponentModel.PropertyChangedEventArgs", {
23391        ctor: function (propertyName, newValue, oldValue) {
23392            this.$initialize();
23393            this.propertyName = propertyName;
23394            this.newValue = newValue;
23395            this.oldValue = oldValue;
23396        }
23397    });
23398
23399    // @source Convert.js
23400
23401    var scope = {};
23402
23403    scope.convert = {
23404        typeCodes: {
23405            Empty: 0,
23406            Object: 1,
23407            DBNull: 2,
23408            Boolean: 3,
23409            Char: 4,
23410            SByte: 5,
23411            Byte: 6,
23412            Int16: 7,
23413            UInt16: 8,
23414            Int32: 9,
23415            UInt32: 10,
23416            Int64: 11,
23417            UInt64: 12,
23418            Single: 13,
23419            Double: 14,
23420            Decimal: 15,
23421            DateTime: 16,
23422            String: 18
23423        },
23424
23425        convertTypes: [
23426            null,
23427            System.Object,
23428            null,
23429            System.Boolean,
23430            System.Char,
23431            System.SByte,
23432            System.Byte,
23433            System.Int16,
23434            System.UInt16,
23435            System.Int32,
23436            System.UInt32,
23437            System.Int64,
23438            System.UInt64,
23439            System.Single,
23440            System.Double,
23441            System.Decimal,
23442            System.DateTime,
23443            System.Object,
23444            System.String
23445        ],
23446
23447        toBoolean: function (value, formatProvider) {
23448            value = H5.unbox(value, true);
23449
23450            switch (typeof (value)) {
23451                case "boolean":
23452                    return value;
23453
23454                case "number":
23455                    return value !== 0; // non-zero int/float value is always converted to True;
23456
23457                case "string":
23458                    var lowCaseVal = value.toLowerCase().trim();
23459
23460                    if (lowCaseVal === "true") {
23461                        return true;
23462                    } else if (lowCaseVal === "false") {
23463                        return false;
23464                    } else {
23465                        throw new System.FormatException.$ctor1("String was not recognized as a valid Boolean.");
23466                    }
23467
23468                case "object":
23469                    if (value == null) {
23470                        return false;
23471                    }
23472
23473                    if (value instanceof System.Decimal) {
23474                        return !value.isZero();
23475                    }
23476
23477                    if (System.Int64.is64Bit(value)) {
23478                        return value.ne(0);
23479                    }
23480
23481                    break;
23482            }
23483
23484            // TODO: #822 When IConvertible is implemented, try it before throwing InvalidCastEx
23485            var typeCode = scope.internal.suggestTypeCode(value);
23486            scope.internal.throwInvalidCastEx(typeCode, scope.convert.typeCodes.Boolean);
23487
23488            // try converting using IConvertible
23489            return scope.convert.convertToType(scope.convert.typeCodes.Boolean, value, formatProvider || null);
23490        },
23491
23492        toChar: function (value, formatProvider, valueTypeCode) {
23493            var typeCodes = scope.convert.typeCodes,
23494                isChar = H5.is(value, System.Char);
23495
23496            value = H5.unbox(value, true);
23497
23498            if (value instanceof System.Decimal) {
23499                value = value.toFloat();
23500            }
23501
23502            if (value instanceof System.Int64 || value instanceof System.UInt64) {
23503                value = value.toNumber();
23504            }
23505
23506            var type = typeof (value);
23507
23508            valueTypeCode = valueTypeCode || scope.internal.suggestTypeCode(value);
23509
23510            if (valueTypeCode === typeCodes.String && value == null) {
23511                type = "string";
23512            }
23513
23514            if (valueTypeCode !== typeCodes.Object || isChar) {
23515                switch (type) {
23516                    case "boolean":
23517                        scope.internal.throwInvalidCastEx(typeCodes.Boolean, typeCodes.Char);
23518
23519                    case "number":
23520                        var isFloatingType = scope.internal.isFloatingType(valueTypeCode);
23521
23522                        if (isFloatingType || value % 1 !== 0) {
23523                            scope.internal.throwInvalidCastEx(valueTypeCode, typeCodes.Char);
23524                        }
23525
23526                        scope.internal.validateNumberRange(value, typeCodes.Char, true);
23527
23528                        return value;
23529
23530                    case "string":
23531                        if (value == null) {
23532                            throw new System.ArgumentNullException.$ctor1("value");
23533                        }
23534
23535                        if (value.length !== 1) {
23536                            throw new System.FormatException.$ctor1("String must be exactly one character long.");
23537                        }
23538
23539                        return value.charCodeAt(0);
23540                }
23541            }
23542
23543            if (valueTypeCode === typeCodes.Object || type === "object") {
23544                if (value == null) {
23545                    return 0;
23546                }
23547
23548                if (H5.isDate(value)) {
23549                    scope.internal.throwInvalidCastEx(typeCodes.DateTime, typeCodes.Char);
23550                }
23551            }
23552
23553            // TODO: #822 When IConvertible is implemented, try it before throwing InvalidCastEx
23554            scope.internal.throwInvalidCastEx(valueTypeCode, scope.convert.typeCodes.Char);
23555
23556            // try converting using IConvertible
23557            return scope.convert.convertToType(typeCodes.Char, value, formatProvider || null);
23558        },
23559
23560        toSByte: function (value, formatProvider, valueTypeCode) {
23561            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.SByte, valueTypeCode || null);
23562        },
23563
23564        toByte: function (value, formatProvider) {
23565            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Byte);
23566        },
23567
23568        toInt16: function (value, formatProvider) {
23569            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Int16);
23570        },
23571
23572        toUInt16: function (value, formatProvider) {
23573            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.UInt16);
23574        },
23575
23576        toInt32: function (value, formatProvider) {
23577            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Int32);
23578        },
23579
23580        toUInt32: function (value, formatProvider) {
23581            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.UInt32);
23582        },
23583
23584        toInt64: function (value, formatProvider) {
23585            var result = scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Int64);
23586            return new System.Int64(result);
23587        },
23588
23589        toUInt64: function (value, formatProvider) {
23590            var result = scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.UInt64);
23591            return new System.UInt64(result);
23592        },
23593
23594        toSingle: function (value, formatProvider) {
23595            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Single);
23596        },
23597
23598        toDouble: function (value, formatProvider) {
23599            return scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Double);
23600        },
23601
23602        toDecimal: function (value, formatProvider) {
23603            if (value instanceof System.Decimal) {
23604                return value;
23605            }
23606
23607            return new System.Decimal(scope.internal.toNumber(value, formatProvider || null, scope.convert.typeCodes.Decimal));
23608        },
23609
23610        toDateTime: function (value, formatProvider) {
23611            var typeCodes = scope.convert.typeCodes;
23612
23613            value = H5.unbox(value, true);
23614
23615            switch (typeof (value)) {
23616                case "boolean":
23617                    scope.internal.throwInvalidCastEx(typeCodes.Boolean, typeCodes.DateTime);
23618
23619                case "number":
23620                    var fromType = scope.internal.suggestTypeCode(value);
23621                    scope.internal.throwInvalidCastEx(fromType, typeCodes.DateTime);
23622
23623                case "string":
23624                    value = System.DateTime.parse(value, formatProvider || null);
23625
23626                    return value;
23627
23628                case "object":
23629                    if (value == null) {
23630                        return scope.internal.getMinValue(typeCodes.DateTime);
23631                    }
23632
23633                    if (H5.isDate(value)) {
23634                        return value;
23635                    }
23636
23637                    if (value instanceof System.Decimal) {
23638                        scope.internal.throwInvalidCastEx(typeCodes.Decimal, typeCodes.DateTime);
23639                    }
23640
23641                    if (value instanceof System.Int64) {
23642                        scope.internal.throwInvalidCastEx(typeCodes.Int64, typeCodes.DateTime);
23643                    }
23644
23645                    if (value instanceof System.UInt64) {
23646                        scope.internal.throwInvalidCastEx(typeCodes.UInt64, typeCodes.DateTime);
23647                    }
23648
23649                    break;
23650            }
23651
23652            // TODO: #822 When IConvertible is implemented, try it before throwing InvalidCastEx
23653            var valueTypeCode = scope.internal.suggestTypeCode(value);
23654
23655            scope.internal.throwInvalidCastEx(valueTypeCode, scope.convert.typeCodes.DateTime);
23656
23657            // try converting using IConvertible
23658            return scope.convert.convertToType(typeCodes.DateTime, value, formatProvider || null);
23659        },
23660
23661        toString: function (value, formatProvider, valueTypeCode) {
23662            if (value && value.$boxed) {
23663                return value.toString();
23664            }
23665
23666            var typeCodes = scope.convert.typeCodes,
23667                type = typeof (value);
23668
23669            switch (type) {
23670                case "boolean":
23671                    return value ? "True" : "False";
23672
23673                case "number":
23674                    if ((valueTypeCode || null) === typeCodes.Char) {
23675                        return String.fromCharCode(value);
23676                    }
23677
23678                    if (isNaN(value)) {
23679                        return "NaN";
23680                    }
23681
23682                    if (value % 1 !== 0) {
23683                        value = parseFloat(value.toPrecision(15));
23684                    }
23685
23686                    return value.toString();
23687
23688                case "string":
23689                    return value;
23690
23691                case "object":
23692                    if (value == null) {
23693                        return "";
23694                    }
23695
23696                    // If the object has an override to the toString() method,
23697                    // then just return its result
23698                    if (value.toString !== Object.prototype.toString) {
23699                        return value.toString();
23700                    }
23701
23702                    if (H5.isDate(value)) {
23703                        return System.DateTime.format(value, null, formatProvider || null);
23704                    }
23705
23706                    if (value instanceof System.Decimal) {
23707                        if (value.isInteger()) {
23708                            return value.toFixed(0, 4);
23709                        }
23710                        return value.toPrecision(value.precision());
23711                    }
23712
23713                    if (System.Int64.is64Bit(value)) {
23714                        return value.toString();
23715                    }
23716
23717                    if (value.format) {
23718                        return value.format(null, formatProvider || null);
23719                    }
23720
23721                    var typeName = H5.getTypeName(value);
23722
23723                    return typeName;
23724            }
23725
23726            // try converting using IConvertible
23727            return scope.convert.convertToType(scope.convert.typeCodes.String, value, formatProvider || null);
23728        },
23729
23730        toNumberInBase: function (str, fromBase, typeCode) {
23731            if (fromBase !== 2 && fromBase !== 8 && fromBase !== 10 && fromBase !== 16) {
23732                throw new System.ArgumentException.$ctor1("Invalid Base.");
23733            }
23734
23735            var typeCodes = scope.convert.typeCodes;
23736
23737            if (str == null) {
23738                if (typeCode === typeCodes.Int64) {
23739                    return System.Int64.Zero;
23740                }
23741
23742                if (typeCode === typeCodes.UInt64) {
23743                    return System.UInt64.Zero;
23744                }
23745
23746                return 0;
23747            }
23748
23749            if (str.length === 0) {
23750                throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index was out of range. Must be non-negative and less than the size of the collection.");
23751            }
23752
23753            // Let's process the string in lower case.
23754            str = str.toLowerCase();
23755
23756            var minValue = scope.internal.getMinValue(typeCode),
23757                maxValue = scope.internal.getMaxValue(typeCode);
23758
23759            // Calculate offset (start index)
23760            var isNegative = false,
23761                startIndex = 0;
23762
23763            if (str[startIndex] === "-") {
23764                if (fromBase !== 10) {
23765                    throw new System.ArgumentException.$ctor1("String cannot contain a minus sign if the base is not 10.");
23766                }
23767
23768                if (minValue >= 0) {
23769                    throw new System.OverflowException.$ctor1("The string was being parsed as an unsigned number and could not have a negative sign.");
23770                }
23771
23772                isNegative = true;
23773                ++startIndex;
23774            } else if (str[startIndex] === "+") {
23775                ++startIndex;
23776            }
23777
23778            if (fromBase === 16 && str.length >= 2 && str[startIndex] === "0" && str[startIndex + 1] === "x") {
23779                startIndex += 2;
23780            }
23781
23782            // Fill allowed codes for the specified base:
23783            var allowedCodes;
23784
23785            if (fromBase === 2) {
23786                allowedCodes = scope.internal.charsToCodes("01");
23787            } else if (fromBase === 8) {
23788                allowedCodes = scope.internal.charsToCodes("01234567");
23789            } else if (fromBase === 10) {
23790                allowedCodes = scope.internal.charsToCodes("0123456789");
23791            } else if (fromBase === 16) {
23792                allowedCodes = scope.internal.charsToCodes("0123456789abcdef");
23793            } else {
23794                throw new System.ArgumentException.$ctor1("Invalid Base.");
23795            }
23796
23797            // Create charCode-to-Value map
23798            var codeValues = {};
23799
23800            for (var i = 0; i < allowedCodes.length; i++) {
23801                var allowedCode = allowedCodes[i];
23802
23803                codeValues[allowedCode] = i;
23804            }
23805
23806            var firstAllowed = allowedCodes[0],
23807                lastAllowed = allowedCodes[allowedCodes.length - 1],
23808                res,
23809                totalMax,
23810                code,
23811                j;
23812
23813            if (typeCode === typeCodes.Int64 || typeCode === typeCodes.UInt64) {
23814                for (j = startIndex; j < str.length; j++) {
23815                    code = str[j].charCodeAt(0);
23816
23817                    if (!(code >= firstAllowed && code <= lastAllowed)) {
23818                        if (j === startIndex) {
23819                            throw new System.FormatException.$ctor1("Could not find any recognizable digits.");
23820                        } else {
23821                            throw new System.FormatException.$ctor1("Additional non-parsable characters are at the end of the string.");
23822                        }
23823                    }
23824                }
23825
23826                var isSign = typeCode === typeCodes.Int64;
23827
23828                if (isSign) {
23829                    res = new System.Int64(H5.$Long.fromString(str, false, fromBase));
23830                } else {
23831                    res = new System.UInt64(H5.$Long.fromString(str, true, fromBase));
23832                }
23833
23834                if (res.toString(fromBase) !== System.String.trimStartZeros(str)) {
23835                    throw new System.OverflowException.$ctor1("Value was either too large or too small.");
23836                }
23837
23838                return res;
23839            } else {
23840                // Parse the number:
23841                res = 0;
23842                totalMax = maxValue - minValue + 1;
23843
23844                for (j = startIndex; j < str.length; j++) {
23845                    code = str[j].charCodeAt(0);
23846
23847                    if (code >= firstAllowed && code <= lastAllowed) {
23848                        res *= fromBase;
23849                        res += codeValues[code];
23850
23851                        if (res > scope.internal.typeRanges.Int64_MaxValue) {
23852                            throw new System.OverflowException.$ctor1("Value was either too large or too small.");
23853                        }
23854                    } else {
23855                        if (j === startIndex) {
23856                            throw new System.FormatException.$ctor1("Could not find any recognizable digits.");
23857                        } else {
23858                            throw new System.FormatException.$ctor1("Additional non-parsable characters are at the end of the string.");
23859                        }
23860                    }
23861                }
23862
23863                if (isNegative) {
23864                    res *= -1;
23865                }
23866
23867                if (res > maxValue && fromBase !== 10 && minValue < 0) {
23868                    // Assume that the value is negative, transform it:
23869                    res = res - totalMax;
23870                }
23871
23872                if (res < minValue || res > maxValue) {
23873                    throw new System.OverflowException.$ctor1("Value was either too large or too small.");
23874                }
23875
23876                return res;
23877            }
23878        },
23879
23880        toStringInBase: function (value, toBase, typeCode) {
23881            var typeCodes = scope.convert.typeCodes;
23882
23883            value = H5.unbox(value, true);
23884
23885            if (toBase !== 2 && toBase !== 8 && toBase !== 10 && toBase !== 16) {
23886                throw new System.ArgumentException.$ctor1("Invalid Base.");
23887            }
23888
23889            var minValue = scope.internal.getMinValue(typeCode),
23890                maxValue = scope.internal.getMaxValue(typeCode),
23891                special = System.Int64.is64Bit(value);
23892
23893            if (special) {
23894                if (value.lt(minValue) || value.gt(maxValue)) {
23895                    throw new System.OverflowException.$ctor1("Value was either too large or too small for an unsigned byte.");
23896                }
23897            } else if (value < minValue || value > maxValue) {
23898                throw new System.OverflowException.$ctor1("Value was either too large or too small for an unsigned byte.");
23899            }
23900
23901            // Handle negative numbers:
23902            var isNegative = false;
23903
23904            if (special) {
23905                if (toBase === 10) {
23906                    return value.toString();
23907                } else {
23908                    return value.value.toUnsigned().toString(toBase);
23909                }
23910            } else if (value < 0) {
23911                if (toBase === 10) {
23912                    isNegative = true;
23913                    value *= -1;
23914                } else {
23915                    value = (maxValue + 1 - minValue) + value;
23916                }
23917            }
23918
23919            // Fill allowed codes for the specified base:
23920            var allowedChars;
23921
23922            if (toBase === 2) {
23923                allowedChars = "01";
23924            } else if (toBase === 8) {
23925                allowedChars = "01234567";
23926            } else if (toBase === 10) {
23927                allowedChars = "0123456789";
23928            } else if (toBase === 16) {
23929                allowedChars = "0123456789abcdef";
23930            } else {
23931                throw new System.ArgumentException.$ctor1("Invalid Base.");
23932            }
23933
23934            // Fill Value-To-Char map:
23935            var charByValues = {},
23936                allowedCharArr = allowedChars.split(""),
23937                allowedChar;
23938
23939            for (var i = 0; i < allowedCharArr.length; i++) {
23940                allowedChar = allowedCharArr[i];
23941
23942                charByValues[i] = allowedChar;
23943            }
23944
23945            // Parse the number:
23946            var res = "";
23947
23948            if (value === 0 || (special && value.eq(0))) {
23949                res = "0";
23950            } else {
23951                var mod, char;
23952
23953                if (special) {
23954                    while (value.gt(0)) {
23955                        mod = value.mod(toBase);
23956                        value = value.sub(mod).div(toBase);
23957
23958                        char = charByValues[mod.toNumber()];
23959                        res += char;
23960                    }
23961                } else {
23962                    while (value > 0) {
23963                        mod = value % toBase;
23964                        value = (value - mod) / toBase;
23965
23966                        char = charByValues[mod];
23967                        res += char;
23968                    }
23969                }
23970            }
23971
23972            if (isNegative) {
23973                res += "-";
23974            }
23975
23976            res = res.split("").reverse().join("");
23977
23978            return res;
23979        },
23980
23981        toBase64String: function (inArray, offset, length, options) {
23982            if (inArray == null) {
23983                throw new System.ArgumentNullException.$ctor1("inArray");
23984            }
23985
23986            offset = offset || 0;
23987            length = length != null ? length : inArray.length;
23988            options = options || 0; // 0 - means "None", 1 - stands for "InsertLineBreaks"
23989
23990            if (length < 0) {
23991                throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index was out of range. Must be non-negative and less than the size of the collection.");
23992            }
23993
23994            if (offset < 0) {
23995                throw new System.ArgumentOutOfRangeException.$ctor4("offset", "Value must be positive.");
23996            }
23997
23998            if (options < 0 || options > 1) {
23999                throw new System.ArgumentException.$ctor1("Illegal enum value.");
24000            }
24001
24002            var inArrayLength = inArray.length;
24003
24004            if (offset > (inArrayLength - length)) {
24005                throw new System.ArgumentOutOfRangeException.$ctor4("offset", "Offset and length must refer to a position in the string.");
24006            }
24007
24008            if (inArrayLength === 0) {
24009                return "";
24010            }
24011
24012            var insertLineBreaks = (options === 1),
24013                strArrayLen = scope.internal.toBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);
24014
24015            var strArray = [];
24016            strArray.length = strArrayLen;
24017
24018            scope.internal.convertToBase64Array(strArray, inArray, offset, length, insertLineBreaks);
24019
24020            var str = strArray.join("");
24021
24022            return str;
24023        },
24024
24025        toBase64CharArray: function (inArray, offsetIn, length, outArray, offsetOut, options) {
24026            if (inArray == null) {
24027                throw new System.ArgumentNullException.$ctor1("inArray");
24028            }
24029
24030            if (outArray == null) {
24031                throw new System.ArgumentNullException.$ctor1("outArray");
24032            }
24033
24034            if (length < 0) {
24035                throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index was out of range. Must be non-negative and less than the size of the collection.");
24036            }
24037
24038            if (offsetIn < 0) {
24039                throw new System.ArgumentOutOfRangeException.$ctor4("offsetIn", "Value must be positive.");
24040            }
24041
24042            if (offsetOut < 0) {
24043                throw new System.ArgumentOutOfRangeException.$ctor4("offsetOut", "Value must be positive.");
24044            }
24045
24046            options = options || 0; // 0 - means "None", 1 - stands for "InsertLineBreaks"
24047
24048            if (options < 0 || options > 1) {
24049                throw new System.ArgumentException.$ctor1("Illegal enum value.");
24050            }
24051
24052            var inArrayLength = inArray.length;
24053
24054            if (offsetIn > inArrayLength - length) {
24055                throw new System.ArgumentOutOfRangeException.$ctor4("offsetIn", "Offset and length must refer to a position in the string.");
24056            }
24057
24058            if (inArrayLength === 0) {
24059                return 0;
24060            }
24061
24062            var insertLineBreaks = options === 1,
24063                outArrayLength = outArray.length; //This is the maximally required length that must be available in the char array
24064
24065            // Length of the char buffer required
24066            var numElementsToCopy = scope.internal.toBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);
24067
24068            if (offsetOut > (outArrayLength - numElementsToCopy)) {
24069                throw new System.ArgumentOutOfRangeException.$ctor4("offsetOut", "Either offset did not refer to a position in the string, or there is an insufficient length of destination character array.");
24070            }
24071
24072            var charsArr = [],
24073                charsArrLength = scope.internal.convertToBase64Array(charsArr, inArray, offsetIn, length, insertLineBreaks);
24074
24075            scope.internal.charsToCodes(charsArr, outArray, offsetOut);
24076
24077            return charsArrLength;
24078        },
24079
24080        fromBase64String: function (s) {
24081            // "s" is an unfortunate parameter name, but we need to keep it for backward compat.
24082
24083            if (s == null) {
24084                throw new System.ArgumentNullException.$ctor1("s");
24085            }
24086
24087            var sChars = s.split(""),
24088                bytes = scope.internal.fromBase64CharPtr(sChars, 0, sChars.length);
24089
24090            return bytes;
24091        },
24092
24093        fromBase64CharArray: function (inArray, offset, length) {
24094            if (inArray == null) {
24095                throw new System.ArgumentNullException.$ctor1("inArray");
24096            }
24097
24098            if (length < 0) {
24099                throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index was out of range. Must be non-negative and less than the size of the collection.");
24100            }
24101
24102            if (offset < 0) {
24103                throw new System.ArgumentOutOfRangeException.$ctor4("offset", "Value must be positive.");
24104            }
24105
24106            if (offset > (inArray.length - length)) {
24107                throw new System.ArgumentOutOfRangeException.$ctor4("offset", "Offset and length must refer to a position in the string.");
24108            }
24109
24110            var chars = scope.internal.codesToChars(inArray),
24111                bytes = scope.internal.fromBase64CharPtr(chars, offset, length);
24112
24113            return bytes;
24114        },
24115
24116        getTypeCode: function (t) {
24117            if (t == null) {
24118                return System.TypeCode.Object;
24119            }
24120            if (t === System.Double) {
24121                return System.TypeCode.Double;
24122            }
24123            if (t === System.Single) {
24124                return System.TypeCode.Single;
24125            }
24126            if (t === System.Decimal) {
24127                return System.TypeCode.Decimal;
24128            }
24129            if (t === System.Byte) {
24130                return System.TypeCode.Byte;
24131            }
24132            if (t === System.SByte) {
24133                return System.TypeCode.SByte;
24134            }
24135            if (t === System.UInt16) {
24136                return System.TypeCode.UInt16;
24137            }
24138            if (t === System.Int16) {
24139                return System.TypeCode.Int16;
24140            }
24141            if (t === System.UInt32) {
24142                return System.TypeCode.UInt32;
24143            }
24144            if (t === System.Int32) {
24145                return System.TypeCode.Int32;
24146            }
24147            if (t === System.UInt64) {
24148                return System.TypeCode.UInt64;
24149            }
24150            if (t === System.Int64) {
24151                return System.TypeCode.Int64;
24152            }
24153            if (t === System.Boolean) {
24154                return System.TypeCode.Boolean;
24155            }
24156            if (t === System.Char) {
24157                return System.TypeCode.Char;
24158            }
24159            if (t === System.DateTime) {
24160                return System.TypeCode.DateTime;
24161            }
24162            if (t === System.String) {
24163                return System.TypeCode.String;
24164            }
24165            return System.TypeCode.Object;
24166        },
24167
24168        changeConversionType: function (value, conversionType, provider) {
24169            if (conversionType == null) {
24170                throw new System.ArgumentNullException.$ctor1("conversionType");
24171            }
24172
24173            if (value == null) {
24174                if (H5.Reflection.isValueType(conversionType)) {
24175                    throw new System.InvalidCastException.$ctor1("Null object cannot be converted to a value type.");
24176                }
24177                return null;
24178            }
24179
24180            var fromTypeCode = scope.convert.getTypeCode(H5.getType(value)),
24181                ic = H5.as(value, System.IConvertible);
24182
24183            if (ic == null && fromTypeCode == System.TypeCode.Object) {
24184                if (H5.referenceEquals(H5.getType(value), conversionType)) {
24185                    return value;
24186                }
24187                throw new System.InvalidCastException.$ctor1("Cannot convert to IConvertible");
24188            }
24189
24190            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Boolean, scope.convert.convertTypes)])) {
24191                return ic == null ? scope.convert.toBoolean(value, provider) : ic.System$IConvertible$ToBoolean(provider);
24192            }
24193            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Char, scope.convert.convertTypes)])) {
24194                return ic == null ? scope.convert.toChar(value, provider, fromTypeCode) : ic.System$IConvertible$ToChar(provider);
24195            }
24196            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.SByte, scope.convert.convertTypes)])) {
24197                return ic == null ? scope.convert.toSByte(value, provider, fromTypeCode) : ic.System$IConvertible$ToSByte(provider);
24198            }
24199            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Byte, scope.convert.convertTypes)])) {
24200                return ic == null ? scope.convert.toByte(value, provider) : ic.System$IConvertible$ToByte(provider);
24201            }
24202            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Int16, scope.convert.convertTypes)])) {
24203                return ic == null ? scope.convert.toInt16(value, provider) : ic.System$IConvertible$ToInt16(provider);
24204            }
24205            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.UInt16, scope.convert.convertTypes)])) {
24206                return ic == null ? scope.convert.toUInt16(value, provider) : ic.System$IConvertible$ToUInt16(provider);
24207            }
24208            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Int32, scope.convert.convertTypes)])) {
24209                return ic == null ? scope.convert.toInt32(value, provider) : ic.System$IConvertible$ToInt32(provider);
24210            }
24211            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.UInt32, scope.convert.convertTypes)])) {
24212                return ic == null ? scope.convert.toUInt32(value, provider) : ic.System$IConvertible$ToUInt32(provider);
24213            }
24214            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Int64, scope.convert.convertTypes)])) {
24215                return ic == null ? scope.convert.toInt64(value, provider) : ic.System$IConvertible$ToInt64(provider);
24216            }
24217            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.UInt64, scope.convert.convertTypes)])) {
24218                return ic == null ? scope.convert.toUInt64(value, provider) : ic.System$IConvertible$ToUInt64(provider);
24219            }
24220            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Single, scope.convert.convertTypes)])) {
24221                return ic == null ? scope.convert.toSingle(value, provider) : ic.System$IConvertible$ToSingle(provider);
24222            }
24223            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Double, scope.convert.convertTypes)])) {
24224                return ic == null ? scope.convert.toDouble(value, provider) : ic.System$IConvertible$ToDouble(provider);
24225            }
24226            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Decimal, scope.convert.convertTypes)])) {
24227                return ic == null ? scope.convert.toDecimal(value, provider) : ic.System$IConvertible$ToDecimal(provider);
24228            }
24229            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.DateTime, scope.convert.convertTypes)])) {
24230                return ic == null ? scope.convert.toDateTime(value, provider) : ic.System$IConvertible$ToDateTime(prov
24230ider);
24231            }
24232            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.String, scope.convert.convertTypes)])) {
24233                return ic == null ? scope.convert.toString(value, provider, fromTypeCode) : ic.System$IConvertible$ToString(provider);
24234            }
24235            if (H5.referenceEquals(conversionType, scope.convert.convertTypes[System.Array.index(System.TypeCode.Object, scope.convert.convertTypes)])) {
24236                return value;
24237            }
24238
24239            if (ic == null) {
24240                throw new System.InvalidCastException.$ctor1("Cannot convert to IConvertible");
24241            }
24242
24243            return ic.System$IConvertible$ToType(conversionType, provider);
24244        },
24245
24246        changeType: function (value, typeCode, formatProvider) {
24247            if (H5.isFunction(typeCode)) {
24248                return scope.convert.changeConversionType(value, typeCode, formatProvider);
24249            }
24250
24251            if (value == null && (typeCode === System.TypeCode.Empty || typeCode === System.TypeCode.String || typeCode === System.TypeCode.Object)) {
24252                return null;
24253            }
24254
24255            var fromTypeCode = scope.convert.getTypeCode(H5.getType(value)),
24256                v = H5.as(value, System.IConvertible);
24257
24258            if (v == null && fromTypeCode == System.TypeCode.Object) {
24259                throw new System.InvalidCastException.$ctor1("Cannot convert to IConvertible");
24260            }
24261
24262            switch (typeCode) {
24263                case System.TypeCode.Boolean:
24264                    return v == null ? scope.convert.toBoolean(value, formatProvider) : v.System$IConvertible$ToBoolean(provider);
24265                case System.TypeCode.Char:
24266                    return v == null ? scope.convert.toChar(value, formatProvider, fromTypeCode) : v.System$IConvertible$ToChar(provider);
24267                case System.TypeCode.SByte:
24268                    return v == null ? scope.convert.toSByte(value, formatProvider, fromTypeCode) : v.System$IConvertible$ToSByte(provider);
24269                case System.TypeCode.Byte:
24270                    return v == null ? scope.convert.toByte(value, formatProvider, fromTypeCode) : v.System$IConvertible$ToByte(provider);
24271                case System.TypeCode.Int16:
24272                    return v == null ? scope.convert.toInt16(value, formatProvider) : v.System$IConvertible$ToInt16(provider);
24273                case System.TypeCode.UInt16:
24274                    return v == null ? scope.convert.toUInt16(value, formatProvider) : v.System$IConvertible$ToUInt16(provider);
24275                case System.TypeCode.Int32:
24276                    return v == null ? scope.convert.toInt32(value, formatProvider) : v.System$IConvertible$ToInt32(provider);
24277                case System.TypeCode.UInt32:
24278                    return v == null ? scope.convert.toUInt32(value, formatProvider) : v.System$IConvertible$ToUInt32(provider);
24279                case System.TypeCode.Int64:
24280                    return v == null ? scope.convert.toInt64(value, formatProvider) : v.System$IConvertible$ToInt64(provider);
24281                case System.TypeCode.UInt64:
24282                    return v == null ? scope.convert.toUInt64(value, formatProvider) : v.System$IConvertible$ToUInt64(provider);
24283                case System.TypeCode.Single:
24284                    return v == null ? scope.convert.toSingle(value, formatProvider) : v.System$IConvertible$ToSingle(provider);
24285                case System.TypeCode.Double:
24286                    return v == null ? scope.convert.toDouble(value, formatProvider) : v.System$IConvertible$ToDouble(provider);
24287                case System.TypeCode.Decimal:
24288                    return v == null ? scope.convert.toDecimal(value, formatProvider) : v.System$IConvertible$ToDecimal(provider);
24289                case System.TypeCode.DateTime:
24290                    return v == null ? scope.convert.toDateTime(value, formatProvider) : v.System$IConvertible$ToDateTime(provider);
24291                case System.TypeCode.String:
24292                    return v == null ? scope.convert.toString(value, formatProvider, fromTypeCode) : v.System$IConvertible$ToString(provider);
24293                case System.TypeCode.Object:
24294                    return value;
24295                case System.TypeCode.DBNull:
24296                    throw new System.InvalidCastException.$ctor1("Cannot convert DBNull values");
24297                case System.TypeCode.Empty:
24298                    throw new System.InvalidCastException.$ctor1("Cannot convert Empty values");
24299                default:
24300                    throw new System.ArgumentException.$ctor1("Unknown type co
24300de");
24301            }
24302        }
24303    };
24304
24305    scope.internal = {
24306        base64Table: [
24307            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
24308            "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d",
24309            "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
24310            "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7",
24311            "8", "9", "+", "/", "="
24312        ],
24313
24314        typeRanges: {
24315            Char_MinValue: 0,
24316            Char_MaxValue: 65535,
24317
24318            Byte_MinValue: 0,
24319            Byte_MaxValue: 255,
24320
24321            SByte_MinValue: -128,
24322            SByte_MaxValue: 127,
24323
24324            Int16_MinValue: -32768,
24325            Int16_MaxValue: 32767,
24326
24327            UInt16_MinValue: 0,
24328            UInt16_MaxValue: 65535,
24329
24330            Int32_MinValue: -2147483648,
24331            Int32_MaxValue: 2147483647,
24332
24333            UInt32_MinValue: 0,
24334            UInt32_MaxValue: 4294967295,
24335
24336            Int64_MinValue: System.Int64.MinValue,
24337            Int64_MaxValue: System.Int64.MaxValue,
24338
24339            UInt64_MinValue: System.UInt64.MinValue,
24340            UInt64_MaxValue: System.UInt64.MaxValue,
24341
24342            Single_MinValue: -3.40282347e+38,
24343            Single_MaxValue: 3.40282347e+38,
24344
24345            Double_MinValue: -1.7976931348623157e+308,
24346            Double_MaxValue: 1.7976931348623157e+308,
24347
24348            Decimal_MinValue: System.Decimal.MinValue,
24349            Decimal_MaxValue: System.Decimal.MaxValue
24350        },
24351
24352        base64LineBreakPosition: 76,
24353
24354        getTypeCodeName: function (typeCode) {
24355            var typeCodes = scope.convert.typeCodes;
24356
24357            if (scope.internal.typeCodeNames == null) {
24358                var names = {};
24359
24360                for (var codeName in typeCodes) {
24361                    if (!typeCodes.hasOwnProperty(codeName)) {
24362                        continue;
24363                    }
24364
24365                    var codeValue = typeCodes[codeName];
24366
24367                    names[codeValue] = codeName;
24368                }
24369                scope.internal.typeCodeNames = names;
24370            }
24371
24372            var name = scope.internal.typeCodeNames[typeCode];
24373
24374            if (name == null) {
24375                throw System.ArgumentOutOfRangeException("typeCode", "The specified typeCode is undefined.");
24376            }
24377
24378            return name;
24379        },
24380
24381        suggestTypeCode: function (value) {
24382            var typeCodes = scope.convert.typeCodes,
24383                type = typeof (value);
24384
24385            switch (type) {
24386                case "boolean":
24387                    return typeCodes.Boolean;
24388
24389                case "number":
24390                    if (value % 1 !== 0) {
24391                        return typeCodes.Double;
24392                    }
24393
24394                    return typeCodes.Int32;
24395
24396                case "string":
24397                    return typeCodes.String;
24398
24399                case "object":
24400                    if (H5.isDate(value)) {
24401                        return typeCodes.DateTime;
24402                    }
24403
24404                    if (value != null) {
24405                        return typeCodes.Object;
24406                    }
24407
24408                    break;
24409            }
24410            return null;
24411        },
24412
24413        getMinValue: function (typeCode) {
24414            var typeCodes = scope.convert.typeCodes;
24415
24416            switch (typeCode) {
24417                case typeCodes.Char:
24418                    return scope.internal.typeRanges.Char_MinValue;
24419                case typeCodes.SByte:
24420                    return scope.internal.typeRanges.SByte_MinValue;
24421                case typeCodes.Byte:
24422                    return scope.internal.typeRanges.Byte_MinValue;
24423                case typeCodes.Int16:
24424                    return scope.internal.typeRanges.Int16_MinValue;
24425                case typeCodes.UInt16:
24426                    return scope.internal.typeRanges.UInt16_MinValue;
24427                case typeCodes.Int32:
24428                    return scope.internal.typeRanges.Int32_MinValue;
24429                case typeCodes.UInt32:
24430                    return scope.internal.typeRanges.UInt32_MinValue;
24431                case typeCodes.Int64:
24432                    return scope.internal.typeRanges.Int64_MinValue;
24433                case typeCodes.UInt64:
24434                    return scope.internal.typeRanges.UInt64_MinValue;
24435                case typeCodes.Single:
24436                    return scope.internal.typeRanges.Single_MinValue;
24437                case typeCodes.Double:
24438                    return scope.internal.typeRanges.Double_MinValue;
24439                case typeCodes.Decimal:
24440                    return scope.internal.typeRanges.Decimal_MinValue;
24441                case typeCodes.DateTime:
24442                    return System.DateTime.getMinValue();
24443
24444                default:
24445                    return null;
24446            }
24447        },
24448
24449        getMaxValue: function (typeCode) {
24450            var typeCodes = scope.convert.typeCodes;
24451
24452            switch (typeCode) {
24453                case typeCodes.Char:
24454                    return scope.internal.typeRanges.Char_MaxValue;
24455                case typeCodes.SByte:
24456                    return scope.internal.typeRanges.SByte_MaxValue;
24457                case typeCodes.Byte:
24458                    return scope.internal.typeRanges.Byte_MaxValue;
24459                case typeCodes.Int16:
24460                    return scope.internal.typeRanges.Int16_MaxValue;
24461                case typeCodes.UInt16:
24462                    return scope.internal.typeRanges.UInt16_MaxValue;
24463                case typeCodes.Int32:
24464                    return scope.internal.typeRanges.Int32_MaxValue;
24465                case typeCodes.UInt32:
24466                    return scope.internal.typeRanges.UInt32_MaxValue;
24467                case typeCodes.Int64:
24468                    return scope.internal.typeRanges.Int64_MaxValue;
24469                case typeCodes.UInt64:
24470                    return scope.internal.typeRanges.UInt64_MaxValue;
24471                case typeCodes.Single:
24472                    return scope.internal.typeRanges.Single_MaxValue;
24473                case typeCodes.Double:
24474                    return scope.internal.typeRanges.Double_MaxValue;
24475                case typeCodes.Decimal:
24476                    return scope.internal.typeRanges.Decimal_MaxValue;
24477                case typeCodes.DateTime:
24478                    return System.DateTime.getMaxValue();
24479                default:
24480                    throw new System.ArgumentOutOfRangeException.$ctor4("typeCode", "The specified typeCode is undefined.");
24481            }
24482        },
24483
24484        isFloatingType: function (typeCode) {
24485            var typeCodes = scope.convert.typeCodes,
24486                isFloatingType =
24487                    typeCode === typeCodes.Single ||
24488                    typeCode === typeCodes.Double ||
24489                    typeCode === typeCodes.Decimal;
24490
24491            return isFloatingType;
24492        },
24493
24494        toNumber: function (value, formatProvider, typeCode, valueTypeCode) {
24495            value = H5.unbox(value, true);
24496
24497            var typeCodes = scope.convert.typeCodes,
24498                type = typeof (value),
24499                isFloating = scope.internal.isFloatingType(typeCode);
24500
24501            if (valueTypeCode === typeCodes.String) {
24502                type = "string";
24503            }
24504
24505            if (System.Int64.is64Bit(value) || value instanceof System.Decimal) {
24506                type = "number";
24507            }
24508
24509            switch (type) {
24510                case "boolean":
24511                    return value ? 1 : 0;
24512
24513                case "number":
24514                    if (typeCode === typeCodes.Decimal) {
24515                        scope.internal.validateNumberRange(value, typeCode, true);
24516
24517                        return new System.Decimal(value, formatProvider);
24518                    }
24519
24520                    if (typeCode === typeCodes.Int64) {
24521                        scope.internal.validateNumberRange(value, typeCode, true);
24522
24523                        return new System.Int64(value);
24524                    }
24525
24526                    if (typeCode === typeCodes.UInt64) {
24527                        scope.internal.validateNumberRange(value, typeCode, true);
24528
24529                        return new System.UInt64(value);
24530                    }
24531
24532                    if (System.Int64.is64Bit(value)) {
24533                        value = value.toNumber();
24534                    } else if (value instanceof System.Decimal) {
24535                        value = value.toFloat();
24536                    }
24537
24538                    if (!isFloating && (value % 1 !== 0)) {
24539                        value = scope.internal.roundToInt(value, typeCode);
24540                    }
24541
24542                    if (isFloating) {
24543                        var minValue = scope.internal.getMinValue(typeCode),
24544                            maxValue = scope.internal.getMaxValue(typeCode);
24545
24546                        if (value > maxValue) {
24547                            value = Infinity;
24548                        } else if (value < minValue) {
24549                            value = -Infinity;
24550                        }
24551                    }
24552
24553                    scope.internal.validateNumberRange(value, typeCode, false);
24554                    return value;
24555
24556                case "string":
24557                    if (value == null) {
24558                        if (formatProvider != null) {
24559                            throw new System.ArgumentNullException.$ctor3("String", "Value cannot be null.");
24560                        }
24561
24562                        return 0;
24563                    }
24564
24565                    if (isFloating) {
24566                        var nfInfo = (formatProvider || System.Globalization.CultureInfo.getCurrentCulture()).getFormat(System.Globalization.NumberFormatInfo),
24567                            point = nfInfo.numberDecimalSeparator;
24568
24569                        if (typeCode === typeCodes.Decimal) {
24570                            if (!new RegExp("^[+-]?(\\d+|\\d+.|\\d*\\" + point +"\\d+)$").test(value)) {
24571                                if (!/^[+-]?[0-9]+$/.test(value)) {
24572                                    throw new System.FormatException.$ctor1("Input string was not in a correct format.");
24573                                }
24574                            }
24575
24576                            value = new System.Decimal(value, formatProvider);
24577                        } else {
24578                            if (!new RegExp("^[-+]?[0-9]*\\" + point +"?[0-9]+([eE][-+]?[0-9]+)?$").test(value)) {
24579                                throw new System.FormatException.$ctor1("Input string was not in a correct format.");
24580                            }
24581
24582                            value = H5.Int.parseFloat(value, formatProvider);
24583                        }
24584                    } else {
24585                        if (!/^[+-]?[0-9]+$/.test(value)) {
24586                            throw new System.FormatException.$ctor1("Input string was not in a correct format.");
24587                        }
24588
24589                        var str = value;
24590
24591                        if (typeCode === typeCodes.Int64) {
24592                            value = new System.Int64(value);
24593
24594                            if (System.String.trimStartZeros(str) !== value.toString()) {
24595                                this.throwOverflow(scope.internal.getTypeCodeName(typeCode));
24596                            }
24597                        } else if (typeCode === typeCodes.UInt64) {
24598                            value = new System.UInt64(value);
24599
24600                            if (System.String.trimStartZeros(str) !== value.toString()) {
24601                                this.throwOverflow(scope.internal.getTypeCodeName(typeCode));
24602                            }
24603                        } else {
24604                            value = parseInt(value, 10);
24605                        }
24606                    }
24607
24608                    if (isNaN(value)) {
24609                        throw new System.FormatException.$ctor1("Input string was not in a correct format.");
24610                    }
24611
24612                    scope.internal.validateNumberRange(value, typeCode, true);
24613
24614                    return value;
24615
24616                case "object":
24617                    if (value == null) {
24618                        return 0;
24619                    }
24620
24621                    if (H5.isDate(value)) {
24622                        scope.internal.throwInvalidCastEx(scope.convert.typeCodes.DateTime, typeCode);
24623                    }
24624
24625                    break;
24626            }
24627
24628            // TODO: #822 When IConvertible is implemented, try it before throwing InvalidCastEx
24629            valueTypeCode = valueTypeCode || scope.internal.suggestTypeCode(value);
24630            scope.internal.throwInvalidCastEx(valueTypeCode, typeCode);
24631
24632            // try converting using IConvertible
24633            return scope.convert.convertToType(typeCode, value, formatProvider);
24634        },
24635
24636        validateNumberRange: function (value, typeCode, denyInfinity) {
24637            var typeCodes = scope.convert.typeCodes,
24638                minValue = scope.internal.getMinValue(typeCode),
24639                maxValue = scope.internal.getMaxValue(typeCode),
24640                typeName = scope.internal.getTypeCodeName(typeCode);
24641
24642            if (typeCode === typeCodes.Single ||
24643                typeCode === typeCodes.Double) {
24644                if (!denyInfinity && (value === Infinity || value === -Infinity)) {
24645                    return;
24646                }
24647            }
24648
24649            if (typeCode === typeCodes.Decimal || typeCode === typeCodes.Int64 || typeCode === typeCodes.UInt64) {
24650                if (typeCode === typeCodes.Decimal) {
24651                    if (!System.Int64.is64Bit(value)) {
24652                        if (minValue.gt(value) || maxValue.lt(value)) {
24653                            this.throwOverflow(typeName);
24654                        }
24655                    }
24656
24657                    value = new System.Decimal(value);
24658                } else if (typeCode === typeCodes.Int64) {
24659                    if (value instanceof System.UInt64) {
24660                        if (value.gt(System.Int64.MaxValue)) {
24661                            this.throwOverflow(typeName);
24662                        }
24663                    } else if (value instanceof System.Decimal) {
24664                        if ((value.gt(new System.Decimal(maxValue)) || value.lt(new System.Decimal(minValue)))) {
24665                            this.throwOverflow(typeName);
24666                        }
24667                    } else if (!(value instanceof System.Int64)) {
24668                        if (minValue.toNumber() > value || maxValue.toNumber() < value) {
24669                            this.throwOverflow(typeName);
24670                        }
24671                    }
24672
24673                    value = new System.Int64(value);
24674                } else if (typeCode === typeCodes.UInt64) {
24675                    if (value instanceof System.Int64) {
24676                        if (value.isNegative()) {
24677                            this.throwOverflow(typeName);
24678                        }
24679                    } else if (value instanceof System.Decimal) {
24680                        if ((value.gt(new System.Decimal(maxValue)) || value.lt(new System.Decimal(minValue)))) {
24681                            this.throwOverflow(typeName);
24682                        }
24683                    } else if (!(value instanceof System.UInt64)) {
24684                        if (minValue.toNumber() > value || maxValue.toNumber() < value) {
24685                            this.throwOverflow(typeName);
24686                        }
24687                    }
24688
24689                    value = new System.UInt64(value);
24690                }
24691            } else if (value < minValue || value > maxValue) {
24692                this.throwOverflow(typeName);
24693            }
24694        },
24695
24696        throwOverflow: function (typeName) {
24697            throw new System.OverflowException.$ctor1("Value was either too large or too small for '" + typeName + "'.");
24698        },
24699
24700        roundToInt: function (value, typeCode) {
24701            if (value % 1 === 0) {
24702                return value;
24703            }
24704
24705            var intPart;
24706
24707            if (value >= 0) {
24708                intPart = Math.floor(value);
24709            } else {
24710                intPart = -1 * Math.floor(-value);
24711            }
24712
24713            var floatPart = value - intPart,
24714                minValue = scope.internal.getMinValue(typeCode),
24715                maxValue = scope.internal.getMaxValue(typeCode);
24716
24717            if (value >= 0.0) {
24718                if (value < (maxValue + 0.5)) {
24719                    if (floatPart > 0.5 || floatPart === 0.5 && (intPart & 1) !== 0) {
24720                        ++intPart;
24721                    }
24722
24723                    return intPart;
24724                }
24725            } else if (value >= (minValue - 0.5)) {
24726                if (floatPart < -0.5 || floatPart === -0.5 && (intPart & 1) !== 0) {
24727                    --intPart;
24728                }
24729
24730                return intPart;
24731            }
24732
24733            var typeName = scope.internal.getTypeCodeName(typeCode);
24734
24735            throw new System.OverflowException.$ctor1("Value was either too large or too small for an '" + typeName + "'.");
24736        },
24737
24738        toBase64_CalculateAndValidateOutputLength: function (inputLength, insertLineBreaks) {
24739            var base64LineBreakPosition = scope.internal.base64LineBreakPosition,
24740                outlen = ~~(inputLength / 3) * 4; // the base length - we want integer division here.
24741
24742            outlen += ((inputLength % 3) !== 0) ? 4 : 0; // at most 4 more chars for the remainder
24743
24744            if (outlen === 0) {
24745                return 0;
24746            }
24747
24748            if (insertLineBreaks) {
24749                var newLines = ~~(outlen / base64LineBreakPosition);
24750
24751                if ((outlen % base64LineBreakPosition) === 0) {
24752                    --newLines;
24753                }
24754
24755                outlen += newLines * 2; // the number of line break chars we'll add, "\r\n"
24756            }
24757
24758            // If we overflow an int then we cannot allocate enough
24759            // memory to output the value so throw
24760            if (outlen > 2147483647) {
24761                throw new System.OutOfMemoryException();
24762            }
24763
24764            return outlen;
24765        },
24766
24767        convertToBase64Array: function (outChars, inData, offset, length, insertLineBreaks) {
24768            var base64Table = scope.internal.base64Table,
24769                base64LineBreakPosition = scope.internal.base64LineBreakPosition,
24770                lengthmod3 = length % 3,
24771                calcLength = offset + (length - lengthmod3),
24772                charCount = 0,
24773                j = 0;
24774
24775            // Convert three bytes at a time to base64 notation.  This will consume 4 chars.
24776            var i;
24777
24778            for (i = offset; i < calcLength; i += 3) {
24779                if (insertLineBreaks) {
24780                    if (charCount === base64LineBreakPosition) {
24781                        outChars[j++] = "\r";
24782                        outChars[j++] = "\n";
24783                        charCount = 0;
24784                    }
24785
24786                    charCount += 4;
24787                }
24788
24789                outChars[j] = base64Table[(inData[i] & 0xfc) >> 2];
24790                outChars[j + 1] = base64Table[((inData[i] & 0x03) << 4) | ((inData[i + 1] & 0xf0) >> 4)];
24791                outChars[j + 2] = base64Table[((inData[i + 1] & 0x0f) << 2) | ((inData[i + 2] & 0xc0) >> 6)];
24792                outChars[j + 3] = base64Table[(inData[i + 2] & 0x3f)];
24793                j += 4;
24794            }
24795
24796            //Where we left off before
24797            i = calcLength;
24798
24799            if (insertLineBreaks && (lengthmod3 !== 0) && (charCount === scope.internal.base64LineBreakPosition)) {
24800                outChars[j++] = "\r";
24801                outChars[j++] = "\n";
24802            }
24803
24804            switch (lengthmod3) {
24805                case 2: //One character padding needed
24806                    outChars[j] = base64Table[(inData[i] & 0xfc) >> 2];
24807                    outChars[j + 1] = base64Table[((inData[i] & 0x03) << 4) | ((inData[i + 1] & 0xf0) >> 4)];
24808                    outChars[j + 2] = base64Table[(inData[i + 1] & 0x0f) << 2];
24809                    outChars[j + 3] = base64Table[64]; //Pad
24810                    j += 4;
24811
24812                    break;
24813
24814                case 1: // Two character padding needed
24815                    outChars[j] = base64Table[(inData[i] & 0xfc) >> 2];
24816                    outChars[j + 1] = base64Table[(inData[i] & 0x03) << 4];
24817                    outChars[j + 2] = base64Table[64]; //Pad
24818                    outChars[j + 3] = base64Table[64]; //Pad
24819                    j += 4;
24820
24821                    break;
24822            }
24823
24824            return j;
24825        },
24826
24827        fromBase64CharPtr: function (input, offset, inputLength) {
24828            if (inputLength < 0) {
24829                throw new System.ArgumentOutOfRangeException.$ctor4("inputLength", "Index was out of range. Must be non-negative and less than the size of the collection.");
24830            }
24831
24832            if (offset < 0) {
24833                throw new System.ArgumentOutOfRangeException.$ctor4("offset", "Value must be positive.");
24834            }
24835
24836            // We need to get rid of any trailing white spaces.
24837            // Otherwise we would be rejecting input such as "abc= ":
24838            while (inputLength > 0) {
24839                var lastChar = input[offset + inputLength - 1];
24840
24841                if (lastChar !== " " && lastChar !== "\n" && lastChar !== "\r" && lastChar !== "\t") {
24842                    break;
24843                }
24844
24845                inputLength--;
24846            }
24847
24848            // Compute the output length:
24849            var resultLength = scope.internal.fromBase64_ComputeResultLength(input, offset, inputLength);
24850
24851            if (0 > resultLength) {
24852                throw new System.InvalidOperationException.$ctor1("Contract voilation: 0 <= resultLength.");
24853            }
24854
24855            // resultLength can be zero. We will still enter FromBase64_Decode and process the input.
24856            // It may either simply write no bytes (e.g. input = " ") or throw (e.g. input = "ab").
24857
24858            // Create result byte blob:
24859            var decodedBytes = [];
24860            decodedBytes.length = resultLength;
24861
24862            // Convert Base64 chars into bytes:
24863            scope.internal.fromBase64_Decode(input, offset, inputLength, decodedBytes, 0, resultLength);
24864
24865            // We are done:
24866            return decodedBytes;
24867        },
24868
24869        fromBase64_Decode: function (input, inputIndex, inputLength, dest, destIndex, destLength) {
24870            var startDestIndex = destIndex;
24871
24872            // You may find this method weird to look at. It’s written for performance, not aesthetics.
24873            // You will find unrolled loops label jumps and bit manipulations.
24874
24875            var intA = "A".charCodeAt(0),
24876                inta = "a".charCodeAt(0),
24877                int0 = "0".charCodeAt(0),
24878                intEq = "=".charCodeAt(0),
24879                intPlus = "+".charCodeAt(0),
24880                intSlash = "/".charCodeAt(0),
24881                intSpace = " ".charCodeAt(0),
24882                intTab = "\t".charCodeAt(0),
24883                intNLn = "\n".charCodeAt(0),
24884                intCRt = "\r".charCodeAt(0),
24885                intAtoZ = ("Z".charCodeAt(0) - "A".charCodeAt(0)),
24886                int0To9 = ("9".charCodeAt(0) - "0".charCodeAt(0));
24887
24888            var endInputIndex = inputIndex + inputLength,
24889                endDestIndex = destIndex + destLength;
24890
24891            // Current char code/value:
24892            var currCode;
24893
24894            // This 4-byte integer will contain the 4 codes of the current 4-char group.
24895            // Eeach char codes for 6 bits = 24 bits.
24896            // The remaining byte will be FF, we use it as a marker when 4 chars have been processed.
24897            var currBlockCodes = 0x000000FF;
24898
24899            var allInputConsumed = false,
24900                equalityCharEncountered = false;
24901
24902            while (true) {
24903                // break when done:
24904                if (inputIndex >= endInputIndex) {
24905                    allInputConsumed = true;
24906
24907                    break;
24908                }
24909
24910                // Get current char:
24911                currCode = input[inputIndex].charCodeAt(0);
24912                inputIndex++;
24913
24914                // Determine current char code (unsigned Int comparison):
24915                if (((currCode - intA) >>> 0) <= intAtoZ) {
24916                    currCode -= intA;
24917                } else if (((currCode - inta) >>> 0) <= intAtoZ) {
24918                    currCode -= (inta - 26);
24919                } else if (((currCode - int0) >>> 0) <= int0To9) {
24920                    currCode -= (int0 - 52);
24921                } else {
24922                    // Use the slower switch for less common cases:
24923                    switch (currCode) {
24924                        // Significant chars:
24925                        case intPlus:
24926                            currCode = 62;
24927
24928                            break;
24929
24930                        case intSlash:
24931                            currCode = 63;
24932
24933                            break;
24934
24935                            // Legal no-value chars (we ignore these):
24936                        case intCRt:
24937                        case intNLn:
24938                        case intSpace:
24939                        case intTab:
24940                            continue;
24941
24942                            // The equality char is only legal at the end of the input.
24943                            // Jump after the loop to make it easier for the JIT register predictor to do a good job for the loop itself:
24944                        case intEq:
24945                            equalityCharEncountered = true;
24946
24947                            break;
24948
24949                            // Other chars are illegal:
24950                        default:
24951                            throw new System.FormatException.$ctor1("The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.");
24952                    }
24953                }
24954
24955                if (equalityCharEncountered) {
24956                    break;
24957                }
24958
24959                // Ok, we got the code. Save it:
24960                currBlockCodes = (currBlockCodes << 6) | currCode;
24961
24962                // Last bit in currBlockCodes will be on after in shifted right 4 times:
24963                if ((currBlockCodes & 0x80000000) !== 0) {
24964                    if ((endDestIndex - destIndex) < 3) {
24965                        return -1;
24966                    }
24967
24968                    dest[destIndex] = 0xFF & (currBlockCodes >> 16);
24969                    dest[destIndex + 1] = 0xFF & (currBlockCodes >> 8);
24970                    dest[destIndex + 2] = 0xFF & (currBlockCodes);
24971                    destIndex += 3;
24972
24973                    currBlockCodes = 0x000000FF;
24974                }
24975            } // end of while
24976
24977            if (!allInputConsumed && !equalityCharEncountered) {
24978                throw new System.InvalidOperationException.$ctor1("Contract violation: should never get here.");
24979            }
24980
24981            if (equalityCharEncountered) {
24982                if (currCode !== intEq) {
24983                    throw new System.InvalidOperationException.$ctor1("Contract violation: currCode == intEq.");
24984                }
24985
24986                // Recall that inputIndex is now one position past where '=' was read.
24987                // '=' can only be at the last input pos:
24988                if (inputIndex === endInputIndex) {
24989                    // Code is zero for trailing '=':
24990                    currBlockCodes <<= 6;
24991
24992                    // The '=' did not complete a 4-group. The input must be bad:
24993                    if ((currBlockCodes & 0x80000000) === 0) {
24994                        throw new System.FormatException.$ctor1("Invalid length for a Base-64 char array or string.");
24995                    }
24996
24997                    if ((endDestIndex - destIndex) < 2) {
24998                        // Autch! We underestimated the output length!
24999                        return -1;
25000                    }
25001
25002                    // We are good, store bytes form this past group. We had a single "=", so we take two bytes:
25003                    dest[destIndex] = 0xFF & (currBlockCodes >> 16);
25004                    dest[destIndex + 1] = 0xFF & (currBlockCodes >> 8);
25005                    destIndex += 2;
25006
25007                    currBlockCodes = 0x000000FF;
25008                } else { // '=' can also be at the pre-last position iff the last is also a '=' excluding the white spaces:
25009                    // We need to get rid of any intermediate white spaces.
25010                    // Otherwise we would be rejecting input such as "abc= =":
25011                    while (inputIndex < (endInputIndex - 1)) {
25012                        var lastChar = input[inputIndex];
25013
25014                        if (lastChar !== " " && lastChar !== "\n" && lastChar !== "\r" && lastChar !== "\t") {
25015                            break;
25016                        }
25017
25018                        inputIndex++;
25019                    }
25020
25021                    if (inputIndex === (endInputIndex - 1) && input[inputIndex] === "=") {
25022                        // Code is zero for each of the two '=':
25023                        currBlockCodes <<= 12;
25024
25025                        // The '=' did not complete a 4-group. The input must be bad:
25026                        if ((currBlockCodes & 0x80000000) === 0) {
25027                            throw new System.FormatException.$ctor1("Invalid length for a Base-64 char array or string.");
25028                        }
25029
25030                        if ((endDestIndex - destIndex) < 1) {
25031                            // Autch! We underestimated the output length!
25032                            return -1;
25033                        }
25034
25035                        // We are good, store bytes form this past group. We had a "==", so we take only one byte:
25036                        dest[destIndex] = 0xFF & (currBlockCodes >> 16);
25037                        destIndex++;
25038
25039                        currBlockCodes = 0x000000FF;
25040                    } else {
25041                        // '=' is not ok at places other than the end:
25042                        throw new System.FormatException.$ctor1("The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.");
25043                    }
25044                }
25045            }
25046
25047            // We get here either from above or by jumping out of the loop:
25048            // The last block of chars has less than 4 items
25049            if (currBlockCodes !== 0x000000FF) {
25050                throw new System.FormatException.$ctor1("Invalid length for a Base-64 char array or string.");
25051            }
25052
25053            // Return how many bytes were actually recovered:
25054            return (destIndex - startDestIndex);
25055        },
25056
25057        fromBase64_ComputeResultLength: function (input, startIndex, inputLength) {
25058            var intEq = "=",
25059                intSpace = " ";
25060
25061            if (inputLength < 0) {
25062                throw new System.ArgumentOutOfRangeException.$ctor4("inputLength", "Index was out of range. Must be non-negative and less than the size of the collection.");
25063            }
25064
25065            var endIndex = startIndex + inputLength,
25066                usefulInputLength = inputLength,
25067                padding = 0;
25068
25069            while (startIndex < endIndex) {
25070                var c = input[startIndex];
25071
25072                startIndex++;
25073
25074                // We want to be as fast as possible and filter out spaces with as few comparisons as possible.
25075                // We end up accepting a number of illegal chars as legal white-space chars.
25076                // This is ok: as soon as we hit them during actual decode we will recognise them as illegal and throw.
25077                if (c <= intSpace) {
25078                    usefulInputLength--;
25079                } else if (c === intEq) {
25080                    usefulInputLength--;
25081                    padding++;
25082                }
25083            }
25084
25085            if (0 > usefulInputLength) {
25086                throw new System.InvalidOperationException.$ctor1("Contract violation: 0 <= usefulInputLength.");
25087            }
25088
25089            if (0 > padding) {
25090                // For legal input, we can assume that 0 <= padding < 3. But it may be more for illegal input.
25091                // We will notice it at decode when we see a '=' at the wrong place.
25092                throw new System.InvalidOperationException.$ctor1("Contract violation: 0 <= padding.");
25093            }
25094
25095            // Perf: reuse the variable that stored the number of '=' to store the number of bytes encoded by the
25096            // last group that contains the '=':
25097            if (padding !== 0) {
25098                if (padding === 1) {
25099                    padding = 2;
25100                } else if (padding === 2) {
25101                    padding = 1;
25102                } else {
25103                    throw new System.FormatException.$ctor1("The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.");
25104                }
25105            }
25106
25107            // Done:
25108            return ~~(usefulInputLength / 4) * 3 + padding;
25109        },
25110
25111        charsToCodes: function (chars, codes, codesOffset) {
25112            if (chars == null) {
25113                return null;
25114            }
25115
25116            codesOffset = codesOffset || 0;
25117
25118            if (codes == null) {
25119                codes = [];
25120                codes.length = chars.length;
25121            }
25122
25123            for (var i = 0; i < chars.length; i++) {
25124                codes[i + codesOffset] = chars[i].charCodeAt(0);
25125            }
25126
25127            return codes;
25128        },
25129
25130        codesToChars: function (codes, chars) {
25131            if (codes == null) {
25132                return null;
25133            }
25134
25135            chars = chars || [];
25136
25137            for (var i = 0; i < codes.length; i++) {
25138                var code = codes[i];
25139
25140                chars[i] = String.fromCharCode(code);
25141            }
25142
25143            return chars;
25144        },
25145
25146        throwInvalidCastEx: function (fromTypeCode, toTypeCode) {
25147            var fromType = scope.internal.getTypeCodeName(fromTypeCode),                toType = scope.internal.getTypeCodeName(toTypeCode);
25148
25149            throw new System.InvalidCastException.$ctor1("Invalid cast from '" + fromType + "' to '" + toType + "'.");
25150        }
25151    };
25152
25153    System.Convert = scope.convert;
25154
25155    // @source ClientWebSocket.js
25156
25157    H5.define("System.Net.WebSockets.ClientWebSocket", {
25158        inherits: [System.IDisposable],
25159
25160        ctor: function () {
25161            this.$initialize();
25162            this.messageBuffer = [];
25163            this.state = "none";
25164            this.options = new System.Net.WebSockets.ClientWebSocketOptions();
25165            this.disposed = false;
25166            this.closeStatus = null;
25167            this.closeStatusDescription = null;
25168        },
25169
25170        getCloseStatus: function () {
25171            return this.closeStatus;
25172        },
25173
25174        getState: function () {
25175            return this.state;
25176        },
25177
25178        getCloseStatusDescription: function () {
25179            return this.closeStatusDescription;
25180        },
25181
25182        getSubProtocol: function () {
25183            return this.socket ? this.socket.protocol : null;
25184        },
25185
25186        onCloseHandler: function(event) {
25187            var reason,
25188                success = false;
25189
25190            // See http://tools.ietf.org/html/rfc6455#section-7.4.1
25191            if (event.code == 1000) {
25192                reason = "Status code: " + event.code + ". Normal closure, meaning that the purpose for which the connection was established has been fulfilled.";
25193                success = true;
25194            } else if (event.code == 1001)
25195                reason = "Status code: " + event.code + ". An endpoint is \"going away\", such as a server going down or a browser having navigated away from a page.";
25196            else if (event.code == 1002)
25197                reason = "Status code: " + event.code + ". An endpoint is terminating the connection due to a protocol error";
25198            else if (event.code == 1003)
25199                reason = "Status code: " + event.code + ". An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).";
25200            else if (event.code == 1004)
25201                reason = "Status code: " + event.code + ". Reserved. The specific meaning might be defined in the future.";
25202            else if (event.code == 1005)
25203                reason = "Status code: " + event.code + ". No status code was actually present.";
25204            else if (event.code == 1006)
25205                reason = "Status code: " + event.code + ". The connection was closed abnormally, e.g., without sending or receiving a Close control frame";
25206            else if (event.code == 1007)
25207                reason = "Status code: " + event.code + ". An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message).";
25208            else if (event.code == 1008)
25209                reason = "Status code: " + event.code + ". An endpoint is terminating the connection because it has received a message that \"violates its policy\". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy.";
25210            else if (event.code == 1009)
25211                reason = "Status code: " + event.code + ". An endpoint is terminating the connection because it has received a message that is too big for it to process.";
25212            else if (event.code == 1010) // Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.
25213                reason = "Status code: " + event.code + ". An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. <br /> Specifically, the extensions that are needed are: " + event.reason;
25214            else if (event.code == 1011)
25215                reason = "Status code: " + event.code + ". A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.";
25216            else if (event.code == 1015)
25217                reason = "Status code: " + event.code + ". The connection was closed due to a failure to perform a TLS handshake 
25217(e.g., the server certificate can't be verified).";
25218            else
25219                reason = "Unknown reason";
25220
25221            return {
25222                code: event.code,
25223                reason: reason
25224            };
25225        },
25226
25227        connectAsync: function (uri, cancellationToken) {
25228            if (this.state !== "none") {
25229                throw new System.InvalidOperationException.$ctor1("Socket is not in initial state");
25230            }
25231
25232            this.options.setToReadOnly();
25233            this.state = "connecting";
25234
25235            var tcs = new System.Threading.Tasks.TaskCompletionSource(),
25236                self = this;
25237
25238            try {
25239                this.socket = new WebSocket(uri.getAbsoluteUri(), this.options.requestedSubProtocols);
25240
25241                this.socket.onerror = function (e) {
25242                    setTimeout(function () {
25243                        if (self.closeInfo && !self.closeInfo.success) {
25244                            e.message = self.closeInfo.reason;
25245                        }
25246                        tcs.setException(System.Exception.create(e));
25247                    }, 10);
25248                };
25249
25250                this.socket.binaryType = "arraybuffer";
25251                this.socket.onopen = function () {
25252                    self.state = "open";
25253                    tcs.setResult(null);
25254                };
25255
25256                this.socket.onmessage = function (e) {
25257                    var data = e.data,
25258                        message = {},
25259                        i;
25260
25261                    message.bytes = [];
25262
25263                    if (typeof (data) === "string") {
25264                        for (i = 0; i < data.length; ++i) {
25265                            message.bytes.push(data.charCodeAt(i));
25266                        }
25267
25268                        message.messageType = "text";
25269                        self.messageBuffer.push(message);
25270
25271                        return;
25272                    }
25273
25274                    if (data instanceof ArrayBuffer) {
25275                        var dataView = new Uint8Array(data);
25276
25277                        for (i = 0; i < dataView.length; i++) {
25278                            message.bytes.push(dataView[i]);
25279                        }
25280
25281                        message.messageType = "binary";
25282                        self.messageBuffer.push(message);
25283
25284                        return;
25285                    }
25286
25287                    throw new System.ArgumentException.$ctor1("Invalid message type.");
25288                };
25289
25290                this.socket.onclose = function (e) {
25291                    self.state = "closed";
25292                    self.closeStatus = e.code;
25293                    self.closeStatusDescription = e.reason;
25294                    self.closeInfo = self.onCloseHandler(e);
25295                }
25296            } catch (e) {
25297                tcs.setException(System.Exception.create(e));
25298            }
25299
25300            return tcs.task;
25301        },
25302
25303        sendAsync: function (buffer, messageType, endOfMessage, cancellationToken) {
25304            this.throwIfNotConnected();
25305
25306            var tcs = new System.Threading.Tasks.TaskCompletionSource();
25307
25308            try {
25309                if (messageType === "close") {
25310                    this.socket.close();
25311                } else {
25312                    var array = buffer.getArray(),
25313                        count = buffer.getCount(),
25314                        offset = buffer.getOffset();
25315
25316                    var data = new Uint8Array(count);
25317
25318                    for (var i = 0; i < count; i++) {
25319                        data[i] = array[i + offset];
25320                    }
25321
25322                    if (messageType === "text") {
25323                        data = String.fromCharCode.apply(null, data);
25324                    }
25325
25326                    this.socket.send(data);
25327                }
25328
25329                tcs.setResult(null);
25330            } catch (e) {
25331                tcs.setException(System.Exception.create(e));
25332            }
25333
25334            return tcs.task;
25335        },
25336
25337        receiveAsync: function (buffer, cancellationToken) {
25338            this.throwIfNotConnected();
25339
25340            var task,
25341                tcs = new System.Threading.Tasks.TaskCompletionSource(),
25342                self = this,
25343                asyncBody = H5.fn.bind(this, function () {
25344                    try {
25345                        if (cancellationToken.getIsCancellationRequested()) {
25346                            tcs.setException(new System.Threading.Tasks.TaskCanceledException("Receive has been cancelled.", tcs.task));
25347
25348                            return;
25349                        }
25350
25351                        if (self.messageBuffer.length === 0) {
25352                            task = System.Threading.Tasks.Task.delay(0);
25353                            task.continueWith(asyncBody);
25354
25355                            return;
25356                        }
25357
25358                        var message = self.messageBuffer[0],
25359                            array = buffer.getArray(),
25360                            resultBytes,
25361                            endOfMessage;
25362
25363                        if (message.bytes.length <= array.length) {
25364                            self.messageBuffer.shift();
25365                            resultBytes = message.bytes;
25366                            endOfMessage = true;
25367                        } else {
25368                            resultBytes = message.bytes.slice(0, array.length);
25369                            message.bytes = message.bytes.slice(array.length, message.bytes.length);
25370                            endOfMessage = false;
25371                        }
25372
25373                        for (var i = 0; i < resultBytes.length; i++) {
25374                            array[i] = resultBytes[i];
25375                        }
25376
25377                        tcs.setResult(new System.Net.WebSockets.WebSocketReceiveResult(
25378                            resultBytes.length, message.messageType, endOfMessage));
25379                    } catch (e) {
25380                        tcs.setException(System.Exception.create(e));
25381                    }
25382                }, arguments);
25383
25384            asyncBody();
25385
25386            return tcs.task;
25387        },
25388
25389        closeAsync: function (closeStatus, statusDescription, cancellationToken) {
25390            this.throwIfNotConnected();
25391
25392            if (this.state !== "open") {
25393                throw new System.InvalidOperationException.$ctor1("Socket is not in connected state");
25394            }
25395
25396            var tcs = new System.Threading.Tasks.TaskCompletionSource(),
25397                self = this,
25398                task,
25399                asyncBody = function () {
25400                    if (self.state === "closed") {
25401                        tcs.setResult(null);
25402                        return;
25403                    }
25404
25405                    if (cancellationToken.getIsCancellationRequested()) {
25406                        tcs.setException(new System.Threading.Tasks.TaskCanceledException("Closing has been cancelled.", tcs.task));
25407                        return;
25408                    }
25409
25410                    task = System.Threading.Tasks.Task.delay(0);
25411                    task.continueWith(asyncBody);
25412                };
25413            try {
25414                this.state = "closesent";
25415                this.socket.close(closeStatus, statusDescription);
25416            } catch (e) {
25417                tcs.setException(System.Exception.create(e));
25418            }
25419
25420            asyncBody();
25421
25422            return tcs.task;
25423        },
25424
25425        closeOutputAsync: function (closeStatus, statusDescription, cancellationToken) {
25426            this.throwIfNotConnected();
25427
25428            if (this.state !== "open") {
25429                throw new System.InvalidOperationException.$ctor1("Socket is not in connected state");
25430            }
25431
25432            var tcs = new System.Threading.Tasks.TaskCompletionSource();
25433
25434            try {
25435                this.state = "closesent";
25436                this.socket.close(closeStatus, statusDescription);
25437                tcs.setResult(null);
25438            } catch (e) {
25439                tcs.setException(System.Exception.create(e));
25440            }
25441
25442            return tcs.task;
25443        },
25444
25445        abort: function () {
25446            this.Dispose();
25447        },
25448
25449        Dispose: function () {
25450            if (this.disposed) {
25451                return;
25452            }
25453
25454            this.disposed = true;
25455            this.messageBuffer = [];
25456
25457            if (state === "open") {
25458                this.state = "closesent";
25459                this.socket.close();
25460            }
25461        },
25462
25463        throwIfNotConnected: function () {
25464            if (this.disposed) {
25465                throw new System.InvalidOperationException.$ctor1("Socket is disposed.");
25466            }
25467
25468            if (this.socket.readyState !== 1) {
25469                throw new System.InvalidOperationException.$ctor1("Socket is not connected.");
25470            }
25471        }
25472    });
25473
25474    H5.define("System.Net.WebSockets.ClientWebSocketOptions", {
25475        ctor: function () {
25476            this.$initialize();
25477            this.isReadOnly = false;
25478            this.requestedSubProtocols = [];
25479        },
25480
25481        setToReadOnly: function () {
25482            if (this.isReadOnly) {
25483                throw new System.InvalidOperationException.$ctor1("Options are already readonly.");
25484            }
25485
25486            this.isReadOnly = true;
25487        },
25488
25489        addSubProtocol: function (subProtocol) {
25490            if (this.isReadOnly) {
25491                throw new System.InvalidOperationException.$ctor1("Socket already started.");
25492            }
25493
25494            if (this.requestedSubProtocols.indexOf(subProtocol) > -1) {
25495                throw new System.ArgumentException.$ctor1("Socket cannot have duplicate sub-protocols.", "subProtocol");
25496            }
25497
25498            this.requestedSubProtocols.push(subProtocol);
25499        }
25500    });
25501
25502    H5.define("System.Net.WebSockets.WebSocketReceiveResult", {
25503        ctor: function (count, messageType, endOfMessage, closeStatus, closeStatusDescription) {
25504            this.$initialize();
25505            this.count = count;
25506            this.messageType = messageType;
25507            this.endOfMessage = endOfMessage;
25508            this.closeStatus = closeStatus;
25509            this.closeStatusDescription = closeStatusDescription;
25510        },
25511
25512        getCount: function () {
25513            return this.count;
25514        },
25515
25516        getMessageType: function () {
25517            return this.messageType;
25518        },
25519
25520        getEndOfMessage: function () {
25521            return this.endOfMessage;
25522        },
25523
25524        getCloseStatus: function () {
25525            return this.closeStatus;
25526        },
25527
25528        getCloseStatusDescription: function () {
25529            return this.closeStatusDescription;
25530        }
25531    });
25532
25533    // @source Uri.js
25534
25535    H5.assembly("System", {}, function ($asm, globals) {
25536        "use strict";
25537
25538        H5.define("System.Uri", {
25539            statics: {
25540                methods: {
25541                    equals: function (uri1, uri2) {
25542                        if (uri1 == uri2) {
25543                            return true;
25544                        }
25545
25546                        if (uri1 == null || uri2 == null) {
25547                            return false;
25548                        }
25549
25550                        return uri2.equals(uri1);
25551                    },
25552
25553                    notEquals: function (uri1, uri2) {
25554                        return !System.Uri.equals(uri1, uri2);
25555                    }
25556                }
25557            },
25558
25559            ctor: function (uriString) {
25560                this.$initialize();
25561                this.absoluteUri = uriString;
25562            },
25563
25564            getAbsoluteUri: function () {
25565                return this.absoluteUri;
25566            },
25567
25568            toJSON: function () {
25569                return this.absoluteUri;
25570            },
25571
25572            toString: function () {
25573                return this.absoluteUri;
25574            },
25575
25576            equals: function (uri) {
25577                if (uri == null || !H5.is(uri, System.Uri)) {
25578                    return false;
25579                }
25580
25581                return this.absoluteUri === uri.absoluteUri;
25582            }
25583        });
25584    }, true);
25585
25586    // @source Generator.js
25587
25588    H5.define("H5.GeneratorEnumerable", {
25589        inherits: [System.Collections.IEnumerable],
25590
25591        config: {
25592            alias: [
25593            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator"
25594            ]
25595        },
25596
25597        ctor: function (action) {
25598            this.$initialize();
25599            this.GetEnumerator = action;
25600            this.System$Collections$IEnumerable$GetEnumerator = action;
25601        }
25602    });
25603
25604    H5.define("H5.GeneratorEnumerable$1", function (T)
25605    {
25606        return {
25607            inherits: [System.Collections.Generic.IEnumerable$1(T)],
25608
25609            config: {
25610                alias: [
25611                "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"]
25612                ]
25613            },
25614
25615            ctor: function (action) {
25616                this.$initialize();
25617                this.GetEnumerator = action;
25618                this["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator"] = action;
25619                this["System$Collections$Generic$IEnumerable$1$GetEnumerator"] = action;
25620            }
25621        };
25622    });
25623
25624    H5.define("H5.GeneratorEnumerator", {
25625        inherits: [System.Collections.IEnumerator],
25626
25627        current: null,
25628
25629        config: {
25630            properties: {
25631                Current: {
25632                    get: function () {
25633                        return this.getCurrent();
25634                    }
25635                }
25636            },
25637
25638            alias: [
25639                "getCurrent", "System$Collections$IEnumerator$getCurrent",
25640                "moveNext", "System$Collections$IEnumerator$moveNext",
25641                "reset", "System$Collections$IEnumerator$reset",
25642                "Current", "System$Collections$IEnumerator$Current"
25643            ]
25644        },
25645
25646        ctor: function (action) {
25647            this.$initialize();
25648            this.moveNext = action;
25649            this.System$Collections$IEnumerator$moveNext = action;
25650        },
25651
25652        getCurrent: function () {
25653            return this.current;
25654        },
25655
25656        getCurrent$1: function () {
25657            return this.current;
25658        },
25659
25660        reset: function () {
25661            throw new System.NotSupportedException();
25662        }
25663    });
25664
25665    H5.define("H5.GeneratorEnumerator$1", function (T) {
25666        return {
25667            inherits: [System.Collections.Generic.IEnumerator$1(T), System.IDisposable],
25668
25669            current: null,
25670
25671            config: {
25672                properties: {
25673                    Current: {
25674                        get: function () {
25675                            return this.getCurrent();
25676                        }
25677                    },
25678
25679                    Current$1: {
25680                        get: function () {
25681                            return this.getCurrent();
25682                        }
25683                    }
25684                },
25685                alias: [
25686                    "getCurrent", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$getCurrent$1", "System$Collections$Generic$IEnumerator$1$getCurrent$1"],
25687                    "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"],
25688                    "Current", "System$Collections$IEnumerator$Current",
25689                    "Dispose", "System$IDisposable$Dispose",
25690                    "moveNext", "System$Collections$IEnumerator$moveNext",
25691                    "reset", "System$Collections$IEnumerator$reset"
25692                ]
25693            },
25694
25695            ctor: function (action, final) {
25696                this.$initialize();
25697                this.moveNext = action;
25698                this.System$Collections$IEnumerator$moveNext = action;
25699                this.final = final;
25700            },
25701
25702            getCurrent: function () {
25703                return this.current;
25704            },
25705
25706            getCurrent$1: function () {
25707                return this.current;
25708            },
25709
25710            System$Collections$IEnumerator$getCurrent: function () {
25711                return this.current;
25712            },
25713
25714            Dispose: function () {
25715                if (this.final) {
25716                    this.final();
25717                }
25718            },
25719
25720            reset: function () {
25721                throw new System.NotSupportedException();
25722            }
25723        };
25724    });
25725    // @source linq.js
25726
25727/*--------------------------------------------------------------------------
25728 * linq.js - LINQ for JavaScript
25729 * ver 3.0.4-Beta5 (Jun. 20th, 2013)
25730 *
25731 * created and maintained by neuecc <[email protected]>
25732 * licensed under MIT License
25733 * http://linqjs.codeplex.com/
25734 *------------------------------------------------------------------------*/
25735
25736(function (root, undefined) {
25737    // ReadOnly Function
25738    var Functions = {
25739        Identity: function (x) { return x; },
25740        True: function () { return true; },
25741        Blank: function () { }
25742    };
25743
25744    // const Type
25745    var Types = {
25746        Boolean: typeof true,
25747        Number: typeof 0,
25748        String: typeof "",
25749        Object: typeof {},
25750        Undefined: typeof undefined,
25751        Function: typeof function () { }
25752    };
25753
25754    // createLambda cache
25755    var funcCache = { "": Functions.Identity };
25756
25757    // private utility methods
25758    var Utils = {
25759        // Create anonymous function from lambda expression string
25760        createLambda: function (expression) {
25761            if (expression == null) return Functions.Identity;
25762            if (typeof expression === Types.String) {
25763                // get from cache
25764                var f = funcCache[expression];
25765                if (f != null) {
25766                    return f;
25767                }
25768
25769                if (expression.indexOf("=>") === -1) {
25770                    var regexp = new RegExp("[$]+", "g");
25771
25772                    var maxLength = 0;
25773                    var match;
25774                    while ((match = regexp.exec(expression)) != null) {
25775                        var paramNumber = match[0].length;
25776                        if (paramNumber > maxLength) {
25777                            maxLength = paramNumber;
25778                        }
25779                    }
25780
25781                    var argArray = [];
25782                    for (var i = 1; i <= maxLength; i++) {
25783                        var dollar = "";
25784                        for (var j = 0; j < i; j++) {
25785                            dollar += "$";
25786                        }
25787                        argArray.push(dollar);
25788                    }
25789
25790                    var args = Array.prototype.join.call(argArray, ",");
25791
25792                    f = new Function(args, "return " + expression);
25793                    funcCache[expression] = f;
25794                    return f;
25795                }
25796                else {
25797                    var expr = expression.match(/^[(\s]*([^()]*?)[)\s]*=>(.*)/);
25798                    f = new Function(expr[1], "return " + expr[2]);
25799                    funcCache[expression] = f;
25800                    return f;
25801                }
25802            }
25803            return expression;
25804        },
25805
25806        isIEnumerable: function (obj) {
25807            if (typeof Enumerator !== Types.Undefined) {
25808                try {
25809                    new Enumerator(obj); // check JScript(IE)'s Enumerator
25810                    return true;
25811                }
25812                catch (e) { }
25813            }
25814
25815            return false;
25816        },
25817
25818        // IE8's defineProperty is defined but cannot use, therefore check defineProperties
25819        defineProperty: (Object.defineProperties != null)
25820            ? function (target, methodName, value) {
25821                Object.defineProperty(target, methodName, {
25822                    enumerable: false,
25823                    configurable: true,
25824                    writable: true,
25825                    value: value
25826                })
25827            }
25828            : function (target, methodName, value) {
25829                target[methodName] = value;
25830            },
25831
25832        compare: function (a, b) {
25833            return (a === b) ? 0
25834                 : (a > b) ? 1
25835                 : -1;
25836        },
25837
25838        Dispose: function (obj) {
25839            if (obj != null) obj.Dispose();
25840        }
25841    };
25842
25843    // IEnumerator State
25844    var State = { Before: 0, Running: 1, After: 2 };
25845
25846    // "Enumerator" is conflict JScript's "Enumerator"
25847    var IEnumerator = function (initialize, tryGetNext, dispose) {
25848        var yielder = new Yielder();
25849        var state = State.Before;
25850
25851        this.getCurrent = yielder.getCurrent;
25852        this.reset = function () { throw new Error("Reset is not supported"); };
25853
25854        this.moveNext = function () {
25855            try {
25856                switch (state) {
25857                    case State.Before:
25858                        state = State.Running;
25859                        initialize();
25860                        // fall through
25861                    case State.Running:
25862                        if (tryGetNext.apply(yielder)) {
25863                            return true;
25864                        }
25865                        else {
25866                            this.Dispose();
25867                            return false;
25868                        }
25869                    case State.After:
25870                        return false;
25871                }
25872            }
25873            catch (e) {
25874                this.Dispose();
25875                throw e;
25876            }
25877        };
25878
25879        this.Dispose = function () {
25880            if (state != State.Running) return;
25881
25882            try {
25883                dispose();
25884            }
25885            finally {
25886                state = State.After;
25887            }
25888        };
25889
25890        this.System$IDisposable$Dispose = this.Dispose;
25891        this.getCurrent$1 = this.getCurrent;
25892        this.System$Collections$IEnumerator$getCurrent = this.getCurrent;
25893        this.System$Collections$IEnumerator$moveNext = this.moveNext;
25894        this.System$Collections$IEnumerator$reset = this.reset;
25895
25896        Object.defineProperties(this,
25897        {
25898            "Current$1": {
25899                get: this.getCurrent,
25900                enumerable: true
25901            },
25902
25903            "Current": {
25904                get: this.getCurrent,
25905                enumerable: true
25906            },
25907
25908            "System$Collections$IEnumerator$Current": {
25909                get: this.getCurrent,
25910                enumerable: true
25911            }
25912        });
25913    };
25914
25915    IEnumerator.$$inherits = [];
25916    H5.Class.addExtend(IEnumerator, [System.IDisposable, System.Collections.IEnumerator]);
25917
25918    // for tryGetNext
25919    var Yielder = function () {
25920        var current = null;
25921        this.getCurrent = function () { return current; };
25922        this.yieldReturn = function (value) {
25923            current = value;
25924            return true;
25925        };
25926        this.yieldBreak = function () {
25927            return false;
25928        };
25929    };
25930
25931    // Enumerable constuctor
25932    var Enumerable = function (GetEnumerator) {
25933        this.GetEnumerator = GetEnumerator;
25934    };
25935
25936    Enumerable.$$inherits = [];
25937    H5.Class.addExtend(Enumerable, [System.Collections.IEnumerable]);
25938
25939    // Utility
25940
25941    Enumerable.Utils = {}; // container
25942
25943    Enumerable.Utils.createLambda = function (expression) {
25944        return Utils.createLambda(expression);
25945    };
25946
25947    Enumerable.Utils.createEnumerable = function (GetEnumerator) {
25948        return new Enumerable(GetEnumerator);
25949    };
25950
25951    Enumerable.Utils.createEnumerator = function (initialize, tryGetNext, dispose) {
25952        return new IEnumerator(initialize, tryGetNext, dispose);
25953    };
25954
25955    Enumerable.Utils.extendTo = function (type) {
25956        var typeProto = type.prototype;
25957        var enumerableProto;
25958
25959        if (type === Array) {
25960            enumerableProto = ArrayEnumerable.prototype;
25961            Utils.defineProperty(typeProto, "getSource", function () {
25962                return this;
25963            });
25964        }
25965        else {
25966            enumerableProto = Enumerable.prototype;
25967            Utils.defineProperty(typeProto, "GetEnumerator", function () {
25968                return Enumerable.from(this).GetEnumerator();
25969            });
25970        }
25971
25972        for (var methodName in enumerableProto) {
25973            var func = enumerableProto[methodName];
25974
25975            // already extended
25976            if (typeProto[methodName] == func) continue;
25977
25978            // already defined(example Array#reverse/join/forEach...)
25979            if (typeProto[methodName] != null) {
25980                methodName = methodName + "ByLinq";
25981                if (typeProto[methodName] == func) continue; // recheck
25982            }
25983
25984            if (func instanceof Function) {
25985                Utils.defineProperty(typeProto, methodName, func);
25986            }
25987        }
25988    };
25989
25990    // Generator
25991
25992    Enumerable.choice = function () // variable argument
25993    {
25994        var args = arguments;
25995
25996        return new Enumerable(function () {
25997            return new IEnumerator(
25998                function () {
25999                    args = (args[0] instanceof Array) ? args[0]
26000                        : (args[0].GetEnumerator != null) ? args[0].ToArray()
26001                        : args;
26002                },
26003                function () {
26004                    return this.yieldReturn(args[Math.floor(Math.random() * args.length)]);
26005                },
26006                Functions.Blank);
26007        });
26008    };
26009
26010    Enumerable.cycle = function () // variable argument
26011    {
26012        var args = arguments;
26013
26014        return new Enumerable(function () {
26015            var index = 0;
26016            return new IEnumerator(
26017                function () {
26018                    args = (args[0] instanceof Array) ? args[0]
26019                        : (args[0].GetEnumerator != null) ? args[0].ToArray()
26020                        : args;
26021                },
26022                function () {
26023                    if (index >= args.length) index = 0;
26024                    return this.yieldReturn(args[index++]);
26025                },
26026                Functions.Blank);
26027        });
26028    };
26029
26030    // private singleton
26031    var emptyEnumerable = new Enumerable(function () {
26032            return new IEnumerator(
26033                Functions.Blank,
26034                function () { return false; },
26035                Functions.Blank);
26036        });
26037    Enumerable.empty = function () {
26038        return emptyEnumerable;
26039    };
26040
26041    Enumerable.from = function (obj, T) {
26042        if (obj == null) {
26043            return null;
26044        }
26045        if (obj instanceof Enumerable) {
26046            return obj;
26047        }
26048        if (typeof obj == Types.Number || typeof obj == Types.Boolean) {
26049            return Enumerable.repeat(obj, 1);
26050        }
26051        if (typeof obj == Types.String) {
26052            return new Enumerable(function () {
26053                var index = 0;
26054                return new IEnumerator(
26055                    Functions.Blank,
26056                    function () {
26057                        return (index < obj.length) ? this.yieldReturn(obj.charCodeAt(index++)) : false;
26058                    },
26059                    Functions.Blank);
26060            });
26061        }
26062        var ienum = H5.as(obj, System.Collections.IEnumerable);
26063        if (ienum) {
26064            return new Enumerable(function () {
26065                var enumerator;
26066                return new IEnumerator(
26067                    function () { enumerator = H5.getEnumerator(ienum, T); },
26068                    function () {
26069                        var ok = enumerator.moveNext();
26070                        return ok ? this.yieldReturn(enumerator.Current) : false;
26071                    },
26072                    function () {
26073                        var disposable = H5.as(enumerator, System.IDisposable);
26074                        if (disposable) {
26075                            disposable.Dispose();
26076                        }
26077                    }
26078                );
26079            });
26080        }
26081        if (typeof obj != Types.Function) {
26082            // array or array like object
26083            if (typeof obj.length == Types.Number) {
26084                return new ArrayEnumerable(obj);
26085            }
26086
26087            // JScript's IEnumerable
26088            if (!(obj instanceof Object) && Utils.isIEnumerable(obj)) {
26089                return new Enumerable(function () {
26090                    var isFirst = true;
26091                    var enumerator;
26092                    return new IEnumerator(
26093                        function () { enumerator = new Enumerator(obj); },
26094                        function () {
26095                            if (isFirst) isFirst = false;
26096                            else enumerator.moveNext();
26097
26098                            return (enumerator.atEnd()) ? false : this.yieldReturn(enumerator.item());
26099                        },
26100                        Functions.Blank);
26101                });
26102            }
26103
vendor: 6,779 bytes, lines 26104-26298
26104            // WinMD IIterable<T>
26105            if (typeof Windows === Types.Object && typeof obj.first === Types.Function) {
26106                return new Enumerable(function () {
26107                    var isFirst = true;
26108                    var enumerator;
26109                    return new IEnumerator(
26110                        function () { enumerator = obj.first(); },
26111                        function () {
26112                            if (isFirst) isFirst = false;
26113                            else enumerator.moveNext();
26114
26115                            return (enumerator.hasCurrent) ? this.yieldReturn(enumerator.current) : this.yieldBreak();
26116                        },
26117                        Functions.Blank);
26118                });
26119            }
26120        }
26121
26122        // case function/object : Create keyValuePair[]
26123        return new Enumerable(function () {
26124            var array = [];
26125            var index = 0;
26126
26127            return new IEnumerator(
26128                function () {
26129                    for (var key in obj) {
26130                        var value = obj[key];
26131                        if (!(value instanceof Function) && Object.prototype.hasOwnProperty.call(obj, key)) {
26132                            array.push({ key: key, value: value });
26133                        }
26134                    }
26135                },
26136                function () {
26137                    return (index < array.length)
26138                        ? this.yieldReturn(array[index++])
26139                        : false;
26140                },
26141                Functions.Blank);
26142        });
26143    },
26144
26145    Enumerable.make = function (element) {
26146        return Enumerable.repeat(element, 1);
26147    };
26148
26149    // Overload:function (input, pattern)
26150    // Overload:function (input, pattern, flags)
26151    Enumerable.matches = function (input, pattern, flags) {
26152        if (flags == null) flags = "";
26153        if (pattern instanceof RegExp) {
26154            flags += (pattern.ignoreCase) ? "i" : "";
26155            flags += (pattern.multiline) ? "m" : "";
26156            pattern = pattern.source;
26157        }
26158        if (flags.indexOf("g") === -1) flags += "g";
26159
26160        return new Enumerable(function () {
26161            var regex;
26162            return new IEnumerator(
26163                function () { regex = new RegExp(pattern, flags); },
26164                function () {
26165                    var match = regex.exec(input);
26166                    return (match) ? this.yieldReturn(match) : false;
26167                },
26168                Functions.Blank);
26169        });
26170    };
26171
26172    // Overload:function (start, count)
26173    // Overload:function (start, count, step)
26174    Enumerable.range = function (start, count, step) {
26175        if (step == null) step = 1;
26176
26177        return new Enumerable(function () {
26178            var value;
26179            var index = 0;
26180
26181            return new IEnumerator(
26182                function () { value = start - step; },
26183                function () {
26184                    return (index++ < count)
26185                        ? this.yieldReturn(value += step)
26186                        : this.yieldBreak();
26187                },
26188                Functions.Blank);
26189        });
26190    };
26191
26192    // Overload:function (start, count)
26193    // Overload:function (start, count, step)
26194    Enumerable.rangeDown = function (start, count, step) {
26195        if (step == null) step = 1;
26196
26197        return new Enumerable(function () {
26198            var value;
26199            var index = 0;
26200
26201            return new IEnumerator(
26202                function () { value = start + step; },
26203                function () {
26204                    return (index++ < count)
26205                        ? this.yieldReturn(value -= step)
26206                        : this.yieldBreak();
26207                },
26208                Functions.Blank);
26209        });
26210    };
26211
26212    // Overload:function (start, to)
26213    // Overload:function (start, to, step)
26214    Enumerable.rangeTo = function (start, to, step) {
26215        if (step == null) step = 1;
26216
26217        if (start < to) {
26218            return new Enumerable(function () {
26219                var value;
26220
26221                return new IEnumerator(
26222                function () { value = start - step; },
26223                function () {
26224                    var next = value += step;
26225                    return (next <= to)
26226                        ? this.yieldReturn(next)
26227                        : this.yieldBreak();
26228                },
26229                Functions.Blank);
26230            });
26231        }
26232        else {
26233            return new Enumerable(function () {
26234                var value;
26235
26236                return new IEnumerator(
26237                function () { value = start + step; },
26238                function () {
26239                    var next = value -= step;
26240                    return (next >= to)
26241                        ? this.yieldReturn(next)
26242                        : this.yieldBreak();
26243                },
26244                Functions.Blank);
26245            });
26246        }
26247    };
26248
26249    // Overload:function (element)
26250    // Overload:function (element, count)
26251    Enumerable.repeat = function (element, count) {
26252        if (count != null) return Enumerable.repeat(element).take(count);
26253
26254        return new Enumerable(function () {
26255            return new IEnumerator(
26256                Functions.Blank,
26257                function () { return this.yieldReturn(element); },
26258                Functions.Blank);
26259        });
26260    };
26261
26262    Enumerable.repeatWithFinalize = function (initializer, finalizer) {
26263        initializer = Utils.createLambda(initializer);
26264        finalizer = Utils.createLambda(finalizer);
26265
26266        return new Enumerable(function () {
26267            var element;
26268            return new IEnumerator(
26269                function () { element = initializer(); },
26270                function () { return this.yieldReturn(element); },
26271                function () {
26272                    if (element != null) {
26273                        finalizer(element);
26274                        element = null;
26275                    }
26276                });
26277        });
26278    };
26279
26280    // Overload:function (func)
26281    // Overload:function (func, count)
26282    Enumerable.generate = function (func, count) {
26283        if (count != null) return Enumerable.generate(func).take(count);
26284        func = Utils.createLambda(func);
26285
26286        return new Enumerable(function () {
26287            return new IEnumerator(
26288                Functions.Blank,
26289                function () { return this.yieldReturn(func()); },
26290                Functions.Blank);
26291        });
26292    };
26293
26294    // Overload:function ()
26295    // Overload:function (start)
26296    // Overload:function (start, step)
26297    Enumerable.toInfinity = function (start, step) {
26298        if (start == null) start = 0;
26299        if (step == null) step = 1;
26300
26301        return new Enumerable(function () {
26302            var value;
26303            return new IEnumerator(
26304                function () { value = start - step; },
26305                function () { return this.yieldReturn(value += step); },
26306                Functions.Blank);
26307        });
26308    };
26309
26310    // Overload:function ()
26311    // Overload:function (start)
26312    // Overload:function (start, step)
26313    Enumerable.toNegativeInfinity = function (start, step) {
26314        if (start == null) start = 0;
26315        if (step == null) step = 1;
26316
26317        return new Enumerable(function () {
26318            var value;
26319            return new IEnumerator(
26320                function () { value = start + step; },
26321                function () { return this.yieldReturn(value -= step); },
26322                Functions.Blank);
26323        });
26324    };
26325
26326    Enumerable.unfold = function (seed, func) {
26327        func = Utils.createLambda(func);
26328
26329        return new Enumerable(function () {
26330            var isFirst = true;
26331            var value;
26332            return new IEnumerator(
26333                Functions.Blank,
26334                function () {
26335                    if (isFirst) {
26336                        isFirst = false;
26337                        value = seed;
26338                        return this.yieldReturn(value);
26339                    }
26340                    value = func(value);
26341                    return this.yieldReturn(value);
26342                },
26343                Functions.Blank);
26344        });
26345    };
26346
26347    Enumerable.defer = function (enumerableFactory) {
26348        return new Enumerable(function () {
26349            var enumerator;
26350
26351            return new IEnumerator(
26352                function () { enumerator = Enumerable.from(enumerableFactory()).GetEnumerator(); },
26353                function () {
26354                    return (enumerator.moveNext())
26355                        ? this.yieldReturn(enumerator.Current)
26356                        : this.yieldBreak();
26357                },
26358                function () {
26359                    Utils.Dispose(enumerator);
26360                });
26361        });
26362    };
26363
26364    // Extension Methods
26365
26366    /* Projection and Filtering Methods */
26367
26368    // Overload:function (func)
26369    // Overload:function (func, resultSelector<element>)
26370    // Overload:function (func, resultSelector<element, nestLevel>)
26371    Enumerable.prototype.traverseBreadthFirst = function (func, resultSelector) {
26372        var source = this;
26373        func = Utils.createLambda(func);
26374        resultSelector = Utils.createLambda(resultSelector);
26375
26376        return new Enumerable(function () {
26377            var enumerator;
26378            var nestLevel = 0;
26379            var buffer = [];
26380
26381            return new IEnumerator(
26382                function () { enumerator = source.GetEnumerator(); },
26383                function () {
26384                    while (true) {
26385                        if (enumerator.moveNext()) {
26386                            buffer.push(enumerator.Current);
26387                            return this.yieldReturn(resultSelector(enumerator.Current, nestLevel));
26388                        }
26389
26390                        var next = Enumerable.from(buffer).selectMany(function (x) { return func(x); });
26391                        if (!next.any()) {
26392                            return false;
26393                        }
26394                        else {
26395                            nestLevel++;
26396                            buffer = [];
26397                            Utils.Dispose(enumerator);
26398                            enumerator = next.GetEnumerator();
26399                        }
26400                    }
26401                },
26402                function () { Utils.Dispose(enumerator); });
26403        });
26404    };
26405
26406    // Overload:function (func)
26407    // Overload:function (func, resultSelector<element>)
26408    // Overload:function (func, resultSelector<element, nestLevel>)
26409    Enumerable.prototype.traverseDepthFirst = function (func, resultSelector) {
26410        var source = this;
26411        func = Utils.createLambda(func);
26412        resultSelector = Utils.createLambda(resultSelector);
26413
26414        return new Enumerable(function () {
26415            var enumeratorStack = [];
26416            var enumerator;
26417
26418            return new IEnumerator(
26419                function () { enumerator = source.GetEnumerator(); },
26420                function () {
26421                    while (true) {
26422                        if (enumerator.moveNext()) {
26423                            var value = resultSelector(enumerator.Current, enumeratorStack.length);
26424                            enumeratorStack.push(enumerator);
26425                            enumerator = Enumerable.from(func(enumerator.Current)).GetEnumerator();
26426                            return this.yieldReturn(value);
26427                        }
26428
26429                        if (enumeratorStack.length <= 0) return false;
26430                        Utils.Dispose(enumerator);
26431                        enumerator = enumeratorStack.pop();
26432                    }
26433                },
26434                function () {
26435                    try {
26436                        Utils.Dispose(enumerator);
26437                    }
26438                    finally {
26439                        Enumerable.from(enumeratorStack).forEach(function (s) { s.Dispose(); });
26440                    }
26441                });
26442        });
26443    };
26444
26445    Enumerable.prototype.flatten = function () {
26446        var source = this;
26447
26448        return new Enumerable(function () {
26449            var enumerator;
26450            var middleEnumerator = null;
26451
26452            return new IEnumerator(
26453                function () { enumerator = source.GetEnumerator(); },
26454                function () {
26455                    while (true) {
26456                        if (middleEnumerator != null) {
26457                            if (middleEnumerator.moveNext()) {
26458                                return this.yieldReturn(middleEnumerator.Current);
26459                            }
26460                            else {
26461                                middleEnumerator = null;
26462                            }
26463                        }
26464
26465                        if (enumerator.moveNext()) {
26466                            if (enumerator.Current instanceof Array) {
26467                                Utils.Dispose(middleEnumerator);
26468                                middleEnumerator = Enumerable.from(enumerator.Current)
26469                                    .selectMany(Functions.Identity)
26470                                    .flatten()
26471                                    .GetEnumerator();
26472                                continue;
26473                            }
26474                            else {
26475                                return this.yieldReturn(enumerator.Current);
26476                            }
26477                        }
26478
26479                        return false;
26480                    }
26481                },
26482                function () {
26483                    try {
26484                        Utils.Dispose(enumerator);
26485                    }
26486                    finally {
26487                        Utils.Dispose(middleEnumerator);
26488                    }
26489                });
26490        });
26491    };
26492
26493    Enumerable.prototype.pairwise = function (selector) {
26494        var source = this;
26495        selector = Utils.createLambda(selector);
26496
26497        return new Enumerable(function () {
26498            var enumerator;
26499
26500            return new IEnumerator(
26501                function () {
26502                    enumerator = source.GetEnumerator();
26503                    enumerator.moveNext();
26504                },
26505                function () {
26506                    var prev = enumerator.Current;
26507                    return (enumerator.moveNext())
26508                        ? this.yieldReturn(selector(prev, enumerator.Current))
26509                        : false;
26510                },
26511                function () { Utils.Dispose(enumerator); });
26512        });
26513    };
26514
26515    // Overload:function (func)
26516    // Overload:function (seed,func<value,element>)
26517    Enumerable.prototype.scan = function (seed, func) {
26518        var isUseSeed;
26519        if (func == null) {
26520            func = Utils.createLambda(seed); // arguments[0]
26521            isUseSeed = false;
26522        } else {
26523            func = Utils.createLambda(func);
26524            isUseSeed = true;
26525        }
26526        var source = this;
26527
26528        return new Enumerable(function () {
26529            var enumerator;
26530            var value;
26531            var isFirst = true;
26532
26533            return new IEnumerator(
26534                function () { enumerator = source.GetEnumerator(); },
26535                function () {
26536                    if (isFirst) {
26537                        isFirst = false;
26538                        if (!isUseSeed) {
26539                            if (enumerator.moveNext()) {
26540                                return this.yieldReturn(value = enumerator.Current);
26541                            }
26542                        }
26543                        else {
26544                            return this.yieldReturn(value = seed);
26545                        }
26546                    }
26547
26548                    return (enumerator.moveNext())
26549                        ? this.yieldReturn(value = func(value, enumerator.Current))
26550                        : false;
26551                },
26552                function () { Utils.Dispose(enumerator); });
26553        });
26554    };
26555
26556    // Overload:function (selector<element>)
26557    // Overload:function (selector<element,index>)
26558    Enumerable.prototype.select = function (selector) {
26559        selector = Utils.createLambda(selector);
26560
26561        if (selector.length <= 1) {
26562            return new WhereSelectEnumerable(this, null, selector);
26563        }
26564        else {
26565            var source = this;
26566
26567            return new Enumerable(function () {
26568                var enumerator;
26569                var index = 0;
26570
26571                return new IEnumerator(
26572                    function () { enumerator = source.GetEnumerator(); },
26573                    function () {
26574                        return (enumerator.moveNext())
26575                            ? this.yieldReturn(selector(enumerator.Current, index++))
26576                            : false;
26577                    },
26578                    function () { Utils.Dispose(enumerator); });
26579            });
26580        }
26581    };
26582
26583    // Overload:function (collectionSelector<element>)
26584    // Overload:function (collectionSelector<element,index>)
26585    // Overload:function (collectionSelector<element>,resultSelector)
26586    // Overload:function (collectionSelector<element,index>,resultSelector)
26587    Enumerable.prototype.selectMany = function (collectionSelector, resultSelector) {
26588        var source = this;
26589        collectionSelector = Utils.createLambda(collectionSelector);
26590        if (resultSelector == null) resultSelector = function (a, b) { return b; };
26591        resultSelector = Utils.createLambda(resultSelector);
26592
26593        return new Enumerable(function () {
26594            var enumerator;
26595            var middleEnumerator = undefined;
26596            var index = 0;
26597
26598            return new IEnumerator(
26599                function () { enumerator = source.GetEnumerator(); },
26600                function () {
26601                    if (middleEnumerator === undefined) {
26602                        if (!enumerator.moveNext()) return false;
26603                    }
26604                    do {
26605                        if (middleEnumerator == null) {
26606                            var middleSeq = collectionSelector(enumerator.Current, index++);
26607                            middleEnumerator = Enumerable.from(middleSeq).GetEnumerator();
26608                        }
26609                        if (middleEnumerator.moveNext()) {
26610                            return this.yieldReturn(resultSelector(enumerator.Current, middleEnumerator.Current));
26611                        }
26612                        Utils.Dispose(middleEnumerator);
26613                        middleEnumerator = null;
26614                    } while (enumerator.moveNext());
26615                    return false;
26616                },
26617                function () {
26618                    try {
26619                        Utils.Dispose(enumerator);
26620                    }
26621                    finally {
26622                        Utils.Dispose(middleEnumerator);
26623                    }
26624                });
26625        });
26626    };
26627
26628    // Overload:function (predicate<element>)
26629    // Overload:function (predicate<element,index>)
26630    Enumerable.prototype.where = function (predicate) {
26631        predicate = Utils.createLambda(predicate);
26632
26633        if (predicate.length <= 1) {
26634            return new WhereEnumerable(this, predicate);
26635        }
26636        else {
26637            var source = this;
26638
26639            return new Enumerable(function () {
26640                var enumerator;
26641                var index = 0;
26642
26643                return new IEnumerator(
26644                    function () { enumerator = source.GetEnumerator(); },
26645                    function () {
26646                        while (enumerator.moveNext()) {
26647                            if (predicate(enumerator.Current, index++)) {
26648                                return this.yieldReturn(enumerator.Current);
26649                            }
26650                        }
26651                        return false;
26652                    },
26653                    function () { Utils.Dispose(enumerator); });
26654            });
26655        }
26656    };
26657
26658    // Overload:function (selector<element>)
26659    // Overload:function (selector<element,index>)
26660    Enumerable.prototype.choose = function (selector) {
26661        selector = Utils.createLambda(selector);
26662        var source = this;
26663
26664        return new Enumerable(function () {
26665            var enumerator;
26666            var index = 0;
26667
26668            return new IEnumerator(
26669                function () { enumerator = source.GetEnumerator(); },
26670                function () {
26671                    while (enumerator.moveNext()) {
26672                        var result = selector(enumerator.Current, index++);
26673                        if (result != null) {
26674                            return this.yieldReturn(result);
26675                        }
26676                    }
26677                    return this.yieldBreak();
26678                },
26679                function () { Utils.Dispose(enumerator); });
26680        });
26681    };
26682
26683    Enumerable.prototype.ofType = function (type) {
26684        var source = this;
26685
26686        return new Enumerable(function () {
26687            var enumerator;
26688
26689            return new IEnumerator(
26690                function () {
26691                    enumerator = H5.getEnumerator(source);
26692                },
26693                function () {
26694                    while (enumerator.moveNext()) {
26695                        var v = H5.as(enumerator.Current, type);
26696                        if (H5.hasValue(v)) {
26697                            return this.yieldReturn(v);
26698                        }
26699                    }
26700                    return false;
26701                },
26702                function () {
26703                    Utils.Dispose(enumerator);
26704                });
26705        });
26706    };
26707
26708    // mutiple arguments, last one is selector, others are enumerable
26709    Enumerable.prototype.zip = function () {
26710        var args = arguments;
26711        var selector = Utils.createLambda(arguments[arguments.length - 1]);
26712
26713        var source = this;
26714        // optimized case:argument is 2
26715        if (arguments.length == 2) {
26716            var second = arguments[0];
26717
26718            if (second == null) {
26719                throw new System.ArgumentNullException();
26720            }
26721
26722            return new Enumerable(function () {
26723                var firstEnumerator;
26724                var secondEnumerator;
26725                var index = 0;
26726
26727                return new IEnumerator(
26728                function () {
26729                    firstEnumerator = source.GetEnumerator();
26730                    secondEnumerator = Enumerable.from(second).GetEnumerator();
26731                },
26732                function () {
26733                    if (firstEnumerator.moveNext() && secondEnumerator.moveNext()) {
26734                        return this.yieldReturn(selector(firstEnumerator.Current, secondEnumerator.Current, index++));
26735                    }
26736                    return false;
26737                },
26738                function () {
26739                    try {
26740                        Utils.Dispose(firstEnumerator);
26741                    } finally {
26742                        Utils.Dispose(secondEnumerator);
26743                    }
26744                });
26745            });
26746        }
26747        else {
26748            return new Enumerable(function () {
26749                var enumerators;
26750                var index = 0;
26751
26752                return new IEnumerator(
26753                function () {
26754                    var array = Enumerable.make(source)
26755                        .concat(Enumerable.from(args).takeExceptLast().select(Enumerable.from))
26756                        .select(function (x) { return x.GetEnumerator() })
26757                        .ToArray();
26758                    enumerators = Enumerable.from(array);
26759                },
26760                function () {
26761                    if (enumerators.all(function (x) { return x.moveNext() })) {
26762                        var array = enumerators
26763                            .select(function (x) { return x.Current; })
26764                            .ToArray();
26765                        array.push(index++);
26766                        return this.yieldReturn(selector.apply(null, array));
26767                    }
26768                    else {
26769                        return this.yieldBreak();
26770                    }
26771                },
26772                function () {
26773                    Enumerable.from(enumerators).forEach(Utils.Dispose);
26774                });
26775            });
26776        }
26777    };
26778
26779    // mutiple arguments
26780    Enumerable.prototype.merge = function () {
26781        var args = arguments;
26782        var source = this;
26783
26784        return new Enumerable(function () {
26785            var enumerators;
26786            var index = -1;
26787
26788            return new IEnumerator(
26789                function () {
26790                    enumerators = Enumerable.make(source)
26791                        .concat(Enumerable.from(args).select(Enumerable.from))
26792                        .select(function (x) { return x.GetEnumerator() })
26793                        .ToArray();
26794                },
26795                function () {
26796                    while (enumerators.length > 0) {
26797                        index = (index >= enumerators.length - 1) ? 0 : index + 1;
26798                        var enumerator = enumerators[index];
26799
26800                        if (enumerator.moveNext()) {
26801                            return this.yieldReturn(enumerator.Current);
26802                        }
26803                        else {
26804                            enumerator.Dispose();
26805                            enumerators.splice(index--, 1);
26806                        }
26807                    }
26808                    return this.yieldBreak();
26809                },
26810                function () {
26811                    Enumerable.from(enumerators).forEach(Utils.Dispose);
26812                });
26813        });
26814    };
26815
26816    /* Join Methods */
26817
26818    // Overload:function (inner, outerKeySelector, innerKeySelector, resultSelector)
26819    // Overload:function (inner, outerKeySelector, innerKeySelector, resultSelector, compareSelector)
26820    Enumerable.prototype.join = function (inner, outerKeySelector, innerKeySelector, resultSelector, comparer) {
26821        outerKeySelector = Utils.createLambda(outerKeySelector);
26822        innerKeySelector = Utils.createLambda(innerKeySelector);
26823        resultSelector = Utils.createLambda(resultSelector);
26824
26825        if (inner == null) {
26826            throw new System.ArgumentNullException();
26827        }
26828
26829        var source = this;
26830
26831        return new Enumerable(function () {
26832            var outerEnumerator;
26833            var lookup;
26834            var innerElements = null;
26835            var innerCount = 0;
26836
26837            return new IEnumerator(
26838                function () {
26839                    outerEnumerator = source.GetEnumerator();
26840                    lookup = Enumerable.from(inner).toLookup(innerKeySelector, Functions.Identity, comparer);
26841                },
26842                function () {
26843                    while (true) {
26844                        if (innerElements != null) {
26845                            var innerElement = innerElements[innerCount++];
26846                            if (innerElement !== undefined) {
26847                                return this.yieldReturn(resultSelector(outerEnumerator.Current, innerElement));
26848                            }
26849
26850                            innerElement = null;
26851                            innerCount = 0;
26852                        }
26853
26854                        if (outerEnumerator.moveNext()) {
26855                            var key = outerKeySelector(outerEnumerator.Current);
26856                            innerElements = lookup.get(key).ToArray();
26857                        } else {
26858                            return false;
26859                        }
26860                    }
26861                },
26862                function () { Utils.Dispose(outerEnumerator); });
26863        });
26864    };
26865
26866    // Overload:function (inner, outerKeySelector, innerKeySelector, resultSelector)
26867    // Overload:function (inner, outerKeySelector, innerKeySelector, resultSelector, compareSelector)
26868    Enumerable.prototype.groupJoin = function (inner, outerKeySelector, innerKeySelector, resultSelector, comparer) {
26869        outerKeySelector = Utils.createLambda(outerKeySelector);
26870        innerKeySelector = Utils.createLambda(innerKeySelector);
26871        resultSelector = Utils.createLambda(resultSelector);
26872        var source = this;
26873
26874        if (inner == null) {
26875            throw new System.ArgumentNullException();
26876        }
26877
26878        return new Enumerable(function () {
26879            var enumerator = source.GetEnumerator();
26880            var lookup = null;
26881
26882            return new IEnumerator(
26883                function () {
26884                    enumerator = source.GetEnumerator();
26885                    lookup = Enumerable.from(inner).toLookup(innerKeySelector, Functions.Identity, comparer);
26886                },
26887                function () {
26888                    if (enumerator.moveNext()) {
26889                        var innerElement = lookup.get(outerKeySelector(enumerator.Current));
26890                        return this.yieldReturn(resultSelector(enumerator.Current, innerElement));
26891                    }
26892                    return false;
26893                },
26894                function () { Utils.Dispose(enumerator); });
26895        });
26896    };
26897
26898    /* Set Methods */
26899
26900    Enumerable.prototype.all = function (predicate) {
26901        predicate = Utils.createLambda(predicate);
26902
26903        var result = true;
26904        this.forEach(function (x) {
26905            if (!predicate(x)) {
26906                result = false;
26907                return false; // break
26908            }
26909        });
26910        return result;
26911    };
26912
26913    // Overload:function ()
26914    // Overload:function (predicate)
26915    Enumerable.prototype.any = function (predicate) {
26916        predicate = Utils.createLambda(predicate);
26917
26918        var enumerator = this.GetEnumerator();
26919        try {
26920            if (arguments.length == 0) return enumerator.moveNext(); // case:function ()
26921
26922            while (enumerator.moveNext()) // case:function (predicate)
26923            {
26924                if (predicate(enumerator.Current)) return true;
26925            }
26926            return false;
26927        }
26928        finally {
26929            Utils.Dispose(enumerator);
26930        }
26931    };
26932
26933    Enumerable.prototype.isEmpty = function () {
26934        return !this.any();
26935    };
26936
26937    // multiple arguments
26938    Enumerable.prototype.concat = function () {
26939        var source = this;
26940
26941        if (arguments.length == 1) {
26942            var second = arguments[0];
26943
26944            if (second == null) {
26945                throw new System.ArgumentNullException();
26946            }
26947
26948            return new Enumerable(function () {
26949                var firstEnumerator;
26950                var secondEnumerator;
26951
26952                return new IEnumerator(
26953                function () { firstEnumerator = source.GetEnumerator(); },
26954                function () {
26955                    if (secondEnumerator == null) {
26956                        if (firstEnumerator.moveNext()) return this.yieldReturn(firstEnumerator.Current);
26957                        secondEnumerator = Enumerable.from(second).GetEnumerator();
26958                    }
26959                    if (secondEnumerator.moveNext()) return this.yieldReturn(secondEnumerator.Current);
26960                    return false;
26961                },
26962                function () {
26963                    try {
26964                        Utils.Dispose(firstEnumerator);
26965                    }
26966                    finally {
26967                        Utils.Dispose(secondEnumerator);
26968                    }
26969                });
26970            });
26971        }
26972        else {
26973            var args = arguments;
26974
26975            return new Enumerable(function () {
26976                var enumerators;
26977
26978                return new IEnumerator(
26979                    function () {
26980                        enumerators = Enumerable.make(source)
26981                            .concat(Enumerable.from(args).select(Enumerable.from))
26982                            .select(function (x) { return x.GetEnumerator() })
26983                            .ToArray();
26984                    },
26985                    function () {
26986                        while (enumerators.length > 0) {
26987                            var enumerator = enumerators[0];
26988
26989                            if (enumerator.moveNext()) {
26990                                return this.yieldReturn(enumerator.Current);
26991                            }
26992                            else {
26993                                enumerator.Dispose();
26994                                enumerators.splice(0, 1);
26995                            }
26996                        }
26997                        return this.yieldBreak();
26998                    },
26999                    function () {
27000                        Enumerable.from(enumerators).forEach(Utils.Dispose);
27001                    });
27002            });
27003        }
27004    };
27005
27006    Enumerable.prototype.insert = function (index, second) {
27007        var source = this;
27008
27009        return new Enumerable(function () {
27010            var firstEnumerator;
27011            var secondEnumerator;
27012            var count = 0;
27013            var isEnumerated = false;
27014
27015            return new IEnumerator(
27016                function () {
27017                    firstEnumerator = source.GetEnumerator();
27018                    secondEnumerator = Enumerable.from(second).GetEnumerator();
27019                },
27020                function () {
27021                    if (count == index && secondEnumerator.moveNext()) {
27022                        isEnumerated = true;
27023                        return this.yieldReturn(secondEnumerator.Current);
27024                    }
27025                    if (firstEnumerator.moveNext()) {
27026                        count++;
27027                        return this.yieldReturn(firstEnumerator.Current);
27028                    }
27029                    if (!isEnumerated && secondEnumerator.moveNext()) {
27030                        return this.yieldReturn(secondEnumerator.Current);
27031                    }
27032                    return false;
27033                },
27034                function () {
27035                    try {
27036                        Utils.Dispose(firstEnumerator);
27037                    }
27038                    finally {
27039                        Utils.Dispose(secondEnumerator);
27040                    }
27041                });
27042        });
27043    };
27044
27045    Enumerable.prototype.alternate = function (alternateValueOrSequence) {
27046        var source = this;
27047
27048        return new Enumerable(function () {
27049            var buffer;
27050            var enumerator;
27051            var alternateSequence;
27052            var alternateEnumerator;
27053
27054            return new IEnumerator(
27055                function () {
27056                    if (alternateValueOrSequence instanceof Array || alternateValueOrSequence.GetEnumerator != null) {
27057                        alternateSequence = Enumerable.from(Enumerable.from(alternateValueOrSequence).ToArray()); // freeze
27058                    }
27059                    else {
27060                        alternateSequence = Enumerable.make(alternateValueOrSequence);
27061                    }
27062                    enumerator = source.GetEnumerator();
27063                    if (enumerator.moveNext()) buffer = enumerator.Current;
27064                },
27065                function () {
27066                    while (true) {
27067                        if (alternateEnumerator != null) {
27068                            if (alternateEnumerator.moveNext()) {
27069                                return this.yieldReturn(alternateEnumerator.Current);
27070                            }
27071                            else {
27072                                alternateEnumerator = null;
27073                            }
27074                        }
27075
27076                        if (buffer == null && enumerator.moveNext()) {
27077                            buffer = enumerator.Current; // hasNext
27078                            alternateEnumerator = alternateSequence.GetEnumerator();
27079                            continue; // GOTO
27080                        }
27081                        else if (buffer != null) {
27082                            var retVal = buffer;
27083                            buffer = null;
27084                            return this.yieldReturn(retVal);
27085                        }
27086
27087                        return this.yieldBreak();
27088                    }
27089                },
27090                function () {
27091                    try {
27092                        Utils.Dispose(enumerator);
27093                    }
27094                    finally {
27095                        Utils.Dispose(alternateEnumerator);
27096                    }
27097                });
27098        });
27099    };
27100
27101    // Overload:function (value)
27102    // Overload:function (value, compareSelector)
27103    Enumerable.prototype.contains = function (value, comparer) {
27104        comparer = comparer || System.Collections.Generic.EqualityComparer$1.$default;
27105        var enumerator = this.GetEnumerator();
27106        try {
27107            while (enumerator.moveNext()) {
27108                if (comparer.equals2(enumerator.Current, value)) return true;
27109            }
27110            return false;
27111        }
27112        finally {
27113            Utils.Dispose(enumerator);
27114        }
27115    };
27116
27117    Enumerable.prototype.defaultIfEmpty = function (defaultValue) {
27118        var source = this;
27119        if (defaultValue === undefined) defaultValue = null;
27120
27121        return new Enumerable(function () {
27122            var enumerator;
27123            var isFirst = true;
27124
27125            return new IEnumerator(
27126                function () { enumerator = source.GetEnumerator(); },
27127                function () {
27128                    if (enumerator.moveNext()) {
27129                        isFirst = false;
27130                        return this.yieldReturn(enumerator.Current);
27131                    }
27132                    else if (isFirst) {
27133                        isFirst = false;
27134                        return this.yieldReturn(defaultValue);
27135                    }
27136                    return false;
27137                },
27138                function () { Utils.Dispose(enumerator); });
27139        });
27140    };
27141
27142    // Overload:function ()
27143    // Overload:function (compareSelector)
27144    Enumerable.prototype.distinct = function (comparer) {
27145        return this.except(Enumerable.empty(), comparer);
27146    };
27147
27148    Enumerable.prototype.distinctUntilChanged = function (compareSelector) {
27149        compareSelector = Utils.createLambda(compareSelector);
27150        var source = this;
27151
27152        return new Enumerable(function () {
27153            var enumerator;
27154            var compareKey;
27155            var initial;
27156
27157            return new IEnumerator(
27158                function () {
27159                    enumerator = source.GetEnumerator();
27160                },
27161                function () {
27162                    while (enumerator.moveNext()) {
27163                        var key = compareSelector(enumerator.Current);
27164
27165                        if (initial) {
27166                            initial = false;
27167                            compareKey = key;
27168                            return this.yieldReturn(enumerator.Current);
27169                        }
27170
27171                        if (compareKey === key) {
27172                            continue;
27173                        }
27174
27175                        compareKey = key;
27176                        return this.yieldReturn(enumerator.Current);
27177                    }
27178                    return this.yieldBreak();
27179                },
27180                function () { Utils.Dispose(enumerator); });
27181        });
27182    };
27183
27184    // Overload:function (second)
27185    // Overload:function (second, compareSelector)
27186    Enumerable.prototype.except = function (second, comparer) {
27187        var source = this;
27188
27189        if (second == null) {
27190            throw new System.ArgumentNullException();
27191        }
27192
27193        return new Enumerable(function () {
27194            var enumerator,
27195                keys,
27196                hasNull = false;
27197
27198            return new IEnumerator(
27199                function () {
27200                    enumerator = source.GetEnumerator();
27201                    keys = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object)).$ctor3(comparer);
27202
27203                    Enumerable.from(second).forEach(function (key) {
27204                        if (key == null) {
27205                            hasNull = true;
27206                        }
27207                        else if (!keys.containsKey(key)) {
27208                            keys.add(key);
27209                        }
27210                    });
27211                },
27212                function () {
27213                    while (enumerator.moveNext()) {
27214                        var current = enumerator.Current;
27215                        if (current == null) {
27216                            if (!hasNull) {
27217                                hasNull = true;
27218                                return this.yieldReturn(current);
27219                            }
27220                        }
27221                        else if (!keys.containsKey(current)) {
27222                            keys.add(current);
27223                            return this.yieldReturn(current);
27224                        }
27225                    }
27226                    return false;
27227                },
27228                function () { Utils.Dispose(enumerator); });
27229        });
27230    };
27231
27232    // Overload:function (second)
27233    // Overload:function (second, compareSelector)
27234    Enumerable.prototype.intersect = function (second, comparer) {
27235        var source = this;
27236
27237        if (second == null) {
27238            throw new System.ArgumentNullException();
27239        }
27240
27241        return new Enumerable(function () {
27242            var enumerator;
27243            var keys;
27244            var outs;
27245            var hasNull = false;
27246            var hasOutsNull = false;
27247
27248            return new IEnumerator(
27249                function () {
27250                    enumerator = source.GetEnumerator();
27251
27252                    keys = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object)).$ctor3(comparer);
27253                    Enumerable.from(second).forEach(function (key) {
27254                        if (key == null) {
27255                            hasNull = true;
27256                        }
27257                        else if (!keys.containsKey(key)) {
27258                            keys.add(key);
27259                        }
27260                    });
27261                    outs = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object)).$ctor3(comparer);
27262                },
27263                function () {
27264                    while (enumerator.moveNext()) {
27265                        var current = enumerator.Current;
27266                        if (current == null) {
27267                            if (!hasOutsNull && hasNull) {
27268                                hasOutsNull = true;
27269                                return this.yieldReturn(current);
27270                            }
27271                        } else if (!outs.containsKey(current) && keys.containsKey(current)) {
27272                            outs.add(current);
27273                            return this.yieldReturn(current);
27274                        }
27275                    }
27276                    return false;
27277                },
27278                function () { Utils.Dispose(enumerator); });
27279        });
27280    };
27281
27282    // Overload:function (second)
27283    // Overload:function (second, compareSelector)
27284    Enumerable.prototype.sequenceEqual = function (second, comparer) {
27285        comparer = comparer || System.Collections.Generic.EqualityComparer$1.$default;
27286
27287        if (second == null) {
27288            throw new System.ArgumentNullException();
27289        }
27290
27291        var firstEnumerator = this.GetEnumerator();
27292        try {
27293            var secondEnumerator = Enumerable.from(second).GetEnumerator();
27294            try {
27295                while (firstEnumerator.moveNext()) {
27296                    if (!secondEnumerator.moveNext()
27297                    || !comparer.equals2(firstEnumerator.Current, secondEnumerator.Current)) {
27298                        return false;
27299                    }
27300                }
27301
27302                if (secondEnumerator.moveNext()) return false;
27303                return true;
27304            }
27305            finally {
27306                Utils.Dispose(secondEnumerator);
27307            }
27308        }
27309        finally {
27310            Utils.Dispose(firstEnumerator);
27311        }
27312    };
27313
27314    Enumerable.prototype.union = function (second, comparer) {
27315        var source = this;
27316
27317        if (second == null) {
27318            throw new System.ArgumentNullException();
27319        }
27320
27321        return new Enumerable(function () {
27322            var firstEnumerator;
27323            var secondEnumerator;
27324            var keys;
27325            var hasNull = false;
27326
27327            return new IEnumerator(
27328                function () {
27329                    firstEnumerator = source.GetEnumerator();
27330                    keys = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object)).$ctor3(comparer);
27331                },
27332                function () {
27333                    var current;
27334                    if (secondEnumerator === undefined) {
27335                        while (firstEnumerator.moveNext()) {
27336                            current = firstEnumerator.Current;
27337                            if (current == null) {
27338                                if (!hasNull) {
27339                                    hasNull = true;
27340                                    return this.yieldReturn(current);
27341                                }
27342                            }
27343                            else if (!keys.containsKey(current)) {
27344                                keys.add(current);
27345                                return this.yieldReturn(current);
27346                            }
27347                        }
27348                        secondEnumerator = Enumerable.from(second).GetEnumerator();
27349                    }
27350                    while (secondEnumerator.moveNext()) {
27351                        current = secondEnumerator.Current;
27352                        if (current == null) {
27353                            if (!hasNull) {
27354                                hasNull = true;
27355                                return this.yieldReturn(current);
27356                            }
27357                        }
27358                        else if (!keys.containsKey(current)) {
27359                            keys.add(current);
27360                            return this.yieldReturn(current);
27361                        }
27362                    }
27363                    return false;
27364                },
27365                function () {
27366                    try {
27367                        Utils.Dispose(firstEnumerator);
27368                    }
27369                    finally {
27370                        Utils.Dispose(secondEnumerator);
27371                    }
27372                });
27373        });
27374    };
27375
27376    /* Ordering Methods */
27377
27378    Enumerable.prototype.orderBy = function (keySelector, comparer) {
27379        return new OrderedEnumerable(this, keySelector, comparer, false);
27380    };
27381
27382    Enumerable.prototype.orderByDescending = function (keySelector, comparer) {
27383        return new OrderedEnumerable(this, keySelector, comparer, true);
27384    };
27385
27386    Enumerable.prototype.reverse = function () {
27387        var source = this;
27388
27389        return new Enumerable(function () {
27390            var buffer;
27391            var index;
27392
27393            return new IEnumerator(
27394                function () {
27395                    buffer = source.ToArray();
27396                    index = buffer.length;
27397                },
27398                function () {
27399                    return (index > 0)
27400                        ? this.yieldReturn(buffer[--index])
27401                        : false;
27402                },
27403                Functions.Blank);
27404        });
27405    };
27406
27407    Enumerable.prototype.shuffle = function () {
27408        var source = this;
27409
27410        return new Enumerable(function () {
27411            var buffer;
27412
27413            return new IEnumerator(
27414                function () { buffer = source.ToArray(); },
27415                function () {
27416                    if (buffer.length > 0) {
27417                        var i = Math.floor(Math.random() * buffer.length);
27418                        return this.yieldReturn(buffer.splice(i, 1)[0]);
27419                    }
27420                    return false;
27421                },
27422                Functions.Blank);
27423        });
27424    };
27425
27426    Enumerable.prototype.weightedSample = function (weightSelector) {
27427        weightSelector = Utils.createLambda(weightSelector);
27428        var source = this;
27429
27430        return new Enumerable(function () {
27431            var sortedByBound;
27432            var totalWeight = 0;
27433
27434            return new IEnumerator(
27435                function () {
27436                    sortedByBound = source
27437                        .choose(function (x) {
27438                            var weight = weightSelector(x);
27439                            if (weight <= 0) return null; // ignore 0
27440
27441                            totalWeight += weight;
27442                            return { value: x, bound: totalWeight };
27443                        })
27444                        .ToArray();
27445                },
27446                function () {
27447                    if (sortedByBound.length > 0) {
27448                        var draw = Math.floor(Math.random() * totalWeight) + 1;
27449
27450                        var lower = -1;
27451                        var upper = sortedByBound.length;
27452                        while (upper - lower > 1) {
27453                            var index = Math.floor((lower + upper) / 2);
27454                            if (sortedByBound[index].bound >= draw) {
27455                                upper = index;
27456                            }
27457                            else {
27458                                lower = index;
27459                            }
27460                        }
27461
27462                        return this.yieldReturn(sortedByBound[upper].value);
27463                    }
27464
27465                    return this.yieldBreak();
27466                },
27467                Functions.Blank);
27468        });
27469    };
27470
27471    /* Grouping Methods */
27472
27473    // Overload:function (keySelector)
27474    // Overload:function (keySelector,elementSelector)
27475    // Overload:function (keySelector,elementSelector,resultSelector)
27476    // Overload:function (keySelector,elementSelector,resultSelector,compareSelector)
27477    Enumerable.prototype.groupBy = function (keySelector, elementSelector, resultSelector, comparer) {
27478        var source = this;
27479        keySelector = Utils.createLambda(keySelector);
27480        elementSelector = Utils.createLambda(elementSelector);
27481        if (resultSelector != null) resultSelector = Utils.createLambda(resultSelector);
27482
27483        return new Enumerable(function () {
27484            var enumerator;
27485
27486            return new IEnumerator(
27487                function () {
27488                    enumerator = source.toLookup(keySelector, elementSelector, comparer)
27489                        .toEnumerable()
27490                        .GetEnumerator();
27491                },
27492                function () {
27493                    while (enumerator.moveNext()) {
27494                        return (resultSelector == null)
27495                            ? this.yieldReturn(enumerator.Current)
27496                            : this.yieldReturn(resultSelector(enumerator.Current.key(), enumerator.Current));
27497                    }
27498                    return false;
27499                },
27500                function () { Utils.Dispose(enumerator); });
27501        });
27502    };
27503
27504    // Overload:function (keySelector)
27505    // Overload:function (keySelector,elementSelector)
27506    // Overload:function (keySelector,elementSelector,resultSelector)
27507    // Overload:function (keySelector,elementSelector,resultSelector,compareSelector)
27508    Enumerable.prototype.partitionBy = function (keySelector, elementSelector, resultSelector, comparer) {
27509        var source = this;
27510        keySelector = Utils.createLambda(keySelector);
27511        elementSelector = Utils.createLambda(elementSelector);
27512        comparer = comparer || System.Collections.Generic.EqualityComparer$1.$default;
27513        var hasResultSelector;
27514        if (resultSelector == null) {
27515            hasResultSelector = false;
27516            resultSelector = function (key, group) { return new Grouping(key, group); };
27517        }
27518        else {
27519            hasResultSelector = true;
27520            resultSelector = Utils.createLambda(resultSelector);
27521        }
27522
27523        return new Enumerable(function () {
27524            var enumerator;
27525            var key;
27526            var group = [];
27527
27528            return new IEnumerator(
27529                function () {
27530                    enumerator = source.GetEnumerator();
27531                    if (enumerator.moveNext()) {
27532                        key = keySelector(enumerator.Current);
27533                        group.push(elementSelector(enumerator.Current));
27534                    }
27535                },
27536                function () {
27537                    var hasNext;
27538                    while ((hasNext = enumerator.moveNext()) == true) {
27539                        if (comparer.equals2(key, keySelector(enumerator.Current))) {
27540                            group.push(elementSelector(enumerator.Current));
27541                        }
27542                        else break;
27543                    }
27544
27545                    if (group.length > 0) {
27546                        var result = (hasResultSelector)
27547                            ? resultSelector(key, Enumerable.from(group))
27548                            : resultSelector(key, group);
27549                        if (hasNext) {
27550                            key = keySelector(enumerator.Current);
27551                            group = [elementSelector(enumerator.Current)];
27552                        }
27553                        else group = [];
27554
27555                        return this.yieldReturn(result);
27556                    }
27557
27558                    return false;
27559                },
27560                function () { Utils.Dispose(enumerator); });
27561        });
27562    };
27563
27564    Enumerable.prototype.buffer = function (count) {
27565        var source = this;
27566
27567        return new Enumerable(function () {
27568            var enumerator;
27569
27570            return new IEnumerator(
27571                function () { enumerator = source.GetEnumerator(); },
27572                function () {
27573                    var array = [];
27574                    var index = 0;
27575                    while (enumerator.moveNext()) {
27576                        array.push(enumerator.Current);
27577                        if (++index >= count) return this.yieldReturn(array);
27578                    }
27579                    if (array.length > 0) return this.yieldReturn(array);
27580                    return false;
27581                },
27582                function () { Utils.Dispose(enumerator); });
27583        });
27584    };
27585
27586    /* Aggregate Methods */
27587
27588    // Overload:function (func)
27589    // Overload:function (seed,func)
27590    // Overload:function (seed,func,resultSelector)
27591    Enumerable.prototype.aggregate = function (seed, func, resultSelector) {
27592        resultSelector = Utils.createLambda(resultSelector);
27593        return resultSelector(this.scan(seed, func, resultSelector).last());
27594    };
27595
27596    // Overload:function ()
27597    // Overload:function (selector)
27598    Enumerable.prototype.average = function (selector, def) {
27599        if (selector && !def && !H5.isFunction(selector)) {
27600            def = selector;
27601            selector = null;
27602        }
27603
27604        selector = Utils.createLambda(selector);
27605
27606        var sum = def || 0;
27607        var count = 0;
27608        this.forEach(function (x) {
27609            x = selector(x);
27610
27611            if (x instanceof System.Decimal || System.Int64.is64Bit(x)) {
27612                sum = x.add(sum);
27613            }
27614            else if (sum instanceof System.Decimal || System.Int64.is64Bit(sum)) {
27615                sum = sum.add(x);
27616            } else {
27617                sum += x;
27618            }
27619
27620            ++count;
27621        });
27622
27623        if (count === 0) {
27624            throw new System.InvalidOperationException.$ctor1("Sequence contains 
27624no elements");
27625        }
27626
27627        return (sum instanceof System.Decimal || System.Int64.is64Bit(sum)) ? sum.div(count) : (sum / count);
27628    };
27629
27630    Enumerable.prototype.nullableAverage = function (selector, def) {
27631        if (this.any(H5.isNull)) {
27632            return null;
27633        }
27634
27635        return this.average(selector, def);
27636    };
27637
27638    // Overload:function ()
27639    // Overload:function (predicate)
27640    Enumerable.prototype.count = function (predicate) {
27641        predicate = (predicate == null) ? Functions.True : Utils.createLambda(predicate);
27642
27643        var count = 0;
27644        this.forEach(function (x, i) {
27645            if (predicate(x, i))++count;
27646        });
27647        return count;
27648    };
27649
27650    // Overload:function ()
27651    // Overload:function (selector)
27652    Enumerable.prototype.max = function (selector) {
27653        if (selector == null) selector = Functions.Identity;
27654        return this.select(selector).aggregate(function (a, b) {
27655            return (H5.compare(a, b, true) === 1) ? a : b;
27656        });
27657    };
27658
27659    Enumerable.prototype.nullableMax = function (selector) {
27660        if (this.any(H5.isNull)) {
27661            return null;
27662        }
27663
27664        return this.max(selector);
27665    };
27666
27667    // Overload:function ()
27668    // Overload:function (selector)
27669    Enumerable.prototype.min = function (selector) {
27670        if (selector == null) selector = Functions.Identity;
27671        return this.select(selector).aggregate(function (a, b) {
27672            return (H5.compare(a, b, true) === -1) ? a : b;
27673        });
27674    };
27675
27676    Enumerable.prototype.nullableMin = function (selector) {
27677        if (this.any(H5.isNull)) {
27678            return null;
27679        }
27680
27681        return this.min(selector);
27682    };
27683
27684    Enumerable.prototype.maxBy = function (keySelector) {
27685        keySelector = Utils.createLambda(keySelector);
27686        return this.aggregate(function (a, b) {
27687            return (H5.compare(keySelector(a), keySelector(b), true) === 1) ? a : b;
27688        });
27689    };
27690
27691    Enumerable.prototype.minBy = function (keySelector) {
27692        keySelector = Utils.createLambda(keySelector);
27693        return this.aggregate(function (a, b) {
27694            return (H5.compare(keySelector(a), keySelector(b), true) === -1) ? a : b;
27695        });
27696    };
27697
27698    // Overload:function ()
27699    // Overload:function (selector)
27700    Enumerable.prototype.sum = function (selector, def) {
27701        if (selector && !def && !H5.isFunction(selector)) {
27702            def = selector;
27703            selector = null;
27704        }
27705
27706        if (selector == null) selector = Functions.Identity;
27707        var s = this.select(selector).aggregate(0, function (a, b) {
27708             if (a instanceof System.Decimal || System.Int64.is64Bit(a)) {
27709                 return a.add(b);
27710             }
27711             if (b instanceof System.Decimal || System.Int64.is64Bit(b)) {
27712                 return b.add(a);
27713             }
27714             return a + b;
27715        });
27716
27717        if (s === 0 && def) {
27718            return def;
27719        }
27720
27721        return s;
27722    };
27723
27724    Enumerable.prototype.nullableSum = function (selector, def) {
27725        if (this.any(H5.isNull)) {
27726            return null;
27727        }
27728
27729        return this.sum(selector, def);
27730    };
27731
27732    /* Paging Methods */
27733
27734    Enumerable.prototype.elementAt = function (index) {
27735        var value;
27736        var found = false;
27737        this.forEach(function (x, i) {
27738            if (i == index) {
27739                value = x;
27740                found = true;
27741                return false;
27742            }
27743        });
27744
27745        if (!found) throw new Error("index is less than 0 or greater than or equal to the number of elements in source.");
27746        return value;
27747    };
27748
27749    Enumerable.prototype.elementAtOrDefault = function (index, defaultValue) {
27750        if (defaultValue === undefined) defaultValue = null;
27751        var value;
27752        var found = false;
27753        this.forEach(function (x, i) {
27754            if (i == index) {
27755                value = x;
27756                found = true;
27757                return false;
27758            }
27759        });
27760
27761        return (!found) ? defaultValue : value;
27762    };
27763
27764    // Overload:function ()
27765    // Overload:function (predicate)
27766    Enumerable.prototype.first = function (predicate) {
27767        if (predicate != null) return this.where(predicate).first();
27768
27769        var value;
27770        var found = false;
27771        this.forEach(function (x) {
27772            value = x;
27773            found = true;
27774            return false;
27775        });
27776
27777        if (!found) throw new Error("first:No element satisfies the condition.");
27778        return value;
27779    };
27780
27781    Enumerable.prototype.firstOrDefault = function (predicate, defaultValue) {
27782        if (defaultValue === undefined) defaultValue = null;
27783        if (predicate != null) return this.where(predicate).firstOrDefault(null, defaultValue);
27784
27785        var value;
27786        var found = false;
27787        this.forEach(function (x) {
27788            value = x;
27789            found = true;
27790            return false;
27791        });
27792        return (!found) ? defaultValue : value;
27793    };
27794
27795    // Overload:function ()
27796    // Overload:function (predicate)
27797    Enumerable.prototype.last = function (predicate) {
27798        if (predicate != null) return this.where(predicate).last();
27799
27800        var value;
27801        var found = false;
27802        this.forEach(function (x) {
27803            found = true;
27804            value = x;
27805        });
27806
27807        if (!found) throw new Error("last:No element satisfies the condition.");
27808        return value;
27809    };
27810
27811    // Overload:function (defaultValue)
27812    // Overload:function (defaultValue,predicate)
27813    Enumerable.prototype.lastOrDefault = function (predicate, defaultValue) {
27814        if (defaultValue === undefined) defaultValue = null;
27815        if (predicate != null) return this.where(predicate).lastOrDefault(null, defaultValue);
27816
27817        var value;
27818        var found = false;
27819        this.forEach(function (x) {
27820            found = true;
27821            value = x;
27822        });
27823        return (!found) ? defaultValue : value;
27824    };
27825
27826    // Overload:function ()
27827    // Overload:function (predicate)
27828    Enumerable.prototype.single = function (predicate) {
27829        if (predicate != null) return this.where(predicate).single();
27830
27831        var value;
27832        var found = false;
27833        this.forEach(function (x) {
27834            if (!found) {
27835                found = true;
27836                value = x;
27837            } else throw new Error("single:sequence contains more than one element.");
27838        });
27839
27840        if (!found) throw new Error("single:No element satisfies the condition.");
27841        return value;
27842    };
27843
27844    // Overload:function (defaultValue)
27845    // Overload:function (defaultValue,predicate)
27846    Enumerable.prototype.singleOrDefault = function (predicate, defaultValue) {
27847        if (defaultValue === undefined) defaultValue = null;
27848        if (predicate != null) return this.where(predicate).singleOrDefault(null, defaultValue);
27849
27850        var value;
27851        var found = false;
27852        this.forEach(function (x) {
27853            if (!found) {
27854                found = true;
27855                value = x;
27856            } else throw new Error("single:sequence contains more than one element.");
27857        });
27858
27859        return (!found) ? defaultValue : value;
27860    };
27861
27862    Enumerable.prototype.skip = function (count) {
27863        var source = this;
27864
27865        return new Enumerable(function () {
27866            var enumerator;
27867            var index = 0;
27868
27869            return new IEnumerator(
27870                function () {
27871                    enumerator = source.GetEnumerator();
27872                    while (index++ < count && enumerator.moveNext()) {
27873                    }
27874                    ;
27875                },
27876                function () {
27877                    return (enumerator.moveNext())
27878                        ? this.yieldReturn(enumerator.Current)
27879                        : false;
27880                },
27881                function () { Utils.Dispose(enumerator); });
27882        });
27883    };
27884
27885    // Overload:function (predicate<element>)
27886    // Overload:function (predicate<element,index>)
27887    Enumerable.prototype.skipWhile = function (predicate) {
27888        predicate = Utils.createLambda(predicate);
27889        var source = this;
27890
27891        return new Enumerable(function () {
27892            var enumerator;
27893            var index = 0;
27894            var isSkipEnd = false;
27895
27896            return new IEnumerator(
27897                function () { enumerator = source.GetEnumerator(); },
27898                function () {
27899                    while (!isSkipEnd) {
27900                        if (enumerator.moveNext()) {
27901                            if (!predicate(enumerator.Current, index++)) {
27902                                isSkipEnd = true;
27903                                return this.yieldReturn(enumerator.Current);
27904                            }
27905                            continue;
27906                        } else return false;
27907                    }
27908
27909                    return (enumerator.moveNext())
27910                        ? this.yieldReturn(enumerator.Current)
27911                        : false;
27912                },
27913                function () { Utils.Dispose(enumerator); });
27914        });
27915    };
27916
27917    Enumerable.prototype.take = function (count) {
27918        var source = this;
27919
27920        return new Enumerable(function () {
27921            var enumerator;
27922            var index = 0;
27923
27924            return new IEnumerator(
27925                function () { enumerator = source.GetEnumerator(); },
27926                function () {
27927                    return (index++ < count && enumerator.moveNext())
27928                        ? this.yieldReturn(enumerator.Current)
27929                        : false;
27930                },
27931                function () { Utils.Dispose(enumerator); }
27932            );
27933        });
27934    };
27935
27936    // Overload:function (predicate<element>)
27937    // Overload:function (predicate<element,index>)
27938    Enumerable.prototype.takeWhile = function (predicate) {
27939        predicate = Utils.createLambda(predicate);
27940        var source = this;
27941
27942        return new Enumerable(function () {
27943            var enumerator;
27944            var index = 0;
27945
27946            return new IEnumerator(
27947                function () { enumerator = source.GetEnumerator(); },
27948                function () {
27949                    return (enumerator.moveNext() && predicate(enumerator.Current, index++))
27950                        ? this.yieldReturn(enumerator.Current)
27951                        : false;
27952                },
27953                function () { Utils.Dispose(enumerator); });
27954        });
27955    };
27956
27957    // Overload:function ()
27958    // Overload:function (count)
27959    Enumerable.prototype.takeExceptLast = function (count) {
27960        if (count == null) count = 1;
27961        var source = this;
27962
27963        return new Enumerable(function () {
27964            if (count <= 0) return source.GetEnumerator(); // do nothing
27965
27966            var enumerator;
27967            var q = [];
27968
27969            return new IEnumerator(
27970                function () { enumerator = source.GetEnumerator(); },
27971                function () {
27972                    while (enumerator.moveNext()) {
27973                        if (q.length == count) {
27974                            q.push(enumerator.Current);
27975                            return this.yieldReturn(q.shift());
27976                        }
27977                        q.push(enumerator.Current);
27978                    }
27979                    return false;
27980                },
27981                function () { Utils.Dispose(enumerator); });
27982        });
27983    };
27984
27985    Enumerable.prototype.takeFromLast = function (count) {
27986        if (count <= 0 || count == null) return Enumerable.empty();
27987        var source = this;
27988
27989        return new Enumerable(function () {
27990            var sourceEnumerator;
27991            var enumerator;
27992            var q = [];
27993
27994            return new IEnumerator(
27995                function () { sourceEnumerator = source.GetEnumerator(); },
27996                function () {
27997                    if (enumerator == null) {
27998                        while (sourceEnumerator.moveNext()) {
27999                            if (q.length == count) q.shift();
28000                            q.push(sourceEnumerator.Current);
28001                        }
28002                        enumerator = Enumerable.from(q).GetEnumerator();
28003                    }
28004                    return (enumerator.moveNext())
28005                        ? this.yieldReturn(enumerator.Current)
28006                        : false;
28007                },
28008                function () { Utils.Dispose(enumerator); });
28009        });
28010    };
28011
28012    // Overload:function (item)
28013    // Overload:function (predicate)
28014    Enumerable.prototype.indexOf = function (item, comparer) {
28015        var found = null;
28016
28017        // item as predicate
28018        if (typeof (item) === Types.Function) {
28019            this.forEach(function (x, i) {
28020                if (item(x, i)) {
28021                    found = i;
28022                    return false;
28023                }
28024            });
28025        }
28026        else {
28027            comparer = comparer || System.Collections.Generic.EqualityComparer$1.$default;
28028            this.forEach(function (x, i) {
28029                if (comparer.equals2(x, item)) {
28030                    found = i;
28031                    return false;
28032                }
28033            });
28034        }
28035
28036        return (found !== null) ? found : -1;
28037    };
28038
28039    // Overload:function (item)
28040    // Overload:function (predicate)
28041    Enumerable.prototype.lastIndexOf = function (item, comparer) {
28042        var result = -1;
28043
28044        // item as predicate
28045        if (typeof (item) === Types.Function) {
28046            this.forEach(function (x, i) {
28047                if (item(x, i)) result = i;
28048            });
28049        }
28050        else {
28051            comparer = comparer || System.Collections.Generic.EqualityComparer$1.$default;
28052            this.forEach(function (x, i) {
28053                if (comparer.equals2(x, item)) result = i;
28054            });
28055        }
28056
28057        return result;
28058    };
28059
28060    /* Convert Methods */
28061
28062    Enumerable.prototype.asEnumerable = function () {
28063        return Enumerable.from(this);
28064    };
28065
28066    Enumerable.prototype.ToArray = function (T) {
28067        var array = System.Array.init([], T || System.Object);
28068        this.forEach(function (x) { array.push(x); });
28069        return array;
28070    };
28071
28072    Enumerable.prototype.toList = function (T) {
28073        var array = [];
28074        this.forEach(function (x) { array.push(x); });
28075        return new (System.Collections.Generic.List$1(T || System.Object).$ctor1)(array);
28076    };
28077
28078    // Overload:function (keySelector)
28079    // Overload:function (keySelector, elementSelector)
28080    // Overload:function (keySelector, elementSelector, compareSelector)
28081    Enumerable.prototype.toLookup = function (keySelector, elementSelector, comparer) {
28082        keySelector = Utils.createLambda(keySelector);
28083        elementSelector = Utils.createLambda(elementSelector);
28084
28085        var dict = new (System.Collections.Generic.Dictionary$2(System.Object, System.Object)).$ctor3(comparer);
28086        var order = [];
28087        var nullKey;
28088        this.forEach(function (x) {
28089            var key = keySelector(x);
28090            var element = elementSelector(x);
28091
28092            var array = { v: null };
28093
28094            if (key == null) {
28095                if (!nullKey) {
28096                    nullKey = [];
28097                    order.push(key);
28098                }
28099                nullKey.push(element);
28100            }
28101            else if (dict.tryGetValue(key, array)) {
28102                array.v.push(element);
28103            }
28104            else {
28105                order.push(key);
28106                dict.add(key, [element]);
28107            }
28108        });
28109        return new Lookup(dict, order, nullKey);
28110    };
28111
28112    Enumerable.prototype.toObject = function (keySelector, elementSelector) {
28113        keySelector = Utils.createLambda(keySelector);
28114        elementSelector = Utils.createLambda(elementSelector);
28115
28116        var obj = {};
28117        this.forEach(function (x) {
28118            obj[keySelector(x)] = elementSelector(x);
28119        });
28120        return obj;
28121    };
28122
28123    // Overload:function (keySelector, elementSelector)
28124    // Overload:function (keySelector, elementSelector, compareSelector)
28125    Enumerable.prototype.toDictionary = function (keySelector, elementSelector, keyType, valueType, comparer) {
28126        keySelector = Utils.createLambda(keySelector);
28127        elementSelector = Utils.createLambda(elementSelector);
28128
28129        var dict = new (System.Collections.Generic.Dictionary$2(keyType, valueType)).$ctor3(comparer);
28130        this.forEach(function (x) {
28131            dict.add(keySelector(x), elementSelector(x));
28132        });
28133        return dict;
28134    };
28135
28136    // Overload:function ()
28137    // Overload:function (replacer)
28138    // Overload:function (replacer, space)
28139    Enumerable.prototype.toJSONString = function (replacer, space) {
28140        if (typeof JSON === Types.Undefined || JSON.stringify == null) {
28141            throw new Error("toJSONString can't find JSON.stringify. This works native JSON support Browser or include json2.js");
28142        }
28143        return JSON.stringify(this.ToArray(), replacer, space);
28144    };
28145
28146    // Overload:function ()
28147    // Overload:function (separator)
28148    // Overload:function (separator,selector)
28149    Enumerable.prototype.toJoinedString = function (separator, selector) {
28150        if (separator == null) separator = "";
28151        if (selector == null) selector = Functions.Identity;
28152
28153        return this.select(selector).ToArray().join(separator);
28154    };
28155
28156    /* Action Methods */
28157
28158    // Overload:function (action<element>)
28159    // Overload:function (action<element,index>)
28160    Enumerable.prototype.doAction = function (action) {
28161        var source = this;
28162        action = Utils.createLambda(action);
28163
28164        return new Enumerable(function () {
28165            var enumerator;
28166            var index = 0;
28167
28168            return new IEnumerator(
28169                function () { enumerator = source.GetEnumerator(); },
28170                function () {
28171                    if (enumerator.moveNext()) {
28172                        action(enumerator.Current, index++);
28173                        return this.yieldReturn(enumerator.Current);
28174                    }
28175                    return false;
28176                },
28177                function () { Utils.Dispose(enumerator); });
28178        });
28179    };
28180
28181    // Overload:function (action<element>)
28182    // Overload:function (action<element,index>)
28183    // Overload:function (func<element,bool>)
28184    // Overload:function (func<element,index,bool>)
28185    Enumerable.prototype.forEach = function (action) {
28186        action = Utils.createLambda(action);
28187
28188        var index = 0;
28189        var enumerator = this.GetEnumerator();
28190        try {
28191            while (enumerator.moveNext()) {
28192                if (action(enumerator.Current, index++) === false) break;
28193            }
28194        } finally {
28195            Utils.Dispose(enumerator);
28196        }
28197    };
28198
28199    // Overload:function ()
28200    // Overload:function (separator)
28201    // Overload:function (separator,selector)
28202    Enumerable.prototype.write = function (separator, selector) {
28203        if (separator == null) separator = "";
28204        selector = Utils.createLambda(selector);
28205
28206        var isFirst = true;
28207        this.forEach(function (item) {
28208            if (isFirst) isFirst = false;
28209            else document.write(separator);
28210            document.write(selector(item));
28211        });
28212    };
28213
28214    // Overload:function ()
28215    // Overload:function (selector)
28216    Enumerable.prototype.writeLine = function (selector) {
28217        selector = Utils.createLambda(selector);
28218
28219        this.forEach(function (item) {
28220            document.writeln(selector(item) + "<br />");
28221        });
28222    };
28223
28224    Enumerable.prototype.force = function () {
28225        var enumerator = this.GetEnumerator();
28226
28227        try {
28228            while (enumerator.moveNext()) {
28229            }
28230        }
28231        finally {
28232            Utils.Dispose(enumerator);
28233        }
28234    };
28235
28236    /* Functional Methods */
28237
28238    Enumerable.prototype.letBind = function (func) {
28239        func = Utils.createLambda(func);
28240        var source = this;
28241
28242        return new Enumerable(function () {
28243            var enumerator;
28244
28245            return new IEnumerator(
28246                function () {
28247                    enumerator = Enumerable.from(func(source)).GetEnumerator();
28248                },
28249                function () {
28250                    return (enumerator.moveNext())
28251                        ? this.yieldReturn(enumerator.Current)
28252                        : false;
28253                },
28254                function () { Utils.Dispose(enumerator); });
28255        });
28256    };
28257
28258    Enumerable.prototype.share = function () {
28259        var source = this;
28260        var sharedEnumerator;
28261        var disposed = false;
28262
28263        return new DisposableEnumerable(function () {
28264            return new IEnumerator(
28265                function () {
28266                    if (sharedEnumerator == null) {
28267                        sharedEnumerator = source.GetEnumerator();
28268                    }
28269                },
28270                function () {
28271                    if (disposed) throw new Error("enumerator is disposed");
28272
28273                    return (sharedEnumerator.moveNext())
28274                        ? this.yieldReturn(sharedEnumerator.Current)
28275                        : false;
28276                },
28277                Functions.Blank
28278            );
28279        }, function () {
28280            disposed = true;
28281            Utils.Dispose(sharedEnumerator);
28282        });
28283    };
28284
28285    Enumerable.prototype.memoize = function () {
28286        var source = this;
28287        var cache;
28288        var enumerator;
28289        var disposed = false;
28290
28291        return new DisposableEnumerable(function () {
28292            var index = -1;
28293
28294            return new IEnumerator(
28295                function () {
28296                    if (enumerator == null) {
28297                        enumerator = source.GetEnumerator();
28298                        cache = [];
28299                    }
28300                },
28301                function () {
28302                    if (disposed) throw new Error("enumerator is disposed");
28303
28304                    index++;
28305                    if (cache.length <= index) {
28306                        return (enumerator.moveNext())
28307                            ? this.yieldReturn(cache[index] = enumerator.Current)
28308                            : false;
28309                    }
28310
28311                    return this.yieldReturn(cache[index]);
28312                },
28313                Functions.Blank
28314            );
28315        }, function () {
28316            disposed = true;
28317            Utils.Dispose(enumerator);
28318            cache = null;
28319        });
28320    };
28321
28322    /* Error Handling Methods */
28323
28324    Enumerable.prototype.catchError = function (handler) {
28325        handler = Utils.createLambda(handler);
28326        var source = this;
28327
28328        return new Enumerable(function () {
28329            var enumerator;
28330
28331            return new IEnumerator(
28332                function () { enumerator = source.GetEnumerator(); },
28333                function () {
28334                    try {
28335                        return (enumerator.moveNext())
28336                            ? this.yieldReturn(enumerator.Current)
28337                            : false;
28338                    } catch (e) {
28339                        handler(e);
28340                        return false;
28341                    }
28342                },
28343                function () { Utils.Dispose(enumerator); });
28344        });
28345    };
28346
28347    Enumerable.prototype.finallyAction = function (finallyAction) {
28348        finallyAction = Utils.createLambda(finallyAction);
28349        var source = this;
28350
28351        return new Enumerable(function () {
28352            var enumerator;
28353
28354            return new IEnumerator(
28355                function () { enumerator = source.GetEnumerator(); },
28356                function () {
28357                    return (enumerator.moveNext())
28358                        ? this.yieldReturn(enumerator.Current)
28359                        : false;
28360                },
28361                function () {
28362                    try {
28363                        Utils.Dispose(enumerator);
28364                    } finally {
28365                        finallyAction();
28366                    }
28367                });
28368        });
28369    };
28370
28371    /* For Debug Methods */
28372
28373    // Overload:function ()
28374    // Overload:function (selector)
28375    Enumerable.prototype.log = function (selector) {
28376        selector = Utils.createLambda(selector);
28377
28378        return this.doAction(function (item) {
28379            if (typeof console !== Types.Undefined) {
28380                console.log(selector(item));
28381            }
28382        });
28383    };
28384
28385    // Overload:function ()
28386    // Overload:function (message)
28387    // Overload:function (message,selector)
28388    Enumerable.prototype.trace = function (message, selector) {
28389        if (message == null) message = "Trace";
28390        selector = Utils.createLambda(selector);
28391
28392        return this.doAction(function (item) {
28393            if (typeof console !== Types.Undefined) {
28394                console.log(message, selector(item));
28395            }
28396        });
28397    };
28398
28399    // private
28400    var defaultComparer = {
28401        compare: function (x, y) {
28402            if (!H5.hasValue(x)) {
28403                return !H5.hasValue(y) ? 0 : -1;
28404            } else if (!H5.hasValue(y)) {
28405                return 1;
28406            }
28407
28408            if (typeof x == "string" && typeof y == "string") {
28409                var result = System.String.compare(x, y, true);
28410
28411                if (result !== 0) {
28412                    return result;
28413                }
28414            }
28415
28416            return H5.compare(x, y);
28417        }
28418    };
28419    var OrderedEnumerable = function (source, keySelector, comparer, descending, parent) {
28420        this.source = source;
28421        this.keySelector = Utils.createLambda(keySelector);
28422        this.comparer = comparer || defaultComparer;
28423        this.descending = descending;
28424        this.parent = parent;
28425    };
28426    OrderedEnumerable.prototype = new Enumerable();
28427    OrderedEnumerable.prototype.constructor = OrderedEnumerable;
28428    H5.definei("System.Linq.IOrderedEnumerable$1");
28429    OrderedEnumerable.$$inherits = [];
28430    H5.Class.addExtend(OrderedEnumerable, [System.Collections.IEnumerable, System.Linq.IOrderedEnumerable$1]);
28431
28432    OrderedEnumerable.prototype.createOrderedEnumerable = function (keySelector, comparer, descending) {
28433        return new OrderedEnumerable(this.source, keySelector, comparer, descending, this);
28434    };
28435
28436    OrderedEnumerable.prototype.thenBy = function (keySelector, comparer) {
28437        return this.createOrderedEnumerable(keySelector, comparer, false);
28438    };
28439
28440    OrderedEnumerable.prototype.thenByDescending = function (keySelector, comparer) {
28441        return this.createOrderedEnumerable(keySelector, comparer, true);
28442    };
28443
28444    OrderedEnumerable.prototype.GetEnumerator = function () {
28445        var self = this;
28446        var buffer;
28447        var indexes;
28448        var index = 0;
28449
28450        return new IEnumerator(
28451            function () {
28452                buffer = [];
28453                indexes = [];
28454                self.source.forEach(function (item, index) {
28455                    buffer.push(item);
28456                    indexes.push(index);
28457                });
28458                var sortContext = SortContext.create(self, null);
28459                sortContext.GenerateKeys(buffer);
28460
28461                indexes.sort(function (a, b) { return sortContext.compare(a, b); });
28462            },
28463            function () {
28464                return (index < indexes.length)
28465                    ? this.yieldReturn(buffer[indexes[index++]])
28466                    : false;
28467            },
28468            Functions.Blank
28469        );
28470    };
28471
28472    var SortContext = function (keySelector, comparer, descending, child) {
28473        this.keySelector = keySelector;
28474        this.comparer = comparer;
28475        this.descending = descending;
28476        this.child = child;
28477        this.keys = null;
28478    };
28479
28480    SortContext.create = function (orderedEnumerable, currentContext) {
28481        var context = new SortContext(orderedEnumerable.keySelector, orderedEnumerable.comparer, orderedEnumerable.descending, currentContext);
28482        if (orderedEnumerable.parent != null) return SortContext.create(orderedEnumerable.parent, context);
28483        return context;
28484    };
28485
28486    SortContext.prototype.GenerateKeys = function (source) {
28487        var len = source.length;
28488        var keySelector = this.keySelector;
28489        var keys = new Array(len);
28490        for (var i = 0; i < len; i++) keys[i] = keySelector(source[i]);
28491        this.keys = keys;
28492
28493        if (this.child != null) this.child.GenerateKeys(source);
28494    };
28495
28496    SortContext.prototype.compare = function (index1, index2) {
28497        var comparison = this.comparer.compare(this.keys[index1], this.keys[index2]);
28498
28499        if (comparison == 0) {
28500            if (this.child != null) return this.child.compare(index1, index2);
28501            return Utils.compare(index1, index2);
28502        }
28503
28504        return (this.descending) ? -comparison : comparison;
28505    };
28506
28507    var DisposableEnumerable = function (GetEnumerator, dispose) {
28508        this.Dispose = dispose;
28509        Enumerable.call(this, GetEnumerator);
28510    };
28511    DisposableEnumerable.prototype = new Enumerable();
28512
28513    // optimize array or arraylike object
28514
28515    var ArrayEnumerable = function (source) {
vendor: 4,285 bytes, lines 28516-28636
28516        this.getSource = function () { return source; };
28517    };
28518    ArrayEnumerable.prototype = new Enumerable();
28519
28520    ArrayEnumerable.prototype.any = function (predicate) {
28521        return (predicate == null)
28522            ? (this.getSource().length > 0)
28523            : Enumerable.prototype.any.apply(this, arguments);
28524    };
28525
28526    ArrayEnumerable.prototype.count = function (predicate) {
28527        return (predicate == null)
28528            ? this.getSource().length
28529            : Enumerable.prototype.count.apply(this, arguments);
28530    };
28531
28532    ArrayEnumerable.prototype.elementAt = function (index) {
28533        var source = this.getSource();
28534        return (0 <= index && index < source.length)
28535            ? source[index]
28536            : Enumerable.prototype.elementAt.apply(this, arguments);
28537    };
28538
28539    ArrayEnumerable.prototype.elementAtOrDefault = function (index, defaultValue) {
28540        if (defaultValue === undefined) defaultValue = null;
28541        var source = this.getSource();
28542        return (0 <= index && index < source.length)
28543            ? source[index]
28544            : defaultValue;
28545    };
28546
28547    ArrayEnumerable.prototype.first = function (predicate) {
28548        var source = this.getSource();
28549        return (predicate == null && source.length > 0)
28550            ? source[0]
28551            : Enumerable.prototype.first.apply(this, arguments);
28552    };
28553
28554    ArrayEnumerable.prototype.firstOrDefault = function (predicate, defaultValue) {
28555        if (defaultValue === undefined) defaultValue = null;
28556        if (predicate != null) {
28557            return Enumerable.prototype.firstOrDefault.apply(this, arguments);
28558        }
28559
28560        var source = this.getSource();
28561        return source.length > 0 ? source[0] : defaultValue;
28562    };
28563
28564    ArrayEnumerable.prototype.last = function (predicate) {
28565        var source = this.getSource();
28566        return (predicate == null && source.length > 0)
28567            ? source[source.length - 1]
28568            : Enumerable.prototype.last.apply(this, arguments);
28569    };
28570
28571    ArrayEnumerable.prototype.lastOrDefault = function (predicate, defaultValue) {
28572        if (defaultValue === undefined) defaultValue = null;
28573        if (predicate != null) {
28574            return Enumerable.prototype.lastOrDefault.apply(this, arguments);
28575        }
28576
28577        var source = this.getSource();
28578        return source.length > 0 ? source[source.length - 1] : defaultValue;
28579    };
28580
28581    ArrayEnumerable.prototype.skip = function (count) {
28582        var source = this.getSource();
28583
28584        return new Enumerable(function () {
28585            var index;
28586
28587            return new IEnumerator(
28588                function () { index = (count < 0) ? 0 : count; },
28589                function () {
28590                    return (index < source.length)
28591                        ? this.yieldReturn(source[index++])
28592                        : false;
28593                },
28594                Functions.Blank);
28595        });
28596    };
28597
28598    ArrayEnumerable.prototype.takeExceptLast = function (count) {
28599        if (count == null) count = 1;
28600        return this.take(this.getSource().length - count);
28601    };
28602
28603    ArrayEnumerable.prototype.takeFromLast = function (count) {
28604        return this.skip(this.getSource().length - count);
28605    };
28606
28607    ArrayEnumerable.prototype.reverse = function () {
28608        var source = this.getSource();
28609
28610        return new Enumerable(function () {
28611            var index;
28612
28613            return new IEnumerator(
28614                function () {
28615                    index = source.length;
28616                },
28617                function () {
28618                    return (index > 0)
28619                        ? this.yieldReturn(source[--index])
28620                        : false;
28621                },
28622                Functions.Blank);
28623        });
28624    };
28625
28626    ArrayEnumerable.prototype.sequenceEqual = function (second, comparer) {
28627        if ((second instanceof ArrayEnumerable || second instanceof Array)
28628            && comparer == null
28629            && Enumerable.from(second).count() != this.count()) {
28630            return false;
28631        }
28632
28633        return Enumerable.prototype.sequenceEqual.apply(this, arguments);
28634    };
28635
28636    ArrayEnumerable.prototype.toJoinedString = function (separator, selector) {
28637        var source = this.getSource();
28638        if (selector != null || !(source instanceof Array)) {
28639            return Enumerable.prototype.toJoinedString.apply(this, arguments);
28640        }
28641
28642        if (separator == null) separator = "";
28643        return source.join(separator);
28644    };
28645
28646    ArrayEnumerable.prototype.GetEnumerator = function () {
28647        return new H5.ArrayEnumerator(this.getSource());
28648    };
28649
28650    // optimization for multiple where and multiple select and whereselect
28651
28652    var WhereEnumerable = function (source, predicate) {
28653        this.prevSource = source;
28654        this.prevPredicate = predicate; // predicate.length always <= 1
28655    };
28656    WhereEnumerable.prototype = new Enumerable();
28657
28658    WhereEnumerable.prototype.where = function (predicate) {
28659        predicate = Utils.createLambda(predicate);
28660
28661        if (predicate.length <= 1) {
28662            var prevPredicate = this.prevPredicate;
28663            var composedPredicate = function (x) { return prevPredicate(x) && predicate(x); };
28664            return new WhereEnumerable(this.prevSource, composedPredicate);
28665        }
28666        else {
28667            // if predicate use index, can't compose
28668            return Enumerable.prototype.where.call(this, predicate);
28669        }
28670    };
28671
28672    WhereEnumerable.prototype.select = function (selector) {
28673        selector = Utils.createLambda(selector);
28674
28675        return (selector.length <= 1)
28676            ? new WhereSelectEnumerable(this.prevSource, this.prevPredicate, selector)
28677            : Enumerable.prototype.select.call(this, selector);
28678    };
28679
28680    WhereEnumerable.prototype.GetEnumerator = function () {
28681        var predicate = this.prevPredicate;
28682        var source = this.prevSource;
28683        var enumerator;
28684
28685        return new IEnumerator(
28686            function () { enumerator = source.GetEnumerator(); },
28687            function () {
28688                while (enumerator.moveNext()) {
28689                    if (predicate(enumerator.Current)) {
28690                        return this.yieldReturn(enumerator.Current);
28691                    }
28692                }
28693                return false;
28694            },
28695            function () { Utils.Dispose(enumerator); });
28696    };
28697
28698    var WhereSelectEnumerable = function (source, predicate, selector) {
28699        this.prevSource = source;
28700        this.prevPredicate = predicate; // predicate.length always <= 1 or null
28701        this.prevSelector = selector; // selector.length always <= 1
28702    };
28703    WhereSelectEnumerable.prototype = new Enumerable();
28704
28705    WhereSelectEnumerable.prototype.where = function (predicate) {
28706        predicate = Utils.createLambda(predicate);
28707
28708        return (predicate.length <= 1)
28709            ? new WhereEnumerable(this, predicate)
28710            : Enumerable.prototype.where.call(this, predicate);
28711    };
28712
28713    WhereSelectEnumerable.prototype.select = function (selector) {
28714        selector = Utils.createLambda(selector);
28715
28716        if (selector.length <= 1) {
28717            var prevSelector = this.prevSelector;
28718            var composedSelector = function (x) { return selector(prevSelector(x)); };
28719            return new WhereSelectEnumerable(this.prevSource, this.prevPredicate, composedSelector);
28720        }
28721        else {
28722            // if selector use index, can't compose
28723            return Enumerable.prototype.select.call(this, selector);
28724        }
28725    };
28726
28727    WhereSelectEnumerable.prototype.GetEnumerator = function () {
28728        var predicate = this.prevPredicate;
28729        var selector = this.prevSelector;
28730        var source = this.prevSource;
28731        var enumerator;
28732
28733        return new IEnumerator(
28734            function () { enumerator = source.GetEnumerator(); },
28735            function () {
28736                while (enumerator.moveNext()) {
28737                    if (predicate == null || predicate(enumerator.Current)) {
28738                        return this.yieldReturn(selector(enumerator.Current));
28739                    }
28740                }
28741                return false;
28742            },
28743            function () { Utils.Dispose(enumerator); });
28744    };
28745
28746    // Collections
28747
28748    // dictionary = Dictionary<TKey, TValue[]>
28749    var Lookup = function (dictionary, order, nullKey) {
28750        this.count = function () {
28751            return dictionary.Count;
28752        };
28753        this.get = function (key) {
28754            if (key == null) {
28755                return Enumerable.from(nullKey ? nullKey : []);
28756            }
28757
28758            var value = { v: null };
28759            var success = dictionary.tryGetValue(key, value);
28760            return Enumerable.from(success ? value.v : []);
28761        };
28762        this.contains = function (key) {
28763            if (key == null) {
28764                return !!nullKey;
28765            }
28766            return dictionary.containsKey(key);
28767        };
28768        this.toEnumerable = function () {
28769            return Enumerable.from(order).select(function (key) {
28770                if (key == null) {
28771                    return new Grouping(key, nullKey);
28772                }
28773                return new Grouping(key, dictionary.getItem(key));
28774            });
28775        };
28776        this.GetEnumerator = function () {
28777            return this.toEnumerable().GetEnumerator();
28778        };
28779    };
28780
28781    H5.definei("System.Linq.ILookup$2");
28782    Lookup.$$inherits = [];
28783    H5.Class.addExtend(Lookup, [System.Collections.IEnumerable, System.Linq.ILookup$2]);
28784
28785    var Grouping = function (groupKey, elements) {
28786        this.key = function () {
28787            return groupKey;
28788        };
28789        ArrayEnumerable.call(this, elements);
28790    };
28791    Grouping.prototype = new ArrayEnumerable();
28792    H5.definei("System.Linq.IGrouping$2");
28793    Grouping.prototype.constructor = Grouping;
28794
28795    Grouping.$$inherits = [];
28796    H5.Class.addExtend(Grouping, [System.Collections.IEnumerable, System.Linq.IGrouping$2]);
28797
28798    // module export
28799    /*if (typeof define === Types.Function && define.amd) { // AMD
28800        define("linqjs", [], function () { return Enumerable; });
28801    } else if (typeof module !== Types.Undefined && module.exports) { // Node
28802        module.exports = Enumerable;
28803    } else {
28804        root.Enumerable = Enumerable;
28805    }*/
28806
28807    H5.Linq = {};
28808    H5.Linq.Enumerable = Enumerable;
28809
28810    System.Linq = System.Linq || {};
28811    System.Linq.Enumerable = Enumerable;
28812    System.Linq.Grouping$2 = Grouping;
28813    System.Linq.Lookup$2 = Lookup;
28814    System.Linq.OrderedEnumerable$1 = OrderedEnumerable;
28815})(H5.global);
28816
28817    // @source CollectionDataContractAttribute.js
28818
28819    H5.define("System.Runtime.Serialization.CollectionDataContractAttribute", {
28820        inherits: [System.Attribute],
28821        fields: {
28822            _name: null,
28823            _ns: null,
28824            _itemName: null,
28825            _keyName: null,
28826            _valueName: null,
28827            _isReference: false,
28828            _isNameSetExplicitly: false,
28829            _isNamespaceSetExplicitly: false,
28830            _isReferenceSetExplicitly: false,
28831            _isItemNameSetExplicitly: false,
28832            _isKeyNameSetExplicitly: false,
28833            _isValueNameSetExplicitly: false
28834        },
28835        props: {
28836            Namespace: {
28837                get: function () {
28838                    return this._ns;
28839                },
28840                set: function (value) {
28841                    this._ns = value;
28842                    this._isNamespaceSetExplicitly = true;
28843                }
28844            },
28845            IsNamespaceSetExplicitly: {
28846                get: function () {
28847                    return this._isNamespaceSetExplicitly;
28848                }
28849            },
28850            Name: {
28851                get: function () {
28852                    return this._name;
28853                },
28854                set: function (value) {
28855                    this._name = value;
28856                    this._isNameSetExplicitly = true;
28857                }
28858            },
28859            IsNameSetExplicitly: {
28860                get: function () {
28861                    return this._isNameSetExplicitly;
28862                }
28863            },
28864            ItemName: {
28865                get: function () {
28866                    return this._itemName;
28867                },
28868                set: function (value) {
28869                    this._itemName = value;
28870                    this._isItemNameSetExplicitly = true;
28871                }
28872            },
28873            IsItemNameSetExplicitly: {
28874                get: function () {
28875                    return this._isItemNameSetExplicitly;
28876                }
28877            },
28878            KeyName: {
28879                get: function () {
28880                    return this._keyName;
28881                },
28882                set: function (value) {
28883                    this._keyName = value;
28884                    this._isKeyNameSetExplicitly = true;
28885                }
28886            },
28887            IsReference: {
28888                get: function () {
28889                    return this._isReference;
28890                },
28891                set: function (value) {
28892                    this._isReference = value;
28893                    this._isReferenceSetExplicitly = true;
28894                }
28895            },
28896            IsReferenceSetExplicitly: {
28897                get: function () {
28898                    return this._isReferenceSetExplicitly;
28899                }
28900            },
28901            IsKeyNameSetExplicitly: {
28902                get: function () {
28903                    return this._isKeyNameSetExplicitly;
28904                }
28905            },
28906            ValueName: {
28907                get: function () {
28908                    return this._valueName;
28909                },
28910                set: function (value) {
28911                    this._valueName = value;
28912                    this._isValueNameSetExplicitly = true;
28913                }
28914            },
28915            IsValueNameSetExplicitly: {
28916                get: function () {
28917                    return this._isValueNameSetExplicitly;
28918                }
28919            }
28920        },
28921        ctors: {
28922            ctor: function () {
28923                this.$initialize();
28924                System.Attribute.ctor.call(this);
28925            }
28926        }
28927    });
28928
28929    // @source ContractNamespaceAttribute.js
28930
28931    H5.define("System.Runtime.Serialization.ContractNamespaceAttribute", {
28932        inherits: [System.Attribute],
28933        fields: {
28934            _clrNamespace: null,
28935            _contractNamespace: null
28936        },
28937        props: {
28938            ClrNamespace: {
28939                get: function () {
28940                    return this._clrNamespace;
28941                },
28942                set: function (value) {
28943                    this._clrNamespace = value;
28944                }
28945            },
28946            ContractNamespace: {
28947                get: function () {
28948                    return this._contractNamespace;
28949                }
28950            }
28951        },
28952        ctors: {
28953            ctor: function (contractNamespace) {
28954                this.$initialize();
28955                System.Attribute.ctor.call(this);
28956                this._contractNamespace = contractNamespace;
28957            }
28958        }
28959    });
28960
28961    // @source DataContractAttribute.js
28962
28963    H5.define("System.Runtime.Serialization.DataContractAttribute", {
28964        inherits: [System.Attribute],
28965        fields: {
28966            _name: null,
28967            _ns: null,
28968            _isNameSetExplicitly: false,
28969            _isNamespaceSetExplicitly: false,
28970            _isReference: false,
28971            _isReferenceSetExplicitly: false
28972        },
28973        props: {
28974            IsReference: {
28975                get: function () {
28976                    return this._isReference;
28977                },
28978                set: function (value) {
28979                    this._isReference = value;
28980                    this._isReferenceSetExplicitly = true;
28981                }
28982            },
28983            IsReferenceSetExplicitly: {
28984                get: function () {
28985                    return this._isReferenceSetExplicitly;
28986                }
28987            },
28988            Namespace: {
28989                get: function () {
28990                    return this._ns;
28991                },
28992                set: function (value) {
28993                    this._ns = value;
28994                    this._isNamespaceSetExplicitly = true;
28995                }
28996            },
28997            IsNamespaceSetExplicitly: {
28998                get: function () {
28999                    return this._isNamespaceSetExplicitly;
29000                }
29001            },
29002            Name: {
29003                get: function () {
29004                    return this._name;
29005                },
29006                set: function (value) {
29007                    this._name = value;
29008                    this._isNameSetExplicitly = true;
29009                }
29010            },
29011            IsNameSetExplicitly: {
29012                get: function () {
29013                    return this._isNameSetExplicitly;
29014                }
29015            }
29016        },
29017        ctors: {
29018            ctor: function () {
29019                this.$initialize();
29020                System.Attribute.ctor.call(this);
29021            }
29022        }
29023    });
29024
29025    // @source DataMemberAttribute.js
29026
29027    H5.define("System.Runtime.Serialization.DataMemberAttribute", {
29028        inherits: [System.Attribute],
29029        fields: {
29030            _name: null,
29031            _isNameSetExplicitly: false,
29032            _order: 0,
29033            _isRequired: false,
29034            _emitDefaultValue: false
29035        },
29036        props: {
29037            Name: {
29038                get: function () {
29039                    return this._name;
29040                },
29041                set: function (value) {
29042                    this._name = value;
29043                    this._isNameSetExplicitly = true;
29044                }
29045            },
29046            IsNameSetExplicitly: {
29047                get: function () {
29048                    return this._isNameSetExplicitly;
29049                }
29050            },
29051            Order: {
29052                get: function () {
29053                    return this._order;
29054                },
29055                set: function (value) {
29056                    if (value < 0) {
29057                        throw new System.Runtime.Serialization.InvalidDataContractException.$ctor1("Property 'Order' in DataMemberAttribute attribute cannot be a negative number.");
29058                    }
29059                    this._order = value;
29060                }
29061            },
29062            IsRequired: {
29063                get: function () {
29064                    return this._isRequired;
29065                },
29066                set: function (value) {
29067                    this._isRequired = value;
29068                }
29069            },
29070            EmitDefaultValue: {
29071                get: function () {
29072                    return this._emitDefaultValue;
29073                },
29074                set: function (value) {
29075                    this._emitDefaultValue = value;
29076                }
29077            }
29078        },
29079        ctors: {
29080            init: function () {
29081                this._order = -1;
29082                this._emitDefaultValue = true;
29083            },
29084            ctor: function () {
29085                this.$initialize();
29086                System.Attribute.ctor.call(this);
29087            }
29088        }
29089    });
29090
29091    // @source EnumMemberAttribute.js
29092
29093    H5.define("System.Runtime.Serialization.EnumMemberAttribute", {
29094        inherits: [System.Attribute],
29095        fields: {
29096            _value: null,
29097            _isValueSetExplicitly: false
29098        },
29099        props: {
29100            Value: {
29101                get: function () {
29102                    return this._value;
29103                },
29104                set: function (value) {
29105                    this._value = value;
29106                    this._isValueSetExplicitly = true;
29107                }
29108            },
29109            IsValueSetExplicitly: {
29110                get: function () {
29111                    return this._isValueSetExplicitly;
29112                }
29113            }
29114        },
29115        ctors: {
29116            ctor: function () {
29117                this.$initialize();
29118                System.Attribute.ctor.call(this);
29119            }
29120        }
29121    });
29122
29123    // @source IDeserializationCallback.js
29124
29125    H5.define("System.Runtime.Serialization.IDeserializationCallback", {
29126        $kind: "interface"
29127    });
29128
29129    // @source IFormatterConverter.js
29130
29131    H5.define("System.Runtime.Serialization.IFormatterConverter", {
29132        $kind: "interface"
29133    });
29134
29135    // @source IgnoreDataMemberAttribute.js
29136
29137    H5.define("System.Runtime.Serialization.IgnoreDataMemberAttribute", {
29138        inherits: [System.Attribute],
29139        ctors: {
29140            ctor: function () {
29141                this.$initialize();
29142                System.Attribute.ctor.call(this);
29143            }
29144        }
29145    });
29146
29147    // @source InvalidDataContractException.js
29148
29149    H5.define("System.Runtime.Serialization.InvalidDataContractException", {
29150        inherits: [System.Exception],
29151        ctors: {
29152            ctor: function () {
29153                this.$initialize();
29154                System.Exception.ctor.call(this);
29155            },
29156            $ctor1: function (message) {
29157                this.$initialize();
29158                System.Exception.ctor.call(this, message);
29159            },
29160            $ctor2: function (message, innerException) {
29161                this.$initialize();
29162                System.Exception.ctor.call(this, message, innerException);
29163            }
29164        }
29165    });
29166
29167    // @source IObjectReference.js
29168
29169    H5.define("System.Runtime.Serialization.IObjectReference", {
29170        $kind: "interface"
29171    });
29172
29173    // @source ISafeSerializationData.js
29174
29175    H5.define("System.Runtime.Serialization.ISafeSerializationData", {
29176        $kind: "interface"
29177    });
29178
29179    // @source ISerializable.js
29180
29181    H5.define("System.Runtime.Serialization.ISerializable", {
29182        $kind: "interface"
29183    });
29184
29185    // @source ISerializationSurrogateProvider.js
29186
29187    H5.define("System.Runtime.Serialization.ISerializationSurrogateProvider", {
29188        $kind: "interface"
29189    });
29190
29191    // @source KnownTypeAttribute.js
29192
29193    H5.define("System.Runtime.Serialization.KnownTypeAttribute", {
29194        inherits: [System.Attribute],
29195        fields: {
29196            _methodName: null,
29197            _type: null
29198        },
29199        props: {
29200            MethodName: {
29201                get: function () {
29202                    return this._methodName;
29203                }
29204            },
29205            Type: {
29206                get: function () {
29207                    return this._type;
29208                }
29209            }
29210        },
29211        ctors: {
29212            ctor: function () {
29213                this.$initialize();
29214                System.Attribute.ctor.call(this);
29215            },
29216            $ctor2: function (type) {
29217                this.$initialize();
29218                System.Attribute.ctor.call(this);
29219                this._type = type;
29220            },
29221            $ctor1: function (methodName) {
29222                this.$initialize();
29223                System.Attribute.ctor.call(this);
29224                this._methodName = methodName;
29225            }
29226        }
29227    });
29228
29229    // @source SerializationEntry.js
29230
29231    H5.define("System.Runtime.Serialization.SerializationEntry", {
29232        $kind: "struct",
29233        statics: {
29234            methods: {
29235                getDefaultValue: function () { return new System.Runtime.Serialization.SerializationEntry(); }
29236            }
29237        },
29238        fields: {
29239            _name: null,
29240            _value: null,
29241            _type: null
29242        },
29243        props: {
29244            Value: {
29245                get: function () {
29246                    return this._value;
29247                }
29248            },
29249            Name: {
29250                get: function () {
29251                    return this._name;
29252                }
29253            },
29254            ObjectType: {
29255                get: function () {
29256                    return this._type;
29257                }
29258            }
29259        },
29260        ctors: {
29261            $ctor1: function (entryName, entryValue, entryType) {
29262                this.$initialize();
29263                this._name = entryName;
29264                this._value = entryValue;
29265                this._type = entryType;
29266            },
29267            ctor: function () {
29268                this.$initialize();
29269            }
29270        },
29271        methods: {
29272            getHashCode: function () {
29273                var h = H5.addHash([7645431029, this._name, this._value, this._type]);
29274                return h;
29275            },
29276            equals: function (o) {
29277                if (!H5.is(o, System.Runtime.Serialization.SerializationEntry)) {
29278                    return false;
29279                }
29280                return H5.equals(this._name, o._name) && H5.equals(this._value, o._value) && H5.equals(this._type, o._type);
29281            },
29282            $clone: function (to) {
29283                var s = to || new System.Runtime.Serialization.SerializationEntry();
29284                s._name = this._name;
29285                s._value = this._value;
29286                s._type = this._type;
29287                return s;
29288            }
29289        }
29290    });
29291
29292    // @source SerializationException.js
29293
29294    H5.define("System.Runtime.Serialization.SerializationException", {
29295        inherits: [System.SystemException],
29296        statics: {
29297            fields: {
29298                s_nullMessage: null
29299            },
29300            ctors: {
29301                init: function () {
29302                    this.s_nullMessage = "Serialization error.";
29303                }
29304            }
29305        },
29306        ctors: {
29307            ctor: function () {
29308                this.$initialize();
29309                System.SystemException.$ctor1.call(this, System.Runtime.Serialization.SerializationException.s_nullMessage);
29310                this.HResult = -2146233076;
29311            },
29312            $ctor1: function (message) {
29313                this.$initialize();
29314                System.SystemException.$ctor1.call(this, message);
29315                this.HResult = -2146233076;
29316            },
29317            $ctor2: function (message, innerException) {
29318                this.$initialize();
29319                System.SystemException.$ctor2.call(this, message, innerException);
29320                this.HResult = -2146233076;
29321            }
29322        }
29323    });
29324
29325    // @source SerializationInfoEnumerator.js
29326
29327    H5.define("System.Runtime.Serialization.SerializationInfoEnumerator", {
29328        inherits: [System.Collections.IEnumerator],
29329        fields: {
29330            _members: null,
29331            _data: null,
29332            _types: null,
29333            _numItems: 0,
29334            _currItem: 0,
29335            _current: false
29336        },
29337        props: {
29338            System$Collections$IEnumerator$Current: {
29339                get: function () {
29340                    return this.Current.$clone();
29341                }
29342            },
29343            Current: {
29344                get: function () {
29345                    if (this._current === false) {
29346                        throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
29347                    }
29348                    return new System.Runtime.Serialization.SerializationEntry.$ctor1(this._members[System.Array.index(this._currItem, this._members)], this._data[System.Array.index(this._currItem, this._data)], this._types[System.Array.index(this._currItem, this._types)]);
29349                }
29350            },
29351            Name: {
29352                get: function () {
29353                    if (this._current === false) {
29354                        throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
29355                    }
29356                    return this._members[System.Array.index(this._currItem, this._members)];
29357                }
29358            },
29359            Value: {
29360                get: function () {
29361                    if (this._current === false) {
29362                        throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
29363                    }
29364                    return this._data[System.Array.index(this._currItem, this._data)];
29365                }
29366            },
29367            ObjectType: {
29368                get: function () {
29369                    if (this._current === false) {
29370                        throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
29371                    }
29372                    return this._types[System.Array.index(this._currItem, this._types)];
29373                }
29374            }
29375        },
29376        alias: [
29377            "moveNext", "System$Collections$IEnumerator$moveNext",
29378            "reset", "System$Collections$IEnumerator$reset"
29379        ],
29380        ctors: {
29381            ctor: function (members, info, types, numItems) {
29382                this.$initialize();
29383
29384                this._members = members;
29385                this._data = info;
29386                this._types = types;
29387
29388                this._numItems = (numItems - 1) | 0;
29389                this._currItem = -1;
29390                this._current = false;
29391            }
29392        },
29393        methods: {
29394            moveNext: function () {
29395                if (this._currItem < this._numItems) {
29396                    this._currItem = (this._currItem + 1) | 0;
29397                    this._current = true;
29398                } else {
29399                    this._current = false;
29400                }
29401
29402                return this._current;
29403            },
29404            reset: function () {
29405                this._currItem = -1;
29406                this._current = false;
29407            }
29408        }
29409    });
29410
29411    // @source StreamingContext.js
29412
29413    H5.define("System.Runtime.Serialization.StreamingContext", {
29414        $kind: "struct",
29415        statics: {
29416            methods: {
29417                getDefaultValue: function () { return new System.Runtime.Serialization.StreamingContext(); }
29418            }
29419        },
29420        fields: {
29421            _additionalContext: null,
29422            _state: 0
29423        },
29424        props: {
29425            State: {
29426                get: function () {
29427                    return this._state;
29428                }
29429            },
29430            Context: {
29431                get: function () {
29432                    return this._additionalContext;
29433                }
29434            }
29435        },
29436        ctors: {
29437            $ctor1: function (state) {
29438                System.Runtime.Serialization.StreamingContext.$ctor2.call(this, state, null);
29439            },
29440            $ctor2: function (state, additional) {
29441                this.$initialize();
29442                this._state = state;
29443                this._additionalContext = additional;
29444            },
29445            ctor: function () {
29446                this.$initialize();
29447            }
29448        },
29449        methods: {
29450            equals: function (obj) {
29451                if (!(H5.is(obj, System.Runtime.Serialization.StreamingContext))) {
29452                    return false;
29453                }
29454                var ctx = System.Nullable.getValue(H5.cast(H5.unbox(obj, System.Runtime.Serialization.StreamingContext), System.Runtime.Serialization.StreamingContext));
29455                return H5.referenceEquals(ctx._additionalContext, this._additionalContext) && ctx._state === this._state;
29456            },
29457            getHashCode: function () {
29458                return this._state;
29459            },
29460            $clone: function (to) {
29461                var s = to || new System.Runtime.Serialization.StreamingContext();
29462                s._additionalContext = this._additionalContext;
29463                s._state = this._state;
29464                return s;
29465            }
29466        }
29467    });
29468
29469    // @source StreamingContextStates.js
29470
29471    H5.define("System.Runtime.Serialization.StreamingContextStates", {
29472        $kind: "enum",
29473        statics: {
29474            fields: {
29475                CrossProcess: 1,
29476                CrossMachine: 2,
29477                File: 4,
29478                Persistence: 8,
29479                Remoting: 16,
29480                Other: 32,
29481                Clone: 64,
29482                CrossAppDomain: 128,
29483                All: 255
29484            }
29485        },
29486        $flags: true
29487    });
29488
29489    // @source OnSerializingAttribute.js
29490
29491    H5.define("System.Runtime.Serialization.OnSerializingAttribute", {
29492        inherits: [System.Attribute]
29493    });
29494
29495    // @source OnSerializedAttribute.js
29496
29497    H5.define("System.Runtime.Serialization.OnSerializedAttribute", {
29498        inherits: [System.Attribute]
29499    });
29500
29501    // @source OnDeserializingAttribute.js
29502
29503    H5.define("System.Runtime.Serialization.OnDeserializingAttribute", {
29504        inherits: [System.Attribute]
29505    });
29506
29507    // @source OnDeserializedAttribute.js
29508
29509    H5.define("System.Runtime.Serialization.OnDeserializedAttribute", {
29510        inherits: [System.Attribute]
29511    });
29512
29513    // @source SecurityException.js
29514
29515    H5.define("System.Security.SecurityException", {
29516        inherits: [System.SystemException],
29517        statics: {
29518            fields: {
29519                DemandedName: null,
29520                GrantedSetName: null,
29521                RefusedSetName: null,
29522                DeniedName: null,
29523                PermitOnlyName: null,
29524                UrlName: null
29525            },
29526            ctors: {
29527                init: function () {
29528                    this.DemandedName = "Demanded";
29529                    this.GrantedSetName = "GrantedSet";
29530                    this.RefusedSetName = "RefusedSet";
29531                    this.DeniedName = "Denied";
29532                    this.PermitOnlyName = "PermitOnly";
29533                    this.UrlName = "Url";
29534                }
29535            }
29536        },
29537        props: {
29538            Demanded: null,
29539            DenySetInstance: null,
29540            GrantedSet: null,
29541            Method: null,
29542            PermissionState: null,
29543            PermissionType: null,
29544            PermitOnlySetInstance: null,
29545            RefusedSet: null,
29546            Url: null
29547        },
29548        ctors: {
29549            ctor: function () {
29550                this.$initialize();
29551                System.SystemException.$ctor1.call(this, "Security error.");
29552                this.HResult = -2146233078;
29553            },
29554            $ctor1: function (message) {
29555                this.$initialize();
29556                System.SystemException.$ctor1.call(this, message);
29557                this.HResult = -2146233078;
29558            },
29559            $ctor2: function (message, inner) {
29560                this.$initialize();
29561                System.SystemException.$ctor2.call(this, message, inner);
29562                this.HResult = -2146233078;
29563            },
29564            $ctor3: function (message, type) {
29565                this.$initialize();
29566                System.SystemException.$ctor1.call(this, message);
29567                this.HResult = -2146233078;
29568                this.PermissionType = type;
29569            },
29570            $ctor4: function (message, type, state) {
29571                this.$initialize();
29572                System.SystemException.$ctor1.call(this, message);
29573                this.HResult = -2146233078;
29574                this.PermissionType = type;
29575                this.PermissionState = state;
29576            }
29577        },
29578        methods: {
29579            toString: function () {
29580                return H5.toString(this);
29581            }
29582        }
29583    });
29584
29585    // @source UnauthorizedAccessException.js
29586
29587    H5.define("System.UnauthorizedAccessException", {
29588        inherits: [System.SystemException],
29589        ctors: {
29590            ctor: function () {
29591                this.$initialize();
29592                System.SystemException.$ctor1.call(this, "Attempted to perform an unauthorized operation.");
29593                this.HResult = -2147024891;
29594            },
29595            $ctor1: function (message) {
29596                this.$initialize();
29597                System.SystemException.$ctor1.call(this, message);
29598                this.HResult = -2147024891;
29599            },
29600            $ctor2: function (message, inner) {
29601                this.$initialize();
29602                System.SystemException.$ctor2.call(this, message, inner);
29603                this.HResult = -2147024891;
29604            }
29605        }
29606    });
29607
29608    // @source UnhandledExceptionEventArgs.js
29609
29610    H5.define("System.UnhandledExceptionEventArgs", {
29611        fields: {
29612            _exception: null,
29613            _isTerminating: false
29614        },
29615        props: {
29616            ExceptionObject: {
29617                get: function () {
29618                    return this._exception;
29619                }
29620            },
29621            IsTerminating: {
29622                get: function () {
29623                    return this._isTerminating;
29624                }
29625            }
29626        },
29627        ctors: {
29628            ctor: function (exception, isTerminating) {
29629                this.$initialize();
29630                System.Object.call(this);
29631                this._exception = exception;
29632                this._isTerminating = isTerminating;
29633            }
29634        }
29635    });
29636
29637    // @source Regex.js
29638
29639    H5.define("System.Text.RegularExpressions.Regex", {
29640        statics: {
29641            _cacheSize: 15,
29642            _defaultMatchTimeout: System.TimeSpan.fromMilliseconds(-1),
29643
29644            getCacheSize: function () {
29645                return System.Text.RegularExpressions.Regex._cacheSize;
29646            },
29647
29648            setCacheSize: function (value) {
29649                if (value < 0) {
29650                    throw new System.ArgumentOutOfRangeException.$ctor1("value");
29651                }
29652
29653                System.Text.RegularExpressions.Regex._cacheSize = value;
29654                //TODO: remove extra items from cache
29655            },
29656
29657            escape: function (str) {
29658                if (str == null) {
29659                    throw new System.ArgumentNullException.$ctor1("str");
29660                }
29661
29662                return System.Text.RegularExpressions.RegexParser.escape(str);
29663            },
29664
29665            unescape: function (str) {
29666                if (str == null) {
29667                    throw new System.ArgumentNullException.$ctor1("str");
29668                }
29669
29670                return System.Text.RegularExpressions.RegexParser.unescape(str);
29671            },
29672
29673            isMatch: function (input, pattern, options, matchTimeout) {
29674                var scope = System.Text.RegularExpressions;
29675
29676                if (!H5.isDefined(options)) {
29677                    options = scope.RegexOptions.None;
29678                }
29679
29680                if (!H5.isDefined(matchTimeout)) {
29681                    matchTimeout = scope.Regex._defaultMatchTimeout;
29682                }
29683
29684                var regex = new System.Text.RegularExpressions.Regex.ctor(pattern, options, matchTimeout, true);
29685
29686                return regex.isMatch(input);
29687            },
29688
29689            match: function (input, pattern, options, matchTimeout) {
29690                var scope = System.Text.RegularExpressions;
29691
29692                if (!H5.isDefined(options)) {
29693                    options = scope.RegexOptions.None;
29694                }
29695
29696                if (!H5.isDefined(matchTimeout)) {
29697                    matchTimeout = scope.Regex._defaultMatchTimeout;
29698                }
29699
29700                var regex = new System.Text.RegularExpressions.Regex.ctor(pattern, options, matchTimeout, true);
29701
29702                return regex.match(input);
29703            },
29704
29705            matches: function (input, pattern, options, matchTimeout) {
29706                var scope = System.Text.RegularExpressions;
29707
29708                if (!H5.isDefined(options)) {
29709                    options = scope.RegexOptions.None;
29710                }
29711
29712                if (!H5.isDefined(matchTimeout)) {
29713                    matchTimeout = scope.Regex._defaultMatchTimeout;
29714                }
29715
29716                var regex = new System.Text.RegularExpressions.Regex.ctor(pattern, options, matchTimeout, true);
29717
29718                return regex.matches(input);
29719            },
29720
29721            replace: function (input, pattern, replacement, options, matchTimeout) {
29722                var scope = System.Text.RegularExpressions;
29723
29724                if (!H5.isDefined(options)) {
29725                    options = scope.RegexOptions.None;
29726                }
29727
29728                if (!H5.isDefined(matchTimeout)) {
29729                    matchTimeout = scope.Regex._defaultMatchTimeout;
29730                }
29731
29732                var regex = new System.Text.RegularExpressions.Regex.ctor(pattern, options, matchTimeout, true);
29733
29734                return regex.replace(input, replacement);
29735            },
29736
29737            split: function (input, pattern, options, matchTimeout) {
29738                var scope = System.Text.RegularExpressions;
29739
29740                if (!H5.isDefined(options)) {
29741                    options = scope.RegexOptions.None;
29742                }
29743
29744                if (!H5.isDefined(matchTimeout)) {
29745                    matchTimeout = scope.Regex._defaultMatchTimeout;
29746                }
29747
29748                var regex = new System.Text.RegularExpressions.Regex.ctor(pattern, options, matchTimeout, true);
29749
29750                return regex.split(input);
29751            }
29752        },
29753
29754        _pattern: "",
29755        _matchTimeout: System.TimeSpan.fromMilliseconds(-1),
29756        _runner: null,
29757        _caps: null,
29758        _capsize: 0,
29759        _capnames: null,
29760        _capslist: null,
29761
29762        config: {
29763            init: function () {
29764                this._options = System.Text.RegularExpressions.RegexOptions.None;
29765            }
29766        },
29767
29768        ctor: function (pattern, options, matchTimeout, useCache) {
29769            this.$initialize();
29770
29771            if (!H5.isDefined(options)) {
29772                options = System.Text.RegularExpressions.RegexOptions.None;
29773            }
29774
29775            if (!H5.isDefined(matchTimeout)) {
29776                matchTimeout = System.TimeSpan.fromMilliseconds(-1);
29777            }
29778
29779            if (!H5.isDefined(useCache)) {
29780                useCache = false;
29781            }
29782
29783            var scope = System.Text.RegularExpressions;
29784
29785            if (pattern == null) {
29786                throw new System.ArgumentNullException.$ctor1("pattern");
29787            }
29788
29789            if (options < scope.RegexOptions.None || ((options >> 10) !== 0)) {
29790                throw new System.ArgumentOutOfRangeException.$ctor1("options");
29791            }
29792
29793            if (((options & scope.RegexOptions.ECMAScript) !== 0) &&
29794                ((options & ~(scope.RegexOptions.ECMAScript |
29795                    scope.RegexOptions.IgnoreCase |
29796                    scope.RegexOptions.Multiline |
29797                    scope.RegexOptions.CultureInvariant
29798                )) !== 0)) {
29799                throw new System.ArgumentOutOfRangeException.$ctor1("options");
29800            }
29801
29802            // Check if the specified options are supported.
29803            var supportedOptions =
29804                System.Text.RegularExpressions.RegexOptions.IgnoreCase |
29805                System.Text.RegularExpressions.RegexOptions.Multiline |
29806                System.Text.RegularExpressions.RegexOptions.Singleline |
29807                System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace |
29808                System.Text.RegularExpressions.RegexOptions.ExplicitCapture;
29809
29810            if ((options | supportedOptions) !== supportedOptions) {
29811                throw new System.NotSupportedException.$ctor1("Specified Regex options are not supported.");
29812            }
29813
29814            this._validateMatchTimeout(matchTimeout);
29815
29816            this._pattern = pattern;
29817            this._options = options;
29818            this._matchTimeout = matchTimeout;
29819            this._runner = new scope.RegexRunner(this);
29820
29821            //TODO: cache
29822            var patternInfo = this._runner.parsePattern();
29823
29824            this._capnames = patternInfo.sparseSettings.sparseSlotNameMap;
29825            this._capslist = patternInfo.sparseSettings.sparseSlotNameMap.keys;
29826            this._capsize = this._capslist.length;
29827        },
29828
29829        getMatchTimeout: function () {
29830            return this._matchTimeout;
29831        },
29832
29833        getOptions: function () {
29834            return this._options;
29835        },
29836
29837        getRightToLeft: function () {
29838            return (this._options & System.Text.RegularExpressions.RegexOptions.RightToLeft) !== 0;
29839        },
29840
29841        isMatch: function (input, startat) {
29842            if (input == null) {
29843                throw new System.ArgumentNullException.$ctor1("input");
29844            }
29845
29846            if (!H5.isDefined(startat)) {
29847                startat = this.getRightToLeft() ? input.length : 0;
29848            }
29849
29850            var match = this._runner.run(true, -1, input, 0, input.length, startat);
29851
29852            return match == null;
29853        },
29854
29855        match: function (input, startat, arg3) {
29856            if (input == null) {
29857                throw new System.ArgumentNullException.$ctor1("input");
29858            }
29859
29860            var length = input.length,
29861                beginning = 0;
29862
29863            if (arguments.length === 3) {
29864                beginning = startat;
29865                length = arg3;
29866                startat = this.getRightToLeft() ? beginning + length : beginning;
29867            } else if (!H5.isDefined(startat)) {
29868                startat = this.getRightToLeft() ? length : 0;
29869            }
29870
29871            return this._runner.run(false, -1, input, beginning, length, startat);
29872        },
29873
29874        matches: function (input, startat) {
29875            if (input == null) {
29876                throw new System.ArgumentNullException.$ctor1("input");
29877            }
29878
29879            if (!H5.isDefined(startat)) {
29880                startat = this.getRightToLeft() ? input.length : 0;
29881            }
29882
29883            return new System.Text.RegularExpressions.MatchCollection(this, input, 0, input.length, startat);
29884        },
29885
29886        getGroupNames: function () {
29887            if (this._capslist == null) {
29888                var invariantCulture = System.Globalization.CultureInfo.invariantCulture;
29889
29890                var result = [];
29891                var max = this._capsize;
29892                var i;
29893
29894                for (i = 0; i < max; i++) {
29895                    result[i] = System.Convert.toString(i, invariantCulture, System.Convert.typeCodes.Int32);
29896                }
29897
29898                return result;
29899            } else {
29900                return this._capslist.slice();
29901            }
29902        },
29903
29904        getGroupNumbers: function () {
29905            var caps = this._caps;
29906            var result;
29907            var key;
29908            var max;
29909            var i;
29910
29911            if (caps == null) {
29912                result = [];
29913                max = this._capsize;
29914                for (i = 0; i < max; i++) {
29915                    result.push(i);
29916                }
29917            } else {
29918                result = [];
29919
29920                for (key in caps) {
29921                    if (caps.hasOwnProperty(key)) {
29922                        result[caps[key]] = key;
29923                    }
29924                }
29925            }
29926
29927            return result;
29928        },
29929
29930        groupNameFromNumber: function (i) {
29931            if (this._capslist == null) {
29932                if (i >= 0 && i < this._capsize) {
29933                    var invariantCulture = System.Globalization.CultureInfo.invariantCulture;
29934
29935                    return System.Convert.toString(i, invariantCulture, System.Convert.typeCodes.Int32);
29936                }
29937
29938                return "";
29939            } else {
29940                if (this._caps != null) {
29941                    var obj = this._caps[i];
29942
29943                    if (obj == null) {
29944                        return "";
29945                    }
29946
29947                    return parseInt(obj);
29948                }
29949
29950                if (i >= 0 && i < this._capslist.length) {
29951                    return this._capslist[i];
29952                }
29953
29954                return "";
29955            }
29956        },
29957
29958        groupNumberFromName: function (name) {
29959            if (name == null) {
29960                throw new System.ArgumentNullException.$ctor1("name");
29961            }
29962
29963            // look up name if we have a hashtable of names
29964            if (this._capnames != null) {
29965                var ret = this._capnames[name];
29966
29967                if (ret == null) {
29968                    return -1;
29969                }
29970
29971                return parseInt(ret);
29972            }
29973
29974            // convert to an int if it looks like a number
29975            var result = 0;
29976            var ch;
29977            var i;
29978
29979            for (i = 0; i < name.Length; i++) {
29980                ch = name[i];
29981
29982                if (ch > "9" || ch < "0") {
29983                    return -1;
29984                }
29985
29986                result *= 10;
29987                result += (ch - "0");
29988            }
29989
29990            // return int if it's in range
29991            if (result >= 0 && result < this._capsize) {
29992                return result;
29993            }
29994
29995            return -1;
29996        },
29997
29998        replace: function (input, evaluator, count, startat) {
29999            if (input == null) {
30000                throw new System.ArgumentNullException.$ctor1("input");
30001            }
30002
30003            if (!H5.isDefined(count)) {
30004                count = -1;
30005            }
30006
30007            if (!H5.isDefined(startat)) {
30008                startat = this.getRightToLeft() ? input.length : 0;
30009            }
30010
30011            if (evaluator == null) {
30012                throw new System.ArgumentNullException.$ctor1("evaluator");
30013            }
30014
30015            if (H5.isFunction(evaluator)) {
30016                return System.Text.RegularExpressions.RegexReplacement.replace(evaluator, this, input, count, startat);
30017            }
30018
30019            var repl = System.Text.RegularExpressions.RegexParser.parseReplacement(evaluator, this._caps, this._capsize, this._capnames, this._options);
30020            //TODO: Cache
30021
30022            return repl.replace(this, input, count, startat);
30023        },
30024
30025        split: function (input, count, startat) {
30026            if (input == null) {
30027                throw new System.ArgumentNullException.$ctor1("input");
30028            }
30029
30030            if (!H5.isDefined(count)) {
30031                count = 0;
30032            }
30033
30034            if (!H5.isDefined(startat)) {
30035                startat = this.getRightToLeft() ? input.length : 0;
30036            }
30037
30038            return System.Text.RegularExpressions.RegexReplacement.split(this, input, count, startat);
30039        },
30040
30041        _validateMatchTimeout: function (matchTimeout) {
30042            var ms = matchTimeout.getTotalMilliseconds();
30043
30044            if (-1 === ms) {
30045                return;
30046            }
30047
30048            if (ms > 0 && ms <= 2147483646) {
30049                return;
30050            }
30051
30052            throw new System.ArgumentOutOfRangeException.$ctor1("matchTimeout");
30053        }
30054    });
30055
30056    // @source RegexCapture.js
30057
30058    H5.define("System.Text.RegularExpressions.Capture", {
30059        _text: "",
30060        _index: 0,
30061        _length: 0,
30062
30063        ctor: function (text, i, l) {
30064            this.$initialize();
30065            this._text = text;
30066            this._index = i;
30067            this._length = l;
30068        },
30069
30070        getIndex: function () {
30071            return this._index;
30072        },
30073
30074        getLength: function () {
30075            return this._length;
30076        },
30077
30078        getValue: function () {
30079            return this._text.substr(this._index, this._length);
30080        },
30081
30082        toString: function () {
30083            return this.getValue();
30084        },
30085
30086        _getOriginalString: function () {
30087            return this._text;
30088        },
30089
30090        _getLeftSubstring: function () {
30091            return this._text.slice(0, _index);
30092        },
30093
30094        _getRightSubstring: function () {
30095            return this._text.slice(this._index + this._length, this._text.length);
30096        }
30097    });
30098
30099    // @source RegexCaptureCollection.js
30100
30101    H5.define("System.Text.RegularExpressions.CaptureCollection", {
30102        inherits: function () {
30103            return [System.Collections.ICollection];
30104        },
30105
30106        config: {
30107            properties: {
30108                Count: {
30109                    get: function () {
30110                        return this._capcount;
30111                    }
30112                }
30113            },
30114
30115            alias: [
30116            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
30117            "getCount", "System$Collections$ICollection$getCount",
30118            "Count", "System$Collections$ICollection$Count",
30119            "copyTo", "System$Collections$ICollection$copyTo"
30120            ]
30121        },
30122
30123        _group: null,
30124        _capcount: 0,
30125        _captures: null,
30126
30127        ctor: function (group) {
30128            this.$initialize();
30129            this._group = group;
30130            this._capcount = group._capcount;
30131        },
30132
30133        getSyncRoot: function () {
30134            return this._group;
30135        },
30136
30137        getIsSynchronized: function () {
30138            return false;
30139        },
30140
30141        getIsReadOnly: function () {
30142            return true;
30143        },
30144
30145        getCount: function () {
30146            return this._capcount;
30147        },
30148
30149        get: function (i) {
30150            if (i === this._capcount - 1 && i >= 0) {
30151                return this._group;
30152            }
30153
30154            if (i >= this._capcount || i < 0) {
30155                throw new System.ArgumentOutOfRangeException.$ctor1("i");
30156            }
30157
30158            this._ensureCapturesInited();
30159
30160            return this._captures[i];
30161        },
30162
30163        copyTo: function (array, arrayIndex) {
30164            if (array == null) {
30165                throw new System.ArgumentNullException.$ctor1("array");
30166            }
30167
30168            if (array.length < arrayIndex + this._capcount) {
30169                throw new System.IndexOutOfRangeException();
30170            }
30171
30172            var capture;
30173            var i;
30174            var j;
30175
30176            for (i = arrayIndex, j = 0; j < this._capcount; i++, j++) {
30177                capture = this.get(j);
30178                System.Array.set(array, capture, [i]);
30179            }
30180        },
30181
30182        GetEnumerator: function () {
30183            return new System.Text.RegularExpressions.CaptureEnumerator(this);
30184        },
30185
30186        _ensureCapturesInited: function () {
30187            // first time a capture is accessed, compute them all
30188            if (this._captures == null) {
30189                var captures = [];
30190                var j;
30191
30192                captures.length = this._capcount;
30193
30194                for (j = 0; j < this._capcount - 1; j++) {
30195                    var index = this._group._caps[j * 2];
30196                    var length = this._group._caps[j * 2 + 1];
30197
30198                    captures[j] = new System.Text.RegularExpressions.Capture(this._group._text, index, length);
30199                }
30200
30201                if (this._capcount > 0) {
30202                    captures[this._capcount - 1] = this._group;
30203                }
30204
30205                this._captures = captures;
30206            }
30207        }
30208    });
30209
30210    H5.define("System.Text.RegularExpressions.CaptureEnumerator", {
30211        inherits: function () {
30212            return [System.Collections.IEnumerator];
30213        },
30214
30215        config: {
30216            properties: {
30217                Current: {
30218                    get: function () {
30219                        return this.getCurrent();
30220                    }
30221                }
30222            },
30223            alias: [
30224                "getCurrent", "System$Collections$IEnumerator$getCurrent",
30225                "moveNext", "System$Collections$IEnumerator$moveNext",
30226                "reset", "System$Collections$IEnumerator$reset",
30227                "Current", "System$Collections$IEnumerator$Current"
30228            ]
30229        },
30230
30231        _captureColl: null,
30232        _curindex: 0,
30233
30234        ctor: function (captureColl) {
30235            this.$initialize();
30236            this._curindex = -1;
30237            this._captureColl = captureColl;
30238        },
30239
30240        moveNext: function () {
30241            var size = this._captureColl.getCount();
30242
30243            if (this._curindex >= size) {
30244                return false;
30245            }
30246
30247            this._curindex++;
30248            return (this._curindex < size);
30249        },
30250
30251        getCurrent: function () {
30252            return this.getCapture();
30253        },
30254
30255        getCapture: function () {
30256            if (this._curindex < 0 || this._curindex >= this._captureColl.getCount()) {
30257                throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
30258            }
30259
30260            return this._captureColl.get(this._curindex);
30261        },
30262
30263        reset: function () {
30264            this._curindex = -1;
30265        }
30266    });
30267
30268    // @source RegexGroup.js
30269
30270    H5.define("System.Text.RegularExpressions.Group", {
30271        inherits: function () {
30272            return [System.Text.RegularExpressions.Capture];
30273        },
30274
30275        statics: {
30276            config: {
30277                init: function () {
30278                    var empty = new System.Text.RegularExpressions.Group("", [], 0);
30279
30280                    this.getEmpty = function () {
30281                        return empty;
30282                    }
30283                }
30284            },
30285
30286            synchronized: function (group) {
30287                if (group == null) {
30288                    throw new System.ArgumentNullException.$ctor1("group");
30289                }
30290
30291                // force Captures to be computed.
30292                var captures = group.getCaptures();
30293
30294                if (captures.getCount() > 0) {
30295                    captures.get(0);
30296                }
30297
30298                return group;
30299            }
30300        },
30301
30302        _caps: null,
30303        _capcount: 0,
30304        _capColl: null,
30305
30306        ctor: function (text, caps, capcount) {
30307            this.$initialize();
30308            var scope = System.Text.RegularExpressions;
30309            var index = capcount === 0 ? 0 : caps[(capcount - 1) * 2];
30310            var length = capcount === 0 ? 0 : caps[(capcount * 2) - 1];
30311
30312            scope.Capture.ctor.call(this, text, index, length);
30313
30314            this._caps = caps;
30315            this._capcount = capcount;
30316        },
30317
30318        getSuccess: function () {
30319            return this._capcount !== 0;
30320        },
30321
30322        getCaptures: function () {
30323            if (this._capColl == null) {
30324                this._capColl = new System.Text.RegularExpressions.CaptureCollection(this);
30325            }
30326
30327            return this._capColl;
30328        }
30329    });
30330
30331    // @source RegexGroupCollection.js
30332
30333    H5.define("System.Text.RegularExpressions.GroupCollection", {
30334        inherits: function () {
30335            return [System.Collections.ICollection];
30336        },
30337
30338        config: {
30339            properties: {
30340                Count: {
30341                    get: function () {
30342                        return this._match._matchcount.length;
30343                    }
30344                }
30345            },
30346            alias: [
30347            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
30348            "getCount", "System$Collections$ICollection$getCount",
30349            "Count", "System$Collections$ICollection$Count",
30350            "copyTo", "System$Collections$ICollection$copyTo"
30351            ]
30352        },
30353
30354        _match: null,
30355        _captureMap: null,
30356        _groups: null,
30357
30358        ctor: function (match, caps) {
30359            this.$initialize();
30360            this._match = match;
30361            this._captureMap = caps;
30362        },
30363
30364        getSyncRoot: function () {
30365            return this._match;
30366        },
30367
30368        getIsSynchronized: function () {
30369            return false;
30370        },
30371
30372        getIsReadOnly: function () {
30373            return true;
30374        },
30375
30376        getCount: function () {
30377            return this._match._matchcount.length;
30378        },
30379
30380        get: function (groupnum) {
30381            return this._getGroup(groupnum);
30382        },
30383
30384        getByName: function (groupname) {
30385            if (this._match._regex == null) {
30386                return System.Text.RegularExpressions.Group.getEmpty();
30387            }
30388
30389            var groupnum = this._match._regex.groupNumberFromName(groupname);
30390
30391            return this._getGroup(groupnum);
30392        },
30393
30394        copyTo: function (array, arrayIndex) {
30395            if (array == null) {
30396                throw new System.ArgumentNullException.$ctor1("array");
30397            }
30398
30399            var count = this.getCount();
30400
30401            if (array.length < arrayIndex + count) {
30402                throw new System.IndexOutOfRangeException();
30403            }
30404
30405            var group;
30406            var i;
30407            var j;
30408
30409            for (i = arrayIndex, j = 0; j < count; i++, j++) {
30410                group = this._getGroup(j);
30411                System.Array.set(array, group, [i]);
30412            }
30413        },
30414
30415        GetEnumerator: function () {
30416            return new System.Text.RegularExpressions.GroupEnumerator(this);
30417        },
30418
30419        _getGroup: function (groupnum) {
30420            var group;
30421
30422            if (this._captureMap != null) {
30423                var num = this._captureMap[groupnum];
30424
30425                if (num == null) {
30426                    group = System.Text.RegularExpressions.Group.getEmpty();
30427                } else {
30428                    group = this._getGroupImpl(num);
30429                }
30430            } else {
30431                if (groupnum >= this._match._matchcount.length || groupnum < 0) {
30432                    group = System.Text.RegularExpressions.Group.getEmpty();
30433                } else {
30434                    group = this._getGroupImpl(groupnum);
30435                }
30436            }
30437
30438            return group;
30439        },
30440
30441        _getGroupImpl: function (groupnum) {
30442            if (groupnum === 0) {
30443                return this._match;
30444            }
30445
30446            this._ensureGroupsInited();
30447
30448            return this._groups[groupnum];
30449        },
30450
30451        _ensureGroupsInited: function () {
30452            // Construct all the Group objects the first time GetGroup is called
30453            if (this._groups == null) {
30454                var groups = [];
30455
30456                groups.length = this._match._matchcount.length;
30457
30458                if (groups.length > 0) {
30459                    groups[0] = this._match;
30460                }
30461
30462                var matchText;
30463                var matchCaps;
30464                var matchCapcount;
30465                var i;
30466
30467                for (i = 0; i < groups.length - 1; i++) {
30468                    matchText = this._match._text;
30469                    matchCaps = this._match._matches[i + 1];
30470                    matchCapcount = this._match._matchcount[i + 1];
30471                    groups[i + 1] = new System.Text.RegularExpressions.Group(matchText, matchCaps, matchCapcount);
30472                }
30473
30474                this._groups = groups;
30475            }
30476        }
30477    });
30478
30479    H5.define("System.Text.RegularExpressions.GroupEnumerator", {
30480        inherits: function () {
30481            return [System.Collections.IEnumerator];
30482        },
30483
30484        config: {
30485            properties: {
30486                Current: {
30487                    get: function () {
30488                        return this.getCurrent();
30489                    }
30490                }
30491            },
30492
30493            alias: [
30494                "getCurrent", "System$Collections$IEnumerator$getCurrent",
30495                "moveNext", "System$Collections$IEnumerator$moveNext",
30496                "reset", "System$Collections$IEnumerator$reset",
30497                "Current", "System$Collections$IEnumerator$Current"
30498            ]
30499        },
30500
30501        _groupColl: null,
30502        _curindex: 0,
30503
30504        ctor: function (groupColl) {
30505            this.$initialize();
30506            this._curindex = -1;
30507            this._groupColl = groupColl;
30508        },
30509
30510        moveNext: function () {
30511            var size = this._groupColl.getCount();
30512
30513            if (this._curindex >= size) {
30514                return false;
30515            }
30516
30517            this._curindex++;
30518
30519            return (this._curindex < size);
30520        },
30521
30522        getCurrent: function () {
30523            return this.getCapture();
30524        },
30525
30526        getCapture: function () {
30527            if (this._curindex < 0 || this._curindex >= this._groupColl.getCount()) {
30528                throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
30529            }
30530
30531            return this._groupColl.get(this._curindex);
30532        },
30533
30534        reset: function () {
30535            this._curindex = -1;
30536        }
30537    });
30538
30539    // @source RegexMatch.js
30540
30541    H5.define("System.Text.RegularExpressions.Match", {
30542        inherits: function () {
30543            return [System.Text.RegularExpressions.Group];
30544        },
30545
30546        statics: {
30547            config: {
30548                init: function () {
30549                    var empty = new System.Text.RegularExpressions.Match(null, 1, "", 0, 0, 0);
30550
30551                    this.getEmpty = function () {
30552                        return empty;
30553                    }
30554                }
30555            },
30556
30557            synchronized: function (match) {
30558                if (match == null) {
30559                    throw new System.ArgumentNullException.$ctor1("match");
30560                }
30561
30562                // Populate all groups by looking at each one
30563                var groups = match.getGroups();
30564                var groupsCount = groups.getCount();
30565                var group;
30566                var i;
30567
30568                for (i = 0; i < groupsCount; i++) {
30569                    group = groups.get(i);
30570                    System.Text.RegularExpressions.Group.synchronized(group);
30571                }
30572
30573                return match;
30574            }
30575        },
30576
30577        _regex: null,
30578        _matchcount: null,
30579        _matches: null,
30580        _textbeg: 0,
30581        _textend: 0,
30582        _textstart: 0,
30583        _groupColl: null,
30584        _textpos: 0,
30585
30586        ctor: function (regex, capcount, text, begpos, len, startpos) {
30587            this.$initialize();
30588            var scope = System.Text.RegularExpressions;
30589            var caps = [0, 0];
30590
30591            scope.Group.ctor.call(this, text, caps, 0);
30592
30593            this._regex = regex;
30594
30595            this._matchcount = [];
30596            this._matchcount.length = capcount;
30597
30598            var i;
30599
30600            for (i = 0; i < capcount; i++) {
30601                this._matchcount[i] = 0;
30602            }
30603
30604            this._matches = [];
30605            this._matches.length = capcount;
30606            this._matches[0] = caps;
30607
30608            this._textbeg = begpos;
30609            this._textend = begpos + len;
30610            this._textstart = startpos;
30611        },
30612
30613        getGroups: function () {
30614            if (this._groupColl == null) {
30615                this._groupColl = new System.Text.RegularExpressions.GroupCollection(this, null);
30616            }
30617
30618            return this._groupColl;
30619        },
30620
30621        nextMatch: function () {
30622            if (this._regex == null) {
30623                return this;
30624            }
30625
30626            return this._regex._runner.run(false, this._length, this._text, this._textbeg, this._textend - this._textbeg, this._textpos);
30627        },
30628
30629        result: function (replacement) {
30630            if (replacement == null) {
30631                throw new System.ArgumentNullException.$ctor1("replacement");
30632            }
30633
30634            if (this._regex == null) {
30635                throw new System.NotSupportedException.$ctor1("Result cannot be called on a failed Match.");
30636            }
30637
30638            var repl = System.Text.RegularExpressions.RegexParser.parseReplacement(replacement, this._regex._caps, this._regex._capsize, this._regex._capnames, this._regex._options);
30639            //TODO: cache
30640
30641            return repl.replacement(this);
30642        },
30643
30644        _isMatched: function (cap) {
30645            return cap < this._matchcount.length && this._matchcount[cap] > 0 && this._matches[cap][this._matchcount[cap] * 2 - 1] !== (-3 + 1);
30646        },
30647
30648        _addMatch: function (cap, start, len) {
30649            if (this._matches[cap] == null) {
30650                this._matches[cap] = new Array(2);
30651            }
30652
30653            var capcount = this._matchcount[cap];
30654
30655            if (capcount * 2 + 2 > this._matches[cap].length) {
30656                var oldmatches = this._matches[cap];
30657                var newmatches = new Array(capcount * 8);
30658                var j;
30659
30660                for (j = 0; j < capcount * 2; j++) {
30661                    newmatches[j] = oldmatches[j];
30662                }
30663
30664                this._matches[cap] = newmatches;
30665            }
30666
30667            this._matches[cap][capcount * 2] = start;
30668            this._matches[cap][capcount * 2 + 1] = len;
30669            this._matchcount[cap] = capcount + 1;
30670        },
30671
30672        _tidy: function (textpos) {
30673            var interval = this._matches[0];
30674            this._index = interval[0];
30675            this._length = interval[1];
30676            this._textpos = textpos;
30677            this._capcount = this._matchcount[0];
30678        },
30679
30680        _groupToStringImpl: function (groupnum) {
30681            var c = this._matchcount[groupnum];
30682
30683            if (c === 0) {
30684                return "";
30685            }
30686
30687            var matches = this._matches[groupnum];
30688            var capIndex = matches[(c - 1) * 2];
30689            var capLength = matches[(c * 2) - 1];
30690
30691            return this._text.slice(capIndex, capIndex + capLength);
30692        },
30693
30694        _lastGroupToStringImpl: function () {
30695            return this._groupToStringImpl(this._matchcount.length - 1);
30696        }
30697    });
30698
30699    H5.define("System.Text.RegularExpressions.MatchSparse", {
30700        inherits: function () {
30701            return [System.Text.RegularExpressions.Match];
30702        },
30703
30704        _caps: null,
30705
30706        ctor: function (regex, caps, capcount, text, begpos, len, startpos) {
30707            this.$initialize();
30708            var scope = System.Text.RegularExpressions;
30709            scope.Match.ctor.call(this, regex, capcount, text, begpos, len, startpos);
30710
30711            this._caps = caps;
30712        },
30713
30714        getGroups: function () {
30715            if (this._groupColl == null) {
30716                this._groupColl = new System.Text.RegularExpressions.GroupCollection(this, this._caps);
30717            }
30718
30719            return this._groupColl;
30720        },
30721    });
30722
30723    // @source RegexMatchCollection.js
30724
30725    H5.define("System.Text.RegularExpressions.MatchCollection", {
30726        inherits: function () {
30727            return [System.Collections.ICollection];
30728        },
30729
30730        config: {
30731            properties: {
30732                Count: {
30733                    get: function () {
30734                        return this.getCount();
30735                    }
30736                }
30737            },
30738            alias: [
30739            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator",
30740            "getCount", "System$Collections$ICollection$getCount",
30741            "Count", "System$Collections$ICollection$Count",
30742            "copyTo", "System$Collections$ICollection$copyTo"
30743            ]
30744        },
30745
30746        _regex: null,
30747        _input: null,
30748        _beginning: 0,
30749        _length: 0,
30750        _startat: 0,
30751        _prevlen: 0,
30752        _matches: null,
30753        _done: false,
30754
30755        ctor: function (regex, input, beginning, length, startat) {
30756            this.$initialize();
30757            if (startat < 0 || startat > input.Length) {
30758                throw new System.ArgumentOutOfRangeException.$ctor1("startat");
30759            }
30760
30761            this._regex = regex;
30762            this._input = input;
30763            this._beginning = beginning;
30764            this._length = length;
30765            this._startat = startat;
30766            this._prevlen = -1;
30767            this._matches = [];
30768        },
30769
30770        getCount: function () {
30771            if (!this._done) {
30772                this._getMatch(0x7FFFFFFF);
30773            }
30774
30775            return this._matches.length;
30776        },
30777
30778        getSyncRoot: function () {
30779            return this;
30780        },
30781
30782        getIsSynchronized: function () {
30783            return false;
30784        },
30785
30786        getIsReadOnly: function () {
30787            return true;
30788        },
30789
30790        get: function (i) {
30791            var match = this._getMatch(i);
30792
30793            if (match == null) {
30794                throw new System.ArgumentOutOfRangeException.$ctor1("i");
30795            }
30796
30797            return match;
30798        },
30799
30800        copyTo: function (array, arrayIndex) {
30801            if (array == null) {
30802                throw new System.ArgumentNullException.$ctor1("array");
30803            }
30804
30805            var count = this.getCount();
30806
30807            if (array.length < arrayIndex + count) {
30808                throw new System.IndexOutOfRangeException();
30809            }
30810
30811            var match;
30812            var i;
30813            var j;
30814
30815            for (i = arrayIndex, j = 0; j < count; i++, j++) {
30816                match = this._getMatch(j);
30817                System.Array.set(array, match, [i]);
30818            }
30819        },
30820
30821        GetEnumerator: function () {
30822            return new System.Text.RegularExpressions.MatchEnumerator(this);
30823        },
30824
30825        _getMatch: function (i) {
30826            if (i < 0) {
30827                return null;
30828            }
30829
30830            if (this._matches.length > i) {
30831                return this._matches[i];
30832            }
30833
30834            if (this._done) {
30835                return null;
30836            }
30837
30838            var match;
30839
30840            do {
30841                match = this._regex._runner.run(false, this._prevLen, this._input, this._beginning, this._length, this._startat);
30842                if (!match.getSuccess()) {
30843                    this._done = true;
30844                    return null;
30845                }
30846
30847                this._matches.push(match);
30848
30849                this._prevLen = match._length;
30850                this._startat = match._textpos;
30851            } while (this._matches.length <= i);
30852
30853            return match;
30854        }
30855    });
30856
30857    H5.define("System.Text.RegularExpressions.MatchEnumerator", {
30858        inherits: function () {
30859            return [System.Collections.IEnumerator];
30860        },
30861
30862        config: {
30863            properties: {
30864                Current: {
30865                    get: function () {
30866                        return this.getCurrent();
30867                    }
30868                }
30869            },
30870
30871            alias: [
30872                "getCurrent", "System$Collections$IEnumerator$getCurrent",
30873                "moveNext", "System$Collections$IEnumerator$moveNext",
30874                "reset", "System$Collections$IEnumerator$reset",
30875                "Current", "System$Collections$IEnumerator$Current"
30876            ]
30877        },
30878
30879        _matchcoll: null,
30880        _match: null,
30881        _curindex: 0,
30882        _done: false,
30883
30884        ctor: function (matchColl) {
30885            this.$initialize();
30886            this._matchcoll = matchColl;
30887        },
30888
30889        moveNext: function () {
30890            if (this._done) {
30891                return false;
30892            }
30893
30894            this._match = this._matchcoll._getMatch(this._curindex);
30895            this._curindex++;
30896
30897            if (this._match == null) {
30898                this._done = true;
30899
30900                return false;
30901            }
30902
30903            return true;
30904        },
30905
30906        getCurrent: function () {
30907            if (this._match == null) {
30908                throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
30909            }
30910
30911            return this._match;
30912        },
30913
30914        reset: function () {
30915            this._curindex = 0;
30916            this._done = false;
30917            this._match = null;
30918        }
30919    });
30920
30921    // @source RegexOptions.js
30922
30923    H5.define("System.Text.RegularExpressions.RegexOptions", {
30924        statics: {
30925            None: 0x0000,
30926            IgnoreCase: 0x0001,
30927            Multiline: 0x0002,
30928            ExplicitCapture: 0x0004,
30929            Compiled: 0x0008,
30930            Singleline: 0x0010,
30931            IgnorePatternWhitespace: 0x0020,
30932            RightToLeft: 0x0040,
30933            ECMAScript: 0x0100,
30934            CultureInvariant: 0x0200
30935        },
30936
30937        $kind: "enum",
30938        $flags: true
30939    });
30940
30941    // @source RegexRunner.js
30942
30943    H5.define("System.Text.RegularExpressions.RegexRunner", {
30944        statics: {},
30945
30946        _runregex: null,
30947        _netEngine: null,
30948
30949        _runtext: "", // text to search
30950        _runtextpos: 0, // current position in text
30951
30952        _runtextbeg: 0, // beginning of text to search
30953        _runtextend: 0, // end of text to search
30954        _runtextstart: 0, // starting point for search
30955        _quick: false, // true value means IsMatch method call
30956        _prevlen: 0,
30957
30958        ctor: function (regex) {
30959            this.$initialize();
30960
30961            if (regex == null) {
30962                throw new System.ArgumentNullException.$ctor1("regex");
30963            }
30964
30965            this._runregex = regex;
30966
30967            var options = regex.getOptions();
30968            var optionsEnum = System.Text.RegularExpressions.RegexOptions;
30969
30970            var isCaseInsensitive = (options & optionsEnum.IgnoreCase) === optionsEnum.IgnoreCase;
30971            var isMultiline = (options & optionsEnum.Multiline) === optionsEnum.Multiline;
30972            var isSingleline = (options & optionsEnum.Singleline) === optionsEnum.Singleline;
30973            var isIgnoreWhitespace = (options & optionsEnum.IgnorePatternWhitespace) === optionsEnum.IgnorePatternWhitespace;
30974            var isExplicitCapture = (options & optionsEnum.ExplicitCapture) === optionsEnum.ExplicitCapture;
30975
30976            var timeoutMs = regex._matchTimeout.getTotalMilliseconds();
30977
30978            this._netEngine = new System.Text.RegularExpressions.RegexEngine(regex._pattern, isCaseInsensitive, isMultiline, isSingleline, isIgnoreWhitespace, isExplicitCapture, timeoutMs);
30979        },
30980
30981        run: function (quick, prevlen, input, beginning, length, startat) {
30982            if (startat < 0 || startat > input.Length) {
30983                throw new System.ArgumentOutOfRangeException.$ctor4("start", "Start index cannot be less than 0 or greater than input length.");
30984            }
30985
30986            if (length < 0 || length > input.Length) {
30987                throw new ArgumentOutOfRangeException("length", "Length cannot be less than 0 or exceed input length.");
30988            }
30989
30990            this._runtext = input;
30991            this._runtextbeg = beginning;
30992            this._runtextend = beginning + length;
30993            this._runtextstart = startat;
30994            this._quick = quick;
30995            this._prevlen = prevlen;
30996
30997            var stoppos;
30998            var bump;
30999
31000            if (this._runregex.getRightToLeft()) {
31001                stoppos = this._runtextbeg;
31002                bump = -1;
31003            } else {
31004                stoppos = this._runtextend;
31005                bump = 1;
31006            }
31007
31008            if (this._prevlen === 0) {
31009                if (this._runtextstart === stoppos) {
31010                    return System.Text.RegularExpressions.Match.getEmpty();
31011                }
31012
31013                this._runtextstart += bump;
31014            }
31015
31016            // Execute Regex:
31017            var jsMatch = this._netEngine.match(this._runtext, this._runtextstart);
31018
31019            // Convert the results:
31020            var result = this._convertNetEngineResults(jsMatch);
31021            return result;
31022        },
31023
31024        parsePattern: function () {
31025            var result = this._netEngine.parsePattern();
31026
31027            return result;
31028        },
31029
31030        _convertNetEngineResults: function (jsMatch) {
31031            if (jsMatch.success && this._quick) {
31032                return null; // in quick mode, a successful match returns null
31033            }
31034
31035            if (!jsMatch.success) {
31036                return System.Text.RegularExpressions.Match.getEmpty();
31037            }
31038
31039            var patternInfo = this.parsePattern();
31040            var match;
31041
31042            if (patternInfo.sparseSettings.isSparse) {
31043                match = new System.Text.RegularExpressions.MatchSparse(this._runregex, patternInfo.sparseSettings.sparseSlotMap, jsMatch.groups.length, this._runtext, 0, this._runtext.length, this._runtextstart);
31044            } else {
31045                match = new System.Text.RegularExpressions.Match(this._runregex, jsMatch.groups.length, this._runtext, 0, this._runtext.length, this._runtextstart);
31046            }
31047
31048            var jsGroup;
31049            var jsCapture;
31050            var grOrder;
31051            var i;
31052            var j;
31053
31054            for (i = 0; i < jsMatch.groups.length; i++) {
31055                jsGroup = jsMatch.groups[i];
31056
31057                // Paste group index/length according to group ordering:
31058                grOrder = 0;
31059
31060                if (jsGroup.descriptor != null) {
31061                    grOrder = this._runregex.groupNumberFromName(jsGroup.descriptor.name);
31062                }
31063
31064                for (j = 0; j < jsGroup.captures.length; j++) {
31065                    jsCapture = jsGroup.captures[j];
31066                    match._addMatch(grOrder, jsCapture.capIndex, jsCapture.capLength);
31067                }
31068            }
31069
31070            var textEndPos = jsMatch.capIndex + jsMatch.capLength;
31071
31072            match._tidy(textEndPos);
31073
31074            return match;
31075        }
31076    });
31077
31078    // @source RegexParser.js
31079
31080    H5.define("System.Text.RegularExpressions.RegexParser", {
31081        statics: {
31082            _Q: 5, // quantifier
31083            _S: 4, // ordinary stopper
31084            _Z: 3, // ScanBlank stopper
31085            _X: 2, // whitespace
31086            _E: 1, // should be escaped
31087
31088            _category: [
31089                //0 1 2  3  4  5  6  7  8  9  A  B  C  D  E  F  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
31090                0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31091                //! " #  $  %  &  '  (  )  *  +  ,  -  .  /  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
31092                2, 0, 0, 3, 4, 0, 0, 0, 4, 4, 5, 5, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
31093                //@ A B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
31094                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 4, 0,
31095                //' a b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~
31096                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 0, 0, 0
31097            ],
31098
31099            escape: function (input) {
31100                var sb;
31101                var ch;
31102                var lastpos;
31103                var i;
31104
31105                for (i = 0; i < input.length; i++) {
31106                    if (System.Text.RegularExpressions.RegexParser._isMetachar(input[i])) {
31107                        sb = "";
31108                        ch = input[i];
31109
31110                        sb += input.slice(0, i);
31111
31112                        do {
31113                            sb += "\\";
31114
31115                            switch (ch) {
31116                                case "\n":
31117                                    ch = "n";
31118                                    break;
31119                                case "\r":
31120                                    ch = "r";
31121                                    break;
31122                                case "\t":
31123                                    ch = "t";
31124                                    break;
31125                                case "\f":
31126                                    ch = "f";
31127                                    break;
31128                            }
31129
31130                            sb += ch;
31131                            i++;
31132                            lastpos = i;
31133
31134                            while (i < input.length) {
31135                                ch = input[i];
31136
31137                                if (System.Text.RegularExpressions.RegexParser._isMetachar(ch)) {
31138                                    break;
31139                                }
31140
31141                                i++;
31142                            }
31143
31144                            sb += input.slice(lastpos, i);
31145                        } while (i < input.length);
31146
31147                        return sb;
31148                    }
31149                }
31150
31151                return input;
31152            },
31153
31154            unescape: function (input) {
31155                var culture = System.Globalization.CultureInfo.invariantCulture;
31156                var sb;
31157                var lastpos;
31158                var i;
31159                var p;
31160
31161                for (i = 0; i < input.length; i++) {
31162                    if (input[i] === "\\") {
31163                        sb = "";
31164                        p = new System.Text.RegularExpressions.RegexParser(culture);
31165                        p._setPattern(input);
31166
31167                        sb += input.slice(0, i);
31168
31169                        do {
31170                            i++;
31171
31172                            p._textto(i);
31173
31174                            if (i < input.length) {
31175                                sb += p._scanCharEscape();
31176                            }
31177
31178                            i = p._textpos();
31179                            lastpos = i;
31180
31181                            while (i < input.length && input[i] !== "\\") {
31182                                i++;
31183                            }
31184
31185                            sb += input.slice(lastpos, i);
31186                        } while (i < input.length);
31187
31188                        return sb;
31189                    }
31190                }
31191
31192                return input;
31193            },
31194
31195            parseReplacement: function (rep, caps, capsize, capnames, op) {
31196                var culture = System.Globalization.CultureInfo.getCurrentCulture(); // TODO: InvariantCulture
31197                var p = new System.Text.RegularExpressions.RegexParser(culture);
31198
31199                p._options = op;
31200                p._noteCaptures(caps, capsize, capnames);
31201                p._setPattern(rep);
31202
31203                var root = p._scanReplacement();
31204
31205                return new System.Text.RegularExpressions.RegexReplacement(rep, root, caps);
31206            },
31207
31208            _isMetachar: function (ch) {
31209                var code = ch.charCodeAt(0);
31210
31211                return (code <= "|".charCodeAt(0) && System.Text.RegularExpressions.RegexParser._category[code] >= System.Text.RegularExpressions.RegexParser._E);
31212            }
31213        },
31214
31215        _caps: null,
31216        _capsize: 0,
31217        _capnames: null,
31218        _pattern: "",
31219        _currentPos: 0,
31220        _concatenation: null,
31221        _culture: null,
31222
31223        config: {
31224            init: function () {
31225                this._options = System.Text.RegularExpressions.RegexOptions.None;
31226            }
31227        },
31228
31229        ctor: function (culture) {
31230            this.$initialize();
31231            this._culture = culture;
31232            this._caps = {};
31233        },
31234
31235        _noteCaptures: function (caps, capsize, capnames) {
31236            this._caps = caps;
31237            this._capsize = capsize;
31238            this._capnames = capnames;
31239        },
31240
31241        _setPattern: function (pattern) {
31242            if (pattern == null) {
31243                pattern = "";
31244            }
31245
31246            this._pattern = pattern || "";
31247            this._currentPos = 0;
31248        },
31249
31250        _scanReplacement: function () {
31251            this._concatenation = new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Concatenate, this._options);
31252            var c;
31253            var startpos;
31254            var dollarNode;
31255
31256            while (true) {
31257                c = this._charsRight();
31258
31259                if (c === 0) {
31260                    break;
31261                }
31262
31263                startpos = this._textpos();
31264
31265                while (c > 0 && this._rightChar() !== "$") {
31266                    this._moveRight();
31267                    c--;
31268                }
31269
31270                this._addConcatenate(startpos, this._textpos() - startpos);
31271
31272                if (c > 0) {
31273                    if (this._moveRightGetChar() === "$") {
31274                        dollarNode = this._scanDollar();
31275                        this._concatenation.addChild(dollarNode);
31276                    }
31277                }
31278            }
31279
31280            return this._concatenation;
31281        },
31282
31283        _addConcatenate: function (pos, cch /*, bool isReplacement*/ ) {
31284            if (cch === 0) {
31285                return;
31286            }
31287
31288            var node;
31289
31290            if (cch > 1) {
31291                var str = this._pattern.slice(pos, pos + cch);
31292
31293                node = new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Multi, this._options, str);
31294            } else {
31295                var ch = this._pattern[pos];
31296
31297                node = new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.One, this._options, ch);
31298            }
31299
31300            this._concatenation.addChild(node);
31301        },
31302
31303        _useOptionE: function () {
31304            return (this._options & System.Text.RegularExpressions.RegexOptions.ECMAScript) !== 0;
31305        },
31306
31307        _makeException: function (message) {
31308            return new System.ArgumentException("Incorrect pattern. " + message);
31309        },
31310
31311        _scanDollar: function () {
31312            var maxValueDiv10 = 214748364; // Int32.MaxValue / 10;
31313            var maxValueMod10 = 7; // Int32.MaxValue % 10;
31314
31315            if (this._charsRight() === 0) {
31316                return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.One, this._options, "$");
31317            }
31318
31319            var ch = this._rightChar();
31320            var angled;
31321            var backpos = this._textpos();
31322            var lastEndPos = backpos;
31323
31324            // Note angle
31325            if (ch === "{" && this._charsRight() > 1) {
31326                angled = true;
31327                this._moveRight();
31328                ch = this._rightChar();
31329            } else {
31330                angled = false;
31331            }
31332
31333            // Try to parse backreference: \1 or \{1} or \{cap}
31334
31335            var capnum;
31336            var digit;
31337
31338            if (ch >= "0" && ch <= "9") {
31339                if (!angled && this._useOptionE()) {
31340                    capnum = -1;
31341                    var newcapnum = ch - "0";
31342
31343                    this._moveRight();
31344
31345                    if (this._isCaptureSlot(newcapnum)) {
31346                        capnum = newcapnum;
31347                        lastEndPos = this._textpos();
31348                    }
31349
31350                    while (this._charsRight() > 0 && (ch = this._rightChar()) >= "0" && ch <= "9") {
31351                        digit = ch - "0";
31352                        if (newcapnum > (maxValueDiv10) || (newcapnum === (maxValueDiv10) && digit > (maxValueMod10))) {
31353                            throw this._makeException("Capture group is out of range.");
31354                        }
31355
31356                        newcapnum = newcapnum * 10 + digit;
31357
31358                        this._moveRight();
31359
31360                        if (this._isCaptureSlot(newcapnum)) {
31361                            capnum = newcapnum;
31362                            lastEndPos = this._textpos();
31363                        }
31364                    }
31365                    this._textto(lastEndPos);
31366
31367                    if (capnum >= 0) {
31368                        return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Ref, this._options, capnum);
31369                    }
31370                } else {
31371                    capnum = this._scanDecimal();
31372
31373                    if (!angled || this._charsRight() > 0 && this._moveRightGetChar() === "}") {
31374                        if (this._isCaptureSlot(capnum)) {
31375                            return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Ref, this._options, capnum);
31376                        }
31377                    }
31378                }
31379            } else if (angled && this._isWordChar(ch)) {
31380                var capname = this._scanCapname();
31381
31382                if (this._charsRight() > 0 && this._moveRightGetChar() === "}") {
31383                    if (this._isCaptureName(capname)) {
31384                        var captureSlot = this._captureSlotFromName(capname);
31385
31386                        return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Ref, this._options, captureSlot);
31387                    }
31388                }
31389            } else if (!angled) {
31390                capnum = 1;
31391
31392                switch (ch) {
31393                    case "$":
31394                        this._moveRight();
31395                        return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.One, this._options, "$");
31396
31397                    case "&":
31398                        capnum = 0;
31399                        break;
31400
31401                    case "`":
31402                        capnum = System.Text.RegularExpressions.RegexReplacement.LeftPortion;
31403                        break;
31404
31405                    case "\'":
31406                        capnum = System.Text.RegularExpressions.RegexReplacement.RightPortion;
31407                        break;
31408
31409                    case "+":
31410                        capnum = System.Text.RegularExpressions.RegexReplacement.LastGroup;
31411                        break;
31412
31413                    case "_":
31414                        capnum = System.Text.RegularExpressions.RegexReplacement.WholeString;
31415                        break;
31416                }
31417
31418                if (capnum !== 1) {
31419                    this._moveRight();
31420
31421                    return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Ref, this._options, capnum);
31422                }
31423            }
31424
31425            // unrecognized $: literalize
31426
31427            this._textto(backpos);
31428
31429            return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.One, this._options, "$");
31430        },
31431
31432        _scanDecimal: function () {
31433            // Scans any number of decimal digits (pegs value at 2^31-1 if too large)
31434
31435            var maxValueDiv10 = 214748364; // Int32.MaxValue / 10;
31436            var maxValueMod10 = 7; // Int32.MaxValue % 10;
31437            var i = 0;
31438            var ch;
31439            var d;
31440
31441            while (this._charsRight() > 0) {
31442                ch = this._rightChar();
31443
31444                if (ch < "0" || ch > "9") {
31445                    break;
31446                }
31447
31448                d = ch - "0";
31449
31450                this._moveRight();
31451
31452                if (i > (maxValueDiv10) || (i === (maxValueDiv10) && d > (maxValueMod10))) {
31453                    throw this._makeException("Capture group is out of range.");
31454                }
31455
31456                i *= 10;
31457                i += d;
31458            }
31459
31460            return i;
31461        },
31462
31463        _scanOctal: function () {
31464            var d;
31465            var i;
31466            var c;
31467
31468            // Consume octal chars only up to 3 digits and value 0377
31469
31470            c = 3;
31471
31472            if (c > this._charsRight()) {
31473                c = this._charsRight();
31474            }
31475
31476            for (i = 0; c > 0 && (d = this._rightChar() - "0") <= 7; c -= 1) {
31477                this._moveRight();
31478
31479                i *= 8;
31480                i += d;
31481
31482                if (this._useOptionE() && i >= 0x20) {
31483                    break;
31484                }
31485            }
31486
31487            // Octal codes only go up to 255.  Any larger and the behavior that Perl follows
31488            // is simply to truncate the high bits.
31489            i &= 0xFF;
31490
31491            return String.fromCharCode(i);
31492        },
31493
31494        _scanHex: function (c) {
31495            var i;
31496            var d;
31497
31498            i = 0;
31499
31500            if (this._charsRight() >= c) {
31501                for (; c > 0 && ((d = this._hexDigit(this._moveRightGetChar())) >= 0); c -= 1) {
31502                    i *= 0x10;
31503                    i += d;
31504                }
31505            }
31506
31507            if (c > 0) {
31508                throw this._makeException("Insufficient hexadecimal digits.");
31509            }
31510
31511            return i;
31512        },
31513
31514        _hexDigit: function (ch) {
31515            var d;
31516
31517            var code = ch.charCodeAt(0);
31518
31519            if ((d = code - "0".charCodeAt(0)) <= 9) {
31520                return d;
31521            }
31522
31523            if ((d = code - "a".charCodeAt(0)) <= 5) {
31524                return d + 0xa;
31525            }
31526
31527            if ((d = code - "A".charCodeAt(0)) <= 5) {
31528                return d + 0xa;
31529            }
31530
31531            return -1;
31532        },
31533
31534        _scanControl: function () {
31535            if (this._charsRight() <= 0) {
31536                throw this._makeException("Missing control character.");
31537            }
31538
31539            var ch = this._moveRightGetChar();
31540
31541            // \ca interpreted as \cA
31542
31543            var code = ch.charCodeAt(0);
31544
31545            if (code >= "a".charCodeAt(0) && code <= "z".charCodeAt(0)) {
31546                code = code - ("a".charCodeAt(0) - "A".charCodeAt(0));
31547            }
31548
31549            if ((code = (code - "@".charCodeAt(0))) < " ".charCodeAt(0)) {
31550                return String.fromCharCode(code);
31551            }
31552
31553            throw this._makeException("Unrecognized control character.");
31554        },
31555
31556        _scanCapname: function () {
31557            var startpos = this._textpos();
31558
31559            while (this._charsRight() > 0) {
31560                if (!this._isWordChar(this._moveRightGetChar())) {
31561                    this._moveLeft();
31562
31563                    break;
31564                }
31565            }
31566
31567            return _pattern.slice(startpos, this._textpos());
31568        },
31569
31570        _scanCharEscape: function () {
31571            var ch = this._moveRightGetChar();
31572
31573            if (ch >= "0" && ch <= "7") {
31574                this._moveLeft();
31575
31576                return this._scanOctal();
31577            }
31578
31579            switch (ch) {
31580                case "x":
31581                    return this._scanHex(2);
31582                case "u":
31583                    return this._scanHex(4);
31584                case "a":
31585                    return "\u0007";
31586                case "b":
31587                    return "\b";
31588                case "e":
31589                    return "\u001B";
31590                case "f":
31591                    return "\f";
31592                case "n":
31593                    return "\n";
31594                case "r":
31595                    return "\r";
31596                case "t":
31597                    return "\t";
31598                case "v":
31599                    return "\u000B";
31600                case "c":
31601                    return this._scanControl();
31602                default:
31603                    var isInvalidBasicLatin = ch === '8' || ch === '9' || ch === '_';
31604                    if (isInvalidBasicLatin || (!this._useOptionE() && this._isWordChar(ch))) {
31605                        throw this._makeException("Unrecognized escape sequence \\" + ch + ".");
31606                    }
31607                    return ch;
31608            }
31609        },
31610
31611        _captureSlotFromName: function (capname) {
31612            return this._capnames[capname];
31613        },
31614
31615        _isCaptureSlot: function (i) {
31616            if (this._caps != null) {
31617                return this._caps[i] != null;
31618            }
31619
31620            return (i >= 0 && i < this._capsize);
31621        },
31622
31623        _isCaptureName: function (capname) {
31624            if (this._capnames == null) {
31625                return false;
31626            }
31627
31628            return _capnames[capname] != null;
31629        },
31630
31631        _isWordChar: function (ch) {
31632            // Partial implementation,
31633            // see the link for more details (http://referencesource.microsoft.com/#System/regex/system/text/regularexpressions/RegexParser.cs,1156)
31634            return System.Char.isLetter(ch.charCodeAt(0));
31635        },
31636
31637        _charsRight: function () {
31638            return this._pattern.length - this._currentPos;
31639        },
31640
31641        _rightChar: function () {
31642            return this._pattern[this._currentPos];
31643        },
31644
31645        _moveRightGetChar: function () {
31646            return this._pattern[this._currentPos++];
31647        },
31648
31649        _moveRight: function () {
31650            this._currentPos++;
31651        },
31652
31653        _textpos: function () {
31654            return this._currentPos;
31655        },
31656
31657        _textto: function (pos) {
31658            this._currentPos = pos;
31659        },
31660
31661        _moveLeft: function () {
31662            this._currentPos--;
31663        }
31664    });
31665
31666    // @source RegexNode.js
31667
31668    H5.define("System.Text.RegularExpressions.RegexNode", {
31669        statics: {
31670            One: 9, // char     a
31671            Multi: 12, // string   abcdef
31672            Ref: 13, // index    \1
31673            Empty: 23, //          ()
31674            Concatenate: 25 //          ab
31675        },
31676
31677        _type: 0,
31678        _str: null,
31679        _children: null,
31680        _next: null,
31681        _m: 0,
31682
31683        config: {
31684            init: function () {
31685                this._options = System.Text.RegularExpressions.RegexOptions.None;
31686            }
31687        },
31688
31689        ctor: function (type, options, arg) {
31690            this.$initialize();
31691            this._type = type;
31692            this._options = options;
31693
31694            if (type === System.Text.RegularExpressions.RegexNode.Ref) {
31695                this._m = arg;
31696            } else {
31697                this._str = arg || null;
31698            }
31699        },
31700
31701        addChild: function (newChild) {
31702            if (this._children == null) {
31703                this._children = [];
31704            }
31705
31706            var reducedChild = newChild._reduce();
31707            this._children.push(reducedChild);
31708            reducedChild._next = this;
31709        },
31710
31711        childCount: function () {
31712            return this._children == null ? 0 : this._children.length;
31713        },
31714
31715        child: function (i) {
31716            return this._children[i];
31717        },
31718
31719        _reduce: function () {
31720            // Warning: current implementation is just partial (for Replacement servicing)
31721
31722            var n;
31723
31724            switch (this._type) {
31725                case System.Text.RegularExpressions.RegexNode.Concatenate:
31726                    n = this._reduceConcatenation();
31727                    break;
31728
31729                default:
31730                    n = this;
31731                    break;
31732            }
31733
31734            return n;
31735        },
31736
31737        _reduceConcatenation: function () {
31738            var wasLastString = false;
31739            var optionsLast = 0;
31740            var optionsAt;
31741            var at;
31742            var prev;
31743            var i;
31744            var j;
31745            var k;
31746
31747            if (this._children == null) {
31748                return new System.Text.RegularExpressions.RegexNode(System.Text.RegularExpressions.RegexNode.Empty, this._options);
31749            }
31750
31751            for (i = 0, j = 0; i < this._children.length; i++, j++) {
31752                at = this._children[i];
31753
31754                if (j < i) {
31755                    this._children[j] = at;
31756                }
31757
31758                if (at._type === System.Text.RegularExpressions.RegexNode.Concatenate && at._isRightToLeft()) {
31759                    for (k = 0; k < at._children.length; k++) {
31760                        at._children[k]._next = this;
31761                    }
31762
31763                    this._children.splice.apply(this._children, [i + 1, 0].concat(at._children)); // _children.InsertRange(i + 1, at._children);
31764                    j--;
31765                } else if (at._type === System.Text.RegularExpressions.RegexNode.Multi || at._type === System.Text.RegularExpressions.RegexNode.One) {
31766                    // Cannot merge strings if L or I options differ
31767                    optionsAt = at._options & (System.Text.RegularExpressions.RegexOptions.RightToLeft | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
31768
31769                    if (!wasLastString || optionsLast !== optionsAt) {
31770                        wasLastString = true;
31771                        optionsLast = optionsAt;
31772                        continue;
31773                    }
31774
31775                    prev = this._children[--j];
31776
31777                    if (prev._type === System.Text.RegularExpressions.RegexNode.One) {
31778                        prev._type = System.Text.RegularExpressions.RegexNode.Multi;
31779                        prev._str = prev._str;
31780                    }
31781
31782                    if ((optionsAt & System.Text.RegularExpressions.RegexOptions.RightToLeft) === 0) {
31783                        prev._str += at._str;
31784                    } else {
31785                        prev._str = at._str + prev._str;
31786                    }
31787                } else if (at._type === System.Text.RegularExpressions.RegexNode.Empty) {
31788                    j--;
31789                } else {
31790                    wasLastString = false;
31791                }
31792            }
31793
31794            if (j < i) {
31795                this._children.splice(j, i - j);
31796            }
31797
31798            return this._stripEnation(System.Text.RegularExpressions.RegexNode.Empty);
31799        },
31800
31801        _stripEnation: function (emptyType) {
31802            switch (this.childCount()) {
31803                case 0:
31804                    return new scope.RegexNode(emptyType, this._options);
31805                case 1:
31806                    return this.child(0);
31807                default:
31808                    return this;
31809            }
31810        },
31811
31812        _isRightToLeft: function () {
31813            if ((this._options & System.Text.RegularExpressions.RegexOptions.RightToLeft) > 0) {
31814                return true;
31815            }
31816
31817            return false;
31818        },
31819    });
31820
31821    // @source RegexReplacement.js
31822
31823    H5.define("System.Text.RegularExpressions.RegexReplacement", {
31824        statics: {
31825            replace: function (evaluator, regex, input, count, startat) {
31826                if (evaluator == null) {
31827                    throw new System.ArgumentNullException.$ctor1("evaluator");
31828                }
31829
31830                if (count < -1) {
31831                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "Count cannot be less than -1.");
31832                }
31833
31834                if (startat < 0 || startat > input.length) {
31835                    throw new System.ArgumentOutOfRangeException.$ctor4("startat", "Start index cannot be less than 0 or greater than input length.");
31836                }
31837
31838                if (count === 0) {
31839                    return input;
31840                }
31841
31842                var match = regex.match(input, startat);
31843
31844                if (!match.getSuccess()) {
31845                    return input;
31846                } else {
31847                    var sb = "";
31848                    var prevat;
31849                    var matchIndex;
31850                    var matchLength;
31851
31852                    if (!regex.getRightToLeft()) {
31853                        prevat = 0;
31854
31855                        do {
31856                            matchIndex = match.getIndex();
31857                            matchLength = match.getLength();
31858
31859                            if (matchIndex !== prevat) {
31860                                sb += input.slice(prevat, matchIndex);
31861                            }
31862
31863                            prevat = matchIndex + matchLength;
31864                            sb += evaluator(match);
31865
31866                            if (--count === 0) {
31867                                break;
31868                            }
31869
31870                            match = match.nextMatch();
31871                        } while (match.getSuccess());
31872
31873                        if (prevat < input.length) {
31874                            sb += input.slice(prevat, input.length);
31875                        }
31876                    } else {
31877                        var al = [];
31878
31879                        prevat = input.length;
31880
31881                        do {
31882                            matchIndex = match.getIndex();
31883                            matchLength = match.getLength();
31884
31885                            if (matchIndex + matchLength !== prevat) {
31886                                al.push(input.slice(matchIndex + matchLength, prevat));
31887                            }
31888
31889                            prevat = matchIndex;
31890                            al.push(evaluator(match));
31891
31892                            if (--count === 0) {
31893                                break;
31894                            }
31895
31896                            match = match.nextMatch();
31897                        } while (match.getSuccess());
31898
31899                        sb = new StringBuilder();
31900
31901                        if (prevat > 0) {
31902                            sb += sb.slice(0, prevat);
31903                        }
31904
31905                        var i;
31906
31907                        for (i = al.length - 1; i >= 0; i--) {
31908                            sb += al[i];
31909                        }
31910                    }
31911
31912                    return sb;
31913                }
31914            },
31915
31916            split: function (regex, input, count, startat) {
31917                if (count < 0) {
31918                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "Count can't be less than 0.");
31919                }
31920
31921                if (startat < 0 || startat > input.length) {
31922                    throw new System.ArgumentOutOfRangeException.$ctor4("startat", "Start index cannot be less than 0 or greater than input length.");
31923                }
31924
31925                var result = [];
31926
31927                if (count === 1) {
31928                    result.push(input);
31929
31930                    return result;
31931                }
31932
31933                --count;
31934                var match = regex.match(input, startat);
31935
31936                if (!match.getSuccess()) {
31937                    result.push(input);
31938                } else {
31939                    var i;
31940                    var prevat;
31941                    var matchIndex;
31942                    var matchLength;
31943                    var matchGroups;
31944                    var matchGroupsCount;
31945
31946                    if (!regex.getRightToLeft()) {
31947                        prevat = 0;
31948
31949                        for (;;) {
31950                            matchIndex = match.getIndex();
31951                            matchLength = match.getLength();
31952                            matchGroups = match.getGroups();
31953                            matchGroupsCount = matchGroups.getCount();
31954
31955                            result.push(input.slice(prevat, matchIndex));
31956                            prevat = matchIndex + matchLength;
31957
31958                            // add all matched capture groups to the list.
31959                            for (i = 1; i < matchGroupsCount; i++) {
31960                                if (match._isMatched(i)) {
31961                                    result.push(matchGroups.get(i).toString());
31962                                }
31963                            }
31964
31965                            --count;
31966                            if (count === 0) {
31967                                break;
31968                            }
31969
31970                            match = match.nextMatch();
31971
31972                            if (!match.getSuccess()) {
31973                                break;
31974                            }
31975                        }
31976
31977                        result.push(input.slice(prevat, input.length));
31978                    } else {
31979                        prevat = input.length;
31980
31981                        for (;;) {
31982                            matchIndex = match.getIndex();
31983                            matchLength = match.getLength();
31984                            matchGroups = match.getGroups();
31985                            matchGroupsCount = matchGroups.getCount();
31986
31987                            result.push(input.slice(matchIndex + matchLength, prevat));
31988                            prevat = matchIndex;
31989
31990                            // add all matched capture groups to the list.
31991                            for (i = 1; i < matchGroupsCount; i++) {
31992                                if (match._isMatched(i)) {
31993                                    result.push(matchGroups.get(i).toString());
31994                                }
31995                            }
31996
31997                            --count;
31998                            if (count === 0) {
31999                                break;
32000                            }
32001
32002                            match = match.nextMatch();
32003
32004                            if (!match.getSuccess()) {
32005                                break;
32006                            }
32007                        }
32008
32009                        result.push(input.slice(0, prevat));
32010                        result.reverse();
32011                    }
32012                }
32013
32014                return result;
32015            },
32016
32017            Specials: 4,
32018            LeftPortion: -1,
32019            RightPortion: -2,
32020            LastGroup: -3,
32021            WholeString: -4
32022        },
32023
32024        _rep: "",
32025        _strings: [], // table of string constants
32026        _rules: [], // negative -> group #, positive -> string #
32027
32028        ctor: function (rep, concat, caps) {
32029            this.$initialize();
32030            this._rep = rep;
32031
32032            if (concat._type !== System.Text.RegularExpressions.RegexNode.Concatenate) {
32033                throw new System.ArgumentException.$ctor1("Replacement error.");
32034            }
32035
32036            var sb = "";
32037            var strings = [];
32038            var rules = [];
32039            var slot;
32040            var child;
32041            var i;
32042
32043            for (i = 0; i < concat.childCount(); i++) {
32044                child = concat.child(i);
32045
32046                switch (child._type) {
32047                    case System.Text.RegularExpressions.RegexNode.Multi:
32048                    case System.Text.RegularExpressions.RegexNode.One:
32049                        sb += child._str;
32050                        break;
32051
32052                    case System.Text.RegularExpressions.RegexNode.Ref:
32053                        if (sb.length > 0) {
32054                            rules.push(strings.length);
32055                            strings.push(sb);
32056                            sb = "";
32057                        }
32058
32059                        slot = child._m;
32060
32061                        if (caps != null && slot >= 0) {
32062                            slot = caps[slot];
32063                        }
32064
32065                        rules.push(-System.Text.RegularExpressions.RegexReplacement.Specials - 1 - slot);
32066                        break;
32067                    default:
32068                        throw new System.ArgumentException.$ctor1("Replacement error.");
32069                }
32070            }
32071
32072            if (sb.length > 0) {
32073                rules.push(strings.length);
32074                strings.push(sb);
32075            }
32076
32077            this._strings = strings;
32078            this._rules = rules;
32079        },
32080
32081        getPattern: function () {
32082            return _rep;
32083        },
32084
32085        replacement: function (match) {
32086            return this._replacementImpl("", match);
32087        },
32088
32089        replace: function (regex, input, count, startat) {
32090            if (count < -1) {
32091                throw new System.ArgumentOutOfRangeException.$ctor4("count", "Count cannot be less than -1.");
32092            }
32093
32094            if (startat < 0 || startat > input.length) {
32095                throw new System.ArgumentOutOfRangeException.$ctor4("startat", "Start index cannot be less than 0 or greater than input length.");
32096            }
32097
32098            if (count === 0) {
32099                return input;
32100            }
32101
32102            var match = regex.match(input, startat);
32103
32104            if (!match.getSuccess()) {
32105                return input;
32106            } else {
32107                var sb = "";
32108                var prevat;
32109                var matchIndex;
32110                var matchLength;
32111
32112                if (!regex.getRightToLeft()) {
32113                    prevat = 0;
32114
32115                    do {
32116                        matchIndex = match.getIndex();
32117                        matchLength = match.getLength();
32118
32119                        if (matchIndex !== prevat) {
32120                            sb += input.slice(prevat, matchIndex);
32121                        }
32122
32123                        prevat = matchIndex + matchLength;
32124                        sb = this._replacementImpl(sb, match);
32125
32126                        if (--count === 0) {
32127                            break;
32128                        }
32129
32130                        match = match.nextMatch();
32131                    } while (match.getSuccess());
32132
32133                    if (prevat < input.length) {
32134                        sb += input.slice(prevat, input.length);
32135                    }
32136                } else {
32137                    var al = [];
32138
32139                    prevat = input.length;
32140
32141                    do {
32142                        matchIndex = match.getIndex();
32143                        matchLength = match.getLength();
32144
32145                        if (matchIndex + matchLength !== prevat) {
32146                            al.push(input.slice(matchIndex + matchLength, prevat));
32147                        }
32148
32149                        prevat = matchIndex;
32150                        this._replacementImplRTL(al, match);
32151
32152                        if (--count === 0) {
32153                            break;
32154                        }
32155
32156                        match = match.nextMatch();
32157                    } while (match.getSuccess());
32158
32159                    if (prevat > 0) {
32160                        sb += sb.slice(0, prevat);
32161                    }
32162
32163                    var i;
32164
32165                    for (i = al.length - 1; i >= 0; i--) {
32166                        sb += al[i];
32167                    }
32168                }
32169
32170                return sb;
32171            }
32172        },
32173
32174        _replacementImpl: function (sb, match) {
32175            var specials = System.Text.RegularExpressions.RegexReplacement.Specials;
32176            var r;
32177            var i;
32178
32179            for (i = 0; i < this._rules.length; i++) {
32180                r = this._rules[i];
32181
32182                if (r >= 0) {
32183                    // string lookup
32184                    sb += this._strings[r];
32185                } else if (r < -specials) {
32186                    // group lookup
32187                    sb += match._groupToStringImpl(-specials - 1 - r);
32188                } else {
32189                    // special insertion patterns
32190                    switch (-specials - 1 - r) {
32191                        case System.Text.RegularExpressions.RegexReplacement.LeftPortion:
32192                            sb += match._getLeftSubstring();
32193                            break;
32194                        case System.Text.RegularExpressions.RegexReplacement.RightPortion:
32195                            sb += match._getRightSubstring();
32196                            break;
32197                        case System.Text.RegularExpressions.RegexReplacement.LastGroup:
32198                            sb += match._lastGroupToStringImpl();
32199                            break;
32200                        case System.Text.RegularExpressions.RegexReplacement.WholeString:
32201                            sb += match._getOriginalString();
32202                            break;
32203                    }
32204                }
32205            }
32206
32207            return sb;
32208        },
32209
32210        _replacementImplRTL: function (al, match) {
32211            var specials = System.Text.RegularExpressions.RegexReplacement.Specials;
32212            var r;
32213            var i;
32214
32215            for (i = _rules.length - 1; i >= 0; i--) {
32216                r = this._rules[i];
32217
32218                if (r >= 0) {
32219                    // string lookup
32220                    al.push(this._strings[r]);
32221                } else if (r < -specials) {
32222                    // group lookup
32223                    al.push(match._groupToStringImpl(-specials - 1 - r));
32224                } else {
32225                    // special insertion patterns
32226                    switch (-specials - 1 - r) {
32227                        case System.Text.RegularExpressions.RegexReplacement.LeftPortion:
32228                            al.push(match._getLeftSubstring());
32229                            break;
32230                        case System.Text.RegularExpressions.RegexReplacement.RightPortion:
32231                            al.push(match._getRightSubstring());
32232                            break;
32233                        case System.Text.RegularExpressions.RegexReplacement.LastGroup:
32234                            al.push(match._lastGroupToStringImpl());
32235                            break;
32236                        case System.Text.RegularExpressions.RegexReplacement.WholeString:
32237                            al.push(match._getOriginalString());
32238                            break;
32239                    }
32240                }
32241            }
32242        }
32243    });
32244
32245    // @source RegexEngine.js
32246
32247    H5.define("System.Text.RegularExpressions.RegexEngine", {
32248        _pattern: "",
32249        _patternInfo: null,
32250
32251        _text: "",
32252        _textStart: 0,
32253        _timeoutMs: -1,
32254        _timeoutTime: -1,
32255        _settings: null,
32256
32257        _branchType: {
32258            base: 0,
32259            offset: 1,
32260            lazy: 2,
32261            greedy: 3,
32262            or: 4
32263        },
32264
32265        _branchResultKind: {
32266            ok: 1,
32267            endPass: 2,
32268            nextPass: 3,
32269            nextBranch: 4
32270        },
32271
32272        // ============================================================================================
32273        // Public functions
32274        // ============================================================================================
32275        ctor: function (pattern, isCaseInsensitive, isMultiLine, isSingleline, isIgnoreWhitespace, isExplicitCapture, timeoutMs) {
32276            this.$initialize();
32277
32278            if (pattern == null) {
32279                throw new System.ArgumentNullException.$ctor1("pattern");
32280            }
32281
32282            this._pattern = pattern;
32283            this._timeoutMs = timeoutMs;
32284            this._settings = {
32285                ignoreCase: isCaseInsensitive,
32286                multiline: isMultiLine,
32287                singleline: isSingleline,
32288                ignoreWhitespace: isIgnoreWhitespace,
32289                explicitCapture: isExplicitCapture
32290            };
32291        },
32292
32293        match: function (text, textStart) {
32294            if (text == null) {
32295                throw new System.ArgumentNullException.$ctor1("text");
32296            }
32297
32298            if (textStart != null && (textStart < 0 || textStart > text.length)) {
32299                throw new System.ArgumentOutOfRangeException.$ctor4("textStart", "Start index cannot be less than 0 or greater than input length.");
32300            }
32301
32302            this._text = text;
32303            this._textStart = textStart;
32304            this._timeoutTime = this._timeoutMs > 0 ? new Date().getTime() + System.Convert.toInt32(this._timeoutMs + 0.5) : -1;
32305
32306            // Get group descriptors
32307            var patternInfo = this.parsePattern();
32308
32309            if (patternInfo.shouldFail) {
32310                return this._getEmptyMatch();
32311            }
32312
32313            this._checkTimeout();
32314
32315            var scanRes = this._scanAndTransformResult(textStart, patternInfo.tokens, false, null);
32316
32317            return scanRes;
32318        },
32319
32320        parsePattern: function () {
32321            if (this._patternInfo == null) {
32322                var parser = System.Text.RegularExpressions.RegexEngineParser;
32323                var patternInfo = parser.parsePattern(this._pattern, this._cloneSettings(this._settings));
32324                this._patternInfo = patternInfo;
32325            }
32326
32327            return this._patternInfo;
32328        },
32329
32330        // ============================================================================================
32331        // Engine main logic
32332        // ============================================================================================
32333        _scanAndTransformResult: function (textPos, tokens, noOffset, desiredLen) {
32334            var state = this._scan(textPos, this._text.length, tokens, noOffset, desiredLen);
32335            var transformedRes = this._collectScanResults(state, textPos);
32336            return transformedRes;
32337        },
32338
32339        _scan: function (textPos, textEndPos, tokens, noOffset, desiredLen) {
32340            var resKind = this._branchResultKind;
32341            var branches = [];
32342            branches.grCaptureCache = {};
32343
32344            var branch = null;
32345            var res = null;
32346
32347            // Empty pattern case:
32348            if (tokens.length === 0) {
32349                var state = new System.Text.RegularExpressions.RegexEngineState();
32350                state.capIndex = textPos;
32351                state.txtIndex = textPos;
32352                state.capLength = 0;
32353
32354                return state;
32355            }
32356
32357            // Init base branch:
32358            var baseBranchType = noOffset ? this._branchType.base : this._branchType.offset;
32359
32360            var endPos = this._patternInfo.isContiguous ? textPos : textEndPos;
32361            var baseBranch = new System.Text.RegularExpressions.RegexEngineBranch(baseBranchType, textPos, textPos, endPos);
32362
32363            baseBranch.pushPass(0, tokens, this._cloneSettings(this._settings));
32364            baseBranch.started = true;
32365            baseBranch.state.txtIndex = textPos;
32366            branches.push(baseBranch);
32367
32368            while (branches.length) {
32369                branch = branches[branches.length - 1];
32370
32371                res = this._scanBranch(textEndPos, branches, branch);
32372
32373                if (res === resKind.ok && (desiredLen == null || branch.state.capLength === desiredLen)) {
32374                    return branch.state;
32375                }
32376
32377                //if (!this.branchLimit) {
32378                //    this.branchLimit = 1;
32379                //} else {
32380                //    this.branchLimit++;
32381                //    if (this.branchLimit > 200000) {
32382                //        alert("Too many branches :(");
32383                //        break;
32384                //    }
32385                //}
32386
32387                this._advanceToNextBranch(branches, branch);
32388                this._checkTimeout();
32389            }
32390
32391            return null;
32392        },
32393
32394        _scanBranch: function (textEndPos, branches, branch) {
32395            var resKind = this._branchResultKind;
32396            var pass;
32397            var res;
32398
32399            if (branch.mustFail) {
32400                branch.mustFail = false;
32401
32402                return resKind.nextBranch;
32403            }
32404
32405            while (branch.hasPass()) {
32406                pass = branch.peekPass();
32407
32408                if (pass.tokens == null || pass.tokens.length === 0) {
32409                    res = resKind.endPass;
32410                } else {
32411                    // Add alternation branches before scanning:
32412                    if (this._addAlternationBranches(branches, branch, pass) === resKind.nextBranch) {
32413                        return resKind.nextBranch;
32414                    }
32415
32416                    // Scan:
32417                    res = this._scanPass(textEndPos, branches, branch, pass);
32418                }
32419
32420                switch (res) {
32421                    case resKind.nextBranch:
32422                        // Move to the next branch:
32423                        return res;
32424
32425                    case resKind.nextPass:
32426                        // switch to the recently added pass
32427                        continue;
32428
32429                    case resKind.endPass:
32430                    case resKind.ok:
32431                        // End of pass has been reached:
32432                        branch.popPass();
32433                        break;
32434
32435                    default:
32436                        throw new System.InvalidOperationException.$ctor1("Unexpected branch result.");
32437                }
32438            }
32439
32440            return resKind.ok;
32441        },
32442
32443        _scanPass: function (textEndPos, branches, branch, pass) {
32444            var resKind = this._branchResultKind;
32445            var passEndIndex = pass.tokens.length;
32446            var token;
32447            var probe;
32448            var res;
32449
32450            while (pass.index < passEndIndex) {
32451                token = pass.tokens[pass.index];
32452                probe = pass.probe;
32453
32454                // Add probing:
32455                if (probe == null) {
32456                    if (this._addBranchBeforeProbing(branches, branch, pass, token)) {
32457                        return resKind.nextBranch;
32458                    }
32459                } else {
32460                    if (probe.value < probe.min || probe.forced) {
32461                        res = this._scanToken(textEndPos, branches, branch, pass, token);
32462
32463                        if (res !== resKind.ok) {
32464                            return res;
32465                        }
32466
32467                        probe.value += 1;
32468                        probe.forced = false;
32469
32470                        continue;
32471                    }
32472
32473                    this._addBranchAfterProbing(branches, branch, pass, probe);
32474
32475                    if (probe.forced) {
32476                        continue;
32477                    }
32478
32479                    pass.probe = null;
32480                    pass.index++;
32481
32482                    continue;
32483                }
32484
32485                // Process the token:
32486                res = this._scanToken(textEndPos, branches, branch, pass, token);
32487
32488                // Process the result of the token scan:
32489                switch (res) {
32490                    case resKind.nextBranch:
32491                    case resKind.nextPass:
32492                    case resKind.endPass:
32493                        return res;
32494
32495                    case resKind.ok:
32496                        // Advance to the next token within the current pass:
32497                        pass.index++;
32498                        break;
32499
32500                    default:
32501                        throw new System.InvalidOperationException.$ctor1("Unexpected branch-pass result.");
32502                }
32503            }
32504
32505            return resKind.ok;
32506        },
32507
32508        _addAlternationBranches: function (branches, branch, pass) {
32509            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
32510            var branchTypes = this._branchType;
32511            var passEndIndex = pass.tokens.length;
32512            var resKind = this._branchResultKind;
32513            var orIndexes;
32514            var newBranch;
32515            var newPass;
32516            var token;
32517            var i;
32518
32519            // Scan potential alternations:
32520            if (!pass.alternationHandled && !pass.tokens.noAlternation) {
32521                orIndexes = [-1];
32522
32523                for (i = 0; i < passEndIndex; i++) {
32524                    token = pass.tokens[i];
32525
32526                    if (token.type === tokenTypes.alternation) {
32527                        orIndexes.push(i);
32528                    }
32529                }
32530
32531                if (orIndexes.length > 1) {
32532                    for (i = 0; i < orIndexes.length; i++) {
32533                        newBranch = new System.Text.RegularExpressions.RegexEngineBranch(branchTypes.or, i, 0, orIndexes.length, branch.state);
32534                        newBranch.isNotFailing = true;
32535                        newPass = newBranch.peekPass();
32536                        newPass.alternationHandled = true;
32537                        newPass.index = orIndexes[i] + 1;
32538                        branches.splice(branches.length - i, 0, newBranch);
32539                    }
32540
32541                    // The last branch must fail:
32542                    branches[branches.length - orIndexes.length].isNotFailing = false;
32543
32544                    // The parent branch must be ended up immediately:
32545                    branch.mustFail = true;
32546
32547                    pass.alternationHandled = true;
32548
32549                    return resKind.nextBranch;
32550                } else {
32551                    pass.tokens.noAlternation = true;
32552                }
32553            }
32554
32555            return resKind.ok;
32556        },
32557
32558        _addBranchBeforeProbing: function (branches, branch, pass, token) {
32559            // Add +, *, ? branches:
32560            var probe = this._tryGetTokenProbe(token);
32561
32562            if (probe == null) {
32563                return false;
32564            }
32565
32566            pass.probe = probe;
32567
32568            var branchType = probe.isLazy ? this._branchType.lazy : this._branchType.greedy;
32569            var newBranch = new System.Text.RegularExpressions.RegexEngineBranch(branchType, probe.value, probe.min, probe.max, branch.state);
32570
32571            branches.push(newBranch);
32572
32573            return true;
32574        },
32575
32576        _addBranchAfterProbing: function (branches, branch, pass, probe) {
32577            if (probe.isLazy) {
32578                if (probe.value + 1 <= probe.max) {
32579                    var lazyBranch = branch.clone();
32580                    var lazyProbe = lazyBranch.peekPass().probe;
32581
32582                    lazyBranch.value += 1;
32583                    lazyProbe.forced = true;
32584
32585                    // add to the left from the current branch
32586                    branches.splice(branches.length - 1, 0, lazyBranch);
32587                    branch.isNotFailing = true;
32588                }
32589            } else {
32590                if (probe.value + 1 <= probe.max) {
32591                    var greedyBranch = branch.clone();
32592
32593                    greedyBranch.started = true;
32594                    greedyBranch.peekPass().probe = null;
32595                    greedyBranch.peekPass().index++;
32596                    branches.splice(branches.length - 1, 0, greedyBranch);
32597
32598                    probe.forced = true;
32599                    branch.value += 1;
32600                    branch.isNotFailing = true;
32601                }
32602            }
32603        },
32604
32605        _tryGetTokenProbe: function (token) {
32606            var qtoken = token.qtoken;
32607
32608            if (qtoken == null) {
32609                return null;
32610            }
32611
32612            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
32613            var min;
32614            var max;
32615
32616            if (qtoken.type === tokenTypes.quantifier) {
32617                switch (qtoken.value) {
32618                    case "*":
32619                    case "*?":
32620                        min = 0;
32621                        max = 2147483647;
32622                        break;
32623
32624                    case "+":
32625                    case "+?":
32626                        min = 1;
32627                        max = 2147483647;
32628                        break;
32629
32630                    case "?":
32631                    case "??":
32632                        min = 0;
32633                        max = 1;
32634                        break;
32635
32636                    default:
32637                        throw new System.InvalidOperationException.$ctor1("Unexpected quantifier value.");
32638                }
32639            } else if (qtoken.type === tokenTypes.quantifierN) {
32640                min = qtoken.data.n;
32641                max = qtoken.data.n;
32642            } else if (qtoken.type === tokenTypes.quantifierNM) {
32643                min = qtoken.data.n;
32644                max = qtoken.data.m != null ? qtoken.data.m : 2147483647;
32645            } else {
32646                return null;
32647            }
32648
32649            var probe = new System.Text.RegularExpressions.RegexEngineProbe(min, max, 0, qtoken.data.isLazy);
32650            return probe;
32651        },
32652
32653        _advanceToNextBranch: function (branches, branch) {
32654            if (branches.length === 0) {
32655                return;
32656            }
32657
32658            var lastBranch = branches[branches.length - 1];
32659
32660            if (!lastBranch.started) {
32661                lastBranch.started = true;
32662                return;
32663            }
32664
32665            if (branch !== lastBranch) {
32666                throw new System.InvalidOperationException.$ctor1("Current branch is supposed to be the last one.");
32667            }
32668
32669            if (branches.length === 1 && branch.type === this._branchType.offset) {
32670                branch.value++;
32671                branch.state.txtIndex = branch.value;
32672                branch.mustFail = false;
32673
32674                // clear state:
32675                branch.state.capIndex = null;
32676                branch.state.capLength = 0;
32677                branch.state.groups.length = 0;
32678                branch.state.passes.length = 1;
32679                branch.state.passes[0].clearState(this._cloneSettings(this._settings));
32680
32681                if (branch.value > branch.max) {
32682                    branches.pop();
32683                }
32684            } else {
32685                branches.pop();
32686
32687                if (!branch.isNotFailing) {
32688                    lastBranch = branches[branches.length - 1];
32689                    this._advanceToNextBranch(branches, lastBranch);
32690
32691                    return;
32692                }
32693            }
32694        },
32695
32696        _collectScanResults: function (state, textPos) {
32697            var groupDescs = this._patternInfo.groups;
32698            var text = this._text;
32699            var processedGroupNames = {};
32700            var capGroups;
32701            var capGroup;
32702            var groupsMap = {};
32703            var groupDesc;
32704      
32704      var capture;
32705            var group;
32706            var i;
32707
32708            // Create Empty match object:
32709            var match = this._getEmptyMatch();
32710
32711            if (state != null) {
32712                capGroups = state.groups;
32713
32714                // For successful match fill Match object:
32715                this._fillMatch(match, state.capIndex, state.capLength, textPos);
32716
32717                // Fill group captures:
32718                for (i = 0; i < capGroups.length; i++) {
32719                    capGroup = capGroups[i];
32720                    groupDesc = groupDescs[capGroup.rawIndex - 1];
32721
32722                    if (groupDesc.constructs.skipCapture) {
32723                        continue;
32724                    }
32725
32726                    capture = {
32727                        capIndex: capGroup.capIndex,
32728                        capLength: capGroup.capLength,
32729                        value: text.slice(capGroup.capIndex, capGroup.capIndex + capGroup.capLength)
32730                    };
32731
32732                    group = groupsMap[groupDesc.name];
32733
32734                    if (group == null) {
32735                        group = {
32736                            capIndex: 0,
32737                            capLength: 0,
32738                            value: "",
32739                            success: false,
32740                            captures: [capture]
32741                        };
32742
32743                        groupsMap[groupDesc.name] = group;
32744                    } else {
32745                        group.captures.push(capture);
32746                    }
32747                }
32748
32749                // Add groups to Match in the required order:
32750                for (i = 0; i < groupDescs.length; i++) {
32751                    groupDesc = groupDescs[i];
32752
32753                    if (groupDesc.constructs.skipCapture) {
32754                        continue;
32755                    }
32756
32757                    if (processedGroupNames[groupDesc.name] === true) {
32758                        continue;
32759                    }
32760
32761                    group = groupsMap[groupDesc.name];
32762
32763                    if (group == null) {
32764                        group = {
32765                            capIndex: 0,
32766                            capLength: 0,
32767                            value: "",
32768                            success: false,
32769                            captures: []
32770                        };
32771                    } else {
32772                        // Update group values with the last capture info:
32773                        if (group.captures.length > 0) {
32774                            capture = group.captures[group.captures.length - 1];
32775
32776                            group.capIndex = capture.capIndex;
32777                            group.capLength = capture.capLength;
32778                            group.value = capture.value;
32779                            group.success = true;
32780                        }
32781                    }
32782
32783                    processedGroupNames[groupDesc.name] = true;
32784                    group.descriptor = groupDesc; // TODO: check if we can get rid of this
32785                    match.groups.push(group);
32786                }
32787            }
32788
32789            return match;
32790        },
32791
32792        // ============================================================================================
32793        // Token processing
32794        // ============================================================================================
32795        _scanToken: function (textEndPos, branches, branch, pass, token) {
32796            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
32797            var resKind = this._branchResultKind;
32798
32799            switch (token.type) {
32800                case tokenTypes.group:
32801                case tokenTypes.groupImnsx:
32802                case tokenTypes.alternationGroup:
32803                    return this._scanGroupToken(textEndPos, branches, branch, pass, token);
32804
32805                case tokenTypes.groupImnsxMisc:
32806                    return this._scanGroupImnsxToken(token.group.constructs, pass.settings);
32807
32808                case tokenTypes.charGroup:
32809                    return this._scanCharGroupToken(branches, branch, pass, token, false);
32810
32811                case tokenTypes.charNegativeGroup:
32812                    return this._scanCharNegativeGroupToken(branches, branch, pass, token, false);
32813
32814                case tokenTypes.escChar:
32815                case tokenTypes.escCharOctal:
32816                case tokenTypes.escCharHex:
32817                case tokenTypes.escCharUnicode:
32818                case tokenTypes.escCharCtrl:
32819                    return this._scanLiteral(textEndPos, branches, branch, pass, token.data.ch);
32820
32821                case tokenTypes.escCharOther:
32822                case tokenTypes.escCharClass:
32823                    return this._scanEscapeToken(branches, branch, pass, token);
32824
32825                case tokenTypes.escCharClassCategory:
32826                    throw new System.NotSupportedException.$ctor1("Unicode Category constructions are not supported.");
32827
32828                case tokenTypes.escCharClassBlock:
32829                    throw new System.NotSupportedException.$ctor1("Unicode Named block constructions are not supported.");
32830
32831                case tokenTypes.escCharClassDot:
32832                    return this._scanDotToken(textEndPos, branches, branch, pass);
32833
32834                case tokenTypes.escBackrefNumber:
32835                    return this._scanBackrefNumberToken(textEndPos, branches, branch, pass, token);
32836
32837                case tokenTypes.escBackrefName:
32838                    return this._scanBackrefNameToken(textEndPos, branches, branch, pass, token);
32839
32840                case tokenTypes.anchor:
32841                case tokenTypes.escAnchor:
32842                    return this._scanAnchorToken(textEndPos, branches, branch, pass, token);
32843
32844                case tokenTypes.groupConstruct:
32845                case tokenTypes.groupConstructName:
32846                case tokenTypes.groupConstructImnsx:
32847                case tokenTypes.groupConstructImnsxMisc:
32848                    return resKind.ok;
32849
32850                case tokenTypes.alternationGroupCondition:
32851                case tokenTypes.alternationGroupRefNameCondition:
32852                case tokenTypes.alternationGroupRefNumberCondition:
32853                    return this._scanAlternationConditionToken(textEndPos, branches, branch, pass, token);
32854
32855                case tokenTypes.alternation:
32856                    return resKind.endPass;
32857
32858                case tokenTypes.commentInline:
32859                case tokenTypes.commentXMode:
32860                    return resKind.ok;
32861
32862                default:
32863                    return this._scanLiteral(textEndPos, branches, branch, pass, token.value);
32864            }
32865        },
32866
32867        _scanGroupToken: function (textEndPos, branches, branch, pass, token) {
32868            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
32869            var resKind = this._branchResultKind;
32870            var textIndex = branch.state.txtIndex;
32871
32872            if (pass.onHold) {
32873                if (token.type === tokenTypes.group) {
32874                    var rawIndex = token.group.rawIndex;
32875                    var capIndex = pass.onHoldTextIndex;
32876                    var capLength = textIndex - capIndex;
32877
32878                    // Cache value to avoid proceeding with the already checked route:
32879                    var tokenCache = branches.grCaptureCache[rawIndex];
32880
32881                    if (tokenCache == null) {
32882                        tokenCache = {};
32883                        branches.grCaptureCache[rawIndex] = tokenCache;
32884                    }
32885
32886                    var key = capIndex.toString() + "_" + capLength.toString();
32887
32888                    if (tokenCache[key] == null) {
32889                        tokenCache[key] = true;
32890                    } else {
32891                        return resKind.nextBranch;
32892                    }
32893
32894                    if (!token.group.constructs.emptyCapture) {
32895                        if (token.group.isBalancing) {
32896                            branch.state.logCaptureGroupBalancing(token.group, capIndex);
32897                        } else {
32898                            branch.state.logCaptureGroup(token.group, capIndex, capLength);
32899                        }
32900                    }
32901                }
32902
32903                pass.onHold = false;
32904                pass.onHoldTextIndex = -1;
32905
32906                return resKind.ok;
32907            }
32908
32909            if (token.type === tokenTypes.group ||
32910                token.type === tokenTypes.groupImnsx) {
32911                var constructs = token.group.constructs;
32912
32913                // Update Pass settings:
32914                this._scanGroupImnsxToken(constructs, pass.settings);
32915
32916                // Scan Grouping constructs:
32917                if (constructs.isPositiveLookahead || constructs.isNegativeLookahead ||
32918                    constructs.isPositiveLookbehind || constructs.isNegativeLookbehind) {
32919                    var scanLookRes = this._scanLook(branch, textIndex, textEndPos, token);
32920
32921                    return scanLookRes;
32922                } else if (constructs.isNonbacktracking) {
32923                    var scanNonBacktrackingRes = this._scanNonBacktracking(branch, textIndex, textEndPos, token);
32924
32925                    return scanNonBacktrackingRes;
32926                }
32927            }
32928
32929            // Continue scanning a regular group:
32930            pass.onHoldTextIndex = textIndex;
32931            pass.onHold = true;
32932
32933            branch.pushPass(0, token.children, this._cloneSettings(pass.settings));
32934
32935            return resKind.nextPass;
32936        },
32937
32938        _scanGroupImnsxToken: function (constructs, settings) {
32939            var resKind = this._branchResultKind;
32940
32941            if (constructs.isIgnoreCase != null) {
32942                settings.ignoreCase = constructs.isIgnoreCase;
32943            }
32944
32945            if (constructs.isMultiline != null) {
32946                settings.multiline = constructs.isMultiline;
32947            }
32948
32949            if (constructs.isSingleLine != null) {
32950                settings.singleline = constructs.isSingleLine;
32951            }
32952
32953            if (constructs.isIgnoreWhitespace != null) {
32954                settings.ignoreWhitespace = constructs.isIgnoreWhitespace;
32955            }
32956
32957            if (constructs.isExplicitCapture != null) {
32958                settings.explicitCapture = constructs.isExplicitCapture;
32959            }
32960
32961            return resKind.ok;
32962        },
32963
32964        _scanAlternationConditionToken: function (textEndPos, branches, branch, pass, token) {
32965            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
32966            var resKind = this._branchResultKind;
32967            var children = token.children;
32968            var textIndex = branch.state.txtIndex;
32969            var res = resKind.nextBranch;
32970
32971            if (token.type === tokenTypes.alternationGroupRefNameCondition ||
32972                token.type === tokenTypes.alternationGroupRefNumberCondition) {
32973                var grCapture = branch.state.resolveBackref(token.data.packedSlotId);
32974
32975                if (grCapture != null) {
32976                    res = resKind.ok;
32977                } else {
32978                    res = resKind.nextBranch;
32979                }
32980            } else {
32981                // Resolve expression:
32982                var state = this._scan(textIndex, textEndPos, children, true, null);
32983
32984                if (this._combineScanResults(branch, state)) {
32985                    res = resKind.ok;
32986                }
32987            }
32988
32989            if (res === resKind.nextBranch && pass.tokens.noAlternation) {
32990                res = resKind.endPass;
32991            }
32992
32993            return res;
32994        },
32995
32996        _scanLook: function (branch, textIndex, textEndPos, token) {
32997            var constructs = token.group.constructs;
32998            var resKind = this._branchResultKind;
32999            var children = token.children;
33000            var expectedRes;
33001            var actualRes;
33002
33003            var isLookahead = constructs.isPositiveLookahead || constructs.isNegativeLookahead;
33004            var isLookbehind = constructs.isPositiveLookbehind || constructs.isNegativeLookbehind;
33005
33006            if (isLookahead || isLookbehind) {
33007                children = children.slice(1, children.length); // remove constructs
33008
33009                expectedRes = constructs.isPositiveLookahead || constructs.isPositiveLookbehind;
33010
33011                if (isLookahead) {
33012                    actualRes = this._scanLookAhead(branch, textIndex, textEndPos, children);
33013                } else {
33014                    actualRes = this._scanLookBehind(branch, textIndex, textEndPos, children);
33015                }
33016
33017                if (expectedRes === actualRes) {
33018                    return resKind.ok;
33019                } else {
33020                    return resKind.nextBranch;
33021                }
33022            }
33023
33024            return null;
33025        },
33026
33027        _scanLookAhead: function (branch, textIndex, textEndPos, tokens) {
33028            var state = this._scan(textIndex, textEndPos, tokens, true, null);
33029
33030            return this._combineScanResults(branch, state);
33031        },
33032
33033        _scanLookBehind: function (branch, textIndex, textEndPos, tokens) {
33034            var currIndex = textIndex;
33035            var strLen;
33036            var state;
33037
33038            while (currIndex >= 0) {
33039                strLen = textIndex - currIndex;
33040                state = this._scan(currIndex, textEndPos, tokens, true, strLen);
33041
33042                if (this._combineScanResults(branch, state)) {
33043                    return true;
33044                }
33045
33046                --currIndex;
33047            }
33048
33049            return false;
33050        },
33051
33052        _scanNonBacktracking: function (branch, textIndex, textEndPos, token) {
33053            var resKind = this._branchResultKind;
33054            var children = token.children;
33055            children = children.slice(1, children.length); // remove constructs
33056
33057            var state = this._scan(textIndex, textEndPos, children, true, null);
33058
33059            if (!state) {
33060                return resKind.nextBranch;
33061            }
33062
33063            branch.state.logCapture(state.capLength);
33064
33065            return resKind.ok;
33066        },
33067
33068        _scanLiteral: function (textEndPos, branches, branch, pass, literal) {
33069            var resKind = this._branchResultKind;
33070            var index = branch.state.txtIndex;
33071
33072            if (index + literal.length > textEndPos) {
33073                return resKind.nextBranch;
33074            }
33075
33076            var i;
33077
33078            if (pass.settings.ignoreCase) {
33079                for (i = 0; i < literal.length; i++) {
33080                    if (this._text[index + i].toLowerCase() !== literal[i].toLowerCase()) {
33081                        return resKind.nextBranch;
33082                    }
33083                }
33084            } else {
33085                for (i = 0; i < literal.length; i++) {
33086                    if (this._text[index + i] !== literal[i]) {
33087                        return resKind.nextBranch;
33088                    }
33089                }
33090            }
33091
33092            branch.state.logCapture(literal.length);
33093
33094            return resKind.ok;
33095        },
33096
33097        _scanWithJsRegex: function (branches, branch, pass, token, tokenValue) {
33098            var resKind = this._branchResultKind;
33099            var index = branch.state.txtIndex;
33100            var ch = this._text[index];
33101
33102            if (ch == null) {
33103                ch = "";
33104            }
33105
33106            var options = pass.settings.ignoreCase ? "i" : "";
33107
33108            var rgx = token.rgx;
33109
33110            if (rgx == null) {
33111                if (tokenValue == null) {
33112                    tokenValue = token.value;
33113                }
33114
33115                rgx = new RegExp(tokenValue, options);
33116                token.rgx = rgx;
33117            }
33118
33119            if (rgx.test(ch)) {
33120                branch.state.logCapture(ch.length);
33121
33122                return resKind.ok;
33123            }
33124
33125            return resKind.nextBranch;
33126        },
33127
33128        _scanWithJsRegex2: function (textIndex, pattern) {
33129            var resKind = this._branchResultKind;
33130            var ch = this._text[textIndex];
33131
33132            if (ch == null) {
33133                ch = "";
33134            }
33134
33135
33136            var rgx = new RegExp(pattern, "");
33137
33138            if (rgx.test(ch)) {
33139                return resKind.ok;
33140            }
33141
33142            return resKind.nextBranch;
33143        },
33144
33145        _scanCharGroupToken: function (branches, branch, pass, token, skipLoggingCapture) {
33146            var tokenTypes = System.Text.RegularExpressions.RegexEngineParser.tokenTypes;
33147            var resKind = this._branchResultKind;
33148            var index = branch.state.txtIndex;
33149            var ch = this._text[index];
33150
33151            if (ch == null) {
33152                return resKind.nextBranch;
33153            }
33154
33155            var i;
33156            var j;
33157            var n = ch.charCodeAt(0);
33158            var ranges = token.data.ranges;
33159            var range;
33160            var upperCh;
33161
33162            // Check susbstruct group:
33163            if (token.data.substractToken != null) {
33164                var substractRes;
33165
33166                if (token.data.substractToken.type === tokenTypes.charGroup) {
33167                    substractRes = this._scanCharGroupToken(branches, branch, pass, token.data.substractToken, true);
33168                } else if (token.data.substractToken.type === tokenTypes.charNegativeGroup) {
33169                    substractRes = this._scanCharNegativeGroupToken(branches, branch, pass, token.data.substractToken, true);
33170                } else {
33171                    throw new System.InvalidOperationException.$ctor1("Unexpected substuct group token.");
33172                }
33173
33174                if (substractRes === resKind.ok) {
33175                    return token.type === tokenTypes.charGroup ? resKind.nextBranch : resKind.ok;
33176                }
33177            }
33178
33179            // Try CharClass tokens like: \s \S \d \D
33180            if (ranges.charClassToken != null) {
33181                var charClassRes = this._scanWithJsRegex(branches, branch, pass, ranges.charClassToken);
33182
33183                if (charClassRes === resKind.ok) {
33184                    return resKind.ok;
33185                }
33186            }
33187
33188            // 2 iterations - to handle both cases: upper and lower
33189            for (j = 0; j < 2; j++) {
33190                //TODO: [Performance] Use binary search
33191                for (i = 0; i < ranges.length; i++) {
33192                    range = ranges[i];
33193
33194                    if (range.n > n) {
33195                        break;
33196                    }
33197
33198                    if (n <= range.m) {
33199                        if (!skipLoggingCapture) {
33200                            branch.state.logCapture(1);
33201                        }
33202
33203                        return resKind.ok;
33204                    }
33205                }
33206
33207                if (upperCh == null && pass.settings.ignoreCase) {
33208                    upperCh = ch.toUpperCase();
33209
33210                    // Invert case for the 2nd attempt;
33211                    if (ch === upperCh) {
33212                        ch = ch.toLowerCase();
33213                    } else {
33214                        ch = upperCh;
33215                    }
33216
33217                    n = ch.charCodeAt(0);
33218                }
33219            }
33220
33221            return resKind.nextBranch;
33222        },
33223
33224        _scanCharNegativeGroupToken: function (branches, branch, pass, token, skipLoggingCapture) {
33225            var resKind = this._branchResultKind;
33226            var index = branch.state.txtIndex;
33227            var ch = this._text[index];
33228
33229            if (ch == null) {
33230                return resKind.nextBranch;
33231            }
33232
33233            // Get result for positive group:
33234            var positiveRes = this._scanCharGroupToken(branches, branch, pass, token, true);
33235
33236            // Inverse the positive result:
33237            if (positiveRes === resKind.ok) {
33238                return resKind.nextBranch;
33239            }
33240
33241            if (!skipLoggingCapture) {
33242                branch.state.logCapture(1);
33243            }
33244
33245            return resKind.ok;
33246        },
33247
33248        _scanEscapeToken: function (branches, branch, pass, token) {
33249            return this._scanWithJsRegex(branches, branch, pass, token);
33250        },
33251
33252        _scanDotToken: function (textEndPos, branches, branch, pass) {
33253            var resKind = this._branchResultKind;
33254            var index = branch.state.txtIndex;
33255
33256            if (pass.settings.singleline) {
33257                if (index < textEndPos) {
33258                    branch.state.logCapture(1);
33259
33260                    return resKind.ok;
33261                }
33262            } else {
33263                if (index < textEndPos && this._text[index] !== "\n") {
33264                    branch.state.logCapture(1);
33265
33266                    return resKind.ok;
33267                }
33268            }
33269
33270            return resKind.nextBranch;
33271        },
33272
33273        _scanBackrefNumberToken: function (textEndPos, branches, branch, pass, token) {
33274            var resKind = this._branchResultKind;
33275
33276            var grCapture = branch.state.resolveBackref(token.data.slotId);
33277
33278            if (grCapture == null) {
33279                return resKind.nextBranch;
33280            }
33281
33282            var grCaptureTxt = this._text.slice(grCapture.capIndex, grCapture.capIndex + grCapture.capLength);
33283
33284            return this._scanLiteral(textEndPos, branches, branch, pass, grCaptureTxt);
33285        },
33286
33287        _scanBackrefNameToken: function (textEndPos, branches, branch, pass, token) {
33288            var resKind = this._branchResultKind;
33289
33290            var grCapture = branch.state.resolveBackref(token.data.slotId);
33291
33292            if (grCapture == null) {
33293                return resKind.nextBranch;
33294            }
33295
33296            var grCaptureTxt = this._text.slice(grCapture.capIndex, grCapture.capIndex + grCapture.capLength);
33297
33298            return this._scanLiteral(textEndPos, branches, branch, pass, grCaptureTxt);
33299        },
33300
33301        _scanAnchorToken: function (textEndPos, branches, branch, pass, token) {
33302            var resKind = this._branchResultKind;
33303            var index = branch.state.txtIndex;
33304
33305            if (token.value === "\\b" || token.value === "\\B") {
33306                var prevIsWord = index > 0 && this._scanWithJsRegex2(index - 1, "\\w") === resKind.ok;
33307                var currIsWord = this._scanWithJsRegex2(index, "\\w") === resKind.ok;
33308
33309                if ((prevIsWord === currIsWord) === (token.value === "\\B")) {
33310                    return resKind.ok;
33311                }
33312            } else if (token.value === "^") {
33313                if (index === 0) {
33314                    return resKind.ok;
33315                }
33316
33317                if (pass.settings.multiline && this._text[index - 1] === "\n") {
33318                    return resKind.ok;
33319                }
33320            } else if (token.value === "$") {
33321                if (index === textEndPos) {
33322                    return resKind.ok;
33323                }
33324
33325                if (pass.settings.multiline && this._text[index] === "\n") {
33326                    return resKind.ok;
33327                }
33328            } else if (token.value === "\\A") {
33329                if (index === 0) {
33330                    return resKind.ok;
33331                }
33332            } else if (token.value === "\\z") {
33333                if (index === textEndPos) {
33334                    return resKind.ok;
33335                }
33336            } else if (token.value === "\\Z") {
33337                if (index === textEndPos) {
33338                    return resKind.ok;
33339                }
33340
33341                if (index === textEndPos - 1 && this._text[index] === "\n") {
33342                    return resKind.ok;
33343                }
33344            } else if (token.value === "\\G") {
33345                return resKind.ok;
33346            }
33347
33348            return resKind.nextBranch;
33349        },
33350
33351        // ============================================================================================
33352        // Auxiliary functions
33353        // ============================================================================================
33354        _cloneSettings: function (settings) {
33355            var cloned = {
33356                ignoreCase: settings.ignoreCase,
33357                multiline: settings.multiline,
33358                singleline: settings.singleline,
33359                ignoreWhitespace: settings.ignoreWhitespace,
33360                explicitCapture: settings.explicitCapture
33361            };
33362
33363            return cloned;
33364        },
33365
33366        _combineScanResults: function (branch, srcState) {
33367            if (srcState != null) {
33368                var dstGroups = branch.state.groups;
33369                var srcGroups = srcState.groups;
33370                var srcGroupsLen = srcGroups.length;
33371                var i;
33372
33373                for (i = 0; i < srcGroupsLen; ++i) {
33374                    dstGroups.push(srcGroups[i]);
33375                }
33376
33377                return true;
33378            }
33379            return false;
33380        },
33381
33382        _getEmptyMatch: function () {
33383            var match = {
33384                capIndex: 0,    // start index of total capture
33385                capLength: 0,   // length of total capture
33386                success: false,
33387                value: "",
33388                groups: [],
33389                captures: []
33390            };
33391
33392            return match;
33393        },
33394
33395        _fillMatch: function (match, capIndex, capLength, textPos) {
33396            if (capIndex == null) {
33397                capIndex = textPos;
33398            }
33399
33400            match.capIndex = capIndex;
33401            match.capLength = capLength;
33402            match.success = true;
33403            match.value = this._text.slice(capIndex, capIndex + capLength);
33404
33405            match.groups.push({
33406                capIndex: capIndex,
33407                capLength: capLength,
33408                value: match.value,
33409                success: true,
33410                captures: [
33411                    {
33412                        capIndex: capIndex,
33413                        capLength: capLength,
33414                        value: match.value
33415                    }
33416                ]
33417            });
33418
33419            match.captures.push(match.groups[0].captures[0]);
33420        },
33421
33422        _checkTimeout: function () {
33423            if (this._timeoutTime < 0) {
33424                return;
33425            }
33426
33427            var time = new Date().getTime();
33428
33429            if (time >= this._timeoutTime) {
33430                throw new System.RegexMatchTimeoutException(this._text, this._pattern, System.TimeSpan.fromMilliseconds(this._timeoutMs));
33431            }
33432        }
33433    });
33434
33435    // @source RegexEngineBranch.js
33436
33437    H5.define("System.Text.RegularExpressions.RegexEngineBranch", {
33438        type: 0,
33439        value: 0,
33440        min: 0,
33441        max: 0,
33442
33443        isStarted: false,
33444        isNotFailing: false,
33445
33446        state: null,
33447
33448        ctor: function (branchType, currVal, minVal, maxVal, parentState) {
33449            this.$initialize();
33450
33451            this.type = branchType;
33452
33453            this.value = currVal;
33454            this.min = minVal;
33455            this.max = maxVal;
33456
33457            this.state = parentState != null ? parentState.clone() : new System.Text.RegularExpressions.RegexEngineState();
33458        },
33459
33460        pushPass: function (index, tokens, settings) {
33461            var pass = new System.Text.RegularExpressions.RegexEnginePass(index, tokens, settings);
33462
33463            this.state.passes.push(pass);
33464        },
33465
33466        peekPass: function () {
33467            return this.state.passes[this.state.passes.length - 1];
33468        },
33469
33470        popPass: function () {
33471            return this.state.passes.pop();
33472        },
33473
33474        hasPass: function () {
33475            return this.state.passes.length > 0;
33476        },
33477
33478        clone: function () {
33479            var cloned = new System.Text.RegularExpressions.RegexEngineBranch(this.type, this.value, this.min, this.max, this.state);
33480
33481            cloned.isNotFailing = this.isNotFailing;
33482
33483            return cloned;
33484        }
33485    });
33486
33487    // @source RegexEngineState.js
33488
33489    H5.define("System.Text.RegularExpressions.RegexEngineState", {
33490        txtIndex: 0, // current index
33491        capIndex: null, // first index of captured text
33492        capLength: 0, // current length
33493        passes: null,
33494        groups: null, // captured groups
33495
33496        ctor: function () {
33497            this.$initialize();
33498
33499            this.passes = [];
33500            this.groups = [];
33501        },
33502
33503        logCapture: function (length) {
33504            if (this.capIndex == null) {
33505                this.capIndex = this.txtIndex;
33506            }
33507
33508            this.txtIndex += length;
33509            this.capLength += length;
33510        },
33511
33512        logCaptureGroup: function (group, index, length) {
33513            this.groups.push({ rawIndex: group.rawIndex, slotId: group.packedSlotId, capIndex: index, capLength: length });
33514        },
33515
33516        logCaptureGroupBalancing: function (group, capIndex) {
33517            var balancingSlotId = group.balancingSlotId;
33518            var groups = this.groups;
33519            var index = groups.length - 1;
33520            var group2;
33521            var group2Index;
33522
33523            while (index >= 0) {
33524                if (groups[index].slotId === balancingSlotId) {
33525                    group2 = groups[index];
33526                    group2Index = index;
33527
33528                    break;
33529                }
33530                --index;
33531            }
33532
33533            if (group2 != null && group2Index != null) {
33534                groups.splice(group2Index, 1); // remove group2 from the collection
33535
33536                // Add balancing group value:
33537                if (group.constructs.name1 != null) {
33538                    var balCapIndex = group2.capIndex + group2.capLength;
33539                    var balCapLength = capIndex - balCapIndex;
33540
33541                    this.logCaptureGroup(group, balCapIndex, balCapLength);
33542                }
33543
33544                return true;
33545            }
33546
33547            return false;
33548        },
33549
33550        resolveBackref: function (packedSlotId) {
33551            var groups = this.groups;
33552            var index = groups.length - 1;
33553
33554            while (index >= 0) {
33555                if (groups[index].slotId === packedSlotId) {
33556                    return groups[index];
33557                }
33558
33559                --index;
33560            }
33561
33562            return null;
33563        },
33564
33565        clone: function () {
33566            var cloned = new System.Text.RegularExpressions.RegexEngineState();
33567            cloned.txtIndex = this.txtIndex;
33568            cloned.capIndex = this.capIndex;
33569            cloned.capLength = this.capLength;
33570
33571            // Clone passes:
33572            var clonedPasses = cloned.passes;
33573            var thisPasses = this.passes;
33574            var len = thisPasses.length;
33575            var clonedItem;
33576            var i;
33577
33578            for (i = 0; i < len; i++) {
33579                clonedItem = thisPasses[i].clone();
33580                clonedPasses.push(clonedItem);
33581            }
33582
33583            // Clone groups:
33584            var clonedGroups = cloned.groups;
33585            var thisGroups = this.groups;
33586            len = thisGroups.length;
33587
33588            for (i = 0; i < len; i++) {
33589                clonedItem = thisGroups[i];
33590                clonedGroups.push(clonedItem);
33591            }
33592
33593            return cloned;
33594        }
33595    });
33596
33597    // @source RegexEnginePass.js
33598
33599    H5.define("System.Text.RegularExpressions.RegexEnginePass", {
33600        index: 0,
33601        tokens: null,
33602        probe: null,
33603
33604        onHold: false,
33605        onHoldTextIndex: -1,
33606        alternationHandled: false,
33607
33608        settings: null,
33609
33610        ctor: function (index, tokens, settings) {
33611            this.$initialize();
33612
33613            this.index = index;
33614            this.tokens = tokens;
33615            this.settings = settings;
33616        },
33617
33618        clearState: function (settings) {
33619            this.index = 0;
33620            this.probe = null;
33621            this.onHold = false;
33622            this.onHoldTextIndex = -1;
33623            this.alternationHandled = false;
33624            this.settings = settings;
33625        },
33626
33627        clone: function () {
33628            var cloned = new System.Text.RegularExpressions.RegexEnginePass(this.index, this.tokens, this.settings);
33629
33630            cloned.onHold = this.onHold;
33631            cloned.onHoldTextIndex = this.onHoldTextIndex;
33632            cloned.alternationHandled = this.alternationHandled;
33633            cloned.probe = this.probe != null ? this.probe.clone() : null;
33634
33635            return cloned;
33636        }
33637    });
33638
33639    // @source RegexEngineProbe.js
33640
33641    H5.define("System.Text.RegularExpressions.RegexEngineProbe", {
33642        min: 0,
33643        max: 0,
33644        value: 0,
33645        isLazy: false,
33646        forced: false,
33647
33648        ctor: function (min, max, value, isLazy) {
33649            this.$initialize();
33650
33651            this.min = min;
33652            this.max = max;
33653            this.value = value;
33654            this.isLazy = isLazy;
33655            this.forced = false;
33656        },
33657
33658        clone: function () {
33659            var cloned = new System.Text.RegularExpressions.RegexEngineProbe(this.min, this.max, this.value, this.isLazy);
33660
33661            cloned.forced = this.forced;
33662
33663            return cloned;
33664        }
33665    });
33666
33667    // @source RegexEngineParser.js
33668
33669    H5.define("System.Text.RegularExpressions.RegexEngineParser", {
33670        statics: {
33671            _hexSymbols: "0123456789abcdefABCDEF",
33672            _octSymbols: "01234567",
33673            _decSymbols: "0123456789",
33674
33675            _escapedChars: "abtrvfnexcu",
33676            _escapedCharClasses: "pPwWsSdD",
33677            _escapedAnchors: "AZzGbB",
33678            _escapedSpecialSymbols: " .,$^{}[]()|*+-=?\\|/\"':;~!@#%&",
33679
33680            _whiteSpaceChars: " \r\n\t\v\f\u00A0\uFEFF", //TODO: This is short version of .NET WhiteSpace category.
33681            _unicodeCategories: ["Lu", "Ll", "Lt", "Lm", "Lo", "L", "Mn", "Mc", "Me", "M", "Nd", "Nl", "No", "N", "Pc", "Pd", "Ps", "Pe", "Pi", "Pf", "Po", "P", "Sm", "Sc", "Sk", "So", "S", "Zs", "Zl", "Zp", "Z", "Cc", "Cf", "Cs", "Co", "Cn", "C"],
33682            _namedCharBlocks: ["IsBasicLatin", "IsLatin-1Supplement", "IsLatinExtended-A", "IsLatinExtended-B", "IsIPAExtensions", "IsSpacingModifierLetters", "IsCombiningDiacriticalMarks", "IsGreek", "IsGreekandCoptic", "IsCyrillic", "IsCyrillicSupplement", "IsArmenian", "IsHebrew", "IsArabic", "IsSyriac", "IsThaana", "IsDevanagari", "IsBengali", "IsGurmukhi", "IsGujarati", "IsOriya", "IsTamil", "IsTelugu", "IsKannada", "IsMalayalam", "IsSinhala", "IsThai", "IsLao", "IsTibetan", "IsMyanmar", "IsGeorgian", "IsHangulJamo", "IsEthiopic", "IsCherokee", "IsUnifiedCanadianAboriginalSyllabics", "IsOgham", "IsRunic", "IsTagalog", "IsHanunoo", "IsBuhid", "IsTagbanwa", "IsKhmer", "IsMongolian", "IsLimbu", "IsTaiLe", "IsKhmerSymbols", "IsPhoneticExtensions", "IsLatinExtendedAdditional", "IsGreekExtended", "IsGeneralPunctuation", "IsSuperscriptsandSubscripts", "IsCurrencySymbols", "IsCombiningDiacriticalMarksforSymbols", "IsCombiningMarksforSymbols", "IsLetterlikeSymbols", "IsNumberForms", "IsArrows", "IsMathematicalOperators", "IsMiscellaneousTechnical", "IsControlPictures", "IsOpticalCharacterRecognition", "IsEnclosedAlphanumerics", "IsBoxDrawing", "IsBlockElements", "IsGeometricShapes", "IsMiscellaneousSymbols", "IsDingbats", "IsMiscellaneousMathematicalSymbols-A", "IsSupplementalArrows-A", "IsBraillePatterns", "IsSupplementalArrows-B", "IsMiscellaneousMathematicalSymbols-B", "IsSupplementalMathematicalOperators", "IsMiscellaneousSymbolsandArrows", "IsCJKRadicalsSupplement", "IsKangxiRadicals", "IsIdeographicDescriptionCharacters", "IsCJKSymbolsandPunctuation", "IsHiragana", "IsKatakana", "IsBopomofo", "IsHangulCompatibilityJamo", "IsKanbun", "IsBopomofoExtended", "IsKatakanaPhoneticExtensions", "IsEnclosedCJKLettersandMonths", "IsCJKCompatibility", "IsCJKUnifiedIdeographsExtensionA", "IsYijingHexagramSymbols", "IsCJKUnifiedIdeographs", "IsYiSyllables", "IsYiRadicals", "IsHangulSyllables", "IsHighSurrogates", "IsHighPrivateUseSurrogates", "IsLowSurrogates", "IsPrivateUse or IsPrivateUseArea", "IsCJKCompatibilityIdeographs", "IsAlphabeticPresentationForms", "IsArabicPresentationForms-A", "IsVariationSelectors", "IsCombiningHalfMarks", "IsCJKCompatibilityForms", "IsSmallFormVariants", "IsArabicPresentationForms-B", "IsHalfwidthandFullwidthForms", "IsSpecials"],
33683            _controlChars: ["@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_"],
33684
33685            tokenTypes: {
33686                literal: 0,
33687
33688                escChar: 110,
33689                escCharOctal: 111,
33690                escCharHex: 112,
33691                escCharCtrl: 113,
33692                escCharUnicode: 114,
33693                escCharOther: 115,
33694
33695                escCharClass: 120,
33696                escCharClassCategory: 121,
33697                escCharClassBlock: 122,
33698                escCharClassDot: 123,
33699
33700                escAnchor: 130,
33701
33702                escBackrefNumber: 140,
33703                escBackrefName: 141,
33704
33705                charGroup: 200,
33706                charNegativeGroup: 201,
33707                charInterval: 202,
33708
33709                anchor: 300,
33710
33711                group: 400,
33712                groupImnsx: 401,
33713                groupImnsxMisc: 402,
33714
33715                groupConstruct: 403,
33716                groupConstructName: 404,
33717                groupConstructImnsx: 405,
33718                groupConstructImnsxMisc: 406,
33719
33720                quantifier: 500,
33721                quantifierN: 501,
33722                quantifierNM: 502,
33723
33724                alternation: 600,
33725                alternationGroup: 601,
33726                alternationGroupCondition: 602,
33727                alternationGroupRefNumberCondition: 603,
33728                alternationGroupRefNameCondition: 604,
33729
33730                commentInline: 700,
33731                commentXMode: 701
33732            },
33733
33734            parsePattern: function (pattern, settings) {
33735                var scope = System.Text.RegularExpressions.RegexEngineParser;
33736
33737                // Parse tokens in the original pattern:
33738                var tokens = scope._parsePatternImpl(pattern, settings, 0, pattern.length);
33739
33740                // Collect and fill group descriptors into Group tokens.
33741                // We need do it before any token modification.
33742                var groups = [];
33743                scope._fillGroupDescriptors(tokens, groups);
33744
33745                // Fill Sparse Info:
33746                var sparseSettings = scope._getGroupSparseInfo(groups);
33747
33748                // Fill balancing info for the groups with "name2":
33749                scope._fillBalancingGroupInfo(groups, sparseSettings);
33750
33751                // Transform tokens for usage in JS RegExp:
33752                scope._preTransformBackrefTokens(pattern, tokens, sparseSettings);
33753                scope._transformRawTokens(settings, tokens, sparseSettings, [], [], 0);
33754
33755                // Update group descriptors as tokens have been transformed (at least indexes were changed):
33756                scope._updateGroupDescriptors(tokens);
33757
33758                var result = {
33759                    groups: groups,
33760                    sparseSettings: sparseSettings,
33761                    isContiguous: settings.isContiguous || false,
33762                    shouldFail: settings.shouldFail || false,
33763                    tokens: tokens
33764                };
33765
33766                return result;
33767            },
33768
33769            _transformRawTokens: function (settings, tokens, sparseSettings, allowedPackedSlotIds, nestedGroupIds, nestingLevel) {
33770                var scope = System.Text.RegularExpressions.RegexEngineParser;
33771                var tokenTypes = scope.tokenTypes;
33772                var prevToken;
33773                var token;
33774                var value;
33775                var packedSlotId;
33776                var groupNumber;
33777                var matchRes;
33778                var localNestedGroupIds;
33779                var localSettings;
33780                var qtoken;
33781                var i;
33782
33783                // Transform/adjust tokens collection to work with JS RegExp:
33784                for (i = 0; i < tokens.length; i++) {
33785                    token = tokens[i];
33786
33787                    if (i < tokens.length - 1) {
33788                        qtoken = tokens[i + 1];
33789
33790                        switch (qtoken.type) {
33791                            case tokenTypes.quantifier:
33792                            case tokenTypes.quantifierN:
33793                            case tokenTypes.quantifierNM:
33794                                token.qtoken = qtoken;
33795                                tokens.splice(i + 1, 1);
33796                                --i;
33797                        }
33798                    }
33799
33800                    if (token.type === tokenTypes.escBackrefNumber) {
33801                        groupNumber = token.data.number;
33802                        packedSlotId = sparseSettings.getPackedSlotIdBySlotNumber(groupNumber);
33803
33804                        if (packedSlotId == null) {
33805                            throw new System.ArgumentException.$ctor1("Reference to undefined group number " + groupNumber.toString() + ".");
33806                        }
33807
33808                        if (allowedPackedSlotIds.indexOf(packedSlotId) < 0) {
33809                            settings.shouldFail = true; // Backreferences to unreachable group number lead to an empty match.
33810
33811                            continue;
33812                        }
33813
33814                        token.data.slotId = packedSlotId;
33815                    } else if (token.type === tokenTypes.escBackrefName) {
33816                        value = token.data.name;
33817                        packedSlotId = sparseSettings.getPackedSlotIdBySlotName(value);
33818
33819                        if (packedSlotId == null) {
33820                            // TODO: Move this code to earlier stages
33821                            // If the name is number, treat the backreference as a numbered:
33822                            matchRes = scope._matchChars(value, 0, value.length, scope._decSymbols);
33823
33824                            if (matchRes.matchLength === value.length) {
33825                                value = "\\" + value;
33826                                scope._updatePatternToken(token, tokenTypes.escBackrefNumber, token.index, value.length, value);
33827                                --i; // process the token again
33828
33829                                continue;
33830                            }
33831
33832                            throw new System.ArgumentException.$ctor1("Reference to undefined group name '" + value + "'.");
33833                        }
33834
33835                        if (allowedPackedSlotIds.indexOf(packedSlotId) < 0) {
33836                            settings.shouldFail = true; // Backreferences to unreachable group number lead to an empty match.
33837
33838                            continue;
33839                        }
33840
33841                        token.data.slotId = packedSlotId;
33842                    } else if (token.type === tokenTypes.anchor || token.type === tokenTypes.escAnchor) {
33843                        if (token.value === "\\G") {
33844                            if (nestingLevel === 0 && i === 0) {
33845                                settings.isContiguous = true;
33846                            } else {
33847                                settings.shouldFail = true;
33848                            }
33849
33850                            tokens.splice(i, 1);
33851                            --i;
33852
33853                            continue;
33854                        }
33855                    } else if (token.type === tokenTypes.commentInline || token.type === tokenTypes.commentXMode) {
33856                        // We can safely remove comments from the pattern
33857                        tokens.splice(i, 1);
33858                        --i;
33859
33860                        continue;
33861                    } else if (token.type === tokenTypes.literal) {
33862                        // Combine literal tokens for better performance:
33863                        if (i > 0 && !token.qtoken) {
33864                            prevToken = tokens[i - 1];
33865
33866                            if (prevToken.type === tokenTypes.literal && !prevToken.qtoken) {
33867                                prevToken.value += token.value;
33868                                prevToken.length += token.length;
33869
33870                                tokens.splice(i, 1);
33871                                --i;
33872
33873                                continue;
33874                            }
33875                        }
33876                    } else if (token.type === tokenTypes.alternationGroupCondition) {
33877                        if (token.data != null) {
33878                            if (token.data.number != null) {
33879                                packedSlotId = sparseSettings.getPackedSlotIdBySlotNumber(token.data.number);
33880
33881                                if (packedSlotId == null) {
33882                                    throw new System.ArgumentException.$ctor1("Reference to undefined group number " + value + ".");
33883                                }
33884
33885                                token.data.packedSlotId = packedSlotId;
33886                                scope._updatePatternToken(token, tokenTypes.alternationGroupRefNumberCondition, token.index, token.length, token.value);
33887                            } else {
33888                                packedSlotId = sparseSettings.getPackedSlotIdBySlotName(token.data.name);
33889
33890                                if (packedSlotId != null) {
33891                                    token.data.packedSlotId = packedSlotId;
33892                                    scope._updatePatternToken(token, tokenTypes.alternationGroupRefNameCondition, token.index, token.length, token.value);
33893                                } else {
33894                                    delete token.data;
33895                                }
33896                            }
33897                        }
33898                    }
33899
33900                    // Update children tokens:
33901                    if (token.children && token.children.length) {
33902                        localNestedGroupIds = token.type === tokenTypes.group ? [token.group.rawIndex] : [];
33903                        localNestedGroupIds = localNestedGroupIds.concat(nestedGroupIds);
33904
33905                        localSettings = token.localSettings || settings;
33906                        scope._transformRawTokens(localSettings, token.children, sparseSettings, allowedPackedSlotIds, localNestedGroupIds, nestingLevel + 1);
33907                        settings.shouldFail = settings.shouldFail || localSettings.shouldFail;
33908                        settings.isContiguous = settings.isContiguous || localSettings.isContiguous;
33909                    }
33910
33911                    // Group is processed. Now it can be referenced with Backref:
33912                    if (token.type === tokenTypes.group) {
33913                        allowedPackedSlotIds.push(token.group.packedSlotId);
33914                    }
33915                }
33916            },
33917
33918            _fillGroupDescriptors: function (tokens, groups) {
33919                var scope = System.Text.RegularExpressions.RegexEngineParser;
33920                var group;
33921                var i;
33922
33923                // Fill group structure:
33924                scope._fillGroupStructure(groups, tokens, null);
33925
33926                // Assign name or id:
33927                var groupId = 1;
33928
33929                for (i = 0; i < groups.length; i++) {
33930                    group = groups[i];
33931
33932                    if (group.constructs.name1 != null) {
33933                        group.name = group.constructs.name1;
33934                        group.hasName = true;
33935                    } else {
33936                        group.hasName = false;
33937                        group.name = groupId.toString();
33938                        ++groupId;
33939                    }
33940                }
33941            },
33942
33943            _fillGroupStructure: function (groups, tokens, parentGroup) {
33944                var scope = System.Text.RegularExpressions.RegexEngineParser;
33945                var tokenTypes = scope.tokenTypes;
33946                var group;
33947                var token;
33948                var constructs;
33949                var constructCandidateToken;
33950                var hasChildren;
33951                var i;
33952
33953                for (i = 0; i < tokens.length; i++) {
33954                    token = tokens[i];
33955                    hasChildren = token.children && token.children.length;
33956
33957                    if (token.type === tokenTypes.group || token.type === tokenTypes.groupImnsx || token.type === tokenTypes.groupImnsxMisc) {
33958                        group = {
33959                            rawIndex: groups.length + 1,
33960                            number: -1,
33961
33962                            parentGroup: null,
33963                            innerGroups: [],
33964
33965                            name: null,
33966                            hasName: false,
33967
33968                            constructs: null,
33969                            quantifier: null,
33970
33971                            exprIndex: -1,
33972                            exprLength: 0,
33973                            expr: null,
33974                            exprFull: null
33975                        };
33976
33977                        token.group = group;
33978
33979                        if (token.type === tokenTypes.group) {
33980                            groups.push(group);
33981
33982                            if (parentGroup != null) {
33983                                token.group.parentGroup = parentGroup;
33984                                parentGroup.innerGroups.push(group);
33985                            }
33986                        }
33987
33988                        // fill group constructs:
33989                        constructCandidateToken = hasChildren ? token.children[0] : null;
33990                        group.constructs = scope._fillGroupConstructs(constructCandidateToken);
33991                        constructs = group.constructs;
33992
33993                        if (token.isNonCapturingExplicit) {
33994                            delete token.isNonCapturingExplicit;
33995                            constructs.isNonCapturingExplicit = true;
33996                        }
33997
33998                        if (token.isEmptyCapturing) {
33999                            delete token.isEmptyCapturing;
34000                            constructs.emptyCapture = true;
34001                        }
34002
34003                        constructs.skipCapture =
34004                            constructs.isNonCapturing ||
34005                            constructs.isNonCapturingExplicit ||
34006                            constructs.isNonbacktracking ||
34007                            constructs.isPositiveLookahead ||
34008                            constructs.isNegativeLookahead ||
34009                            constructs.isPositiveLookbehind ||
34010                            constructs.isNegativeLookbehind ||
34011                            (constructs.name1 == null && constructs.name2 != null);
34012                    }
34013
34014                    // fill group descriptors for inner tokens:
34015                    if (hasChildren) {
34016                        scope._fillGroupStructure(groups, token.children, token.group);
34017                    }
34018                }
34019            },
34020
34021            _getGroupSparseInfo: function (groups) {
34022                var scope = System.Text.RegularExpressions.RegexEngineParser;
34023
34024                var explNumberedGroups = {};
34025                var explNumberedGroupKeys = [];
34026                var explNamedGroups = {};
34027                var explGroups;
34028
34029                var numberedGroups;
34030                var slotNumber;
34031                var slotName;
34032                var group;
34033                var i;
34034                var j;
34035
34036                var sparseSlotMap = { 0: 0 };
34037                sparseSlotMap.lastSlot = 0;
34038
34039                var sparseSlotNameMap = { "0": 0 };
34040                sparseSlotNameMap.keys = ["0"];
34041
34042                // Fill Explicit Numbers:
34043                for (i = 0; i < groups.length; i++) {
34044                    group = groups[i];
34045
34046                    if (group.constructs.skipCapture) {
34047                        continue;
34048                    }
34049
34050                    if (group.constructs.isNumberName1) {
34051                        slotNumber = parseInt(group.constructs.name1);
34052                        explNumberedGroupKeys.push(slotNumber);
34053
34054                        if (explNumberedGroups[slotNumber]) {
34055                            explNumberedGroups[slotNumber].push(group);
34056                        } else {
34057                            explNumberedGroups[slotNumber] = [group];
34058                        }
34059                    } else {
34060                        slotName = group.constructs.name1;
34061
34062                        if (explNamedGroups[slotName]) {
34063                            explNamedGroups[slotName].push(group);
34064                        } else {
34065                            explNamedGroups[slotName] = [group];
34066                        }
34067                    }
34068                }
34069
34070                // Sort explicitly set Number names:
34071                var sortNum = function (a, b) {
34072                    return a - b;
34073                };
34074
34075                explNumberedGroupKeys.sort(sortNum);
34076
34077                // Add group without names first (emptyCapture = false first, than emptyCapture = true):
34078                var allowEmptyCapture = false;
34079
34080                for (j = 0; j < 2; j++) {
34081                    for (i = 0; i < groups.length; i++) {
34082                        group = groups[i];
34083
34084                        if (group.constructs.skipCapture) {
34085                            continue;
34086                        }
34087
34088                        if ((group.constructs.emptyCapture === true) !== allowEmptyCapture) {
34089                            continue;
34090                        }
34091
34092                        slotNumber = sparseSlotNameMap.keys.length;
34093
34094                        if (!group.hasName) {
34095                            numberedGroups = [group];
34096                            explGroups = explNumberedGroups[slotNumber];
34097
34098                            if (explGroups != null) {
34099                                numberedGroups = numberedGroups.concat(explGroups);
34100                                explNumberedGroups[slotNumber] = null;
34101                            }
34102
34103                            scope._addSparseSlotForSameNamedGroups(numberedGroups, slotNumber, sparseSlotMap, sparseSlotNameMap);
34104                        }
34105                    }
34106                    allowEmptyCapture = true;
34107                }
34108
34109                // Then add named groups:
34110                for (i = 0; i < groups.length; i++) {
34111                    group = groups[i];
34112
34113                    if (group.constructs.skipCapture) {
34114                        continue;
34115                    }
34116
34117                    if (!group.hasName || group.constructs.isNumberName1) {
34118                        continue;
34119                    }
34120
34121                    // If the slot is already occupied by an explicitly numbered group,
34122                    // add this group to the slot:
34123                    slotNumber = sparseSlotNameMap.keys.length;
34124                    explGroups = explNumberedGroups[slotNumber];
34125
34126                    while (explGroups != null) {
34127                        scope._addSparseSlotForSameNamedGroups(explGroups, slotNumber, sparseSlotMap, sparseSlotNameMap);
34128
34129                        explNumberedGroups[slotNumber] = null; // Group is processed.
34130                        slotNumber = sparseSlotNameMap.keys.length;
34131                        explGroups = explNumberedGroups[slotNumber];
34132                    }
34133
34134                    if (!group.constructs.isNumberName1) {
34135                        slotNumber = sparseSlotNameMap.keys.length;
34136                        explGroups = explNumberedGroups[slotNumber];
34137
34138                        while (explGroups != null) {
34139                            scope._addSparseSlotForSameNamedGroups(explGroups, slotNumber, sparseSlotMap, sparseSlotNameMap);
34140
34141                            explNumberedGroups[slotNumber] = null; // Group is processed.
34142                            slotNumber = sparseSlotNameMap.keys.length;
34143                            explGroups = explNumberedGroups[slotNumber];
34144                        }
34145                    }
34146
34147                    // Add the named group(s) to the 1st free slot:
34148                    slotName = group.constructs.name1;
34149                    explGroups = explNamedGroups[slotName];
34150
34151                    if (explGroups != null) {
34152                        scope._addSparseSlotForSameNamedGroups(explGroups, slotNumber, sparseSlotMap, sparseSlotNameM
34152ap);
34153                        explNamedGroups[slotName] = null;  // Group is processed.
34154                    }
34155                }
34156
34157                // Add the rest explicitly numbered groups:
34158                for (i = 0; i < explNumberedGroupKeys.length; i++) {
34159                    slotNumber = explNumberedGroupKeys[i];
34160                    explGroups = explNumberedGroups[slotNumber];
34161
34162                    if (explGroups != null) {
34163                        scope._addSparseSlotForSameNamedGroups(explGroups, slotNumber, sparseSlotMap, sparseSlotNameMap);
34164
34165                        explNumberedGroups[slotNumber] = null; // Group is processed.
34166                    }
34167                }
34168
34169                return {
34170                    isSparse: sparseSlotMap.isSparse || false, //sparseSlotNumbers.length !== (1 + sparseSlotNumbers[sparseSlotNumbers.length - 1]),
34171                    sparseSlotMap: sparseSlotMap,           // <SlotNumber, PackedSlotId>
34172                    sparseSlotNameMap: sparseSlotNameMap,   // <SlotName, PackedSlotId>
34173
34174                    getPackedSlotIdBySlotNumber: function (slotNumber) {
34175                        return this.sparseSlotMap[slotNumber];
34176                    },
34177
34178                    getPackedSlotIdBySlotName: function (slotName) {
34179                        return this.sparseSlotNameMap[slotName];
34180                    }
34181                };
34182            },
34183
34184            _addSparseSlot: function (group, slotNumber, sparseSlotMap, sparseSlotNameMap) {
34185                var packedSlotId = sparseSlotNameMap.keys.length; // 0-based index. Raw Slot number, 0,1..n (without gaps)
34186
34187                group.packedSlotId = packedSlotId;
34188
34189                sparseSlotMap[slotNumber] = packedSlotId;
34190                sparseSlotNameMap[group.name] = packedSlotId;
34191                sparseSlotNameMap.keys.push(group.name);
34192
34193                if (!sparseSlotMap.isSparse && ((slotNumber - sparseSlotMap.lastSlot) > 1)) {
34194                    sparseSlotMap.isSparse = true;
34195                }
34196
34197                sparseSlotMap.lastSlot = slotNumber;
34198            },
34199
34200            _addSparseSlotForSameNamedGroups: function (groups, slotNumber, sparseSlotMap, sparseSlotNameMap) {
34201                var scope = System.Text.RegularExpressions.RegexEngineParser;
34202                var i;
34203
34204                scope._addSparseSlot(groups[0], slotNumber, sparseSlotMap, sparseSlotNameMap);
34205                var sparseSlotId = groups[0].sparseSlotId;
34206                var packedSlotId = groups[0].packedSlotId;
34207
34208                // Assign SlotID for all expl. named groups in this slot.
34209                if (groups.length > 1) {
34210                    for (i = 1; i < groups.length; i++) {
34211                        groups[i].sparseSlotId = sparseSlotId;
34212                        groups[i].packedSlotId = packedSlotId;
34213                    }
34214                }
34215            },
34216
34217            _fillGroupConstructs: function (childToken) {
34218                var scope = System.Text.RegularExpressions.RegexEngineParser;
34219                var tokenTypes = scope.tokenTypes;
34220                var constructs = {
34221                    name1: null,
34222                    name2: null,
34223
34224                    isNumberName1: false,
34225                    isNumberName2: false,
34226
34227                    isNonCapturing: false,
34228                    isNonCapturingExplicit: false,
34229
34230                    isIgnoreCase: null,
34231                    isMultiline: null,
34232                    isExplicitCapture: null,
34233                    isSingleLine: null,
34234                    isIgnoreWhitespace: null,
34235
34236                    isPositiveLookahead: false,
34237                    isNegativeLookahead: false,
34238                    isPositiveLookbehind: false,
34239                    isNegativeLookbehind: false,
34240
34241                    isNonbacktracking: false
34242                };
34243
34244                if (childToken == null) {
34245                    return constructs;
34246                }
34247
34248                if (childToken.type === tokenTypes.groupConstruct) {
34249                    // ?:
34250                    // ?=
34251                    // ?!
34252                    // ?<=
34253                    // ?<!
34254                    // ?>
34255
34256                    switch (childToken.value) {
34257                        case "?:":
34258                            constructs.isNonCapturing = true;
34259                            break;
34260
34261                        case "?=":
34262                            constructs.isPositiveLookahead = true;
34263                            break;
34264
34265                        case "?!":
34266                            constructs.isNegativeLookahead = true;
34267                            break;
34268
34269                        case "?>":
34270                            constructs.isNonbacktracking = true;
34271                            break;
34272
34273                        case "?<=":
34274                            constructs.isPositiveLookbehind = true;
34275                            break;
34276
34277                        case "?<!":
34278                            constructs.isNegativeLookbehind = true;
34279                            break;
34280
34281                        default:
34282                            throw new System.ArgumentException.$ctor1("Unrecognized grouping construct.");
34283                    }
34284                } else if (childToken.type === tokenTypes.groupConstructName) {
34285                    // ?<name1>
34286                    // ?'name1'
34287                    // ?<name1-name2>
34288                    // ?'name1-name2'
34289
34290                    var nameExpr = childToken.value.slice(2, childToken.length - 1);
34291                    var groupNames = nameExpr.split("-");
34292
34293                    if (groupNames.length === 0 || groupNames.length > 2) {
34294                        throw new System.ArgumentException.$ctor1("Invalid group name.");
34295                    }
34296
34297                    if (groupNames[0].length) {
34298                        constructs.name1 = groupNames[0];
34299
34300                        var nameRes1 = scope._validateGroupName(groupNames[0]);
34301
34302                        constructs.isNumberName1 = nameRes1.isNumberName;
34303                    }
34304
34305                    if (groupNames.length === 2) {
34306                        constructs.name2 = groupNames[1];
34307
34308                        var nameRes2 = scope._validateGroupName(groupNames[1]);
34309
34310                        constructs.isNumberName2 = nameRes2.isNumberName;
34311                    }
34312                } else if (childToken.type === tokenTypes.groupConstructImnsx || childToken.type === tokenTypes.groupConstructImnsxMisc) {
34313                    // ?imnsx-imnsx:
34314                    var imnsxPostfixLen = childToken.type === tokenTypes.groupConstructImnsx ? 1 : 0;
34315                    var imnsxExprLen = childToken.length - 1 - imnsxPostfixLen; // - prefix - postfix
34316                    var imnsxVal = true;
34317                    var ch;
34318                    var i;
34319
34320                    for (i = 1; i <= imnsxExprLen; i++) {
34321                        ch = childToken.value[i];
34322
34323                        if (ch === "-") {
34324                            imnsxVal = false;
34325                        } else if (ch === "i") {
34326                            constructs.isIgnoreCase = imnsxVal;
34327                        } else if (ch === "m") {
34328                            constructs.isMultiline = imnsxVal;
34329                        } else if (ch === "n") {
34330                            constructs.isExplicitCapture = imnsxVal;
34331                        } else if (ch === "s") {
34332                            constructs.isSingleLine = imnsxVal;
34333                        } else if (ch === "x") {
34334                            constructs.isIgnoreWhitespace = imnsxVal;
34335                        }
34336                    }
34337                }
34338
34339                return constructs;
34340            },
34341
34342            _validateGroupName: function (name) {
34343                if (!name || !name.length) {
34344                    throw new System.ArgumentException.$ctor1("Invalid group name: Group names must begin with a word character.");
34345                }
34346
34347                var isDigit = name[0] >= "0" && name[0] <= "9";
34348
34349                if (isDigit) {
34350                    var scope = System.Text.RegularExpressions.RegexEngineParser;
34351                    var res = scope._matchChars(name, 0, name.length, scope._decSymbols);
34352
34353                    if (res.matchLength !== name.length) {
34354                        throw new System.ArgumentException.$ctor1("Invalid group name: Group names must begin with a word character.");
34355                    }
34356                }
34357
34358                return {
34359                    isNumberName: isDigit
34360                };
34361            },
34362
34363            _fillBalancingGroupInfo: function (groups, sparseSettings) {
34364                var group;
34365                var i;
34366
34367                // Assign name or id:
34368                for (i = 0; i < groups.length; i++) {
34369                    group = groups[i];
34370
34371                    if (group.constructs.name2 != null) {
34372                        group.isBalancing = true;
34373
34374                        group.balancingSlotId = sparseSettings.getPackedSlotIdBySlotName(group.constructs.name2);
34375
34376                        if (group.balancingSlotId == null) {
34377                            throw new System.ArgumentException.$ctor1("Reference to undefined group name '" + group.constructs.name2 + "'.");
34378                        }
34379                    }
34380                }
34381            },
34382
34383            _preTransformBackrefTokens: function (pattern, tokens, sparseSettings) {
34384                var scope = System.Text.RegularExpressions.RegexEngineParser;
34385                var tokenTypes = scope.tokenTypes;
34386
34387                var groupNumber;
34388                var octalCharToken;
34389                var extraLength;
34390                var literalToken;
34391                var token;
34392                var i;
34393
34394                for (i = 0; i < tokens.length; i++) {
34395                    token = tokens[i];
34396
34397                    if (token.type === tokenTypes.escBackrefNumber) {
34398                        groupNumber = token.data.number;
34399
34400                        if (groupNumber >= 1 && sparseSettings.getPackedSlotIdBySlotNumber(groupNumber) != null) {
34401                            // Expressions from \10 and greater are considered backreferences
34402                            // if there is a group corresponding to that number;
34403                            // otherwise, they are interpreted as octal codes.
34404                            continue; // validated
34405                        }
34406
34407                        if (groupNumber <= 9) {
34408                            // The expressions \1 through \9 are always interpreted as backreferences, and not as octal codes.
34409                            throw new System.ArgumentException.$ctor1("Reference to undefined group number " + groupNumber.toString() + ".");
34410                        }
34411
34412                        // Otherwise, transform the token to OctalNumber:
34413                        octalCharToken = scope._parseOctalCharToken(token.value, 0, token.length);
34414
34415                        if (octalCharToken == null) {
34416                            throw new System.ArgumentException.$ctor1("Unrecognized escape sequence " + token.value.slice(0, 2) + ".");
34417                        }
34418
34419                        extraLength = token.length - octalCharToken.length;
34420                        scope._modifyPatternToken(token, pattern, tokenTypes.escCharOctal, null, octalCharToken.length);
34421                        token.data = octalCharToken.data;
34422
34423                        if (extraLength > 0) {
34424                            literalToken = scope._createPatternToken(pattern, tokenTypes.literal, token.index + token.length, extraLength);
34425                            tokens.splice(i + 1, 0, literalToken);
34426                        }
34427                    }
34428
34429                    if (token.children && token.children.length) {
34430                        scope._preTransformBackrefTokens(pattern, token.children, sparseSettings);
34431                    }
34432                }
34433            },
34434
34435            _updateGroupDescriptors: function (tokens, parentIndex) {
34436                var scope = System.Text.RegularExpressions.RegexEngineParser;
34437                var tokenTypes = scope.tokenTypes;
34438                var group;
34439                var token;
34440                var quantCandidateToken;
34441                var childrenValue;
34442                var childrenIndex;
34443                var i;
34444
34445                var index = parentIndex || 0;
34446
34447                for (i = 0; i < tokens.length; i++) {
34448                    token = tokens[i];
34449                    token.index = index;
34450
34451                    // Calculate children indexes/lengths to update parent length:
34452                    if (token.children) {
34453                        childrenIndex = token.childrenPostfix.length;
34454                        scope._updateGroupDescriptors(token.children, index + childrenIndex);
34455
34456                        // Update parent value if children have been changed:
34457                        childrenValue = scope._constructPattern(token.children);
34458                        token.value = token.childrenPrefix + childrenValue + token.childrenPostfix;
34459                        token.length = token.value.length;
34460                    }
34461
34462                    // Update group information:
34463                    if (token.type === tokenTypes.group && token.group) {
34464                        group = token.group;
34465                        group.exprIndex = token.index;
34466                        group.exprLength = token.length;
34467
34468                        if (i + 1 < tokens.length) {
34469                            quantCandidateToken = tokens[i + 1];
34470
34471                            if (quantCandidateToken.type === tokenTypes.quantifier ||
34472                                quantCandidateToken.type === tokenTypes.quantifierN ||
34473                                quantCandidateToken.type === tokenTypes.quantifierNM) {
34474                                group.quantifier = quantCandidateToken.value;
34475                            }
34476                        }
34477
34478                        group.expr = token.value;
34479                        group.exprFull = group.expr + (group.quantifier != null ? group.quantifier : "");
34480                    }
34481
34482                    // Update current index:
34483                    index += token.length;
34484                }
34485            },
34486
34487            _constructPattern: function (tokens) {
34488                var pattern = "";
34489                var token;
34490                var i;
34491
34492                for (i = 0; i < tokens.length; i++) {
34493                    token = tokens[i];
34494                    pattern += token.value;
34495                }
34496
34497                return pattern;
34498            },
34499
34500            _parsePatternImpl: function (pattern, settings, startIndex, endIndex) {
34501                if (pattern == null) {
34502                    throw new System.ArgumentNullException.$ctor1("pattern");
34503                }
34504
34505                if (startIndex < 0 || startIndex > pattern.length) {
34506                    throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
34507                }
34508
34509                if (endIndex < startIndex || endIndex > pattern.length) {
34510                    throw new System.ArgumentOutOfRangeException.$ctor1("endIndex");
34511                }
34512
34513                var scope = System.Text.RegularExpressions.RegexEngineParser;
34514                var tokenTypes = scope.tokenTypes;
34515                var tokens = [];
34516                var token;
34517                var ch;
34518                var i;
34519
34520                i = startIndex;
34521
34522                while (i < endIndex) {
34523                    ch = pattern[i];
34524
34525                    // Ignore whitespaces (if it was requested):
34526                    if (settings.ignoreWhitespace && scope._whiteSpaceChars.indexOf(ch) >= 0) {
34527                        ++i;
34528
34529                        continue;
34530                    }
34531
34532                    if (ch === ".") {
34533                        token = scope._parseDotToken(pattern, i, endIndex);
34534                    } else if (ch === "\\") {
34535                        token = scope._parseEscapeToken(pattern, i, endIndex);
34536                    } else if (ch === "[") {
34537                        token = scope._parseCharRangeToken(pattern, i, endIndex);
34538                    } else if (ch === "^" || ch === "$") {
34539                        token = scope._parseAnchorToken(pattern, i);
34540                    } else if (ch === "(") {
34541                        token = scope._parseGroupToken(pattern, settings, i, endIndex);
34542                    } else if (ch === "|") {
34543                        token = scope._parseAlternationToken(pattern, i);
34544                    } else if (ch === "#" && settings.ignoreWhitespace) {
34545                        token = scope._parseXModeCommentToken(pattern, i, endIndex);
34546                    } else {
34547                        token = scope._parseQuantifierToken(pattern, i, endIndex);
34548                    }
34549
34550                    if (token == null) {
34551                        token = scope._createPatternToken(pattern, tokenTypes.literal, i, 1);
34552                    }
34553
34554                    if (token != null) {
34555                        tokens.push(token);
34556                        i += token.length;
34557                    }
34558                }
34559
34560                return tokens;
34561            },
34562
34563            _parseEscapeToken: function (pattern, i, endIndex) {
34564                var scope = System.Text.RegularExpressions.RegexEngineParser;
34565                var tokenTypes = scope.tokenTypes;
34566
34567                var ch = pattern[i];
34568
34569                if (ch !== "\\") {
34570                    return null;
34571                }
34572
34573                if (i + 1 >= endIndex) {
34574                    throw new System.ArgumentException.$ctor1("Illegal \\ at end of pattern.");
34575                }
34576
34577                ch = pattern[i + 1];
34578
34579                // Parse a sequence for a numbered reference ("Backreference Constructs")
34580                if (ch >= "1" && ch <= "9") {
34581                    // check if the number is a group backreference
34582                    var groupDigits = scope._matchChars(pattern, i + 1, endIndex, scope._decSymbols, 3); // assume: there are not more than 999 groups
34583                    var backrefNumberToken = scope._createPatternToken(pattern, tokenTypes.escBackrefNumber, i, 1 + groupDigits.matchLength); // "\nnn"
34584
34585                    backrefNumberToken.data = { number: parseInt(groupDigits.match, 10) };
34586
34587                    return backrefNumberToken;
34588                }
34589
34590                // Parse a sequence for "Anchors"
34591                if (scope._escapedAnchors.indexOf(ch) >= 0) {
34592                    return scope._createPatternToken(pattern, tokenTypes.escAnchor, i, 2); // "\A" or "\Z" or "\z" or "\G" or "\b" or "\B"
34593                }
34594
34595                // Parse a sequence for "Character Escapes" or "Character Classes"
34596                var escapedCharToken = scope._parseEscapedChar(pattern, i, endIndex);
34597
34598                if (escapedCharToken != null) {
34599                    return escapedCharToken;
34600                }
34601
34602                // Parse a sequence for a named backreference ("Backreference Constructs")
34603                if (ch === "k") {
34604                    if (i + 2 < endIndex) {
34605                        var nameQuoteCh = pattern[i + 2];
34606
34607                        if (nameQuoteCh === "'" || nameQuoteCh === "<") {
34608                            var closingCh = nameQuoteCh === "<" ? ">" : "'";
34609                            var refNameChars = scope._matchUntil(pattern, i + 3, endIndex, closingCh);
34610
34611                            if (refNameChars.unmatchLength === 1 && refNameChars.matchLength > 0) {
34612                                var backrefNameToken = scope._createPatternToken(pattern, tokenTypes.escBackrefName, i, 3 + refNameChars.matchLength + 1); // "\k<Name>" or "\k'Name'"
34613
34614                                backrefNameToken.data = { name: refNameChars.match };
34615
34616                                return backrefNameToken;
34617                            }
34618                        }
34619                    }
34620
34621                    throw new System.ArgumentException.$ctor1("Malformed \\k<...> named back reference.");
34622                }
34623
34624                // Temp fix (until IsWordChar is not supported):
34625                // See more: https://referencesource.microsoft.com/#System/regex/system/text/regularexpressions/RegexParser.cs,1414
34626                // Unescaping of any of the following ASCII characters results in the character itself
34627                var code = ch.charCodeAt(0);
34628
34629                if ((code >= 0 && code < 48) ||
34630                    (code > 57 && code < 65) ||
34631                    (code > 90 && code < 95) ||
34632                    (code === 96) ||
34633                    (code > 122 && code < 128)) {
34634                    var token = scope._createPatternToken(pattern, tokenTypes.escChar, i, 2);
34635
34636                    token.data = { n: code, ch: ch };
34637
34638                    return token;
34639                }
34640
34641                // Unrecognized escape sequence:
34642                throw new System.ArgumentException.$ctor1("Unrecognized escape sequence \\" + ch + ".");
34643            },
34644
34645            _parseOctalCharToken: function (pattern, i, endIndex) {
34646                var scope = System.Text.RegularExpressions.RegexEngineParser;
34647                var tokenTypes = scope.tokenTypes;
34648
34649                var ch = pattern[i];
34650
34651                if (ch === "\\" && i + 1 < endIndex) {
34652                    ch = pattern[i + 1];
34653
34654                    if (ch >= "0" && ch <= "7") {
34655                        var octalDigits = scope._matchChars(pattern, i + 1, endIndex, scope._octSymbols, 3);
34656                        var octalVal = parseInt(octalDigits.match, 8);
34657                        var token = scope._createPatternToken(pattern, tokenTypes.escCharOctal, i, 1 + octalDigits.matchLength); // "\0" or "\nn" or "\nnn"
34658
34659                        token.data = { n: octalVal, ch: String.fromCharCode(octalVal) };
34660
34661                        return token;
34662                    }
34663                }
34664
34665                return null;
34666            },
34667
34668            _parseEscapedChar: function (pattern, i, endIndex) {
34669                var scope = System.Text.RegularExpressions.RegexEngineParser;
34670                var tokenTypes = scope.tokenTypes;
34671                var token;
34672
34673                var ch = pattern[i];
34674
34675                if (ch !== "\\" || i + 1 >= endIndex) {
34676                    return null;
34677                }
34678
34679                ch = pattern[i + 1];
34680
34681                // Parse a sequence for "Character Escapes"
34682                if (scope._escapedChars.indexOf(ch) >= 0) {
34683                    if (ch === "x") {
34684                        var hexDigits = scope._matchChars(pattern, i + 2, endIndex, scope._hexSymbols, 2);
34685
34686                        if (hexDigits.matchLength !== 2) {
34687                            throw new System.ArgumentException.$ctor1("Insufficient hexadecimal digits.");
34688                        }
34689
34690                        var hexVal = parseInt(hexDigits.match, 16);
34691
34692                        token = scope._createPatternToken(pattern, tokenTypes.escCharHex, i, 4); // "\xnn"
34693                        token.data = { n: hexVal, ch: String.fromCharCode(hexVal) };
34694
34695                        return token;
34696                    } else if (ch === "c") {
34697                        if (i + 2 >= endIndex) {
34698                            throw new System.ArgumentException.$ctor1("Missing control character.");
34699                        }
34700
34701                        var ctrlCh = pattern[i + 2];
34702
34703                        ctrlCh = ctrlCh.toUpperCase();
34704
34705                        var ctrlIndex = this._controlChars.indexOf(ctrlCh);
34706
34707                        if (ctrlIndex >= 0) {
34708                            token = scope._createPatternToken(pattern, tokenTypes.escCharCtrl, i, 3); // "\cx" or "\cX"
34709                            token.data = { n: ctrlIndex, ch: String.fromCharCode(ctrlIndex) };
34710
34711                            return token;
34712                        }
34713
34714                        throw new System.ArgumentException.$ctor1("Unrecognized control character.");
34715                    } else if (ch === "u") {
34716                        var ucodeDigits = scope._matchChars(pattern, i + 2, endIndex, scope._hexSymbols, 4);
34717
34718                        if (ucodeDigits.matchLength !== 4) {
34719                            throw new System.ArgumentException.$ctor1("Insufficient hexadecimal digits.");
34720                        }
34721
34722                        var ucodeVal = parseInt(ucodeDigits.match, 16);
34723
34724                        token = scope._createPatternToken(pattern, tokenTypes.escCharUnicode, i, 6); // "\unnnn"
34725                        token.data = { n: ucodeVal, ch: String.fromCharCode(ucodeVal) };
34726
34727                        return token;
34728                    }
34729
34730                    token = scope._createPatternToken(pattern, tokenTypes.escChar, i, 2); // "\a" or "\b" or "\t" or "\r" or "\v" or "f" or "n" or "e"-
34731
34732                    var escVal;
34733
34734                    switch (ch) {
34735                        case "a":
34736                            escVal = 7;
34737                            break;
34738                        case "b":
34739                            escVal = 8;
34740                            break;
34741                        case "t":
34742                            escVal = 9;
34743                            break;
34744                        case "r":
34745                            escVal = 13;
34746                            break;
34747                        case "v":
34748                            escVal = 11;
34749                            break;
34750                        case "f":
34751                            escVal = 12;
34752                            break;
34753                        case "n":
34754                            escVal = 10;
34755                            break;
34756                        case "e":
34757                            escVal = 27;
34758                            break;
34759
34760                        default:
34761                            throw new System.ArgumentException.$ctor1("Unexpected escaped char: '" + ch + "'.");
34762                    }
34763
34764                    token.data = { n: escVal, ch: String.fromCharCode(escVal) };
34765
34766                    return token;
34767                }
34768
34769                // Parse a sequence for an octal character("Character Escapes")
34770                if (ch >= "0" && ch <= "7") {
34771                    var octalCharToken = scope._parseOctalCharToken(pattern, i, endIndex);
34772
34773                    return octalCharToken;
34774                }
34775
34776                // Parse a sequence for "Character Classes"
34777                if (scope._escapedCharClasses.indexOf(ch) >= 0) {
34778                    if (ch === "p" || ch === "P") {
34779                        var catNameChars = scope._matchUntil(pattern, i + 2, endIndex, "}"); // the longest category name is 37 + 2 brackets, but .NET does not limit the value on this step
34780
34781                        if (catNameChars.matchLength < 2 || catNameChars.match[0] !== "{" || catNameChars.unmatchLength !== 1) {
34782                            throw new System.ArgumentException.$ctor1("Incomplete \p{X} character escape.");
34783                        }
34784
34785                        var catName = catNameChars.match.slice(1);
34786
34787                        if (scope._unicodeCategories.indexOf(catName) >= 0) {
34788                            return scope._createPatternToken(pattern, tokenTypes.escCharClassCategory, i, 2 + catNameChars.matchLength + 1); // "\p{Name}" or "\P{Name}"
34789                        }
34790
34791                        if (scope._namedCharBlocks.indexOf(catName) >= 0) {
34792                            return scope._createPatternToken(pattern, tokenTypes.escCharClassBlock, i, 2 + catNameChars.matchLength + 1); // "\p{Name}" or "\P{Name}"
34793                        }
34794
34795                        throw new System.ArgumentException.$ctor1("Unknown property '" + catName + "'.");
34796                    }
34797
34798                    return scope._createPatternToken(pattern, tokenTypes.escCharClass, i, 2); // "\w" or "\W" or "\s" or "\S" or "\d" or "\D"
34799                }
34800
34801                // Some other literal
34802                if (scope._escapedSpecialSymbols.indexOf(ch) >= 0) {
34803                    token = scope._createPatternToken(pattern, tokenTypes.escCharOther, i, 2); // "\." or "\$" or ... "\\"
34804                    token.data = { n: ch.charCodeAt(0), ch: ch };
34805                    return token;
34806                }
34807
34808                return null;
34809            },
34810
34811            _parseCharRangeToken: function (pattern, i, endIndex) {
34812                var scope = System.Text.RegularExpressions.RegexEngineParser;
34813                var tokenTypes = scope.tokenTypes;
34814                var tokens = [];
34815                var intervalToken;
34816                var substractToken;
34817                var token;
34818                var isNegative = false;
34819                var noMoreTokenAllowed = false;
34820                var hasSubstractToken = false;
34821
34822                var ch = pattern[i];
34823
34824                if (ch !== "[") {
34825                    return null;
34826                }
34827
34828                var index = i + 1;
34829                var closeBracketIndex = -1;
34830                var toInc;
34831
34832                if (index < endIndex && pattern[index] === "^") {
34833                    isNegative = true;
34834                    index ++;
34835                }
34836
34837                var startIndex = index;
34838
34839                while (index < endIndex) {
34840                    ch = pattern[index];
34841
34842                    noMoreTokenAllowed = hasSubstractToken;
34843
34844                    if (ch === "-" && index + 1 < endIndex && pattern[index + 1] === "[") {
34845                        substractToken = scope._parseCharRangeToken(pattern, index + 1, endIndex);
34846                        substractToken.childrenPrefix = "-" + substractToken.childrenPrefix;
34847                        substractToken.length ++;
34848                        token = substractToken;
34849                        toInc = substractToken.length;
34850                        hasSubstractToken = true;
34851                    } else if (ch === "\\") {
34852                        token = scope._parseEscapedChar(pattern, index, endIndex);
34853
34854                        if (token == null) {
34855                            throw new System.ArgumentException.$ctor1("Unrecognized escape sequence \\" + ch + ".");
34856                        }
34857                        toInc = token.length;
34858                    } else if (ch === "]" && index > startIndex) {
34859                        closeBracketIndex = index;
34860
34861                        break;
34862                    } else {
34863                        token = scope._createPatternToken(pattern, tokenTypes.literal, index, 1);
34864                        toInc = 1;
34865                    }
34866
34867                    if (noMoreTokenAllowed) {
34868                        throw new System.ArgumentException.$ctor1("A subtraction must be the last element in a character class.");
34869                    }
34870
34871                    // Check for interval:
34872                    if (tokens.length > 1) {
34873                        intervalToken = scope._parseCharIntervalToken(pattern, tokens[tokens.length - 2], tokens[tokens.length - 1], token);
34874
34875                        if (intervalToken != null) {
34876                            tokens.pop(); //pop Dush
34877                            tokens.pop(); //pop Interval start
34878                            token = intervalToken;
34879                        }
34880                    }
34881
34882                    // Add token:
34883                    if (token != null) {
34884                        tokens.push(token);
34885                        index += toInc;
34886                    }
34887                }
34888
34889                if (closeBracketIndex < 0 || tokens.length < 1) {
34890                    throw new System.ArgumentException.$ctor1("Unterminated [] set.");
34891                }
34892
34893                var groupToken;
34894
34895                if (!isNegative) {
34896                    groupToken = scope._createPatternToken(pattern, tokenTypes.charGroup, i, 1 + closeBracketIndex - i, tokens, "[", "]");
34897                } else {
34898                    groupToken = scope._createPatternToken(pattern, tokenTypes.charNegativeGroup, i, 1 + closeBracketIndex - i, tokens, "[^", "]");
34899                }
34900
34901                // Create full range data:
34902                var ranges = scope._tidyCharRange(tokens);
34903
34904                groupToken.data = { ranges: ranges };
34905
34906                if (substractToken != null) {
34907                    groupToken.data.substractToken = substractToken;
34908                }
34909
34910                return groupToken;
34911            },
34912
34913            _parseCharIntervalToken: function (pattern, intervalStartToken, dashToken, intervalEndToken) {
34914                var scope = System.Text.RegularExpressions.RegexEngineParser;
34915                var tokenTypes = scope.tokenTypes;
34916
34917                if (dashToken.type !== tokenTypes.literal || dashToken.value !== "-") {
34918                    return null;
34919                }
34920
34921                if (intervalStartToken.type !== tokenTypes.literal &&
34922                    intervalStartToken.type !== tokenTypes.escChar &&
34923                    intervalStartToken.type !== tokenTypes.escCharOctal &&
34924                    intervalStartToken.type !== tokenTypes.escCharHex &&
34925                    intervalStartToken.type !== tokenTypes.escCharCtrl &&
34926                    intervalStartToken.type !== tokenTypes.escCharUnicode &&
34927                    intervalStartToken.type !== tokenTypes.escCharOther) {
34928                    return null;
34929                }
34930
34931                if (intervalEndToken.type !== tokenTypes.literal &&
34932                    intervalEndToken.type !== tokenTypes.escChar &&
34933                    intervalEndToken.type !== tokenTypes.escCharOctal &&
34934                    intervalEndToken.type !== tokenTypes.escCharHex &&
34935                    intervalEndToken.type !== tokenTypes.escCharCtrl &&
34936                    intervalEndToken.type !== tokenTypes.escCharUnicode &&
34937                    intervalEndToken.type !== tokenTypes.escCharOther) {
34938                    return null;
34939                }
34940
34941                var startN;
34942                var startCh;
34943
34944                if (intervalStartToken.type === tokenTypes.literal) {
34945                    startN = intervalStartToken.value.charCodeAt(0);
34946                    startCh = intervalStartToken.value;
34947                } else {
34948                    startN = intervalStartToken.data.n;
34949                    startCh = intervalStartToken.data.ch;
34950                }
34951
34952                var endN;
34953                var endCh;
34954
34955                if (intervalEndToken.type === tokenTypes.literal) {
34956                    endN = intervalEndToken.value.charCodeAt(0);
34957                    endCh = intervalEndToken.value;
34958                } else {
34959                    endN = intervalEndToken.data.n;
34960                    endCh = intervalEndToken.data.ch;
34961                }
34962
34963                if (startN > endN) {
34964                    throw new System.NotSupportedException.$ctor1("[x-y] range in reverse order.");
34965                }
34966
34967                var index = intervalStartToken.index;
34968                var length = intervalStartToken.length + dashToken.length + intervalEndToken.length;
34969                var intervalToken = scope._createPatternToken(pattern, tokenTypes.charInterval, index, length, [intervalStartToken, dashToken, intervalEndToken], "", "");
34970
34971                intervalToken.data = {
34972                    startN: startN,
34973                    startCh: startCh,
34974                    endN: endN,
34975                    endCh: endCh
34976                };
34977
34978                return intervalToken;
34979            },
34980
34981            _tidyCharRange: function (tokens) {
34982                var scope = System.Text.RegularExpressions.RegexEngineParser;
34983                var tokenTypes = scope.tokenTypes;
34984
34985                var j;
34986                var k;
34987                var n;
34988                var m;
34989                var token;
34990                var ranges = [];
34991                var classTokens = [];
34992
34993                var range;
34994                var nextRange;
34995                var toSkip;
34996
34997                for (j = 0; j < tokens.length; j++) {
34998                    token = tokens[j];
34999
35000                    if (token.type === tokenTypes.literal) {
35001                        n = token.value.charCodeAt(0);
35002                        m = n;
35003                    } else if (token.type === tokenTypes.charInterval) {
35004                        n = token.data.startN;
35005                        m = token.data.endN;
35006                    } else if (token.type === tokenTypes.literal ||
35007                        token.type === tokenTypes.escChar ||
35008                        token.type === tokenTypes.escCharOctal ||
35009                        token.type === tokenTypes.escCharHex ||
35010                        token.type === tokenTypes.escCharCtrl ||
35011                        token.type === tokenTypes.escCharUnicode ||
35012                        token.type === tokenTypes.escCharOther) {
35013                        n = token.data.n;
35014                        m = n;
35015                    } else if (
35016                        token.type === tokenTypes.charGroup ||
35017                        token.type === tokenTypes.charNegativeGroup) {
35018                        continue;
35019                    } else {
35020                        classTokens.push(token);
35021                        continue;
35022                    }
35023
35024                    if (ranges.length === 0) {
35025                        ranges.push({ n: n, m: m });
35026                        continue;
35027                    }
35028
35029                    //TODO: [Performance] Use binary search
35030                    for (k = 0; k < ranges.length; k++) {
35031                        if (ranges[k].n > n) {
35032                            break;
35033                        }
35034                    }
35035
35036                    ranges.splice(k, 0, { n: n, m: m });
35037                }
35038
35039                // Combine ranges:
35040                for (j = 0; j < ranges.length; j++) {
35041                    range = ranges[j];
35042
35043                    toSkip = 0;
35044
35045                    for (k = j + 1; k < ranges.length; k++) {
35046                        nextRange = ranges[k];
35047
35048                        if (nextRange.n > 1 + range.m) {
35049                            break;
35050                        }
35051
35052                        toSkip++;
35053
35054                        if (nextRange.m > range.m) {
35055                            range.m = nextRange.m;
35056                        }
35057                    }
35058                    if (toSkip > 0) {
35059                        ranges.splice(j + 1, toSkip);
35060                    }
35061                }
35062
35063                if (classTokens.length > 0) {
35064                    var charClassStr = "[" + scope._constructPattern(classTokens) + "]";
35065                    ranges.charClassToken = scope._createPatternToken(charClassStr, tokenTypes.charGroup, 0, charClassStr.length, tokens, "[", "]");
35066                }
35067
35068                return ranges;
35069            },
35070
35071            _parseDotToken: function (pattern, i) {
35072                var scope = System.Text.RegularExpressions.RegexEngineParser;
35073                var tokenTypes = scope.tokenTypes;
35074
35075                var ch = pattern[i];
35076
35077                if (ch !== ".") {
35078                    return null;
35079                }
35080
35081                return scope._createPatternToken(pattern, tokenTypes.escCharClassDot, i, 1);
35082            },
35083
35084            _parseAnchorToken: function (pattern, i) {
35085                var scope = System.Text.RegularExpressions.RegexEngineParser;
35086                var tokenTypes = scope.tokenTypes;
35087
35088                var ch = pattern[i];
35089
35090                if (ch !== "^" && ch !== "$") {
35091                    return null;
35092                }
35093
35094                return scope._createPatternToken(pattern, tokenTypes.anchor, i, 1);
35095            },
35096
35097            _updateSettingsFromConstructs: function (settings, constructs) {
35098                if (constructs.isIgnoreWhitespace != null) {
35099                    settings.ignoreWhitespace = constructs.isIgnoreWhitespace;
35100                }
35101
35102                if (constructs.isExplicitCapture != null) {
35103                    settings.explicitCapture = constructs.isExplicitCapture;
35104                }
35105            },
35106
35107            _parseGroupToken: function (pattern, settings, i, endIndex) {
35108                var scope = System.Text.RegularExpressions.RegexEngineParser;
35109                var tokenTypes = scope.tokenTypes;
35110                var groupSettings = {
35111                    ignoreWhitespace: settings.ignoreWhitespace,
35112                    explicitCapture: settings.explicitCapture
35113                };
35114
35115                var ch = pattern[i];
35116
35117                if (ch !== "(") {
35118                    return null;
35119                }
35120
35121                var bracketLvl = 1;
35122                var sqBracketCtx = false;
35123                var bodyIndex = i + 1;
35124                var closeBracketIndex = -1;
35125
35126                var isComment = false;
35127                var isAlternation = false;
35128                var isInlineOptions = false;
35129                var isImnsxConstructed = false;
35130                var isNonCapturingExplicit = false;
35131
35132                var grConstructs = null;
35133
35134                // Parse the Group construct, if any:
35135                var constructToken = scope._parseGroupConstructToken(pattern, groupSettings, i + 1, endIndex);
35136
35137                if (constructToken != null) {
35138                    grConstructs = this._fillGroupConstructs(constructToken);
35139
35140                    bodyIndex += constructToken.length;
35141
35142                    if (constructToken.type === tokenTypes.commentInline) {
35143                        isComment = true;
35144                    } else if (constructToken.type === tokenTypes.alternationGroupCondition) {
35145                        isAlternation = true;
35146                    } else if (constructToken.type === tokenTypes.groupConstructImnsx) {
35147                        this._updateSettingsFromConstructs(groupSettings, grConstructs);
35148                        isImnsxConstructed = true;
35149                    } else if (constructToken.type === tokenTypes.groupConstructImnsxMisc) {
35150                        this._updateSettingsFromConstructs(settings, grConstructs); // parent settings!
35151                        isInlineOptions = true;
35152                    }
35153                }
35154
35155                if (groupSettings.explicitCapture && (grConstructs == null || grConstructs.name1 == null)) {
35156                    isNonCapturingExplicit = true;
35157                }
35158
35159                var index = bodyIndex;
35160
35161                while (index < endIndex) {
35162                    ch = pattern[index];
35163
35164                    if (ch === "\\") {
35165                        index ++;
35165 // skip the escaped char
35166                    } else if (ch === "[") {
35167                        sqBracketCtx = true;
35168                    } else if (ch === "]" && sqBracketCtx) {
35169                        sqBracketCtx = false;
35170                    } else if (!sqBracketCtx) {
35171                        if (ch === "(" && !isComment) {
35172                            ++bracketLvl;
35173                        } else if (ch === ")") {
35174                            --bracketLvl;
35175
35176                            if (bracketLvl === 0) {
35177                                closeBracketIndex = index;
35178                                break;
35179                            }
35180                        }
35181                    }
35182
35183                    ++index;
35184                }
35185
35186                var result = null;
35187
35188                if (isComment) {
35189                    if (closeBracketIndex < 0) {
35190                        throw new System.ArgumentException.$ctor1("Unterminated (?#...) comment.");
35191                    }
35192
35193                    result = scope._createPatternToken(pattern, tokenTypes.commentInline, i, 1 + closeBracketIndex - i);
35194                } else {
35195                    if (closeBracketIndex < 0) {
35196                        throw new System.ArgumentException.$ctor1("Not enough )'s.");
35197                    }
35198
35199                    // Parse the "Body" of the group
35200                    var innerTokens = scope._parsePatternImpl(pattern, groupSettings, bodyIndex, closeBracketIndex);
35201
35202                    if (constructToken != null) {
35203                        innerTokens.splice(0, 0, constructToken);
35204                    }
35205
35206                    // If there is an Alternation expression, treat the group as Alternation group
35207                    if (isAlternation) {
35208                        var innerTokensLen = innerTokens.length;
35209                        var innerToken;
35210                        var j;
35211
35212                        // Check that there is only 1 alternation symbol:
35213                        var altCount = 0;
35214
35215                        for (j = 0; j < innerTokensLen; j++) {
35216                            innerToken = innerTokens[j];
35217
35218                            if (innerToken.type === tokenTypes.alternation) {
35219                                ++altCount;
35220
35221                                if (altCount > 1) {
35222                                    throw new System.ArgumentException.$ctor1("Too many | in (?()|).");
35223                                }
35224                            }
35225                        }
35226
35227                        if (altCount === 0) {
35228                            // Though .NET works with this case, it ends up with unexpected result. Let's avoid this behaviour.
35229                            throw new System.NotSupportedException.$ctor1("Alternation group without | is not supported.");
35230                        }
35231
35232                        var altGroupToken = scope._createPatternToken(pattern, tokenTypes.alternationGroup, i, 1 + closeBracketIndex - i, innerTokens, "(", ")");
35233
35234                        result = altGroupToken;
35235                    } else {
35236                        // Create Group token:
35237                        var tokenType = tokenTypes.group;
35238
35239                        if (isInlineOptions) {
35240                            tokenType = tokenTypes.groupImnsxMisc;
35241                        } else if (isImnsxConstructed) {
35242                            tokenType = tokenTypes.groupImnsx;
35243                        }
35244
35245                        var groupToken = scope._createPatternToken(pattern, tokenType, i, 1 + closeBracketIndex - i, innerTokens, "(", ")");
35246
35247                        groupToken.localSettings = groupSettings;
35248                        result = groupToken;
35249                    }
35250                }
35251
35252                if (isNonCapturingExplicit) {
35253                    result.isNonCapturingExplicit = true;
35254                }
35255
35256                return result;
35257            },
35258
35259            _parseGroupConstructToken: function (pattern, settings, i, endIndex) {
35260                // ?<name1>
35261                // ?'name1'
35262                // ?<name1-name2>
35263                // ?'name1-name2'
35264                // ?:
35265                // ?imnsx-imnsx
35266                // ?=
35267                // ?!
35268                // ?<=
35269                // ?<!
35270                // ?>
35271                // ?#
35272
35273                var scope = System.Text.RegularExpressions.RegexEngineParser;
35274                var tokenTypes = scope.tokenTypes;
35275
35276                var ch = pattern[i];
35277
35278                if (ch !== "?" || i + 1 >= endIndex) {
35279                    return null;
35280                }
35281
35282                ch = pattern[i + 1];
35283
35284                if (ch === ":" || ch === "=" || ch === "!" || ch === ">") {
35285                    return scope._createPatternToken(pattern, tokenTypes.groupConstruct, i, 2);
35286                }
35287
35288                if (ch === "#") {
35289                    return scope._createPatternToken(pattern, tokenTypes.commentInline, i, 2);
35290                }
35291
35292                if (ch === "(") {
35293                    return scope._parseAlternationGroupConditionToken(pattern, settings, i, endIndex);
35294                }
35295
35296                if (ch === "<" && i + 2 < endIndex) {
35297                    var ch3 = pattern[i + 2];
35298
35299                    if (ch3 === "=" || ch3 === "!") {
35300                        return scope._createPatternToken(pattern, tokenTypes.groupConstruct, i, 3);
35301                    }
35302                }
35303
35304                if (ch === "<" || ch === "'") {
35305                    var closingCh = ch === "<" ? ">" : ch;
35306                    var nameChars = scope._matchUntil(pattern, i + 2, endIndex, closingCh);
35307
35308                    if (nameChars.unmatchLength !== 1 || nameChars.matchLength === 0) {
35309                        throw new System.ArgumentException.$ctor1("Unrecognized grouping construct.");
35310                    }
35311
35312                    var nameFirstCh = nameChars.match.slice(0, 1);
35313
35314                    if ("`~@#$%^&*()+{}[]|\\/|'\";:,.?".indexOf(nameFirstCh) >= 0) {
35315                        // TODO: replace the "black list" of wrong characters with char class check:
35316                        // According to UTS#18 Unicode Regular Expressions (http://www.unicode.org/reports/tr18/)
35317                        // RL 1.4 Simple Word Boundaries  The class of <word_character> includes all Alphabetic
35318                        // values from the Unicode character database, from UnicodeData.txt [UData], plus the U+200C
35319                        // ZERO WIDTH NON-JOINER and U+200D ZERO WIDTH JOINER.
35320                        throw new System.ArgumentException.$ctor1("Invalid group name: Group names must begin with a word character.");
35321                    }
35322
35323                    return scope._createPatternToken(pattern, tokenTypes.groupConstructName, i, 2 + nameChars.matchLength + 1);
35324                }
35325
35326                var imnsxChars = scope._matchChars(pattern, i + 1, endIndex, "imnsx-");
35327
35328                if (imnsxChars.matchLength > 0 && (imnsxChars.unmatchCh === ":" || imnsxChars.unmatchCh === ")")) {
35329                    var imnsxTokenType = imnsxChars.unmatchCh === ":" ? tokenTypes.groupConstructImnsx : tokenTypes.groupConstructImnsxMisc;
35330                    var imnsxPostfixLen = imnsxChars.unmatchCh === ":" ? 1 : 0;
35331
35332                    return scope._createPatternToken(pattern, imnsxTokenType, i, 1 + imnsxChars.matchLength + imnsxPostfixLen);
35333                }
35334
35335                throw new System.ArgumentException.$ctor1("Unrecognized grouping construct.");
35336            },
35337
35338            _parseQuantifierToken: function (pattern, i, endIndex) {
35339                var scope = System.Text.RegularExpressions.RegexEngineParser;
35340                var tokenTypes = scope.tokenTypes;
35341                var token = null;
35342
35343                var ch = pattern[i];
35344
35345                if (ch === "*" || ch === "+" || ch === "?") {
35346                    token = scope._createPatternToken(pattern, tokenTypes.quantifier, i, 1);
35347                    token.data = { val: ch };
35348                } else if (ch === "{") {
35349                    var dec1Chars = scope._matchChars(pattern, i + 1, endIndex, scope._decSymbols);
35350
35351                    if (dec1Chars.matchLength !== 0) {
35352                        if (dec1Chars.unmatchCh === "}") {
35353                            token = scope._createPatternToken(pattern, tokenTypes.quantifierN, i, 1 + dec1Chars.matchLength + 1);
35354                            token.data = {
35355                                n: parseInt(dec1Chars.match, 10)
35356                            };
35357                        } else if (dec1Chars.unmatchCh === ",") {
35358                            var dec2Chars = scope._matchChars(pattern, dec1Chars.unmatchIndex + 1, endIndex, scope._decSymbols);
35359
35360                            if (dec2Chars.unmatchCh === "}") {
35361                                token = scope._createPatternToken(pattern, tokenTypes.quantifierNM, i, 1 + dec1Chars.matchLength + 1 + dec2Chars.matchLength + 1);
35362                                token.data = {
35363                                    n: parseInt(dec1Chars.match, 10),
35364                                    m: null
35365                                };
35366
35367                                if (dec2Chars.matchLength !== 0) {
35368                                    token.data.m = parseInt(dec2Chars.match, 10);
35369
35370                                    if (token.data.n > token.data.m) {
35371                                        throw new System.ArgumentException.$ctor1("Illegal {x,y} with x > y.");
35372                                    }
35373                                }
35374                            }
35375                        }
35376                    }
35377                }
35378
35379                if (token != null) {
35380                    var nextChIndex = i + token.length;
35381
35382                    if (nextChIndex < endIndex) {
35383                        var nextCh = pattern[nextChIndex];
35384
35385                        if (nextCh === "?") {
35386                            this._modifyPatternToken(token, pattern, token.type, token.index, token.length + 1);
35387                            token.data.isLazy = true;
35388                        }
35389                    }
35390                }
35391
35392                return token;
35393            },
35394
35395            _parseAlternationToken: function (pattern, i) {
35396                var scope = System.Text.RegularExpressions.RegexEngineParser;
35397                var tokenTypes = scope.tokenTypes;
35398
35399                var ch = pattern[i];
35400
35401                if (ch !== "|") {
35402                    return null;
35403                }
35404
35405                return scope._createPatternToken(pattern, tokenTypes.alternation, i, 1
35405);
35406            },
35407
35408            _parseAlternationGroupConditionToken: function (pattern, settings, i, endIndex) {
35409                var scope = System.Text.RegularExpressions.RegexEngineParser;
35410                var tokenTypes = scope.tokenTypes;
35411                var constructToken;
35412                var childToken;
35413                var data = null;
35414
35415                var ch = pattern[i];
35416
35417                if (ch !== "?" || i + 1 >= endIndex || pattern[i + 1] !== "(") {
35418                    return null;
35419                }
35420
35421                // Parse Alternation condition as a group:
35422                var expr = scope._parseGroupToken(pattern, settings, i + 1, endIndex);
35423
35424                if (expr == null) {
35425                    return null;
35426                }
35427
35428                if (expr.type === tokenTypes.commentInline) {
35429                    throw new System.ArgumentException.$ctor1("Alternation conditions cannot be comments.");
35430                }
35431
35432                var children = expr.children;
35433
35434                if (children && children.length) {
35435                    constructToken = children[0];
35436
35437                    if (constructToken.type === tokenTypes.groupConstructName) {
35438                        throw new System.ArgumentException.$ctor1("Alternation conditions do not capture and cannot be named.");
35439                    }
35440
35441                    if (constructToken.type === tokenTypes.groupConstruct || constructToken.type === tokenTypes.groupConstructImnsx) {
35442                        childToken = scope._findFirstGroupWithoutConstructs(children);
35443
35444                        if (childToken != null) {
35445                            childToken.isEmptyCapturing = true;
35446                        }
35447                    }
35448
35449                    if (constructToken.type === tokenTypes.literal) {
35450                        var literalVal = expr.value.slice(1, expr.value.length - 1);
35451                        var isDigit = literalVal[0] >= "0" && literalVal[0] <= "9";
35452
35453                        if (isDigit) {
35454                            var res = scope._matchChars(literalVal, 0, literalVal.length, scope._decSymbols);
35455
35456                            if (res.matchLength !== literalVal.length) {
35457                                throw new System.ArgumentException.$ctor1("Malformed Alternation group number: " + literalVal + ".");
35458                            }
35459
35460                            var number = parseInt(literalVal, 10);
35461                            data = { number: number };
35462                        } else {
35463                            data = { name: literalVal };
35464                        }
35465                    }
35466                }
35467
35468                // Add "Noncapturing" construct if there are no other ones.
35469                if (!children.length || (children[0].type !== tokenTypes.groupConstruct && children[0].type !== tokenTypes.groupConstructImnsx)) {
35470                    constructToken = scope._createPatternToken("?:", tokenTypes.groupConstruct, 0, 2);
35471                    children.splice(0, 0, constructToken);
35472                }
35473
35474                // Transform Group token to Alternation expression token:
35475                var token = scope._createPatternToken(pattern, tokenTypes.alternationGroupCondition, expr.index - 1, 1 + expr.length, [expr], "?", "");
35476
35477                if (data != null) {
35478                    token.data = data;
35479                }
35480
35481                return token;
35482            },
35483
35484            _findFirstGroupWithoutConstructs: function (tokens) {
35485                var scope = System.Text.RegularExpressions.RegexEngineParser;
35486                var tokenTypes = scope.tokenTypes;
35487                var result = null;
35488                var token;
35489                var i;
35490
35491                for (i = 0; i < tokens.length; ++i) {
35492                    token = tokens[i];
35493
35494                    if (token.type === tokenTypes.group && token.children && token.children.length) {
35495                        if (token.children[0].type !== tokenTypes.groupConstruct && token.children[0].type !== tokenTypes.groupConstructImnsx) {
35496                            result = token;
35497
35498                            break;
35499                        }
35500
35501                        if (token.children && token.children.length) {
35502                            result = scope._findFirstGroupWithoutConstructs(token.children);
35503
35504                            if (result != null) {
35505                                break;
35506                            }
35507                        }
35508                    }
35509                }
35510
35511                return result;
35512            },
35513
35514            _parseXModeCommentToken: function (pattern, i, endIndex) {
35515                var scope = System.Text.RegularExpressions.RegexEngineParser;
35516                var tokenTypes = scope.tokenTypes;
35517
35518                var ch = pattern[i];
35519
35520                if (ch !== "#") {
35521                    return null;
35522                }
35523
35524                var index = i + 1;
35525
35526                while (index < endIndex) {
35527                    ch = pattern[index];
35528                    ++index; // index should be changed before breaking
35529
35530                    if (ch === "\n") {
35531                        break;
35532                    }
35533                }
35534
35535                return scope._createPatternToken(pattern, tokenTypes.commentXMode, i, index - i);
35536            },
35537
35538            _createLiteralToken: function (body) {
35539                var scope = System.Text.RegularExpressions.RegexEngineParser;
35540                var token = scope._createPatternToken(body, scope.tokenTypes.literal, 0, body.length);
35541
35542                return token;
35543            },
35544
35545            _createPositiveLookaheadToken: function (body, settings) {
35546                var scope = System.Text.RegularExpressions.RegexEngineParser;
35547
35548                var pattern = "(?=" + body + ")";
35549                var groupToken = scope._parseGroupToken(pattern, settings, 0, pattern.length);
35550
35551                return groupToken;
35552            },
35553
35554            _createPatternToken: function (pattern, type, i, len, innerTokens, innerTokensPrefix, innerTokensPostfix) {
35555                var token = {
35556                    type: type,
35557                    index: i,
35558                    length: len,
35559                    value: pattern.slice(i, i + len)
35560                };
35561
35562                if (innerTokens != null && innerTokens.length > 0) {
35563                    token.children = innerTokens;
35564                    token.childrenPrefix = innerTokensPrefix;
35565                    token.childrenPostfix = innerTokensPostfix;
35566                }
35567
35568                return token;
35569            },
35570
35571            _modifyPatternToken: function (token, pattern, type, i, len) {
35572                if (type != null) {
35573                    token.type = type;
35574                }
35575
35576                if (i != null || len != null) {
35577                    if (i != null) {
35578                        token.index = i;
35579                    }
35580
35581                    if (len != null) {
35582                        token.length = len;
35583                    }
35584
35585                    token.value = pattern.slice(token.index, token.index + token.length);
35586                }
35587            },
35588
35589            _updatePatternToken: function (token, type, i, len, value) {
35590                token.type = type;
35591                token.index = i;
35592                token.length = len;
35593                token.value = value;
35594            },
35595
35596            _matchChars: function (str, startIndex, endIndex, allowedChars, maxLength) {
35597                var res = {
35598                    match: "",
35599                    matchIndex: -1,
35600                    matchLength: 0,
35601                    unmatchCh: "",
35602                    unmatchIndex: -1,
35603                    unmatchLength: 0
35604                };
35605
35606                var index = startIndex;
35607                var ch;
35608
35609                if (maxLength != null && maxLength >= 0) {
35610                    endIndex = startIndex + maxLength;
35611                }
35612
35613                while (index < endIndex) {
35614                    ch = str[index];
35615
35616                    if (allowedChars.indexOf(ch) < 0) {
35617                        res.unmatchCh = ch;
35618                        res.unmatchIndex = index;
35619                        res.unmatchLength = 1;
35620
35621                        break;
35622                    }
35623
35624                    index++;
35625                }
35626
35627                if (index > startIndex) {
35628                    res.match = str.slice(startIndex, index);
35629                    res.matchIndex = startIndex;
35630                    res.matchLength = index - startIndex;
35631                }
35632
35633                return res;
35634            },
35635
35636            _matchUntil: function (str, startIndex, endIndex, unallowedChars, maxLength) {
35637                var res = {
35638                    match: "",
35639                    matchIndex: -1,
35640                    matchLength: 0,
35641                    unmatchCh: "",
35642                    unmatchIndex: -1,
35643                    unmatchLength: 0
35644                };
35645
35646                var index = startIndex;
35647                var ch;
35648
35649                if (maxLength != null && maxLength >= 0) {
35650                    endIndex = startIndex + maxLength;
35651                }
35652
35653                while (index < endIndex) {
35654                    ch = str[index];
35655
35656                    if (unallowedChars.indexOf(ch) >= 0) {
35657                        res.unmatchCh = ch;
35658                        res.unmatchIndex = index;
35659                        res.unmatchLength = 1;
35660
35661                        break;
35662                    }
35663
35664                    index++;
35665                }
35666
35667                if (index > startIndex) {
35668                    res.match = str.slice(startIndex, index);
35669                    res.matchIndex = startIndex;
35670                    res.matchLength = index - startIndex;
35671                }
35672
35673                return res;
35674            }
35675        }
35676    });
35677
35678    // @source BitConverter.js
35679
35680    H5.define("System.BitConverter", {
35681        statics: {
35682            fields: {
35683                isLittleEndian: false,
35684                arg_ArrayPlusOffTooSmall: null
35685            },
35686            ctors: {
35687                init: function () {
35688                    this.isLittleEndian = System.BitConverter.getIsLittleEndian();
35689                    this.arg_ArrayPlusOffTooSmall = "Destination array is not long enough to copy all the items in the collection. Check array index and length.";
35690                }
35691            },
35692            methods: {
35693                getBytes: function (value) {
35694                    return value ? System.Array.init([1], System.Byte) : System.Array.init([0], System.Byte);
35695                },
35696                getBytes$1: function (value) {
35697                    return System.BitConverter.getBytes$3(H5.Int.sxs(value & 65535));
35698                },
35699                getBytes$3: function (value) {
35700                    var view = System.BitConverter.view(2);
35701                    view.setInt16(0, value);
35702
35703                    return System.BitConverter.getViewBytes(view);
35704                },
35705                getBytes$4: function (value) {
35706                    var view = System.BitConverter.view(4);
35707                    view.setInt32(0, value);
35708
35709                    return System.BitConverter.getViewBytes(view);
35710                },
35711                getBytes$5: function (value) {
35712                    var view = System.BitConverter.getView(value);
35713
35714                    return System.BitConverter.getViewBytes(view);
35715                },
35716                getBytes$7: function (value) {
35717                    var view = System.BitConverter.view(2);
35718                    view.setUint16(0, value);
35719
35720                    return System.BitConverter.getViewBytes(view);
35721                },
35722                getBytes$8: function (value) {
35723                    var view = System.BitConverter.view(4);
35724                    view.setUint32(0, value);
35725
35726                    return System.BitConverter.getViewBytes(view);
35727                },
35728                getBytes$9: function (value) {
35729                    var view = System.BitConverter.getView(System.Int64.clip64(value));
35730
35731                    return System.BitConverter.getViewBytes(view);
35732                },
35733                getBytes$6: function (value) {
35734                    var view = System.BitConverter.view(4);
35735                    view.setFloat32(0, value);
35736
35737                    return System.BitConverter.getViewBytes(view);
35738                },
35739                getBytes$2: function (value) {
35740                    if (isNaN(value)) {
35741                        if (System.BitConverter.isLittleEndian) {
35742                            return System.Array.init([0, 0, 0, 0, 0, 0, 248, 255], System.Byte);
35743                        } else {
35744                            return System.Array.init([255, 248, 0, 0, 0, 0, 0, 0], System.Byte);
35745                        }
35746                    }
35747
35748                    var view = System.BitConverter.view(8);
35749                    view.setFloat64(0, value);
35750
35751                    return System.BitConverter.getViewBytes(view);
35752                },
35753                toChar: function (value, startIndex) {
35754                    return ((System.BitConverter.toInt16(value, startIndex)) & 65535);
35755                },
35756                toInt16: function (value, startIndex) {
35757                    System.BitConverter.checkArguments(value, startIndex, 2);
35758
35759                    var view = System.BitConverter.view(2);
35760
35761                    System.BitConverter.setViewBytes(view, value, -1, startIndex);
35762
35763                    return view.getInt16(0);
35764                },
35765                toInt32: function (value, startIndex) {
35766                    System.BitConverter.checkArguments(value, startIndex, 4);
35767
35768                    var view = System.BitConverter.view(4);
35769
35770                    System.BitConverter.setViewBytes(view, value, -1, startIndex);
35771
35772                    return view.getInt32(0);
35773                },
35774                toInt64: function (value, startIndex) {
35775                    System.BitConverter.checkArguments(value, startIndex, 8);
35776
35777                    var low = System.BitConverter.toInt32(value, startIndex);
35778                    var high = System.BitConverter.toInt32(value, ((startIndex + 4) | 0));
35779
35780                    if (System.BitConverter.isLittleEndian) {
35781                        return System.Int64([low, high]);
35782                    }
35783
35784                    return System.Int64([high, low]);
35785                },
35786                toUInt16: function (value, startIndex) {
35787                    return ((System.BitConverter.toInt16(value, startIndex)) & 65535);
35788                },
35789                toUInt32: function (value, startIndex) {
35790                    return ((System.BitConverter.toInt32(value, startIndex)) >>> 0);
35791                },
35792                toUInt64: function (value, startIndex) {
35793                    var l = System.BitConverter.toInt64(value, startIndex);
35794
35795                    return System.UInt64([l.value.low, l.value.high]);
35796                },
35797                toSingle: function (value, startIndex) {
35798                    System.BitConverter.checkArguments(value, startIndex, 4);
35799
35800                    var view = System.BitConverter.view(4);
35801
35802                    System.BitConverter.setViewBytes(view, value, -1, startIndex);
35803
35804                    return view.getFloat32(0);
35805                },
35806                toDouble: function (value, startIndex) {
35807                    System.BitConverter.checkArguments(value, startIndex, 8);
35808
35809                    var view = System.BitConverter.view(8);
35810
35811                    System.BitConverter.setViewBytes(view, value, -1, startIndex);
35812
35813                    return view.getFloat64(0);
35814                },
35815                toString$2: function (value, startIndex, length) {
35816                    if (value == null) {
35817                        throw new System.ArgumentNullException.$ctor1("value");
35818                    }
35819
35820                    if (startIndex < 0 || startIndex >= value.length && startIndex > 0) {
35821                        throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
35822                    }
35823
35824                    if (length < 0) {
35825                        throw new System.ArgumentOutOfRangeException.$ctor1("length");
35826                    }
35827
35828                    if (startIndex > ((value.length - length) | 0)) {
35829                        throw new System.ArgumentException.$ctor1(System.BitConverter.arg_ArrayPlusOffTooSmall);
35830                    }
35831
35832                    if (length === 0) {
35833                        return "";
35834                    }
35835
35836                    if (length > (715827882)) {
35837                        throw new System.ArgumentOutOfRangeException.$ctor4("length", H5.toString((715827882)));
35838                    }
35839
35840                    var chArrayLength = H5.Int.mul(length, 3);
35841
35842                    var chArray = System.Array.init(chArrayLength, 0, System.Char);
35843                    var i = 0;
35844                    var index = startIndex;
35845
35846                    for (i = 0; i < chArrayLength; i = (i + 3) | 0) {
35847                        var b = value[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), value)];
35848                        chArray[System.Array.index(i, chArray)] = System.BitConverter.getHexValue(((H5.Int.div(b, 16)) | 0));
35849                        chArray[System.Array.index(((i + 1) | 0), chArray)] = System.BitConverter.getHexValue(b % 16);
35850                        chArray[System.Array.index(((i + 2) | 0), chArray)] = 45;
35851                    }
35852
35853                    return System.String.fromCharArray(chArray, 0, ((chArray.length - 1) | 0));
35854                },
35855                toString: function (value) {
35856                    if (value == null) {
35857                        throw new System.ArgumentNullException.$ctor1("value");
35858                    }
35859
35860                    return System.BitConverter.toString$2(value, 0, value.length);
35861                },
35862                toString$1: function (value, startIndex) {
35863                    if (value == null) {
35864                        throw new System.ArgumentNullException.$ctor1("value");
35865                    }
35866
35867                    return System.BitConverter.toString$2(value, startIndex, ((value.length - startIndex) | 0));
35868                },
35869                toBoolean: function (value, startIndex) {
35870                    System.BitConverter.checkArguments(value, startIndex, 1);
35871
35872                    return (value[System.Array.index(startIndex, value)] === 0) ? false : true;
35873                },
35874                doubleToInt64Bits: function (value) {
35875                    var view = System.BitConverter.view(8);
35876                    view.setFloat64(0, value);
35877
35878                    return System.Int64([view.getInt32(4), view.getInt32(0)]);
35879                },
35880                int64BitsToDouble: function (value) {
35881                    var view = System.BitConverter.getView(value);
35882
35883                    return view.getFloat64(0);
35884                },
35885                getHexValue: function (i) {
35886                    if (i < 10) {
35887                        return ((((i + 48) | 0)) & 65535);
35888                    }
35889
35890                    return ((((((i - 10) | 0) + 65) | 0)) & 65535);
35891                },
35892                getViewBytes: function (view, count, startIndex) {
35893                    if (count === void 0) { count = -1; }
35894                    if (startIndex === void 0) { startIndex = 0; }
35895                    if (count === -1) {
35896                        count = view.byteLength;
35897                    }
35898
35899                    var r = System.Array.init(count, 0, System.Byte);
35900
35901                    if (System.BitConverter.isLittleEndian) {
35902                        for (var i = (count - 1) | 0; i >= 0; i = (i - 1) | 0) {
35903                            r[System.Array.index(i, r)] = view.getUint8(H5.identity(startIndex, (startIndex = (startIndex + 1) | 0)));
35904                        }
35905                    } else {
35906                        for (var i1 = 0; i1 < count; i1 = (i1 + 1) | 0) {
35907                            r[System.Array.index(i1, r)] = view.getUint8(H5.identity(startIndex, (startIndex = (startIndex + 1) | 0)));
35908                        }
35909                    }
35910
35911                    return r;
35912                },
35913                setViewBytes: function (view, value, count, startIndex) {
35914                    if (count === void 0) { count = -1; }
35915                    if (startIndex === void 0) { startIndex = 0; }
35916                    if (count === -1) {
35917                        count = view.byteLength;
35918                    }
35919
35920                    if (System.BitConverter.isLittleEndian) {
35921                        for (var i = (count - 1) | 0; i >= 0; i = (i - 1) | 0) {
35922                            view.setUint8(i, value[System.Array.index(H5.identity(startIndex, (startIndex = (startIndex + 1) | 0)), value)]);
35923                        }
35924                    } else {
35925                        for (var i1 = 0; i1 < count; i1 = (i1 + 1) | 0) {
35926                            view.setUint8(i1, value[System.Array.index(H5.identity(startIndex, (startIndex = (startIndex + 1) | 0)), value)]);
35927                        }
35928                    }
35929                },
35930                view: function (length) {
35931                    var buffer = new ArrayBuffer(length);
35932                    var view = new DataView(buffer);
35933
35934                    return view;
35935                },
35936                getView: function (value) {
35937                    var view = System.BitConverter.view(8);
35938
35939                    view.setInt32(4, value.value.low);
35940                    view.setInt32(0, value.value.high);
35941
35942                    return view;
35943                },
35944                getIsLittleEndian: function () {
35945                    var view = System.BitConverter.view(2);
35946
35947                    view.setUint8(0, 170);
35948                    view.setUint8(1, 187);
35949
35950                    if (view.getUint16(0) === 43707) {
35951                        return true;
35952                    }
35953
35954                    return false;
35955                },
35956                checkArguments: function (value, startIndex, size) {
35957                    if (value == null) {
35958                        throw new System.ArgumentNullException.$ctor1("null");
35959                    }
35960
35961                    if (System.Int64((startIndex >>> 0)).gte(System.Int64(value.length))) {
35962                        throw new System.ArgumentOutOfRangeException.$ctor1("startIndex");
35963                    }
35964
35965                    if (startIndex > ((value.length - size) | 0)) {
35966                        throw new System.ArgumentException.$ctor1(System.BitConverter.arg_ArrayPlusOffTooSmall);
35967                    }
35968                }
35969            }
35970        }
35971    });
35972
35973    // @source BitArray.js
35974
35975    H5.define("System.Collections.BitArray", {
35976        inherits: [System.Collections.ICollection,System.ICloneable],
35977        statics: {
35978            fields: {
35979                BitsPerInt32: 0,
35980                BytesPerInt32: 0,
35981                BitsPerByte: 0,
35982                _ShrinkThreshold: 0
35983            },
35984            ctors: {
35985                init: function () {
35986                    this.BitsPerInt32 = 32;
35987                    this.BytesPerInt32 = 4;
35988                    this.BitsPerByte = 8;
35989                    this._ShrinkThreshold = 256;
35990                }
35991            },
35992            methods: {
35993                GetArrayLength: function (n, div) {
35994                    return n > 0 ? ((((((H5.Int.div((((n - 1) | 0)), div)) | 0)) + 1) | 0)) : 0;
35995                }
35996            }
35997        },
35998        fields: {
35999            m_array: null,
36000            m_length: 0,
36001            _version: 0
36002        },
36003        props: {
36004            Length: {
36005                get: function () {
36006                    return this.m_length;
36007                },
36008                set: function (value) {
36009                    if (value < 0) {
36010                        throw new System.ArgumentOutOfRangeException.$ctor4("value", "Non-negative number required.");
36011                    }
36012
36013                    var newints = System.Collections.BitArray.GetArrayLength(value, System.Collections.BitArray.BitsPerInt32);
36014                    if (newints > this.m_array.length || ((newints + System.Collections.BitArray._ShrinkThreshold) | 0) < this.m_array.length) {
36015                        var newarray = System.Array.init(newints, 0, System.Int32);
36016                        System.Array.copy(this.m_array, 0, newarray, 0, newints > this.m_array.length ? this.m_array.length : newints);
36017                        this.m_array = newarray;
36018                    }
36019
36020                    if (value > this.m_length) {
36021                        var last = (System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32) - 1) | 0;
36022                        var bits = this.m_length % 32;
36023                        if (bits > 0) {
36024                            this.m_array[System.Array.index(last, this.m_array)] = this.m_array[System.Array.index(last, this.m_array)] & ((((1 << bits) - 1) | 0));
36025                        }
36026
36027                        System.Array.fill(this.m_array, 0, ((last + 1) | 0), ((((newints - last) | 0) - 1) | 0));
36028                    }
36029
36030                    this.m_length = value;
36031                    this._version = (this._version + 1) | 0;
36032                }
36033            },
36034            Count: {
36035                get: function () {
36036                    return this.m_length;
36037                }
36038            },
36039            System$Collections$ICollection$IsSynchronized: {
36040                get: function () {
36041                    return false;
36042                }
36043            },
36044            System$Collections$ICollection$SyncRoot: {
36045                get: function () {
36046                    return this;
36047                }
36048            },
36049            IsReadOnly: {
36050                get: function () {
36051                    return false;
36052                }
36053            }
36054        },
36055        alias: [
36056            "copyTo", "System$Collections$ICollection$copyTo",
36057            "Count", "System$Collections$ICollection$Count",
36058            "clone", "System$ICloneable$clone",
36059            "GetEnumerator", "System$Collections$IEnumerable$GetEnumerator"
36060        ],
36061        ctors: {
36062            $ctor3: function (length) {
36063                System.Collections.BitArray.$ctor4.call(this, length, false);
36064            },
36065            $ctor4: function (length, defaultValue) {
36066                this.$initialize();
36067                if (length < 0) {
36068                    throw new System.ArgumentOutOfRangeException.$ctor4("length", "Index is less than zero.");
36069                }
36070
36071                this.m_array = System.Array.init(System.Collections.BitArray.GetArrayLength(length, System.Collections.BitArray.BitsPerInt32), 0, System.Int32);
36072                this.m_length = length;
36073
36074                var fillValue = defaultValue ? (-1) : 0;
36075                for (var i = 0; i < this.m_array.length; i = (i + 1) | 0) {
36076                    this.m_array[System.Array.index(i, this.m_array)] = fillValue;
36077                }
36078
36079                this._version = 0;
36080            },
36081            $ctor1: function (bytes) {
36082                this.$initialize();
36083                if (bytes == null) {
36084                    throw new System.ArgumentNullException.$ctor1("bytes");
36085                }
36086                if (bytes.length > 268435455) {
36087                    throw new System.ArgumentException.$ctor3(System.String.format("The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue.", [H5.box(System.Collections.BitArray.BitsPerByte, System.Int32)]), "bytes");
36088                }
36089
36090                this.m_array = System.Array.init(System.Collections.BitArray.GetArrayLength(bytes.length, System.Collections.BitArray.BytesPerInt32), 0, System.Int32);
36091                this.m_length = H5.Int.mul(bytes.length, System.Collections.BitArray.BitsPerByte);
36092
36093                var i = 0;
36094                var j = 0;
36095                while (((bytes.length - j) | 0) >= 4) {
36096                    this.m_array[System.Array.index(H5.identity(i, ((i = (i + 1) | 0))), this.m_array)] = (bytes[System.Array.index(j, bytes)] & 255) | ((bytes[System.Array.index(((j + 1) | 0), bytes)] & 255) << 8) | ((bytes[System.Array.index(((j + 2) | 0), bytes)] & 255) << 16) | ((bytes[System.Array.index(((j + 3) | 0), bytes)] & 255) << 24);
36097                    j = (j + 4) | 0;
36098                }
36099
36100                var r = (bytes.length - j) | 0;
36101                if (r === 3) {
36102                    this.m_array[System.Array.index(i, this.m_array)] = ((bytes[System.Array.index(((j + 2) | 0), bytes)] & 255) << 16);
36103                    r = 2;
36104                }
36105
36106                if (r === 2) {
36107                    this.m_array[System.Array.index(i, this.m_array)] = this.m_array[System.Array.index(i, this.m_array)] | ((bytes[System.Array.index(((j + 1) | 0), bytes)] & 255) << 8);
36108                    r = 1;
36109                }
36110
36111                if (r === 1) {
36112                    this.m_array[System.Array.index(i, this.m_array)] = this.m_array[System.Array.index(i, this.m_array)] | (bytes[System.Array.index(j, bytes)] & 255);
36113                }
36114
36115                this._version = 0;
36116            },
36117            ctor: function (values) {
36118                var $t;
36119                this.$initialize();
36120                if (values == null) {
36121                    throw new System.ArgumentNullException.$ctor1("values");
36122                }
36123
36124                this.m_array = System.Array.init(System.Collections.BitArray.GetArrayLength(values.length, System.Collections.BitArray.BitsPerInt32), 0, System.Int32);
36125                this.m_length = values.length;
36126
36127                for (var i = 0; i < values.length; i = (i + 1) | 0) {
36128                    if (values[System.Array.index(i, values)]) {
36129                        this.m_array[System.Array.index(($t = ((H5.Int.div(i, 32)) | 0)), this.m_array)] = this.m_array[System.Array.index($t, this.m_array)] | (1 << (i % 32));
36130                    }
36131                }
36132
36133                this._version = 0;
36134            },
36135            $ctor5: function (values) {
36136                this.$initialize();
36137                if (values == null) {
36138                    throw new System.ArgumentNullException.$ctor1("values");
36139                }
36140                if (values.length > 67108863) {
36141                    throw new System.ArgumentException.$ctor3(System.String.format("The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue.", [H5.box(System.Collections.BitArray.BitsPerInt32, System.Int32)]), "values");
36142                }
36143
36144                this.m_array = System.Array.init(values.length, 0, System.Int32);
36145                this.m_length = H5.Int.mul(values.length, System.Collections.BitArray.BitsPerInt32);
36146
36147                System.Array.copy(values, 0, this.m_array, 0, values.length);
36148
36149                this._version = 0;
36150            },
36151            $ctor2: function (bits) {
36152                this.$initialize();
36153                if (bits == null) {
36154                    throw new System.ArgumentNullException.$ctor1("bits");
36155                }
36156
36157                var arrayLength = System.Collections.BitArray.GetArrayLength(bits.m_length, System.Collections.BitArray.BitsPerInt32);
36158                this.m_array = System.Array.init(arrayLength, 0, System.Int32);
36159                this.m_length = bits.m_length;
36160
36161                System.Array.copy(bits.m_array, 0, this.m_array, 0, arrayLength);
36162
36163                this._version = bits._version;
36164            }
36165        },
36166        methods: {
36167            getItem: function (index) {
36168                return this.Get(index);
36169            },
36170            setItem: function (index, value) {
36171                this.Set(index, value);
36172            },
36173            copyTo: function (array, index) {
36174                if (array == null) {
36175                    throw new System.ArgumentNullException.$ctor1("array");
36176                }
36177
36178                if (index < 0) {
36179                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
36180                }
36181
36182                if (System.Array.getRank(array) !== 1) {
36183                    throw new System.ArgumentException.$ctor1("Only single dimensional arrays are supported for the requested action.");
36184                }
36185
36186                if (H5.is(array, System.Array.type(System.Int32))) {
36187                    System.Array.copy(this.m_array, 0, array, index, System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32));
36188                } else if (H5.is(array, System.Array.type(System.Byte))) {
36189                    var arrayLength = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerByte);
36190                    if ((((array.length - index) | 0)) < arrayLength) {
36191                        throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
36192                    }
36193
36194                    var b = H5.cast(array, System.Array.type(System.Byte));
36195                    for (var i = 0; i < arrayLength; i = (i + 1) | 0) {
36196                        b[System.Array.index(((index + i) | 0), b)] = ((this.m_array[System.Array.index(((H5.Int.div(i, 4)) | 0), this.m_array)] >> (H5.Int.mul((i % 4), 8))) & 255) & 255;
36197                    }
36198                } else if (H5.is(array, System.Array.type(System.Boolean))) {
36199                    if (((array.length - index) | 0) < this.m_length) {
36200                        throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
36201                    }
36202
36203                    var b1 = H5.cast(array, System.Array.type(System.Boolean));
36204                    for (var i1 = 0; i1 < this.m_length; i1 = (i1 + 1) | 0) {
36205                        b1[System.Array.index(((index + i1) | 0), b1)] = ((this.m_array[System.Array.index(((H5.Int.div(i1, 32)) | 0), this.m_array)] >> (i1 % 32)) & 1) !== 0;
36206                    }
36207                } else {
36208                    throw new System.ArgumentException.$ctor1("Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[].");
36209                }
36210            },
36211            Get: function (index) {
36212                if (index < 0 || index >= this.Length) {
36213                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "Index was out of range. Must be non-negative and less than the size of the collection.");
36214                }
36215
36216                return (this.m_array[System.Array.index(((H5.Int.div(index, 32)) | 0), this.m_array)] & (1 << (index % 32))) !== 0;
36217            },
36218            Set: function (index, value) {
36219                var $t, $t1;
36220                if (index < 0 || index >= this.Length) {
36221                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "Index was out of range. Must be non-negative and less than the size of the collection.");
36222                }
36223
36224                if (value) {
36225                    this.m_array[System.Array.index(($t = ((H5.Int.div(index, 32)) | 0)), this.m_array)] = this.m_array[System.Array.index($t, this.m_array)] | (1 << (index % 32));
36226                } else {
36227                    this.m_array[System.Array.index(($t1 = ((H5.Int.div(index, 32)) | 0)), this.m_array)] = this.m_array[System.Array.index($t1, this.m_array)] & (~(1 << (index % 32)));
36228                }
36229
36230                this._version = (this._version + 1) | 0;
36231            },
36232            SetAll: function (value) {
36233                var fillValue = value ? (-1) : 0;
36234                var ints = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32);
36235                for (var i = 0; i < ints; i = (i + 1) | 0) {
36236                    this.m_array[System.Array.index(i, this.m_array)] = fillValue;
36237                }
36238
36239                this._version = (this._version + 1) | 0;
36240            },
36241            And: function (value) {
36242                if (value == null) {
36243                    throw new System.ArgumentNullException.$ctor1("value");
36244                }
36245                if (this.Length !== value.Length) {
36246                    throw new System.ArgumentException.$ctor1("Array lengths must be the same.");
36247                }
36248
36249                var ints = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32);
36250                for (var i = 0; i < ints; i = (i + 1) | 0) {
36251                    this.m_array[System.Array.index(i, this.m_array)] = this.m_array[System.Array.index(i, this.m_array)] & value.m_array[System.Array.index(i, value.m_array)];
36252                }
36253
36254                this._version = (this._version + 1) | 0;
36255                return this;
36256            },
36257            Or: function (value) {
36258                if (value == null) {
36259                    throw new System.ArgumentNullException.$ctor1("value");
36260                }
36261                if (this.Length !== value.Length) {
36262                    throw new System.ArgumentException.$ctor1("Array lengths must be the same.");
36263                }
36264
36265                var ints = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32);
36266                for (var i = 0; i < ints; i = (i + 1) | 0) {
36267                    this.m_array[System.Array.index(i, this.m_array)] = this.m_array[System.Array.index(i, this.m_array)] | value.m_array[System.Array.index(i, value.m_array)];
36268                }
36269
36270                this._version = (this._version + 1) | 0;
36271                return this;
36272            },
36273            Xor: function (value) {
36274                if (value == null) {
36275                    throw new System.ArgumentNullException.$ctor1("value");
36276                }
36277                if (this.Length !== value.Length) {
36278                    throw new System.ArgumentException.$ctor1("Array lengths must be the same.");
36279                }
36280
36281                var ints = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32);
36282                for (var i = 0; i < ints; i = (i + 1) | 0) {
36283                    this.m_array[System.Array.index(i, this.m_array)] = this.m_array[System.Array.index(i, this.m_array)] ^ value.m_array[System.Array.index(i, value.m_array)];
36284                }
36285
36286                this._version = (this._version + 1) | 0;
36287                return this;
36288            },
36289            Not: function () {
36290                var ints = System.Collections.BitArray.GetArrayLength(this.m_length, System.Collections.BitArray.BitsPerInt32);
36291                for (var i = 0; i < ints; i = (i + 1) | 0) {
36292                    this.m_array[System.Array.index(i, this.m_array)] = ~this.m_array[System.Array.index(i, this.m_array)];
36293                }
36294
36295                this._version = (this._version + 1) | 0;
36296                return this;
36297            },
36298            clone: function () {
36299                var bitArray = new System.Collections.BitArray.$ctor5(this.m_array);
36300                bitArray._version = this._version;
36301                bitArray.m_length = this.m_length;
36302                return bitArray;
36303            },
36304            GetEnumerator: function () {
36305                return new System.Collections.BitArray.BitArrayEnumeratorSimple(this);
36306            }
36307        }
36308    });
36309
36310    // @source BitArrayEnumeratorSimple.js
36311
36312    H5.define("System.Collections.BitArray.BitArrayEnumeratorSimple", {
36313        inherits: [System.Collections.IEnumerator],
36314        $kind: "nested class",
36315        fields: {
36316            bitarray: null,
36317            index: 0,
36318            version: 0,
36319            currentElement: false
36320        },
36321        props: {
36322            Current: {
36323                get: function () {
36324                    if (this.index === -1) {
36325                        throw new System.InvalidOperationException.$ctor1("Enumeration has not started. Call MoveNext.");
36326                    }
36327                    if (this.index >= this.bitarray.Count) {
36328                        throw new System.InvalidOperationException.$ctor1("Enumeration already finished.");
36329                    }
36330                    return H5.box(this.currentElement, System.Boolean, System.Boolean.toString);
36331                }
36332            }
36333        },
36334        alias: [
36335            "moveNext", "System$Collections$IEnumerator$moveNext",
36336            "Current", "System$Collections$IEnumerator$Current",
36337            "reset", "System$Collections$IEnumerator$reset"
36338        ],
36339        ctors: {
36340            ctor: function (bitarray) {
36341                this.$initialize();
36342                this.bitarray = bitarray;
36343                this.index = -1;
36344                this.version = bitarray._version;
36345            }
36346        },
36347        methods: {
36348            moveNext: function () {
36349                if (this.version !== this.bitarray._version) {
36350                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
36351                }
36352                if (this.index < (((this.bitarray.Count - 1) | 0))) {
36353                    this.index = (this.index + 1) | 0;
36354                    this.currentElement = this.bitarray.Get(this.index);
36355                    return true;
36356                } else {
36357                    this.index = this.bitarray.Count;
36358                }
36359
36360                return false;
36361            },
36362            reset: function () {
36363                if (this.version !== this.bitarray._version) {
36364                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
36365                }
36366                this.index = -1;
36367            }
36368        }
36369    });
36370
36371    // @source BitHelper.js
36372
36373    H5.define("System.Collections.Generic.BitHelper", {
36374        statics: {
36375            fields: {
36376                MarkedBitFlag: 0,
36377                IntSize: 0
36378            },
36379            ctors: {
36380                init: function () {
36381                    this.MarkedBitFlag = 1;
36382                    this.IntSize = 32;
36383                }
36384            },
36385            methods: {
36386                ToIntArrayLength: function (n) {
36387                    return n > 0 ? (((((H5.Int.div((((n - 1) | 0)), System.Collections.Generic.BitHelper.IntSize)) | 0) + 1) | 0)) : 0;
36388                }
36389            }
36390        },
36391        fields: {
36392            _length: 0,
36393            _array: null
36394        },
36395        ctors: {
36396            ctor: function (bitArray, length) {
36397                this.$initialize();
36398                this._array = bitArray;
36399                this._length = length;
36400            }
36401        },
36402        methods: {
36403            MarkBit: function (bitPosition) {
36404                var bitArrayIndex = (H5.Int.div(bitPosition, System.Collections.Generic.BitHelper.IntSize)) | 0;
36405                if (bitArrayIndex < this._length && bitArrayIndex >= 0) {
36406                    var flag = (System.Collections.Generic.BitHelper.MarkedBitFlag << (bitPosition % System.Collections.Generic.BitHelper.IntSize));
36407                    this._array[System.Array.index(bitArrayIndex, this._array)] = this._array[System.Array.index(bitArrayIndex, this._array)] | flag;
36408                }
36409            },
36410            IsMarked: function (bitPosition) {
36411                var bitArrayIndex = (H5.Int.div(bitPosition, System.Collections.Generic.BitHelper.IntSize)) | 0;
36412                if (bitArrayIndex < this._length && bitArrayIndex >= 0) {
36413                    var flag = (System.Collections.Generic.BitHelper.MarkedBitFlag << (bitPosition % System.Collections.Generic.BitHelper.IntSize));
36414                    return ((this._array[System.Array.index(bitArrayIndex, this._array)] & flag) !== 0);
36415                }
36416                return false;
36417            }
36418        }
36419    });
36420
36421    // @source DictionaryKeyCollectionDebugView.js
36422
36423    H5.define("System.Collections.Generic.DictionaryKeyCollectionDebugView$2", function (TKey, TValue) { return {
36424        fields: {
36425            _collection: null
36426        },
36427        props: {
36428            Items: {
36429                get: function () {
36430                    var items = System.Array.init(System.Array.getCount(this._collection, TKey), function (){
36431                        return H5.getDefaultValue(TKey);
36432                    }, TKey);
36433                    System.Array.copyTo(this._collection, items, 0, TKey);
36434                    return items;
36435                }
36436            }
36437        },
36438        ctors: {
36439            ctor: function (collection) {
36440                this.$initialize();
36441                if (collection == null) {
36442                    throw new System.ArgumentNullException.$ctor1("collection");
36443                }
36444
36445                this._collection = collection;
36446            }
36447        }
36448    }; });
36449
36450    // @source DictionaryValueCollectionDebugView.js
36451
36452    H5.define("System.Collections.Generic.DictionaryValueCollectionDebugView$2", function (TKey, TValue) { return {
36453        fields: {
36454            _collection: null
36455        },
36456        props: {
36457            Items: {
36458                get: function () {
36459                    var items = System.Array.init(System.Array.getCount(this._collection, TValue), function (){
36460                        return H5.getDefaultValue(TValue);
36461                    }, TValue);
36462                    System.Array.copyTo(this._collection, items, 0, TValue);
36463                    return items;
36464                }
36465            }
36466        },
36467        ctors: {
36468            ctor: function (collection) {
36469                this.$initialize();
36470                if (collection == null) {
36471                    throw new System.ArgumentNullException.$ctor1("collection");
36472                }
36473
36474                this._collection = collection;
36475            }
36476        }
36477    }; });
36478
36479    // @source EnumerableHelpers.js
36480
36481    H5.define("H5.Collections.EnumerableHelpers", {
36482        statics: {
36483            methods: {
36484                ToArray: function (T, source) {
36485                    var count = { };
36486                    var results = { v : H5.Collections.EnumerableHelpers.ToArray$1(T, source, count) };
36487                    System.Array.resize(results, count.v, function () {
36488                        return H5.getDefaultValue(T);
36489                    }, T);
36490                    return results.v;
36491                },
36492                ToArray$1: function (T, source, length) {
36493                    var en = H5.getEnumerator(source, T);
36494                    try {
36495                        if (en.System$Collections$IEnumerator$moveNext()) {
36496                            var DefaultCapacity = 4;
36497                            var arr = { v : System.Array.init(DefaultCapacity, function (){
36498                                return H5.getDefaultValue(T);
36499                            }, T) };
36500                            arr.v[System.Array.index(0, arr.v)] = en[H5.geti(en, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")];
36501                            var count = 1;
36502
36503                            while (en.System$Collections$IEnumerator$moveNext()) {
36504                                if (count === arr.v.length) {
36505                                    var MaxArrayLength = 2146435071;
36506
36507                                    var newLength = count << 1;
36508                                    if ((newLength >>> 0) > MaxArrayLength) {
36509                                        newLength = MaxArrayLength <= count ? ((count + 1) | 0) : MaxArrayLength;
36510                                    }
36511
36512                                    System.Array.resize(arr, newLength, function () {
36513                                        return H5.getDefaultValue(T);
36514                                    }, T);
36515                                }
36516
36517                                arr.v[System.Array.index(H5.identity(count, ((count = (count + 1) | 0))), arr.v)] = en[H5.geti(en, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")];
36518                            }
36519
36520                            length.v = count;
36521                            return arr.v;
36522                        }
36523                    }
36524                    finally {
36525                        if (H5.hasValue(en)) {
36526                            en.System$IDisposable$Dispose();
36527                        }
36528                    }
36529
36530                    length.v = 0;
36531                    return System.Array.init(0, function (){
36532                        return H5.getDefaultValue(T);
36533                    }, T);
36534                }
36535            }
36536        }
36537    });
36538
36539    // @source HashSet.js
36540
36541    H5.define("System.Collections.Generic.HashSet$1", function (T) { return {
36542        inherits: [System.Collections.Generic.ICollection$1(T),System.Collections.Generic.ISet$1(T),System.Collections.Generic.IReadOnlyCollection$1(T)],
36543        statics: {
36544            fields: {
36545                Lower31BitMask: 0,
36546                ShrinkThreshold: 0
36547            },
36548            ctors: {
36549                init: function () {
36550                    this.Lower31BitMask = 2147483647;
36551                    this.ShrinkThreshold = 3;
36552                }
36553            },
36554            methods: {
36555                HashSetEquals: function (set1, set2, comparer) {
36556                    var $t, $t1, $t2;
36557                    if (set1 == null) {
36558                        return (set2 == null);
36559                    } else if (set2 == null) {
36560                        return false;
36561                    }
36562                    if (System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(set1, set2)) {
36563                        if (set1.Count !== set2.Count) {
36564                            return false;
36565                        }
36566                        $t = H5.getEnumerator(set2);
36567                        try {
36568                            while ($t.moveNext()) {
36569                                var item = $t.Current;
36570                                if (!set1.contains(item)) {
36571                                    return false;
36572                                }
36573                            }
36574                        } finally {
36575                            if (H5.is($t, System.IDisposable)) {
36576                                $t.System$IDisposable$Dispose();
36577                            }
36578                        }
36579                        return true;
36580                    } else {
36581                        $t1 = H5.getEnumerator(set2);
36582                        try {
36583                            while ($t1.moveNext()) {
36584                                var set2Item = $t1.Current;
36585                                var found = false;
36586                                $t2 = H5.getEnumerator(set1);
36587                                try {
36588                                    while ($t2.moveNext()) {
36589                                        var set1Item = $t2.Current;
36590                                        if (comparer[H5.geti(comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](set2Item, set1Item)) {
36591                                            found = true;
36592                                            break;
36593                                        }
36594                                    }
36595                                } finally {
36596                                    if (H5.is($t2, System.IDisposable)) {
36597                                        $t2.System$IDisposable$Dispose();
36598                                    }
36599                                }
36600                                if (!found) {
36601                                    return false;
36602                                }
36603                            }
36604                        } finally {
36605                            if (H5.is($t1, System.IDisposable)) {
36606                                $t1.System$IDisposable$Dispose();
36607                            }
36608                        }
36609                        return true;
36610                    }
36611                },
36612                AreEqualityComparersEqual: function (set1, set2) {
36613                    return H5.equals(set1.Comparer, set2.Comparer);
36614                }
36615            }
36616        },
36617        fields: {
36618            _buckets: null,
36619            _slots: null,
36620            _count: 0,
36621            _lastIndex: 0,
36622            _freeList: 0,
36623            _comparer: null,
36624            _version: 0
36625        },
36626        props: {
36627            Count: {
36628                get: function () {
36629                    return this._count;
36630                }
36631            },
36632            IsReadOnly: {
36633                get: function () {
36634                    return false;
36635                }
36636            },
36637            Comparer: {
36638                get: function () {
36639                    return this._comparer;
36640                }
36641            }
36642        },
36643        alias: [
36644            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
36645            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
36646            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
36647            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
36648            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove",
36649            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
36650            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
36651            "IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly",
36652            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator",
36653            "add", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$add",
36654            "unionWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$unionWith",
36655            "intersectWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$intersectWith",
36656            "exceptWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$exceptWith",
36657            "symmetricExceptWith", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$symmetricExceptWith",
36658            "isSubsetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isSubsetOf",
36659            "isProperSubsetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isProperSubsetOf",
36660            "isSupersetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isSupersetOf",
36661            "isProperSupersetOf", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$isProperSupersetOf",
36662            "overlaps", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$overlaps",
36663            "setEquals", "System$Collections$Generic$ISet$1$" + H5.getTypeAlias(T) + "$setEquals"
36664        ],
36665        ctors: {
36666            ctor: function () {
36667                System.Collections.Generic.HashSet$1(T).$ctor3.call(this, System.Collections.Generic.EqualityComparer$1(T).def);
36668            },
36669            $ctor3: function (comparer) {
36670                this.$initialize();
36671                if (comparer == null) {
36672                    comparer = System.Collections.Generic.EqualityComparer$1(T).def;
36673                }
36674                this._comparer = comparer;
36675                this._lastIndex = 0;
36676                this._count = 0;
36677                this._freeList = -1;
36678                this._version = 0;
36679            },
36680            $ctor1: function (collection) {
36681                System.Collections.Generic.HashSet$1(T).$ctor2.call(this, collection, System.Collections.Generic.EqualityComparer$1(T).def);
36682            },
36683            $ctor2: function (collection, comparer) {
36684                System.Collections.Generic.HashSet$1(T).$ctor3.call(this, comparer);
36685                if (collection == null) {
36686                    throw new System.ArgumentNullException.$ctor1("collection");
36687                }
36688                var suggestedCapacity = 0;
36689                var coll;
36690                if (((coll = H5.as(collection, System.Collections.Generic.ICollection$1(T)))) != null) {
36691                    suggestedCapacity = System.Array.getCount(coll, T);
36692                }
36693                this.Initialize(suggestedCapacity);
36694                this.unionWith(collection);
36695                if ((this._count === 0 && this._slots.length > System.Collections.HashHelpers.GetMinPrime()) || (this._count > 0 && ((H5.Int.div(this._slots.length, this._count)) | 0) > System.Collections.Generic.HashSet$1(T).ShrinkThreshold)) {
36696                    this.TrimExcess();
36697                }
36698            }
36699        },
36700        methods: {
36701            System$Collections$Generic$ICollection$1$add: function (item) {
36702                this.AddIfNotPresent(item);
36703            },
36704            add: function (item) {
36705                return this.AddIfNotPresent(item);
36706            },
36707            clear: function () {
36708                if (this._lastIndex > 0) {
36709                    for (var i = 0; i < this._lastIndex; i = (i + 1) | 0) {
36710                        this._slots[System.Array.index(i, this._slots)] = new (System.Collections.Generic.HashSet$1.Slot(T))();
36711                    }
36712
36713                    for (var i1 = 0; i1 < this._buckets.length; i1 = (i1 + 1) | 0) {
36714                        this._buckets[System.Array.index(i1, this._buckets)] = 0;
36715                    }
36716
36717                    this._lastIndex = 0;
36718                    this._count = 0;
36719                    this._freeList = -1;
36720                }
36721                this._version = (this._version + 1) | 0;
36722            },
36723            ArrayClear: function (array, index, length) { },
36724            contains: function (item) {
36725                if (this._buckets != null) {
36726                    var hashCode = this.InternalGetHashCode(item);
36727                    for (var i = (this._buckets[System.Array.index(hashCode % this._buckets.length, this._buckets)] - 1) | 0; i >= 0; i = this._slots[System.Array.index(i, this._slots)].next) {
36728                        if (this._slots[System.Array.index(i, this._slots)].hashCode === hashCode && this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this._slots[System.Array.index(i, this._slots)].value, item)) {
36729                            return true;
36730                        }
36731                    }
36732                }
36733                return false;
36734            },
36735            copyTo: function (array, arrayIndex) {
36736                this.CopyTo$1(array, arrayIndex, this._count);
36737            },
36738            CopyTo: function (array) {
36739                this.CopyTo$1(array, 0, this._count);
36740            },
36741            CopyTo$1: function (array, arrayIndex, count) {
36742                if (array == null) {
36743                    throw new System.ArgumentNullException.$ctor1("array");
36744                }
36745                if (arrayIndex < 0) {
36746                    throw new System.ArgumentOutOfRangeException.$ctor1("arrayIndex");
36747                }
36748                if (count < 0) {
36749                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
36750                }
36751                if (arrayIndex > array.length || count > ((array.length - arrayIndex) | 0)) {
36752                    throw new System.ArgumentException.$ctor1("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
36753                }
36754                var numCopied = 0;
36755                for (var i = 0; i < this._lastIndex && numCopied < count; i = (i + 1) | 0) {
36756                    if (this._slots[System.Array.index(i, this._slots)].hashCode >= 0) {
36757                        array[System.Array.index(((arrayIndex + numCopied) | 0), array)] = this._slots[System.Array.index(i, this._slots)].value;
36758                        numCopied = (numCopied + 1) | 0;
36759                    }
36760                }
36761            },
36762            remove: function (item) {
36763                if (this._buckets != null) {
36764                    var hashCode = this.InternalGetHashCode(item);
36765                    var bucket = hashCode % this._buckets.length;
36766                    var last = -1;
36767                    for (var i = (this._buckets[System.Array.index(bucket, this._buckets)] - 1) | 0; i >= 0; last = i, i = this._slots[System.Array.index(i, this._slots)].next) {
36768                        if (this._slots[System.Array.index(i, this._slots)].hashCode === hashCode && this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this._slots[System.Array.index(i, this._slots)].value, item)) {
36769                            if (last < 0) {
36770                                this._buckets[System.Array.index(bucket, this._buckets)] = (this._slots[System.Array.index(i, this._slots)].next + 1) | 0;
36771                            } else {
36772                                this._slots[System.Array.index(last, this._slots)].next = this._slots[System.Array.index(i, this._slots)].next;
36773                            }
36774                            this._slots[System.Array.index(i, this._slots)].hashCode = -1;
36775                            this._slots[System.Array.index(i, this._slots)].value = H5.getDefaultValue(T);
36776                            this._slots[System.Array.index(i, this._slots)].next = this._freeList;
36777                            this._count = (this._count - 1) | 0;
36778                            this._version = (this._version + 1) | 0;
36779                            if (this._count === 0) {
36780                                this._lastIndex = 0;
36781                                this._freeList = -1;
36782                            } else {
36783                                this._freeList = i;
36784                            }
36785                            return true;
36786                        }
36787                    }
36788                }
36789                return false;
36790            },
36791            GetEnumerator: function () {
36792                return new (System.Collections.Generic.HashSet$1.Enumerator(T)).$ctor1(this);
36793            },
36794            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
36795                return new (System.Collections.Generic.HashSet$1.Enumerator(T)).$ctor1(this).$clone();
36796            },
36797            System$Collections$IEnumerable$GetEnumerator: function () {
36798                return new (System.Collections.Generic.HashSet$1.Enumerator(T)).$ctor1(this).$clone();
36799            },
36800            unionWith: function (other) {
36801                var $t;
36802                if (other == null) {
36803                    throw new System.ArgumentNullException.$ctor1("other");
36804                }
36805                $t = H5.getEnumerator(other, T);
36806                try {
36807                    while ($t.moveNext()) {
36808                        var item = $t.Current;
36809                        this.AddIfNotPresent(item);
36810                    }
36811                } finally {
36812                    if (H5.is($t, System.IDisposable)) {
36813                        $t.System$IDisposable$Dispose();
36814                    }
36815                }
36816            },
36817            intersectWith: function (other) {
36818                if (other == null) {
36819                    throw new System.ArgumentNullException.$ctor1("other");
36820                }
36821                if (this._count === 0) {
36822                    return;
36823                }
36824                var otherAsCollection;
36825                if (((otherAsCollection = H5.as(other, System.Collections.Generic.ICollection$1(T)))) != null) {
36826                    if (System.Array.getCount(otherAsCollection, T) === 0) {
36827                        this.clear();
36828                        return;
36829                    }
36830                    var otherAsSet;
36831                    if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36832                        this.IntersectWithHashSetWithSameEC(otherAsSet);
36833                        return;
36834                    }
36835                }
36836                this.IntersectWithEnumerable(other);
36837            },
36838            exceptWith: function (other) {
36839                var $t;
36840                if (other == null) {
36841                    throw new System.ArgumentNullException.$ctor1("other");
36842                }
36843                if (this._count === 0) {
36844                    return;
36845                }
36846                if (H5.referenceEquals(other, this)) {
36847                    this.clear();
36848                    return;
36849                }
36850                $t = H5.getEnumerator(other, T);
36851                try {
36852                    while ($t.moveNext()) {
36853                        var element = $t.Current;
36854                        this.remove(element);
36855                    }
36856                } finally {
36857                    if (H5.is($t, System.IDisposable)) {
36858                        $t.System$IDisposable$Dispose();
36859                    }
36860                }
36861            },
36862            symmetricExceptWith: function (other) {
36863                if (other == null) {
36864                    throw new System.ArgumentNullException.$ctor1("other");
36865                }
36866                if (this._count === 0) {
36867                    this.unionWith(other);
36868                    return;
36869                }
36870                if (H5.referenceEquals(other, this)) {
36871                    this.clear();
36872                    return;
36873                }
36874                var otherAsSet;
36875                if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36876                    this.SymmetricExceptWithUniqueHashSet(otherAsSet);
36877                } else {
36878                    this.SymmetricExceptWithEnumerable(other);
36879                }
36880            },
36881            isSubsetOf: function (other) {
36882                if (other == null) {
36883                    throw new System.ArgumentNullException.$ctor1("other");
36884                }
36885                if (this._count === 0) {
36886                    return true;
36887                }
36888                var otherAsSet;
36889                if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36890                    if (this._count > otherAsSet.Count) {
36891                        return false;
36892                    }
36893                    return this.IsSubsetOfHashSetWithSameEC(otherAsSet);
36894                } else {
36895                    var result = this.CheckUniqueAndUnfoundElements(other, false);
36896                    return (result.uniqueCount === this._count && result.unfoundCount >= 0);
36897                }
36898            },
36899            isProperSubsetOf: function (other) {
36900                if (other == null) {
36901                    throw new System.ArgumentNullException.$ctor1("other");
36902                }
36903                var otherAsCollection;
36904                if (((otherAsCollection = H5.as(other, System.Collections.Generic.ICollection$1(T)))) != null) {
36905                    if (this._count === 0) {
36906                        return System.Array.getCount(otherAsCollection, T) > 0;
36907                    }
36908                    var otherAsSet;
36909                    if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36910                        if (this._count >= otherAsSet.Count) {
36911                            return false;
36912                        }
36913                        return this.IsSubsetOfHashSetWithSameEC(otherAsSet);
36914                    }
36915                }
36916                var result = this.CheckUniqueAndUnfoundElements(other, false);
36917                return (result.uniqueCount === this._count && result.unfoundCount > 0);
36918            },
36919            isSupersetOf: function (other) {
36920                if (other == null) {
36921                    throw new System.ArgumentNullException.$ctor1("other");
36922                }
36923                var otherAsCollection;
36924                if (((otherAsCollection = H5.as(other, System.Collections.Generic.ICollection$1(T)))) != null) {
36925                    if (System.Array.getCount(otherAsCollection, T) === 0) {
36926                        return true;
36927                    }
36928                    var otherAsSet;
36929                    if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36930                        if (otherAsSet.Count > this._count) {
36931                            return false;
36932                        }
36933                    }
36934                }
36935                return this.ContainsAllElements(other);
36936            },
36937            isProperSupersetOf: function (other) {
36938                if (other == null) {
36939                    throw new System.ArgumentNullException.$ctor1("other");
36940                }
36941                if (this._count === 0) {
36942                    return false;
36943                }
36944                var otherAsCollection;
36945                if (((otherAsCollection = H5.as(other, System.Collections.Generic.ICollection$1(T)))) != null) {
36946                    if (System.Array.getCount(otherAsCollection, T) === 0) {
36947                        return true;
36948                    }
36949                    var otherAsSet;
36950                    if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36951                        if (otherAsSet.Count >= this._count) {
36952                            return false;
36953                        }
36954                        return this.ContainsAllElements(otherAsSet);
36955                    }
36956                }
36957                var result = this.CheckUniqueAndUnfoundElements(other, true);
36958                return (result.uniqueCount < this._count && result.unfoundCount === 0);
36959            },
36960            overlaps: function (other) {
36961                var $t;
36962                if (other == null) {
36963                    throw new System.ArgumentNullException.$ctor1("other");
36964                }
36965                if (this._count === 0) {
36966                    return false;
36967                }
36968                $t = H5.getEnumerator(other, T);
36969                try {
36970                    while ($t.moveNext()) {
36971                        var element = $t.Current;
36972                        if (this.contains(element)) {
36973                            return true;
36974                        }
36975                    }
36976                } finally {
36977                    if (H5.is($t, System.IDisposable)) {
36978                        $t.System$IDisposable$Dispose();
36979                    }
36980                }
36981                return false;
36982            },
36983            setEquals: function (other) {
36984                if (other == null) {
36985                    throw new System.ArgumentNullException.$ctor1("other");
36986                }
36987                var otherAsSet;
36988                if (((otherAsSet = H5.as(other, System.Collections.Generic.HashSet$1(T)))) != null && System.Collections.Generic.HashSet$1(T).AreEqualityComparersEqual(this, otherAsSet)) {
36989                    if (this._count !== otherAsSet.Count) {
36990                        return false;
36991                    }
36992                    return this.ContainsAllElements(otherAsSet);
36993                } else {
36994                    var otherAsCollection;
36995                    if (((otherAsCollection = H5.as(other, System.Collections.Generic.ICollection$1(T)))) != null) {
36996                        if (this._count === 0 && System.Array.getCount(otherAsCollection, T) > 0) {
36997                            return false;
36998                        }
36999                    }
37000                    var result = this.CheckUniqueAndUnfoundElements(other, true);
37001                    return (result.uniqueCount === this._count && result.unfoundCount === 0);
37002                }
37003            },
37004            RemoveWhere: function (match) {
37005                if (H5.staticEquals(match, null)) {
37006                    throw new System.ArgumentNullException.$ctor1("match");
37007                }
37008                var numRemoved = 0;
37009                for (var i = 0; i < this._lastIndex; i = (i + 1) | 0) {
37010                    if (this._slots[System.Array.index(i, this._slots)].hashCode >= 0) {
37011                        var value = this._slots[System.Array.index(i, this._slots)].value;
37012                        if (match(value)) {
37013                            if (this.remove(value)) {
37014                                numRemoved = (numRemoved + 1) | 0;
37015                            }
37016                        }
37017                    }
37018                }
37019                return numRemoved;
37020            },
37021            TrimExcess: function () {
37022                if (this._count === 0) {
37023                    this._buckets = null;
37024                    this._slots = null;
37025                    this._version = (this._version + 1) | 0;
37026                } else {
37027                    var newSize = System.Collections.HashHelpers.GetPrime(this._count);
37028                    var newSlots = System.Array.init(newSize, function (){
37029                        return new (System.Collections.Generic.HashSet$1.Slot(T))();
37030                    }, System.Collections.Generic.HashSet$1.Slot(T));
37031                    var newBuckets = System.Array.init(newSize, 0, System.Int32);
37032                    var newIndex = 0;
37033                    for (var i = 0; i < this._lastIndex; i = (i + 1) | 0) {
37034                        if (this._slots[System.Array.index(i, this._slots)].hashCode >= 0) {
37035                            newSlots[System.Array.index(newIndex, newSlots)] = this._slots[System.Array.index(i, this._slots)].$clone();
37036                            var bucket = newSlots[System.Array.index(newIndex, newSlots)].hashCode % newSize;
37037                            newSlots[System.Array.index(newIndex, newSlots)].next = (newBuckets[System.Array.index(bucket, newBuckets)] - 1) | 0;
37038                            newBuckets[System.Array.index(bucket, newBuckets)] = (newIndex + 1) | 0;
37039                            newIndex = (newIndex + 1) | 0;
37040                        }
37041                    }
37042                    this._lastIndex = newIndex;
37043                    this._slots = newSlots;
37044                    this._buckets = newBuckets;
37045                    this._freeList = -1;
37046                }
37047            },
37048            Initialize: function (capacity) {
37049                var size = System.Collections.HashHelpers.GetPrime(capacity);
37050                this._buckets = System.Array.init(size, 0, System.Int32);
37051                this._slots = System.Array.init(size, function (){
37052                    return new (System.Collections.Generic.HashSet$1.Slot(T))();
37053                }, System.Collections.Generic.HashSet$1.Slot(T));
37054            },
37055            IncreaseCapacity: function () {
37056                var newSize = System.Collections.HashHelpers.ExpandPrime(this._count);
37057                if (newSize <= this._count) {
37058                    throw new System.ArgumentException.$ctor1("HashSet capacity is too big.");
37059                }
37060                this.SetCapacity(newSize, false);
37061            },
37062            SetCapacity: function (newSize, forceNewHashCodes) {
37063                var newSlots = System.Array.init(newSize, function (){
37064                    return new (System.Collections.Generic.HashSet$1.Slot(T))();
37065                }, System.Collections.Generic.HashSet$1.Slot(T));
37066                if (this._slots != null) {
37067                    for (var i = 0; i < this._lastIndex; i = (i + 1) | 0) {
37068                        newSlots[System.Array.index(i, newSlots)] = this._slots[System.Array.index(i, this._slots)].$clone();
37069                    }
37070                }
37071                if (forceNewHashCodes) {
37072                    for (var i1 = 0; i1 < this._lastIndex; i1 = (i1 + 1) | 0) {
37073                        if (newSlots[System.Array.index(i1, newSlots)].hashCode !== -1) {
37074                            newSlots[System.Array.index(i1, newSlots)].hashCode = this.InternalGetHashCode(ne
37074wSlots[System.Array.index(i1, newSlots)].value);
37075                        }
37076                    }
37077                }
37078                var newBuckets = System.Array.init(newSize, 0, System.Int32);
37079                for (var i2 = 0; i2 < this._lastIndex; i2 = (i2 + 1) | 0) {
37080                    var bucket = newSlots[System.Array.index(i2, newSlots)].hashCode % newSize;
37081                    newSlots[System.Array.index(i2, newSlots)].next = (newBuckets[System.Array.index(bucket, newBuckets)] - 1) | 0;
37082                    newBuckets[System.Array.index(bucket, newBuckets)] = (i2 + 1) | 0;
37083                }
37084                this._slots = newSlots;
37085                this._buckets = newBuckets;
37086            },
37087            AddIfNotPresent: function (value) {
37088                if (this._buckets == null) {
37089                    this.Initialize(0);
37090                }
37091                var hashCode = this.InternalGetHashCode(value);
37092                var bucket = hashCode % this._buckets.length;
37093                for (var i = (this._buckets[System.Array.index(bucket, this._buckets)] - 1) | 0; i >= 0; i = this._slots[System.Array.index(i, this._slots)].next) {
37094                    if (this._slots[System.Array.index(i, this._slots)].hashCode === hashCode && this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this._slots[System.Array.index(i, this._slots)].value, value)) {
37095                        return false;
37096                    }
37097                }
37098                var index;
37099                if (this._freeList >= 0) {
37100                    index = this._freeList;
37101                    this._freeList = this._slots[System.Array.index(index, this._slots)].next;
37102                } else {
37103                    if (this._lastIndex === this._slots.length) {
37104                        this.IncreaseCapacity();
37105                        bucket = hashCode % this._buckets.length;
37106                    }
37107                    index = this._lastIndex;
37108                    this._lastIndex = (this._lastIndex + 1) | 0;
37109                }
37110                this._slots[System.Array.index(index, this._slots)].hashCode = hashCode;
37111                this._slots[System.Array.index(index, this._slots)].value = value;
37112                this._slots[System.Array.index(index, this._slots)].next = (this._buckets[System.Array.index(bucket, this._buckets)] - 1) | 0;
37113                this._buckets[System.Array.index(bucket, this._buckets)] = (index + 1) | 0;
37114                this._count = (this._count + 1) | 0;
37115                this._version = (this._version + 1) | 0;
37116                return true;
37117            },
37118            ContainsAllElements: function (other) {
37119                var $t;
37120                $t = H5.getEnumerator(other, T);
37121                try {
37122                    while ($t.moveNext()) {
37123                        var element = $t.Current;
37124                        if (!this.contains(element)) {
37125                            return false;
37126                        }
37127                    }
37128                } finally {
37129                    if (H5.is($t, System.IDisposable)) {
37130                        $t.System$IDisposable$Dispose();
37131                    }
37132                }
37133                return true;
37134            },
37135            IsSubsetOfHashSetWithSameEC: function (other) {
37136                var $t;
37137                $t = H5.getEnumerator(this);
37138                try {
37139                    while ($t.moveNext()) {
37140                        var item = $t.Current;
37141                        if (!other.contains(item)) {
37142                            return false;
37143                        }
37144                    }
37145                } finally {
37146                    if (H5.is($t, System.IDisposable)) {
37147                        $t.System$IDisposable$Dispose();
37148                    }
37149                }
37150                return true;
37151            },
37152            IntersectWithHashSetWithSameEC: function (other) {
37153                for (var i = 0; i < this._lastIndex; i = (i + 1) | 0) {
37154                    if (this._slots[System.Array.index(i, this._slots)].hashCode >= 0) {
37155                        var item = this._slots[System.Array.index(i, this._slots)].value;
37156                        if (!other.contains(item)) {
37157                            this.remove(item);
37158                        }
37159                    }
37160                }
37161            },
37162            IntersectWithEnumerable: function (other) {
37163                var $t;
37164                var originalLastIndex = this._lastIndex;
37165                var intArrayLength = System.Collections.Generic.BitHelper.ToIntArrayLength(originalLastIndex);
37166                var bitHelper;
37167                var bitArray = System.Array.init(intArrayLength, 0, System.Int32);
37168                bitHelper = new System.Collections.Generic.BitHelper(bitArray, intArrayLength);
37169                $t = H5.getEnumerator(other, T);
37170                try {
37171                    while ($t.moveNext()) {
37172                        var item = $t.Current;
37173                        var index = this.InternalIndexOf(item);
37174                        if (index >= 0) {
37175                            bitHelper.MarkBit(index);
37176                        }
37177                    }
37178                } finally {
37179                    if (H5.is($t, System.IDisposable)) {
37180                        $t.System$IDisposable$Dispose();
37181                    }
37182                }
37183                for (var i = 0; i < originalLastIndex; i = (i + 1) | 0) {
37184                    if (this._slots[System.Array.index(i, this._slots)].hashCode >= 0 && !bitHelper.IsMarked(i)) {
37185                        this.remove(this._slots[System.Array.index(i, this._slots)].value);
37186                    }
37187                }
37188            },
37189            InternalIndexOf: function (item) {
37190                var hashCode = this.InternalGetHashCode(item);
37191                for (var i = (this._buckets[System.Array.index(hashCode % this._buckets.length, this._buckets)] - 1) | 0; i >= 0; i = this._slots[System.Array.index(i, this._slots)].next) {
37192                    if ((this._slots[System.Array.index(i, this._slots)].hashCode) === hashCode && this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this._slots[System.Array.index(i, this._slots)].value, item)) {
37193                        return i;
37194                    }
37195                }
37196                return -1;
37197            },
37198            SymmetricExceptWithUniqueHashSet: function (other) {
37199                var $t;
37200                $t = H5.getEnumerator(other);
37201                try {
37202                    while ($t.moveNext()) {
37203                        var item = $t.Current;
37204                        if (!this.remove(item)) {
37205                            this.AddIfNotPresent(item);
37206                        }
37207                    }
37208                } finally {
37209                    if (H5.is($t, System.IDisposable)) {
37210                        $t.System$IDisposable$Dispose();
37211                    }
37212                }
37213            },
37214            SymmetricExceptWithEnumerable: function (other) {
37215                var $t;
37216                var originalLastIndex = this._lastIndex;
37217                var intArrayLength = System.Collections.Generic.BitHelper.ToIntArrayLength(originalLastIndex);
37218                var itemsToRemove;
37219                var itemsAddedFromOther;
37220                var itemsToRemoveArray = System.Array.init(intArrayLength, 0, System.Int32);
37221                itemsToRemove = new System.Collections.Generic.BitHelper(itemsToRemoveArray, intArrayLength);
37222                var itemsAddedFromOtherArray = System.Array.init(intArrayLength, 0, System.Int32);
37223                itemsAddedFromOther = new System.Collections.Generic.BitHelper(itemsAddedFromOtherArray, intArrayLength);
37224                $t = H5.getEnumerator(other, T);
37225                try {
37226                    while ($t.moveNext()) {
37227                        var item = $t.Current;
37228                        var location = { v : 0 };
37229                        var added = this.AddOrGetLocation(item, location);
37230                        if (added) {
37231                            itemsAddedFromOther.MarkBit(location.v);
37232                        } else {
37233                            if (location.v < originalLastIndex && !itemsAddedFromOther.IsMarked(location.v)) {
37234                                itemsToRemove.MarkBit(location.v);
37235                            }
37236                        }
37237                    }
37238                } finally {
37239                    if (H5.is($t, System.IDisposable)) {
37240                        $t.System$IDisposable$Dispose();
37241                    }
37242                }
37243                for (var i = 0; i < originalLastIndex; i = (i + 1) | 0) {
37244                    if (itemsToRemove.IsMarked(i)) {
37245                        this.remove(this._slots[System.Array.index(i, this._slots)].value);
37246                    }
37247                }
37248            },
37249            AddOrGetLocation: function (value, location) {
37250                var hashCode = this.InternalGetHashCode(value);
37251                var bucket = hashCode % this._buckets.length;
37252                for (var i = (this._buckets[System.Array.index(bucket, this._buckets)] - 1) | 0; i >= 0; i = this._slots[System.Array.index(i, this._slots)].next) {
37253                    if (this._slots[System.Array.index(i, this._slots)].hashCode === hashCode && this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$equals2", "System$Collections$Generic$IEqualityComparer$1$equals2")](this._slots[System.Array.index(i, this._slots)].value, value)) {
37254                        location.v = i;
37255                        return false;
37256                    }
37257                }
37258                var index;
37259                if (this._freeList >= 0) {
37260                    index = this._freeList;
37261                    this._freeList = this._slots[System.Array.index(index, this._slots)].next;
37262                } else {
37263                    if (this._lastIndex === this._slots.length) {
37264                        this.IncreaseCapacity();
37265                        bucket = hashCode % this._buckets.length;
37266                    }
37267                    index = this._lastIndex;
37268                    this._lastIndex = (this._lastIndex + 1) | 0;
37269                }
37270                this._slots[System.Array.index(index, this._slots)].hashCode = hashCode;
37271                this._slots[System.Array.index(index, this._slots)].value = value;
37272                this._slots[System.Array.index(index, this._slots)].next = (this._buckets[System.Array.index(bucket, this._buckets)] - 1) | 0;
37273                this._buckets[System.Array.index(bucket, this._buckets)] = (index + 1) | 0;
37274                this._count = (this._count + 1) | 0;
37275                this._version = (this._version + 1) | 0;
37276                location.v = index;
37277                return true;
37278            },
37279            CheckUniqueAndUnfoundElements: function (other, returnIfUnfound) {
37280                var $t, $t1;
37281                var result = new (System.Collections.Generic.HashSet$1.ElementCount(T))();
37282                if (this._count === 0) {
37283                    var numElementsInOther = 0;
37284                    $t = H5.getEnumerator(other, T);
37285                    try {
37286                        while ($t.moveNext()) {
37287                            var item = $t.Current;
37288                            numElementsInOther = (numElementsInOther + 1) | 0;
37289                            break;
37290                        }
37291                    } finally {
37292                        if (H5.is($t, System.IDisposable)) {
37293                            $t.System$IDisposable$Dispose();
37294                        }
37295                    }
37296                    result.uniqueCount = 0;
37297                    result.unfoundCount = numElementsInOther;
37298                    return result.$clone();
37299                }
37300                var originalLastIndex = this._lastIndex;
37301                var intArrayLength = System.Collections.Generic.BitHelper.ToIntArrayLength(originalLastIndex);
37302                var bitHelper;
37303                var bitArray = System.Array.init(intArrayLength, 0, System.Int32);
37304                bitHelper = new System.Collections.Generic.BitHelper(bitArray, intArrayLength);
37305                var unfoundCount = 0;
37306                var uniqueFoundCount = 0;
37307                $t1 = H5.getEnumerator(other, T);
37308                try {
37309                    while ($t1.moveNext()) {
37310                        var item1 = $t1.Current;
37311                        var index = this.InternalIndexOf(item1);
37312                        if (index >= 0) {
37313                            if (!bitHelper.IsMarked(index)) {
37314                                bitHelper.MarkBit(index);
37315                                uniqueFoundCount = (uniqueFoundCount + 1) | 0;
37316                            }
37317                        } else {
37318                            unfoundCount = (unfoundCount + 1) | 0;
37319                            if (returnIfUnfound) {
37320                                break;
37321                            }
37322                        }
37323                    }
37324                } finally {
37325                    if (H5.is($t1, System.IDisposable)) {
37326                        $t1.System$IDisposable$Dispose();
37327                    }
37328                }
37329                result.uniqueCount = uniqueFoundCount;
37330                result.unfoundCount = unfoundCount;
37331                return result.$clone();
37332            },
37333            ToArray: function () {
37334                var newArray = System.Array.init(this.Count, function (){
37335                    return H5.getDefaultValue(T);
37336                }, T);
37337                this.CopyTo(newArray);
37338                return newArray;
37339            },
37340            InternalGetHashCode: function (item) {
37341                if (item == null) {
37342                    return 0;
37343                }
37344                return this._comparer[H5.geti(this._comparer, "System$Collections$Generic$IEqualityComparer$1$" + H5.getTypeAlias(T) + "$getHashCode2", "System$Collections$Generic$IEqualityComparer$1$getHashCode2")](item) & System.Collections.Generic.HashSet$1(T).Lower31BitMask;
37345            }
37346        }
37347    }; });
37348
37349    // @source ElementCount.js
37350
37351    H5.define("System.Collections.Generic.HashSet$1.ElementCount", function (T) { return {
37352        $kind: "nested struct",
37353        statics: {
37354            methods: {
37355                getDefaultValue: function () { return new (System.Collections.Generic.HashSet$1.ElementCount(T))(); }
37356            }
37357        },
37358        fields: {
37359            uniqueCount: 0,
37360            unfoundCount: 0
37361        },
37362        ctors: {
37363            ctor: function () {
37364                this.$initialize();
37365            }
37366        },
37367        methods: {
37368            getHashCode: function () {
37369                var h = H5.addHash([4920463385, this.uniqueCount, this.unfoundCount]);
37370                return h;
37371            },
37372            equals: function (o) {
37373                if (!H5.is(o, System.Collections.Generic.HashSet$1.ElementCount(T))) {
37374                    return false;
37375                }
37376                return H5.equals(this.uniqueCount, o.uniqueCount) && H5.equals(this.unfoundCount, o.unfoundCount);
37377            },
37378            $clone: function (to) {
37379                var s = to || new (System.Collections.Generic.HashSet$1.ElementCount(T))();
37380                s.uniqueCount = this.uniqueCount;
37381                s.unfoundCount = this.unfoundCount;
37382                return s;
37383            }
37384        }
37385    }; });
37386
37387    // @source Enumerator.js
37388
37389    H5.define("System.Collections.Generic.HashSet$1.Enumerator", function (T) { return {
37390        inherits: [System.Collections.Generic.IEnumerator$1(T)],
37391        $kind: "nested struct",
37392        statics: {
37393            methods: {
37394                getDefaultValue: function () { return new (System.Collections.Generic.HashSet$1.Enumerator(T))(); }
37395            }
37396        },
37397        fields: {
37398            _set: null,
37399            _index: 0,
37400            _version: 0,
37401            _current: H5.getDefaultValue(T)
37402        },
37403        props: {
37404            Current: {
37405                get: function () {
37406                    return this._current;
37407                }
37408            },
37409            System$Collections$IEnumerator$Current: {
37410                get: function () {
37411                    if (this._index === 0 || this._index === ((this._set._lastIndex + 1) | 0)) {
37412                        throw new System.InvalidOperationException.$ctor1("Enumeration has either not started or has already finished.");
37413                    }
37414                    return this.Current;
37415                }
37416            }
37417        },
37418        alias: [
37419            "Dispose", "System$IDisposable$Dispose",
37420            "moveNext", "System$Collections$IEnumerator$moveNext",
37421            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
37422        ],
37423        ctors: {
37424            $ctor1: function (set) {
37425                this.$initialize();
37426                this._set = set;
37427                this._index = 0;
37428                this._version = set._version;
37429                this._current = H5.getDefaultValue(T);
37430            },
37431            ctor: function () {
37432                this.$initialize();
37433            }
37434        },
37435        methods: {
37436            Dispose: function () { },
37437            moveNext: function () {
37438                var $t, $t1;
37439                if (this._version !== this._set._version) {
37440                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
37441                }
37442                while (this._index < this._set._lastIndex) {
37443                    if (($t = this._set._slots)[System.Array.index(this._index, $t)].hashCode >= 0) {
37444                        this._current = ($t1 = this._set._slots)[System.Array.index(this._index, $t1)].value;
37445                        this._index = (this._index + 1) | 0;
37446                        return true;
37447                    }
37448                    this._index = (this._index + 1) | 0;
37449                }
37450                this._index = (this._set._lastIndex + 1) | 0;
37451                this._current = H5.getDefaultValue(T);
37452                return false;
37453            },
37454            System$Collections$IEnumerator$reset: function () {
37455                if (this._version !== this._set._version) {
37456                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
37457                }
37458                this._index = 0;
37459                this._current = H5.getDefaultValue(T);
37460            },
37461            getHashCode: function () {
37462                var h = H5.addHash([3788985113, this._set, this._index, this._version, this._current]);
37463                return h;
37464            },
37465            equals: function (o) {
37466                if (!H5.is(o, System.Collections.Generic.HashSet$1.Enumerator(T))) {
37467                    return false;
37468                }
37469                return H5.equals(this._set, o._set) && H5.equals(this._index, o._index) && H5.equals(this._version, o._version) && H5.equals(this._current, o._current);
37470            },
37471            $clone: function (to) {
37472                var s = to || new (System.Collections.Generic.HashSet$1.Enumerator(T))();
37473                s._set = this._set;
37474                s._index = this._index;
37475                s._version = this._version;
37476                s._current = this._current;
37477                return s;
37478            }
37479        }
37480    }; });
37481
37482    // @source Slot.js
37483
37484    H5.define("System.Collections.Generic.HashSet$1.Slot", function (T) { return {
37485        $kind: "nested struct",
37486        statics: {
37487            methods: {
37488                getDefaultValue: function () { return new (System.Collections.Generic.HashSet$1.Slot(T))(); }
37489            }
37490        },
37491        fields: {
37492            hashCode: 0,
37493            value: H5.getDefaultValue(T),
37494            next: 0
37495        },
37496        ctors: {
37497            ctor: function () {
37498                this.$initialize();
37499            }
37500        },
37501        methods: {
37502            getHashCode: function () {
37503                var h = H5.addHash([1953459283, this.hashCode, this.value, this.next]);
37504                return h;
37505            },
37506            equals: function (o) {
37507                if (!H5.is(o, System.Collections.Generic.HashSet$1.Slot(T))) {
37508                    return false;
37509                }
37510                return H5.equals(this.hashCode, o.hashCode) && H5.equals(this.value, o.value) && H5.equals(this.next, o.next);
37511            },
37512            $clone: function (to) {
37513                var s = to || new (System.Collections.Generic.HashSet$1.Slot(T))();
37514                s.hashCode = this.hashCode;
37515                s.value = this.value;
37516                s.next = this.next;
37517                return s;
37518            }
37519        }
37520    }; });
37521
37522    // @source Enumerator.js
37523
37524    H5.define("System.Collections.Generic.List$1.Enumerator", function (T) { return {
37525        inherits: [System.Collections.Generic.IEnumerator$1(T),System.Collections.IEnumerator],
37526        $kind: "nested struct",
37527        statics: {
37528            methods: {
37529                getDefaultValue: function () { return new (System.Collections.Generic.List$1.Enumerator(T))(); }
37530            }
37531        },
37532        fields: {
37533            list: null,
37534            index: 0,
37535            version: 0,
37536            current: H5.getDefaultValue(T)
37537        },
37538        props: {
37539            Current: {
37540                get: function () {
37541                    return this.current;
37542                }
37543            },
37544            System$Collections$IEnumerator$Current: {
37545                get: function () {
37546                    if (this.index === 0 || this.index === ((this.list._size + 1) | 0)) {
37547                        throw new System.InvalidOperationException.ctor();
37548                    }
37549                    return this.Current;
37550                }
37551            }
37552        },
37553        alias: [
37554            "Dispose", "System$IDisposable$Dispose",
37555            "moveNext", "System$Collections$IEnumerator$moveNext",
37556            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
37557        ],
37558        ctors: {
37559            $ctor1: function (list) {
37560                this.$initialize();
37561                this.list = list;
37562                this.index = 0;
37563                this.version = list._version;
37564                this.current = H5.getDefaultValue(T);
37565            },
37566            ctor: function () {
37567                this.$initialize();
37568            }
37569        },
37570        methods: {
37571            Dispose: function () { },
37572            moveNext: function () {
37573
37574                var localList = this.list;
37575
37576                if (this.version === localList._version && ((this.index >>> 0) < (localList._size >>> 0))) {
37577                    this.current = localList._items[System.Array.index(this.index, localList._items)];
37578                    this.index = (this.index + 1) | 0;
37579                    return true;
37580                }
37581                return this.MoveNextRare();
37582            },
37583            MoveNextRare: function () {
37584                if (this.version !== this.list._version) {
37585                    throw new System.InvalidOperationException.ctor();
37586                }
37587
37588                this.index = (this.list._size + 1) | 0;
37589                this.current = H5.getDefaultValue(T);
37590                return false;
37591            },
37592            System$Collections$IEnumerator$reset: function () {
37593                if (this.version !== this.list._version) {
37594                    throw new System.InvalidOperationException.ctor();
37595                }
37596
37597                this.index = 0;
37598                this.current = H5.getDefaultValue(T);
37599            },
37600            getHashCode: function () {
37601                var h = H5.addHash([3788985113, this.list, this.index, this.version, this.current]);
37602                return h;
37603            },
37604            equals: function (o) {
37605                if (!H5.is(o, System.Collections.Generic.List$1.Enumerator(T))) {
37606                    return false;
37607                }
37608                return H5.equals(this.list, o.list) && H5.equals(this.index, o.index) && H5.equals(this.version, o.version) && H5.equals(this.current, o.current);
37609            },
37610            $clone: function (to) {
37611                var s = to || new (System.Collections.Generic.List$1.Enumerator(T))();
37612                s.list = this.list;
37613                s.index = this.index;
37614                s.version = this.version;
37615                s.current = this.current;
37616                return s;
37617            }
37618        }
37619    }; });
37620
37621    // @source Queue.js
37622
37623    H5.define("System.Collections.Generic.Queue$1", function (T) { return {
37624        inherits: [System.Collections.Generic.IEnumerable$1(T),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(T)],
37625        statics: {
37626            fields: {
37627                MinimumGrow: 0,
37628                GrowFactor: 0,
37629                DefaultCapacity: 0
37630            },
37631            ctors: {
37632                init: function () {
37633                    this.MinimumGrow = 4;
37634                    this.GrowFactor = 200;
37635                    this.DefaultCapacity = 4;
37636                }
37637            }
37638        },
37639        fields: {
37640            _array: null,
37641            _head: 0,
37642            _tail: 0,
37643            _size: 0,
37644            _version: 0
37645        },
37646        props: {
37647            Count: {
37648                get: function () {
37649                    return this._size;
37650                }
37651            },
37652            System$Collections$ICollection$IsSynchronized: {
37653                get: function () {
37654                    return false;
37655                }
37656            },
37657            System$Collections$ICollection$SyncRoot: {
37658                get: function () {
37659                    return this;
37660                }
37661            },
37662            IsReadOnly: {
37663                get: function () {
37664                    return false;
37665                }
37666            }
37667        },
37668        alias: [
37669            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
37670            "Count", "System$Collections$ICollection$Count",
37671            "copyTo", "System$Collections$ICollection$copyTo",
37672            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator"
37673        ],
37674        ctors: {
37675            ctor: function () {
37676                this.$initialize();
37677                this._array = System.Array.init(0, function (){
37678                    return H5.getDefaultValue(T);
37679                }, T);
37680            },
37681            $ctor2: function (capacity) {
37682                this.$initialize();
37683                if (capacity < 0) {
37684                    throw new System.ArgumentOutOfRangeException.$ctor4("capacity", "Non-negative number required.");
37685                }
37686                this._array = System.Array.init(capacity, function (){
37687                    return H5.getDefaultValue(T);
37688                }, T);
37689            },
37690            $ctor1: function (collection) {
37691                this.$initialize();
37692                if (collection == null) {
37693                    throw new System.ArgumentNullException.$ctor1("collection");
37694                }
37695
37696                this._array = System.Array.init(System.Collections.Generic.Queue$1(T).DefaultCapacity, function (){
37697                    return H5.getDefaultValue(T);
37698                }, T);
37699
37700                var en = H5.getEnumerator(collection, T);
37701                try {
37702                    while (en.System$Collections$IEnumerator$moveNext()) {
37703                        this.Enqueue(en[H5.geti(en, "System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1")]);
37704                    }
37705                }
37706                finally {
37707                    if (H5.hasValue(en)) {
37708                        en.System$IDisposable$Dispose();
37709                    }
37710                }
37711            }
37712        },
37713        methods: {
37714            copyTo: function (array, index) {
37715                if (array == null) {
37716                    throw new System.ArgumentNullException.$ctor1("array");
37717                }
37718
37719                if (System.Array.getRank(array) !== 1) {
37720                    throw new System.ArgumentException.$ctor1("Only single dimensional arrays are supported for the requested action.");
37721                }
37722
37723                if (index < 0) {
37724                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
37725                }
37726
37727                var arrayLen = array.length;
37728                if (((arrayLen - index) | 0) < this._size) {
37729                    throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
37730                }
37731
37732                var numToCopy = this._size;
37733                if (numToCopy === 0) {
37734                    return;
37735                }
37736
37737                var firstPart = (((this._array.length - this._head) | 0) < numToCopy) ? ((this._array.length - this._head) | 0) : numToCopy;
37738                System.Array.copy(this._array, this._head, array, index, firstPart);
37739
37740                numToCopy = (numToCopy - firstPart) | 0;
37741                if (numToCopy > 0) {
37742                    System.Array.copy(this._array, 0, array, ((((index + this._array.length) | 0) - this._head) | 0), numToCopy);
37743                }
37744            },
37745            CopyTo: function (array, arrayIndex) {
37746                if (array == null) {
37747                    throw new System.ArgumentNullException.$ctor1("array");
37748                }
37749
37750                if (arrayIndex < 0 || arrayIndex > array.length) {
37751                    throw new System.ArgumentOutOfRangeException.$ctor4("arrayIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
37752                }
37753
37754                var arrayLen = array.length;
37755                if (((arrayLen - arrayIndex) | 0) < this._size) {
37756                    throw new System.ArgumentException.$ctor1("Offset and length 
37756were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
37757                }
37758
37759                var numToCopy = (((arrayLen - arrayIndex) | 0) < this._size) ? (((arrayLen - arrayIndex) | 0)) : this._size;
37760                if (numToCopy === 0) {
37761                    return;
37762                }
37763
37764                var firstPart = (((this._array.length - this._head) | 0) < numToCopy) ? ((this._array.length - this._head) | 0) : numToCopy;
37765                System.Array.copy(this._array, this._head, array, arrayIndex, firstPart);
37766                numToCopy = (numToCopy - firstPart) | 0;
37767                if (numToCopy > 0) {
37768                    System.Array.copy(this._array, 0, array, ((((arrayIndex + this._array.length) | 0) - this._head) | 0), numToCopy);
37769                }
37770            },
37771            Clear: function () {
37772                if (this._head < this._tail) {
37773                    System.Array.fill(this._array, function () {
37774                        return H5.getDefaultValue(T);
37775                    }, this._head, this._size);
37776                } else {
37777                    System.Array.fill(this._array, function () {
37778                        return H5.getDefaultValue(T);
37779                    }, this._head, ((this._array.length - this._head) | 0));
37780                    System.Array.fill(this._array, function () {
37781                        return H5.getDefaultValue(T);
37782                    }, 0, this._tail);
37783                }
37784
37785                this._head = 0;
37786                this._tail = 0;
37787                this._size = 0;
37788                this._version = (this._version + 1) | 0;
37789            },
37790            Enqueue: function (item) {
37791                if (this._size === this._array.length) {
37792                    var newcapacity = (H5.Int.div(H5.Int.mul(this._array.length, System.Collections.Generic.Queue$1(T).GrowFactor), 100)) | 0;
37793                    if (newcapacity < ((this._array.length + System.Collections.Generic.Queue$1(T).MinimumGrow) | 0)) {
37794                        newcapacity = (this._array.length + System.Collections.Generic.Queue$1(T).MinimumGrow) | 0;
37795                    }
37796                    this.SetCapacity(newcapacity);
37797                }
37798
37799                this._array[System.Array.index(this._tail, this._array)] = item;
37800                this._tail = this.MoveNext(this._tail);
37801                this._size = (this._size + 1) | 0;
37802                this._version = (this._version + 1) | 0;
37803            },
37804            GetEnumerator: function () {
37805                return new (System.Collections.Generic.Queue$1.Enumerator(T)).$ctor1(this);
37806            },
37807            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
37808                return new (System.Collections.Generic.Queue$1.Enumerator(T)).$ctor1(this).$clone();
37809            },
37810            System$Collections$IEnumerable$GetEnumerator: function () {
37811                return new (System.Collections.Generic.Queue$1.Enumerator(T)).$ctor1(this).$clone();
37812            },
37813            Dequeue: function () {
37814                if (this._size === 0) {
37815                    throw new System.InvalidOperationException.$ctor1("Queue empty.");
37816                }
37817
37818                var removed = this._array[System.Array.index(this._head, this._array)];
37819                this._array[System.Array.index(this._head, this._array)] = H5.getDefaultValue(T);
37820                this._head = this.MoveNext(this._head);
37821                this._size = (this._size - 1) | 0;
37822                this._version = (this._version + 1) | 0;
37823                return removed;
37824            },
37825            Peek: function () {
37826                if (this._size === 0) {
37827                    throw new System.InvalidOperationException.$ctor1("Queue empty.");
37828                }
37829
37830                return this._array[System.Array.index(this._head, this._array)];
37831            },
37832            Contains: function (item) {
37833                var index = this._head;
37834                var count = this._size;
37835
37836                var c = System.Collections.Generic.EqualityComparer$1(T).def;
37837                while (H5.identity(count, ((count = (count - 1) | 0))) > 0) {
37838                    if (item == null) {
37839                        if (this._array[System.Array.index(index, this._array)] == null) {
37840                            return true;
37841                        }
37842                    } else if (this._array[System.Array.index(index, this._array)] != null && c.equals2(this._array[System.Array.index(index, this._array)], item)) {
37843                        return true;
37844                    }
37845                    index = this.MoveNext(index);
37846                }
37847
37848                return false;
37849            },
37850            GetElement: function (i) {
37851                return this._array[System.Array.index((((this._head + i) | 0)) % this._array.length, this._array)];
37852            },
37853            ToArray: function () {
37854                var arr = System.Array.init(this._size, function (){
37855                    return H5.getDefaultValue(T);
37856                }, T);
37857                if (this._size === 0) {
37858                    return arr;
37859                }
37860
37861                if (this._head < this._tail) {
37862                    System.Array.copy(this._array, this._head, arr, 0, this._size);
37863                } else {
37864                    System.Array.copy(this._array, this._head, arr, 0, ((this._array.length - this._head) | 0));
37865                    System.Array.copy(this._array, 0, arr, ((this._array.length - this._head) | 0), this._tail);
37866                }
37867
37868                return arr;
37869            },
37870            SetCapacity: function (capacity) {
37871                var newarray = System.Array.init(capacity, function (){
37872                    return H5.getDefaultValue(T);
37873                }, T);
37874                if (this._size > 0) {
37875                    if (this._head < this._tail) {
37876                        System.Array.copy(this._array, this._head, newarray, 0, this._size);
37877                    } else {
37878                        System.Array.copy(this._array, this._head, newarray, 0, ((this._array.length - this._head) | 0));
37879                        System.Array.copy(this._array, 0, newarray, ((this._array.length - this._head) | 0), this._tail);
37880                    }
37881                }
37882
37883                this._array = newarray;
37884                this._head = 0;
37885                this._tail = (this._size === capacity) ? 0 : this._size;
37886                this._version = (this._version + 1) | 0;
37887            },
37888            MoveNext: function (index) {
37889                var tmp = (index + 1) | 0;
37890                return (tmp === this._array.length) ? 0 : tmp;
37891            },
37892            TrimExcess: function () {
37893                var threshold = H5.Int.clip32(this._array.length * 0.9);
37894                if (this._size < threshold) {
37895                    this.SetCapacity(this._size);
37896                }
37897            }
37898        }
37899    }; });
37900
37901    // @source ICollectionDebugView.js
37902
37903    H5.define("System.Collections.Generic.ICollectionDebugView$1", function (T) { return {
37904        fields: {
37905            _collection: null
37906        },
37907        props: {
37908            Items: {
37909                get: function () {
37910                    var items = System.Array.init(System.Array.getCount(this._collection, T), function (){
37911                        return H5.getDefaultValue(T);
37912                    }, T);
37913                    System.Array.copyTo(this._collection, items, 0, T);
37914                    return items;
37915                }
37916            }
37917        },
37918        ctors: {
37919            ctor: function (collection) {
37920                this.$initialize();
37921                if (collection == null) {
37922                    throw new System.ArgumentNullException.$ctor1("collection");
37923                }
37924
37925                this._collection = collection;
37926            }
37927        }
37928    }; });
37929
37930    // @source IDictionaryDebugView.js
37931
37932    H5.define("System.Collections.Generic.IDictionaryDebugView$2", function (K, V) { return {
37933        fields: {
37934            _dict: null
37935        },
37936        props: {
37937            Items: {
37938                get: function () {
37939                    var items = System.Array.init(System.Array.getCount(this._dict, System.Collections.Generic.KeyValuePair$2(K,V)), function (){
37940                        return new (System.Collections.Generic.KeyValuePair$2(K,V))();
37941                    }, System.Collections.Generic.KeyValuePair$2(K,V));
37942                    System.Array.copyTo(this._dict, items, 0, System.Collections.Generic.KeyValuePair$2(K,V));
37943                    return items;
37944                }
37945            }
37946        },
37947        ctors: {
37948            ctor: function (dictionary) {
37949                this.$initialize();
37950                if (dictionary == null) {
37951                    throw new System.ArgumentNullException.$ctor1("dictionary");
37952                }
37953
37954                this._dict = dictionary;
37955            }
37956        }
37957    }; });
37958
37959    // @source Enumerator.js
37960
37961    H5.define("System.Collections.Generic.Queue$1.Enumerator", function (T) { return {
37962        inherits: [System.Collections.Generic.IEnumerator$1(T),System.Collections.IEnumerator],
37963        $kind: "nested struct",
37964        statics: {
37965            methods: {
37966                getDefaultValue: function () { return new (System.Collections.Generic.Queue$1.Enumerator(T))(); }
37967            }
37968        },
37969        fields: {
37970            _q: null,
37971            _index: 0,
37972            _version: 0,
37973            _currentElement: H5.getDefaultValue(T)
37974        },
37975        props: {
37976            Current: {
37977                get: function () {
37978                    if (this._index < 0) {
37979                        if (this._index === -1) {
37980                            throw new System.InvalidOperationException.$ctor1("Enumeration has not started. Call MoveNext.");
37981                        } else {
37982                            throw new System.InvalidOperationException.$ctor1("Enumeration already finished.");
37983                        }
37984                    }
37985                    return this._currentElement;
37986                }
37987            },
37988            System$Collections$IEnumerator$Current: {
37989                get: function () {
37990                    return this.Current;
37991                }
37992            }
37993        },
37994        alias: [
37995            "Dispose", "System$IDisposable$Dispose",
37996            "moveNext", "System$Collections$IEnumerator$moveNext",
37997            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
37998        ],
37999        ctors: {
38000            $ctor1: function (q) {
38001                this.$initialize();
38002                this._q = q;
38003                this._version = this._q._version;
38004                this._index = -1;
38005                this._currentElement = H5.getDefaultValue(T);
38006            },
38007            ctor: function () {
38008                this.$initialize();
38009            }
38010        },
38011        methods: {
38012            Dispose: function () {
38013                this._index = -2;
38014                this._currentElement = H5.getDefaultValue(T);
38015            },
38016            moveNext: function () {
38017                if (this._version !== this._q._version) {
38018                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
38019                }
38020
38021                if (this._index === -2) {
38022                    return false;
38023                }
38024
38025                this._index = (this._index + 1) | 0;
38026
38027                if (this._index === this._q._size) {
38028                    this._index = -2;
38029                    this._currentElement = H5.getDefaultValue(T);
38030                    return false;
38031                }
38032
38033                this._currentElement = this._q.GetElement(this._index);
38034                return true;
38035            },
38036            System$Collections$IEnumerator$reset: function () {
38037                if (this._version !== this._q._version) {
38038                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
38039                }
38040                this._index = -1;
38041                this._currentElement = H5.getDefaultValue(T);
38042            },
38043            getHashCode: function () {
38044                var h = H5.addHash([3788985113, this._q, this._index, this._version, this._currentElement]);
38045                return h;
38046            },
38047            equals: function (o) {
38048                if (!H5.is(o, System.Collections.Generic.Queue$1.Enumerator(T))) {
38049                    return false;
38050                }
38051                return H5.equals(this._q, o._q) && H5.equals(this._index, o._index) && H5.equals(this._version, o._version) && H5.equals(this._currentElement, o._currentElement);
38052            },
38053            $clone: function (to) {
38054                var s = to || new (System.Collections.Generic.Queue$1.Enumerator(T))();
38055                s._q = this._q;
38056                s._index = this._index;
38057                s._version = this._version;
38058                s._currentElement = this._currentElement;
38059                return s;
38060            }
38061        }
38062    }; });
38063
38064    // @source Stack.js
38065
38066    H5.define("System.Collections.Generic.Stack$1", function (T) { return {
38067        inherits: [System.Collections.Generic.IEnumerable$1(T),System.Collections.ICollection,System.Collections.Generic.IReadOnlyCollection$1(T)],
38068        statics: {
38069            fields: {
38070                DefaultCapacity: 0
38071            },
38072            ctors: {
38073                init: function () {
38074                    this.DefaultCapacity = 4;
38075                }
38076            }
38077        },
38078        fields: {
38079            _array: null,
38080            _size: 0,
38081            _version: 0
38082        },
38083        props: {
38084            Count: {
38085                get: function () {
38086                    return this._size;
38087                }
38088            },
38089            System$Collections$ICollection$IsSynchronized: {
38090                get: function () {
38091                    return false;
38092                }
38093            },
38094            System$Collections$ICollection$SyncRoot: {
38095                get: function () {
38096                    return this;
38097                }
38098            },
38099            IsReadOnly: {
38100                get: function () {
38101                    return false;
38102                }
38103            }
38104        },
38105        alias: [
38106            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
38107            "Count", "System$Collections$ICollection$Count",
38108            "copyTo", "System$Collections$ICollection$copyTo",
38109            "System$Collections$Generic$IEnumerable$1$GetEnumerator", "System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator"
38110        ],
38111        ctors: {
38112            ctor: function () {
38113                this.$initialize();
38114                this._array = System.Array.init(0, function (){
38115                    return H5.getDefaultValue(T);
38116                }, T);
38117            },
38118            $ctor2: function (capacity) {
38119                this.$initialize();
38120                if (capacity < 0) {
38121                    throw new System.ArgumentOutOfRangeException.$ctor4("capacity", "Non-negative number required.");
38122                }
38123                this._array = System.Array.init(capacity, function (){
38124                    return H5.getDefaultValue(T);
38125                }, T);
38126            },
38127            $ctor1: function (collection) {
38128                this.$initialize();
38129                if (collection == null) {
38130                    throw new System.ArgumentNullException.$ctor1("collection");
38131                }
38132                var length = { };
38133                this._array = H5.Collections.EnumerableHelpers.ToArray$1(T, collection, length);
38134                this._size = length.v;
38135            }
38136        },
38137        methods: {
38138            Clear: function () {
38139                System.Array.fill(this._array, function () {
38140                    return H5.getDefaultValue(T);
38141                }, 0, this._size);
38142                this._size = 0;
38143                this._version = (this._version + 1) | 0;
38144            },
38145            Contains: function (item) {
38146                var count = this._size;
38147
38148                var c = System.Collections.Generic.EqualityComparer$1(T).def;
38149                while (H5.identity(count, ((count = (count - 1) | 0))) > 0) {
38150                    if (item == null) {
38151                        if (this._array[System.Array.index(count, this._array)] == null) {
38152                            return true;
38153                        }
38154                    } else if (this._array[System.Array.index(count, this._array)] != null && c.equals2(this._array[System.Array.index(count, this._array)], item)) {
38155                        return true;
38156                    }
38157                }
38158                return false;
38159            },
38160            CopyTo: function (array, arrayIndex) {
38161                if (array == null) {
38162                    throw new System.ArgumentNullException.$ctor1("array");
38163                }
38164
38165                if (arrayIndex < 0 || arrayIndex > array.length) {
38166                    throw new System.ArgumentOutOfRangeException.$ctor4("arrayIndex", "Non-negative number required.");
38167                }
38168
38169                if (((array.length - arrayIndex) | 0) < this._size) {
38170                    throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
38171                }
38172
38173                if (!H5.referenceEquals(array, this._array)) {
38174                    var srcIndex = 0;
38175                    var dstIndex = (arrayIndex + this._size) | 0;
38176                    for (var i = 0; i < this._size; i = (i + 1) | 0) {
38177                        array[System.Array.index(((dstIndex = (dstIndex - 1) | 0)), array)] = this._array[System.Array.index(H5.identity(srcIndex, ((srcIndex = (srcIndex + 1) | 0))), this._array)];
38178                    }
38179                } else {
38180                    System.Array.copy(this._array, 0, array, arrayIndex, this._size);
38181                    System.Array.reverse(array, arrayIndex, this._size);
38182                }
38183            },
38184            copyTo: function (array, arrayIndex) {
38185                if (array == null) {
38186                    throw new System.ArgumentNullException.$ctor1("array");
38187                }
38188
38189                if (System.Array.getRank(array) !== 1) {
38190                    throw new System.ArgumentException.$ctor1("Only single dimensional arrays are supported for the requested action.");
38191                }
38192
38193                if (System.Array.getLower(array, 0) !== 0) {
38194                    throw new System.ArgumentException.$ctor1("The lower bound of target array must be zero.");
38195                }
38196
38197                if (arrayIndex < 0 || arrayIndex > array.length) {
38198                    throw new System.ArgumentOutOfRangeException.$ctor4("arrayIndex", "Non-negative number required.");
38199                }
38200
38201                if (((array.length - arrayIndex) | 0) < this._size) {
38202                    throw new System.ArgumentException.$ctor1("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
38203                }
38204
38205                try {
38206                    System.Array.copy(this._array, 0, array, arrayIndex, this._size);
38207                    System.Array.reverse(array, arrayIndex, this._size);
38208                } catch ($e1) {
38209                    $e1 = System.Exception.create($e1);
38210                    throw new System.ArgumentException.$ctor1("Target array type is not compatible with the type of items in the collection.");
38211                }
38212            },
38213            GetEnumerator: function () {
38214                return new (System.Collections.Generic.Stack$1.Enumerator(T)).$ctor1(this);
38215            },
38216            System$Collections$Generic$IEnumerable$1$GetEnumerator: function () {
38217                return new (System.Collections.Generic.Stack$1.Enumerator(T)).$ctor1(this).$clone();
38218            },
38219            System$Collections$IEnumerable$GetEnumerator: function () {
38220                return new (System.Collections.Generic.Stack$1.Enumerator(T)).$ctor1(this).$clone();
38221            },
38222            TrimExcess: function () {
38223                var threshold = H5.Int.clip32(this._array.length * 0.9);
38224                if (this._size < threshold) {
38225                    var localArray = { v : this._array };
38226                    System.Array.resize(localArray, this._size, function () {
38227                        return H5.getDefaultValue(T);
38228                    }, T);
38229                    this._array = localArray.v;
38230                    this._version = (this._version + 1) | 0;
38231                }
38232            },
38233            Peek: function () {
38234                if (this._size === 0) {
38235                    throw new System.InvalidOperationException.$ctor1("Stack empty.");
38236                }
38237                return this._array[System.Array.index(((this._size - 1) | 0), this._array)];
38238            },
38239            Pop: function () {
38240                if (this._size === 0) {
38241                    throw new System.InvalidOperationException.$ctor1("Stack empty.");
38242                }
38243                this._version = (this._version + 1) | 0;
38244                var item = this._array[System.Array.index(((this._size = (this._size - 1) | 0)), this._array)];
38245                this._array[System.Array.index(this._size, this._array)] = H5.getDefaultValue(T);
38246                return item;
38247            },
38248            Push: function (item) {
38249                if (this._size === this._array.length) {
38250                    var localArray = { v : this._array };
38251                    System.Array.resize(localArray, (this._array.length === 0) ? System.Collections.Generic.Stack$1(T).DefaultCapacity : H5.Int.mul(2, this._array.length), function () {
38252                        return H5.getDefaultValue(T);
38253                    }, T);
38254                    this._array = localArray.v;
38255                }
38256                this._array[System.Array.index(H5.identity(this._size, ((this._size = (this._size + 1) | 0))), this._array)] = item;
38257                this._version = (this._version + 1) | 0;
38258            },
38259            ToArray: function () {
38260                var objArray = System.Array.init(this._size, function (){
38261                    return H5.getDefaultValue(T);
38262                }, T);
38263                var i = 0;
38264                while (i < this._size) {
38265                    objArray[System.Array.index(i, objArray)] = this._array[System.Array.index(((((this._size - i) | 0) - 1) | 0), this._array)];
38266                    i = (i + 1) | 0;
38267                }
38268                return objArray;
38269            }
38270        }
38271    }; });
38272
38273    // @source Enumerator.js
38274
38275    H5.define("System.Collections.Generic.Stack$1.Enumerator", function (T) { return {
38276        inherits: [System.Collections.Generic.IEnumerator$1(T),System.Collections.IEnumerator],
38277        $kind: "nested struct",
38278        statics: {
38279            methods: {
38280                getDefaultValue: function () { return new (System.Collections.Generic.Stack$1.Enumerator(T))(); }
38281            }
38282        },
38283        fields: {
38284            _stack: null,
38285            _index: 0,
38286            _version: 0,
38287            _currentElement: H5.getDefaultValue(T)
38288        },
38289        props: {
38290            Current: {
38291                get: function () {
38292                    if (this._index === -2) {
38293                        throw new System.InvalidOperationException.$ctor1("Enumeration has not started. Call MoveNext.");
38294                    }
38295                    if (this._index === -1) {
38296                        throw new System.InvalidOperationException.$ctor1("Enumeration already finished.");
38297                    }
38298                    return this._currentElement;
38299                }
38300            },
38301            System$Collections$IEnumerator$Current: {
38302                get: function () {
38303                    if (this._index === -2) {
38304                        throw new System.InvalidOperationException.$ctor1("Enumeration has not started. Call MoveNext.");
38305                    }
38306                    if (this._index === -1) {
38307                        throw new System.InvalidOperationException.$ctor1("Enumeration already finished.");
38308                    }
38309                    return this._currentElement;
38310                }
38311            }
38312        },
38313        alias: [
38314            "Dispose", "System$IDisposable$Dispose",
38315            "moveNext", "System$Collections$IEnumerator$moveNext",
38316            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(T) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"]
38317        ],
38318        ctors: {
38319            $ctor1: function (stack) {
38320                this.$initialize();
38321                this._stack = stack;
38322                this._version = this._stack._version;
38323                this._index = -2;
38324                this._currentElement = H5.getDefaultValue(T);
38325            },
38326            ctor: function () {
38327                this.$initialize();
38328            }
38329        },
38330        methods: {
38331            Dispose: function () {
38332                this._index = -1;
38333            },
38334            moveNext: function () {
38335                var $t, $t1;
38336                var retval;
38337                if (this._version !== this._stack._version) {
38338                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
38339                }
38340                if (this._index === -2) {
38341                    this._index = (this._stack._size - 1) | 0;
38342                    retval = (this._index >= 0);
38343                    if (retval) {
38344                        this._currentElement = ($t = this._stack._array)[System.Array.index(this._index, $t)];
38345                    }
38346                    return retval;
38347                }
38348                if (this._index === -1) {
38349                    return false;
38350                }
38351
38352                retval = (((this._index = (this._index - 1) | 0)) >= 0);
38353                if (retval) {
38354                    this._currentElement = ($t1 = this._stack._array)[System.Array.index(this._index, $t1)];
38355                } else {
38356                    this._currentElement = H5.getDefaultValue(T);
38357                }
38358                return retval;
38359            },
38360            System$Collections$IEnumerator$reset: function () {
38361                if (this._version !== this._stack._version) {
38362                    throw new System.InvalidOperationException.$ctor1("Collection was modified; enumeration operation may not execute.");
38363                }
38364                this._index = -2;
38365                this._currentElement = H5.getDefaultValue(T);
38366            },
38367            getHashCode: function () {
38368                var h = H5.addHash([3788985113, this._stack, this._index, this._version, this._currentElement]);
38369                return h;
38370            },
38371            equals: function (o) {
38372                if (!H5.is(o, System.Collections.Generic.Stack$1.Enumerator(T))) {
38373                    return false;
38374                }
38375                return H5.equals(this._stack, o._stack) && H5.equals(this._index, o._index) && H5.equals(this._version, o._version) && H5.equals(this._currentElement, o._currentElement);
38376            },
38377            $clone: function (to) {
38378                var s = to || new (System.Collections.Generic.Stack$1.Enumerator(T))();
38379                s._stack = this._stack;
38380                s._index = this._index;
38381                s._version = this._version;
38382                s._currentElement = this._currentElement;
38383                return s;
38384            }
38385        }
38386    }; });
38387
38388    // @source HashHelpers.js
38389
38390    H5.define("System.Collections.HashHelpers", {
38391        statics: {
38392            fields: {
38393                HashPrime: 0,
38394                MaxPrimeArrayLength: 0,
38395                RandomSeed: 0,
38396                primes: null
38397            },
38398            ctors: {
38399                init: function () {
38400                    this.HashPrime = 101;
38401                    this.MaxPrimeArrayLength = 2146435069;
38402                    this.RandomSeed = System.Guid.NewGuid().getHashCode();
38403                    this.primes = System.Array.init([
38404                        3, 
38405                        7, 
38406                        11, 
38407                        17, 
38408                        23, 
38409                        29, 
38410                        37, 
38411                        47, 
38412                        59, 
38413                        71, 
38414                        89, 
38415                        107, 
38416                        131, 
38417                        163, 
38418                        197, 
38419                        239, 
38420                        293, 
38421                        353, 
38422                        431, 
38423                        521, 
38424                        631, 
38425                        761, 
38426                        919, 
38427                        1103, 
38428                        1327, 
38429                        1597, 
38430                        1931, 
38431                        2333, 
38432                        2801, 
38433                        3371, 
38434                        4049, 
38435                        4861, 
38436                        5839, 
38437                        7013, 
38438                        8419, 
38439                        10103, 
38440                        12143, 
38441                        14591, 
38442                        17519, 
38443                        21023, 
38444                        25229, 
38445                        30293, 
38446                        36353, 
38447                        43627, 
38448                        52361, 
38449                        62851, 
38450                        75431, 
38451                        90523, 
38452                        108631, 
38453                        130363, 
38454                        156437, 
38455                        187751, 
38456                        225307, 
38457                        270371, 
38458                        324449, 
38459                        389357, 
38460                        467237, 
38461                        560689, 
38462                        672827, 
38463                        807403, 
38464                        968897, 
38465                        1162687, 
38466                        1395263, 
38467                        1674319, 
38468                        2009191, 
38469                        2411033, 
38470                        2893249, 
38471                        3471899, 
38472                        4166287, 
38473                        4999559, 
38474                        5999471, 
38475                        7199369
38476                    ], System.Int32);
38477                }
38478            },
38479            methods: {
38480                Combine: function (h1, h2) {
38481                    var rol5 = (((((h1 >>> 0) << 5) >>> 0)) | ((h1 >>> 0) >>> 27)) >>> 0;
38482                    return ((((rol5 | 0) + h1) | 0)) ^ h2;
38483                },
38484                IsPrime: function (candidate) {
38485                    if ((candidate & 1) !== 0) {
38486                        var limit = H5.Int.clip32(Math.sqrt(candidate));
38487                        for (var divisor = 3; divisor <= limit; divisor = (divisor + 2) | 0) {
38488                            if ((candidate % divisor) === 0) {
38489                                return false;
38490                            }
38491                        }
38492                        return true;
38493                    }
38494                    return (candidate === 2);
38495                },
38496                GetPrime: function (min) {
38497                    if (min < 0) {
38498                        throw new System.ArgumentException.$ctor1("Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.");
38499                    }
38500                    for (var i = 0; i < System.Collections.HashHelpers.primes.length; i = (i + 1) | 0) {
38501                        var prime = System.Collections.HashHelpers.primes[System.Array.index(i, System.Collections.HashHelpers.primes)];
38502                        if (prime >= min) {
38503                            return prime;
38504                        }
38505                    }
38506                    for (var i1 = (min | 1); i1 < 2147483647; i1 = (i1 + 2) | 0) {
38507                        if (System.Collections.HashHelpers.IsPrime(i1) && ((((i1 - 1) | 0)) % System.Collections.HashHelpers.HashPrime !== 0)) {
38508                            return i1;
38509                        }
38510                    }
38511                    return min;
38512                },
38513                GetMinPrime: function () {
38514                    return System.Collections.HashHelpers.primes[System.Array.index(0, System.Collections.HashHelpers.primes)];
38515                },
38516                ExpandPrime: function (oldSize) {
38517                    var newSize = H5.Int.mul(2, oldSize);
38518                    if ((newSize >>> 0) > System.Collections.HashHelpers.MaxPrimeArrayLength && System.Collections.HashHelpers.MaxPrimeArrayLength > oldSize) {
38519                        return System.Collections.HashHelpers.MaxPrimeArrayLength;
38520                    }
38521                    return System.Collections.HashHelpers.GetPrime(newSize);
38522                }
38523            }
38524        }
38525    });
38526
38527    // @source Collection.js
38528
38529    H5.define("System.Collections.ObjectModel.Collection$1", function (T) { return {
38530        inherits: [System.Collections.Generic.IList$1(T),System.Collections.IList,System.Collections.Generic.IReadOnlyList$1(T)],
38531        statics: {
38532            methods: {
38533                IsCompatibleObject: function (value) {
38534                    return ((H5.is(value, T)) || (value == null && H5.getDefaultValue(T) == null));
38535                }
38536            }
38537        },
38538        fields: {
38539            items: null,
38540            _syncRoot: null
38541        },
38542        props: {
38543            Count: {
38544                get: function () {
38545                    return System.Array.getCount(this.items, T);
38546                }
38547            },
38548            Items: {
38549                get: function () {
38550                    return this.items;
38551                }
38552            },
38553            System$Collections$Generic$ICollection$1$IsReadOnly: {
38554                get: function () {
38555                    return System.Array.getIsReadOnly(this.items, T);
38556                }
38557            },
38558            System$Collections$ICollection$IsSynchronized: {
38559                get: function () {
38560                    return false;
38561                }
38562            },
38563            System$Collections$ICollection$SyncRoot: {
38564                get: function () {
38565                    if (this._syncRoot == null) {
38566                        var c;
38567                        if (((c = H5.as(this.items, System.Collections.ICollection))) != null) {
38568                            this._syncRoot = c.System$Collections$ICollection$SyncRoot;
38569                        } else {
38570                            throw System.NotImplemented.ByDesign;
38571                        }
38572                    }
38573                    return this._syncRoot;
38574                }
38575            },
38576            System$Collections$IList$IsReadOnly: {
38577                get: function () {
38578                    return System.Array.getIsReadOnly(this.items, T);
38579                }
38580            },
38581            System$Collections$IList$IsFixedSize: {
38582                get: function () {
38583                    var list;
38584                    if (((list = H5.as(this.items, System.Collections.IList))) != null) {
38585                        return System.Array.isFixedSize(list);
38586                    }
38587                    return System.Array.getIsReadOnly(this.items, T);
38588                }
38589            }
38590        },
38591        alias: [
38592            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
38593            "Count", "System$Collections$ICollection$Count",
38594            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
38595            "getItem", ["System$Collections$Generic$IReadOnlyList$1$" + H5.getTypeAlias(T) + "$getItem", "System$Collections$Generic$IReadOnlyList$1$getItem"],
38596            "setItem", ["System$Collections$Generic$IReadOnlyList$1$" + H5.getTypeAlias(T) + "$setItem", "System$Collections$Generic$IReadOnlyList$1$setItem"],
38597            "getItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$getItem",
38598            "setItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$setItem",
38599            "add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
38600            "clear", "System$Collections$IList$clear",
38601            "clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
38602            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
38603            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
38604            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"],
38605            "indexOf", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$indexOf",
38606            "insert", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$insert",
38607            "remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove",
38608            "removeAt", "System$Collections$IList$removeAt",
38609            "removeAt", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$removeAt",
38610            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly"
38611        ],
38612        ctors: {
38613            ctor: function () {
38614                this.$initialize();
38615                this.items = new (System.Collections.Generic.List$1(T)).ctor();
38616            },
38617            $ctor1: function (list) {
38618                this.$initialize();
38619                if (list == null) {
38620                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.list);
38621                }
38622                this.items = list;
38623            }
38624        },
38625        methods: {
38626            getItem: function (index) {
38627                return System.Array.getItem(this.items, index, T);
38628            },
38629            setItem: function (index, value) {
38630                if (System.Array.getIsReadOnly(this.items, T)) {
38631                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38632                }
38633
38634                if (index < 0 || index >= System.Array.getCount(this.items, T)) {
38635                    System.ThrowHelper.ThrowArgumentOutOfRange_IndexException();
38636                }
38637
38638                this.SetItem(index, value);
38639            },
38640            System$Collections$IList$getItem: function (index) {
38641                return System.Array.getItem(this.items, index, T);
38642            },
38643            System$Collections$IList$setItem: function (index, value) {
38644                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(T, value, System.ExceptionArgument.value);
38645
38646                try {
38647                    this.setItem(index, H5.cast(H5.unbox(value, T), T));
38648                } catch ($e1) {
38649                    $e1 = System.Exception.create($e1);
38650                    if (H5.is($e1, System.InvalidCastException)) {
38651                        System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, T);
38652                    } else {
38653                        throw $e1;
38654                    }
38655                }
38656            },
38657            add: function (item) {
38658                if (System.Array.getIsReadOnly(this.items, T)) {
38659                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38660                }
38661
38662                var index = System.Array.getCount(this.items, T);
38663                this.InsertItem(index, item);
38664            },
38665            System$Collections$IList$add: function (value) {
38666                if (System.Array.getIsReadOnly(this.items, T)) {
38667                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38668                }
38669                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(T, value, System.ExceptionArgument.value);
38670
38671                try {
38672                    this.add(H5.cast(H5.unbox(value, T), T));
38673                } catch ($e1) {
38674                    $e1 = System.Exception.create($e1);
38675                    if (H5.is($e1, System.InvalidCastException)) {
38676                        System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, T);
38677                    } else {
38678                        throw $e1;
38679                    }
38680                }
38681
38682                return ((this.Count - 1) | 0);
38683            },
38684            clear: function () {
38685                if (System.Array.getIsReadOnly(this.items, T)) {
38686                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38687                }
38688
38689                this.ClearItems();
38690            },
38691            copyTo: function (array, index) {
38692                System.Array.copyTo(this.items, array, index, T);
38693            },
38694            System$Collections$ICollection$copyTo: function (array, index) {
38695                if (array == null) {
38696                    System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.array);
38697                }
38698
38699                if (System.Array.getRank(array) !== 1) {
38700                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_RankMultiDimNotSupported);
38701                }
38702
38703                if (System.Array.getLower(array, 0) !== 0) {
38704                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_NonZeroLowerBound);
38705                }
38706
38707                if (index < 0) {
38708                    System.ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
38709                }
38710
38711                if (((array.length - index) | 0) < this.Count) {
38712                    System.ThrowHelper.ThrowArgumentException(System.ExceptionResource.Arg_ArrayPlusOffTooSmall);
38713                }
38714                var tArray;
38715                if (((tArray = H5.as(array, System.Array.type(T)))
38715) != null) {
38716                    System.Array.copyTo(this.items, tArray, index, T);
38717                } else {
38718                    var targetType = (H5.getType(array).$elementType || null);
38719                    var sourceType = T;
38720                    if (!(H5.Reflection.isAssignableFrom(targetType, sourceType) || H5.Reflection.isAssignableFrom(sourceType, targetType))) {
38721                        System.ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
38722                    }
38723
38724                    var objects = H5.as(array, System.Array.type(System.Object));
38725                    if (objects == null) {
38726                        System.ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
38727                    }
38728
38729                    var count = System.Array.getCount(this.items, T);
38730                    try {
38731                        for (var i = 0; i < count; i = (i + 1) | 0) {
38732                            objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = System.Array.getItem(this.items, i, T);
38733                        }
38734                    } catch ($e1) {
38735                        $e1 = System.Exception.create($e1);
38736                        if (H5.is($e1, System.ArrayTypeMismatchException)) {
38737                            System.ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
38738                        } else {
38739                            throw $e1;
38740                        }
38741                    }
38742                }
38743            },
38744            contains: function (item) {
38745                return System.Array.contains(this.items, item, T);
38746            },
38747            System$Collections$IList$contains: function (value) {
38748                if (System.Collections.ObjectModel.Collection$1(T).IsCompatibleObject(value)) {
38749                    return this.contains(H5.cast(H5.unbox(value, T), T));
38750                }
38751                return false;
38752            },
38753            GetEnumerator: function () {
38754                return H5.getEnumerator(this.items, T);
38755            },
38756            System$Collections$IEnumerable$GetEnumerator: function () {
38757                return H5.getEnumerator(H5.cast(this.items, System.Collections.IEnumerable));
38758            },
38759            indexOf: function (item) {
38760                return System.Array.indexOf(this.items, item, 0, null, T);
38761            },
38762            System$Collections$IList$indexOf: function (value) {
38763                if (System.Collections.ObjectModel.Collection$1(T).IsCompatibleObject(value)) {
38764                    return this.indexOf(H5.cast(H5.unbox(value, T), T));
38765                }
38766                return -1;
38767            },
38768            insert: function (index, item) {
38769                if (System.Array.getIsReadOnly(this.items, T)) {
38770                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38771                }
38772
38773                if (index < 0 || index > System.Array.getCount(this.items, T)) {
38774                    System.ThrowHelper.ThrowArgumentOutOfRangeException$2(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_ListInsert);
38775                }
38776
38777                this.InsertItem(index, item);
38778            },
38779            System$Collections$IList$insert: function (index, value) {
38780                if (System.Array.getIsReadOnly(this.items, T)) {
38781                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38782                }
38783                System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow(T, value, System.ExceptionArgument.value);
38784
38785                try {
38786                    this.insert(index, H5.cast(H5.unbox(value, T), T));
38787                } catch ($e1) {
38788                    $e1 = System.Exception.create($e1);
38789                    if (H5.is($e1, System.InvalidCastException)) {
38790                        System.ThrowHelper.ThrowWrongValueTypeArgumentException(System.Object, value, T);
38791                    } else {
38792                        throw $e1;
38793                    }
38794                }
38795            },
38796            remove: function (item) {
38797                if (System.Array.getIsReadOnly(this.items, T)) {
38798                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38799                }
38800
38801                var index = System.Array.indexOf(this.items, item, 0, null, T);
38802                if (index < 0) {
38803                    return false;
38804                }
38805                this.RemoveItem(index);
38806                return true;
38807            },
38808            System$Collections$IList$remove: function (value) {
38809                if (System.Array.getIsReadOnly(this.items, T)) {
38810                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38811                }
38812
38813                if (System.Collections.ObjectModel.Collection$1(T).IsCompatibleObject(value)) {
38814                    this.remove(H5.cast(H5.unbox(value, T), T));
38815                }
38816            },
38817            removeAt: function (index) {
38818                if (System.Array.getIsReadOnly(this.items, T)) {
38819                    System.ThrowHelper.ThrowNotSupportedException$1(System.ExceptionResource.NotSupported_ReadOnlyCollection);
38820                }
38821
38822                if (index < 0 || index >= System.Array.getCount(this.items, T)) {
38823                    System.ThrowHelper.ThrowArgumentOutOfRange_IndexException();
38824                }
38825
38826                this.RemoveItem(index);
38827            },
38828            ClearItems: function () {
38829                System.Array.clear(this.items, T);
38830            },
38831            InsertItem: function (index, item) {
38832                System.Array.insert(this.items, index, item, T);
38833            },
38834            RemoveItem: function (index) {
38835                System.Array.removeAt(this.items, index, T);
38836            },
38837            SetItem: function (index, item) {
38838                System.Array.setItem(this.items, index, item, T);
38839            }
38840        }
38841    }; });
38842
38843    // @source ReadOnlyCollection.js
38844
38845    H5.define("System.Collections.ObjectModel.ReadOnlyCollection$1", function (T) { return {
38846        inherits: [System.Collections.Generic.IList$1(T),System.Collections.IList,System.Collections.Generic.IReadOnlyList$1(T)],
38847        statics: {
38848            methods: {
38849                IsCompatibleObject: function (value) {
38850                    return ((H5.is(value, T)) || (value == null && H5.getDefaultValue(T) == null));
38851                }
38852            }
38853        },
38854        fields: {
38855            list: null
38856        },
38857        props: {
38858            Count: {
38859                get: function () {
38860                    return System.Array.getCount(this.list, T);
38861                }
38862            },
38863            System$Collections$ICollection$IsSynchronized: {
38864                get: function () {
38865                    return false;
38866                }
38867            },
38868            System$Collections$ICollection$SyncRoot: {
38869                get: function () {
38870                    return this;
38871                }
38872            },
38873            Items: {
38874                get: function () {
38875                    return this.list;
38876                }
38877            },
38878            System$Collections$IList$IsFixedSize: {
38879                get: function () {
38880                    return true;
38881                }
38882            },
38883            System$Collections$Generic$ICollection$1$IsReadOnly: {
38884                get: function () {
38885                    return true;
38886                }
38887            },
38888            System$Collections$IList$IsReadOnly: {
38889                get: function () {
38890                    return true;
38891                }
38892            }
38893        },
38894        alias: [
38895            "Count", ["System$Collections$Generic$IReadOnlyCollection$1$" + H5.getTypeAlias(T) + "$Count", "System$Collections$Generic$IReadOnlyCollection$1$Count"],
38896            "Count", "System$Collections$ICollection$Count",
38897            "Count", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$Count",
38898            "getItem", ["System$Collections$Generic$IReadOnlyList$1$" + H5.getTypeAlias(T) + "$getItem", "System$Collections$Generic$IReadOnlyList$1$getItem"],
38899            "contains", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$contains",
38900            "copyTo", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$copyTo",
38901            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(T) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"],
38902            "indexOf", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$indexOf",
38903            "System$Collections$Generic$ICollection$1$IsReadOnly", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$IsReadOnly",
38904            "System$Collections$Generic$IList$1$getItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$getItem",
38905            "System$Collections$Generic$IList$1$setItem", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$setItem",
38906            "System$Collections$Generic$ICollection$1$add", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$add",
38907            "System$Collections$Generic$ICollection$1$clear", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$clear",
38908            "System$Collections$Generic$IList$1$insert", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$insert",
38909            "System$Collections$Generic$ICollection$1$remove", "System$Collections$Generic$ICollection$1$" + H5.getTypeAlias(T) + "$remove",
38910            "System$Collections$Generic$IList$1$removeAt", "System$Collections$Generic$IList$1$" + H5.getTypeAlias(T) + "$removeAt"
38911        ],
38912        ctors: {
38913            ctor: function (list) {
38914                this.$initialize();
38915                if (list == null) {
38916                    throw new System.ArgumentNullException.$ctor1("list");
38917                }
38918                this.list = list;
38919            }
38920        },
38921        methods: {
38922            getItem: function (index) {
38923                return System.Array.getItem(this.list, index, T);
38924            },
38925            System$Collections$Generic$IList$1$getItem: function (index) {
38926                return System.Array.getItem(this.list, index, T);
38927            },
38928            System$Collections$Generic$IList$1$setItem: function (index, value) {
38929                throw new System.NotSupportedException.ctor();
38930            },
38931            System$Collections$IList$getItem: function (index) {
38932                return System.Array.getItem(this.list, index, T);
38933            },
38934            System$Collections$IList$setItem: function (index, value) {
38935                throw new System.NotSupportedException.ctor();
38936            },
38937            contains: function (value) {
38938                return System.Array.contains(this.list, value, T);
38939            },
38940            System$Collections$IList$contains: function (value) {
38941                if (System.Collections.ObjectModel.ReadOnlyCollection$1(T).IsCompatibleObject(value)) {
38942                    return this.contains(H5.cast(H5.unbox(value, T), T));
38943                }
38944                return false;
38945            },
38946            copyTo: function (array, index) {
38947                System.Array.copyTo(this.list, array, index, T);
38948            },
38949            System$Collections$ICollection$copyTo: function (array, index) {
38950                if (array == null) {
38951                    throw new System.ArgumentNullException.$ctor1("array");
38952                }
38953
38954                if (System.Array.getRank(array) !== 1) {
38955                    throw new System.ArgumentException.$ctor1("array");
38956                }
38957
38958                if (System.Array.getLower(array, 0) !== 0) {
38959                    throw new System.ArgumentException.$ctor1("array");
38960                }
38961
38962                if (index < 0) {
38963                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
38964                }
38965
38966                if (((array.length - index) | 0) < this.Count) {
38967                    throw new System.ArgumentException.ctor();
38968                }
38969                var items;
38970                if (((items = H5.as(array, System.Array.type(T)))) != null) {
38971                    System.Array.copyTo(this.list, items, index, T);
38972                } else {
38973                    var targetType = (H5.getType(array).$elementType || null);
38974                    var sourceType = T;
38975                    if (!(H5.Reflection.isAssignableFrom(targetType, sourceType) || H5.Reflection.isAssignableFrom(sourceType, targetType))) {
38976                        throw new System.ArgumentException.ctor();
38977                    }
38978                    var objects;
38979                    if (!(((objects = H5.as(array, System.Array.type(System.Object)))) != null)) {
38980                        throw new System.ArgumentException.ctor();
38981                    }
38982
38983                    var count = System.Array.getCount(this.list, T);
38984                    for (var i = 0; i < count; i = (i + 1) | 0) {
38985                        objects[System.Array.index(H5.identity(index, ((index = (index + 1) | 0))), objects)] = System.Array.getItem(this.list, i, T);
38986                    }
38987                }
38988            },
38989            GetEnumerator: function () {
38990                return H5.getEnumerator(this.list, T);
38991            },
38992            System$Collections$IEnumerable$GetEnumerator: function () {
38993                return H5.getEnumerator(H5.cast(this.list, System.Collections.IEnumerable));
38994            },
38995            indexOf: function (value) {
38996                return System.Array.indexOf(this.list, value, 0, null, T);
38997            },
38998            System$Collections$IList$indexOf: function (value) {
38999                if (System.Collections.ObjectModel.ReadOnlyCollection$1(T).IsCompatibleObject(value)) {
39000                    return this.indexOf(H5.cast(H5.unbox(value, T), T));
39001                }
39002                return -1;
39003            },
39004            System$Collections$Generic$ICollection$1$add: function (value) {
39005                throw new System.NotSupportedException.ctor();
39006            },
39007            System$Collections$IList$add: function (value) {
39008                throw new System.NotSupportedException.ctor();
39009            },
39010            System$Collections$Generic$ICollection$1$clear: function () {
39011                throw new System.NotSupportedException.ctor();
39012            },
39013            System$Collections$IList$clear: function () {
39014                throw new System.NotSupportedException.ctor();
39015            },
39016            System$Collections$Generic$IList$1$insert: function (index, value) {
39017                throw new System.NotSupportedException.ctor();
39018            },
39019            System$Collections$IList$insert: function (index, value) {
39020                throw new System.NotSupportedException.ctor();
39021            },
39022            System$Collections$Generic$ICollection$1$remove: function (value) {
39023                throw new System.NotSupportedException.ctor();
39024            },
39025            System$Collections$IList$remove: function (value) {
39026                throw new System.NotSupportedException.ctor();
39027            },
39028            System$Collections$Generic$IList$1$removeAt: function (index) {
39029                throw new System.NotSupportedException.ctor();
39030            },
39031            System$Collections$IList$removeAt: function (index) {
39032                throw new System.NotSupportedException.ctor();
39033            }
39034        }
39035    }; });
39036
39037    // @source BrowsableAttribute.js
39038
39039    H5.define("System.ComponentModel.BrowsableAttribute", {
39040        inherits: [System.Attribute],
39041        statics: {
39042            fields: {
39043                yes: null,
39044                no: null,
39045                default: null
39046            },
39047            ctors: {
39048                init: function () {
39049                    this.yes = new System.ComponentModel.BrowsableAttribute(true);
39050                    this.no = new System.ComponentModel.BrowsableAttribute(false);
39051                    this.default = System.ComponentModel.BrowsableAttribute.yes;
39052                }
39053            }
39054        },
39055        fields: {
39056            browsable: false
39057        },
39058        props: {
39059            Browsable: {
39060                get: function () {
39061                    return this.browsable;
39062                }
39063            }
39064        },
39065        ctors: {
39066            init: function () {
39067                this.browsable = true;
39068            },
39069            ctor: function (browsable) {
39070                this.$initialize();
39071                System.Attribute.ctor.call(this);
39072                this.browsable = browsable;
39073            }
39074        },
39075        methods: {
39076            equals: function (obj) {
39077                if (H5.referenceEquals(obj, this)) {
39078                    return true;
39079                }
39080                var other;
39081
39082                return (((other = H5.as(obj, System.ComponentModel.BrowsableAttribute))) != null) && other.Browsable === this.browsable;
39083            },
39084            getHashCode: function () {
39085                return H5.getHashCode(this.browsable);
39086            }
39087        }
39088    });
39089
39090    // @source DefaultValueAttribute.js
39091
39092    H5.define("System.ComponentModel.DefaultValueAttribute", {
39093        inherits: [System.Attribute],
39094        fields: {
39095            _value: null
39096        },
39097        props: {
39098            Value: {
39099                get: function () {
39100                    return this._value;
39101                }
39102            }
39103        },
39104        ctors: {
39105            $ctor11: function (type, value) {
39106                this.$initialize();
39107                System.Attribute.ctor.call(this);
39108                try {
39109                    if ((type.prototype instanceof System.Enum)) {
39110                        this._value = System.Enum.parse(type, value, true);
39111                    } else if (H5.referenceEquals(type, System.TimeSpan)) {
39112                        throw System.NotImplemented.ByDesign;
39113                    } else {
39114                        throw System.NotImplemented.ByDesign;
39115                    }
39116                } catch ($e1) {
39117                    $e1 = System.Exception.create($e1);
39118                }
39119            },
39120            $ctor2: function (value) {
39121                this.$initialize();
39122                System.Attribute.ctor.call(this);
39123                this._value = H5.box(value, System.Char, String.fromCharCode, System.Char.getHashCode);
39124            },
39125            $ctor1: function (value) {
39126                this.$initialize();
39127                System.Attribute.ctor.call(this);
39128                this._value = H5.box(value, System.Byte);
39129            },
39130            $ctor4: function (value) {
39131                this.$initialize();
39132                System.Attribute.ctor.call(this);
39133                this._value = H5.box(value, System.Int16);
39134            },
39135            $ctor5: function (value) {
39136                this.$initialize();
39137                System.Attribute.ctor.call(this);
39138                this._value = H5.box(value, System.Int32);
39139            },
39140            $ctor6: function (value) {
39141                this.$initialize();
39142                System.Attribute.ctor.call(this);
39143                this._value = value;
39144            },
39145            $ctor9: function (value) {
39146                this.$initialize();
39147                System.Attribute.ctor.call(this);
39148                this._value = H5.box(value, System.Single, System.Single.format, System.Single.getHashCode);
39149            },
39150            $ctor3: function (value) {
39151                this.$initialize();
39152                System.Attribute.ctor.call(this);
39153                this._value = H5.box(value, System.Double, System.Double.format, System.Double.getHashCode);
39154            },
39155            ctor: function (value) {
39156                this.$initialize();
39157                System.Attribute.ctor.call(this);
39158                this._value = H5.box(value, System.Boolean, System.Boolean.toString);
39159            },
39160            $ctor10: function (value) {
39161                this.$initialize();
39162                System.Attribute.ctor.call(this);
39163                this._value = value;
39164            },
39165            $ctor7: function (value) {
39166                this.$initialize();
39167                System.Attribute.ctor.call(this);
39168                this._value = value;
39169            },
39170            $ctor8: function (value) {
39171                this.$initialize();
39172                System.Attribute.ctor.call(this);
39173                this._value = H5.box(value, System.SByte);
39174            },
39175            $ctor12: function (value) {
39176                this.$initialize();
39177                System.Attribute.ctor.call(this);
39178                this._value = H5.box(value, System.UInt16);
39179            },
39180            $ctor13: function (value) {
39181                this.$initialize();
39182                System.Attribute.ctor.call(this);
39183                this._value = H5.box(value, System.UInt32);
39184            },
39185            $ctor14: function (value) {
39186                this.$initialize();
39187                System.Attribute.ctor.call(this);
39188                this._value = value;
39189            }
39190        },
39191        methods: {
39192            equals: function (obj) {
39193                if (H5.referenceEquals(obj, this)) {
39194                    return true;
39195                }
39196                var other;
39197
39198                if (((other = H5.as(obj, System.ComponentModel.DefaultValueAttribute))) != null) {
39199                    if (this.Value != null) {
39200                        return H5.equals(this.Value, other.Value);
39201                    } else {
39202                        return (other.Value == null);
39203                    }
39204                }
39205                return false;
39206            },
39207            getHashCode: function () {
39208                return H5.getHashCode(this);
39209            },
39210            setValue: function (value) {
39211                this._value = value;
39212            }
39213        }
39214    });
39215
39216    // @source Console.js
39217
39218    H5.define("System.Console", {
39219        statics: {
39220            methods: {
39221                write: function (value) {
39222                    System.Console.Write(System.DateTime.format(value));
39223                },
39224                write$1: function (value) {
39225                    System.Console.Write(value.toString());
39226                },
39227                Write: function (value) {
39228                    var con = H5.global.console;
39229
39230                    if (con && con.log) {
39231                        con.log(!H5.isDefined(H5.unbox(value)) ? "" : H5.unbox(value));
39232                    }
39233                },
39234                writeLine: function (value) {
39235                    System.Console.WriteLine(System.DateTime.format(value));
39236                },
39237                writeLine$1: function (value) {
39238                    System.Console.WriteLine(value.toString());
39239                },
39240                WriteLine: function (value) {
39241                    var con = H5.global.console;
39242
39243                    if (con && con.log) {
39244                        con.log(!H5.isDefined(H5.unbox(value)) ? "" : H5.unbox(value));
39245                    }
39246                },
39247                Log: function (value) {
39248                    var con = H5.global.console;
39249
39250                    if (con && con.log) {
39251                        con.log(H5.unbox(value));
39252                    }
39253                },
39254                TransformChars: function (buffer, all, index, count) {
39255                    if (all !== 1) {
39256                        if (buffer == null) {
39257                            throw new System.ArgumentNullException.$ctor1("buffer");
39258                        }
39259
39260                        if (index < 0) {
39261                            throw new System.ArgumentOutOfRangeException.$ctor4("index", "less than zero");
39262                        }
39263
39264                        if (count < 0) {
39265                            throw new System.ArgumentOutOfRangeException.$ctor4("count", "less than zero");
39266                        }
39267
39268                        if (((index + count) | 0) > buffer.length) {
39269                            throw new System.ArgumentException.$ctor1("index plus count specify a position that is not within buffer.");
39270                        }
39271                    }
39272
39273                    var s = "";
39274                    if (buffer != null) {
39275                        if (all === 1) {
39276                            index = 0;
39277                            count = buffer.length;
39278                        }
39279
39280                        for (var i = index; i < ((index + count) | 0); i = (i + 1) | 0) {
39281                            s = (s || "") + String.fromCharCode(buffer[System.Array.index(i, buffer)]);
39282                        }
39283                    }
39284
39285                    return s;
39286                },
39287                Clear: function () {
39288                    var con = H5.global.console;
39289
39290                    if (con && con.clear) {
39291                        con.clear();
39292                    }
39293                }
39294            }
39295        }
39296    });
39297
39298    // @source TokenType.js
39299
39300    H5.define("System.TokenType", {
39301        $kind: "enum",
39302        statics: {
39303            fields: {
39304                NumberToken: 1,
39305                YearNumberToken: 2,
39306                Am: 3,
39307                Pm: 4,
39308                MonthToken: 5,
39309                EndOfString: 6,
39310                DayOfWeekToken: 7,
39311                TimeZoneToken: 8,
39312                EraToken: 9,
39313                DateWordToken: 10,
39314                UnknownToken: 11,
39315                HebrewNumber: 12,
39316                JapaneseEraToken: 13,
39317                TEraToken: 14,
39318                IgnorableSymbol: 15,
39319                SEP_Unk: 256,
39320                SEP_End: 512,
39321                SEP_Space: 768,
39322                SEP_Am: 1024,
39323                SEP_Pm: 1280,
39324                SEP_Date: 1536,
39325                SEP_Time: 1792,
39326                SEP_YearSuff: 2048,
39327                SEP_MonthSuff: 2304,
39328                SEP_DaySuff: 2560,
39329                SEP_HourSuff: 2816,
39330                SEP_MinuteSuff: 3072,
39331                SEP_SecondSuff: 3328,
39332                SEP_LocalTimeMark: 3584,
39333                SEP_DateOrOffset: 3840,
39334                RegularTokenMask: 255,
39335                SeparatorTokenMask: 65280
39336            }
39337        }
39338    });
39339
39340    // @source UnitySerializationHolder.js
39341
39342    H5.define("System.UnitySerializationHolder", {
39343        inherits: [System.Runtime.Serialization.ISerializable,System.Runtime.Serialization.IObjectReference],
39344        statics: {
39345            fields: {
39346                NullUnity: 0
39347            },
39348            ctors: {
39349                init: function () {
39350                    this.NullUnity = 2;
39351                }
39352            }
39353        },
39354        alias: ["GetRealObject", "System$Runtime$Serialization$IObjectReference$GetRealObject"],
39355        methods: {
39356            GetRealObject: function (context) {
39357                throw System.NotImplemented.ByDesign;
39358
39359            }
39360        }
39361    });
39362
39363    // @source DateTimeKind.js
39364
39365    H5.define("System.DateTimeKind", {
39366        $kind: "enum",
39367        statics: {
39368            fields: {
39369                Unspecified: 0,
39370                Utc: 1,
39371                Local: 2
39372            }
39373        }
39374    });
39375
39376    // @source DateTimeOffset.js
39377
39378    H5.define("System.DateTimeOffset", {
39379        inherits: function () { return [System.IComparable,System.IFormattable,System.Runtime.Serialization.ISerializable,System.Runtime.Serialization.IDeserializationCallback,System.IComparable$1(System.DateTimeOffset),System.IEquatable$1(System.DateTimeOffset)]; },
39380        $kind: "struct",
39381        statics: {
39382            fields: {
39383                MaxOffset: System.Int64(0),
39384                MinOffset: System.Int64(0),
39385                UnixEpochTicks: System.Int64(0),
39386                UnixEpochSeconds: System.Int64(0),
39387                UnixEpochMilliseconds: System.Int64(0),
39388                MinValue: null,
39389                MaxValue: null
39390            },
39391            props: {
39392                Now: {
39393                    get: function () {
39394                        return new System.DateTimeOffset.$ctor1(System.DateTime.getNow());
39395                    }
39396                },
39397                UtcNow: {
39398                    get: function () {
39399                        return new System.DateTimeOffset.$ctor1(System.DateTime.getUtcNow());
39400                    }
39401                }
39402            },
39403            ctors: {
39404                init: function () {
39405                    this.MinValue = new System.DateTimeOffset();
39406                    this.MaxValue = new System.DateTimeOffset();
39407                    this.MaxOffset = System.Int64([1488826368,117]);
39408                    this.MinOffset = System.Int64([-1488826368,-118]);
39409                    this.UnixEpochTicks = System.Int64([-139100160,144670709]);
39410                    this.UnixEpochSeconds = System.Int64([2006054656,14]);
39411                    this.UnixEpochMilliseconds = System.Int64([304928768,14467]);
39412                    this.MinValue = new System.DateTimeOffset.$ctor5(System.DateTime.getMinTicks(), System.TimeSpan.zero);
39413                    this.MaxValue = new System.DateTimeOffset.$ctor5(System.DateTime.getMaxTicks(), System.TimeSpan.zero);
39414                }
39415            },
39416            methods: {
39417                Compare: function (first, second) {
39418                    return H5.compare(first.UtcDateTime, second.UtcDateTime);
39419                },
39420                Equals: function (first, second) {
39421                    return H5.equalsT(first.UtcDateTime, second.UtcDateTime);
39422                },
39423                FromFileTime: function (fileTime) {
39424                    return new System.DateTimeOffset.$ctor1(System.DateTime.FromFileTime(fileTime));
39425                },
39426                FromUnixTimeSeconds: function (seconds) {
39427                    var MinSeconds = System.Int64([-2006054656,-15]);
39428                    var MaxSeconds = System.Int64([-769665,58]);
39429
39430                    if (seconds.lt(MinSeconds) || seconds.gt(MaxSeconds)) {
39431                        throw new System.ArgumentOutOfRangeException.$ctor4("seconds", System.String.format(System.Environment.GetResourceString("ArgumentOutOfRange_Range"), MinSeconds, MaxSeconds));
39432                    }
39433
39434                    var ticks = seconds.mul(System.Int64(10000000)).add(System.DateTimeOffset.UnixEpochTicks);
39435                    return new System.DateTimeOffset.$ctor5(ticks, System.TimeSpan.zero);
39436                },
39437                FromUnixTimeMilliseconds: function (milliseconds) {
39438                    var MinMilliseconds = System.Int64([-304928768,-14468]);
39439                    var MaxMilliseconds = System.Int64([-769664001,58999]);
39440
39441                    if (milliseconds.lt(MinMilliseconds) || milliseconds.gt(MaxMilliseconds)) {
39442                        throw new System.ArgumentOutOfRangeException.$ctor4("milliseconds", System.String.format(System.Environment.GetResourceString("ArgumentOutOfRange_Range"), MinMilliseconds, MaxMilliseconds));
39443                    }
39444
39445                    var ticks = milliseconds.mul(System.Int64(10000)).add(System.DateTimeOffset.UnixEpochTicks);
39446                    return new System.DateTimeOffset.$ctor5(ticks, System.TimeSpan.zero);
39447                },
39448                Parse: function (input) {
39449                    var offset = { };
39450                    var dateResult = System.DateTimeParse.Parse$1(input, System.Globalization.DateTimeFormatInfo.currentInfo, 0, offset);
39451                    return new System.DateTimeOffset.$ctor5(System.DateTime.getTicks(dateResult), offset.v);
39452                },
39453                Parse$1: function (input, formatProvider) {
39454                    return System.DateTimeOffset.Parse$2(input, formatProvider, 0);
39455                },
39456                Parse$2: function (input, formatProvider, styles) {
39457                    throw System.NotImplemented.ByDesign;
39458                },
39459                ParseExact: function (input, format, formatProvider) {
39460                    return System.DateTimeOffset.ParseExact$1(input, format, formatProvider, 0);
39461                },
39462                ParseExact$1: function (input, format, formatProvider, styles) {
39463                    throw System.NotImplemented.ByDesign;
39464                },
39465                TryParse: function (input, result) {
39466                    var offset = { };
39467                    var dateResult = { };
39468                    var parsed = System.DateTimeParse.TryParse$1(input, System.Globalization.DateTimeFormatInfo.currentInfo, 0, dateResult, offset);
39469                    result.v = new System.DateTimeOffset.$ctor5(System.DateTime.getTicks(dateResult.v), offset.v);
39470                    return parsed;
39471                },
39472                ValidateOffset: function (offset) {
39473                    var ticks = offset.getTicks();
39474                    if (ticks.mod(System.Int64(600000000)).ne(System.Int64(0))) {
39475                        throw new System.ArgumentException.$ctor3(System.Environment.GetResourceString("Argument_OffsetPrecision"), "offset");
39476                    }
39477                    if (ticks.lt(System.DateTimeOffset.MinOffset) || ticks.gt(System.DateTimeOffset.MaxOffset)) {
39478                        throw new System.ArgumentOutOfRangeException.$ctor4("offset", System.Environment.GetResourceString("Argument_OffsetOutOfRange"));
39479                    }
39480                    return System.Int64.clip16(offset.getTicks().div(System.Int64(600000000)));
39481                },
39482                ValidateDate: function (dateTime, offset) {
39483                    var utcTicks = System.DateTime.getTicks(dateTime).sub(offset.getTicks());
39484                    if (utcTicks.lt(System.DateTime.getMinTicks()) || utcTicks.gt(System.DateTime.getMaxTicks())) {
39485                        throw new System.ArgumentOutOfRangeException.$ctor4("offset", System.Environment.GetResourceString("Argument_UTCOutOfRange"));
39486                    }
39487                    return System.DateTime.create$2(utcTicks, 0);
39488                },
39489                op_Implicit: function (dateTime) {
39490                    return new System.DateTimeOffset.$ctor1(dateTime);
39491                },
39492                op_Addition: function (dateTimeOffset, timeSpan) {
39493                    return new System.DateTimeOffset.$ctor2(System.DateTime.adddt(dateTimeOffset.ClockDateTime, timeSpan), dateTimeOffset.Offset);
39494                },
39495                op_Subtraction: function (dateTimeOffset, timeSpan) {
39496                    return new System.DateTimeOffset.$ctor2(System.DateTime.subdt(dateTimeOffset.ClockDateTime, timeSpan), dateTimeOffset.Offset);
39497                },
39498                op_Subtraction$1: function (left, right) {
39499                    return System.DateTime.subdd(left.UtcDateTime, right.UtcDateTime);
39500                },
39501                op_Equality: function (left, right) {
39502                    return H5.equals(left.UtcDateTime, right.UtcDateTime);
39503                },
39504                op_Inequality: function (left, right) {
39505                    return !H5.equals(left.UtcDateTime, right.UtcDateTime);
39506                },
39507                op_LessThan: function (left, right) {
39508                    return System.DateTime.lt(left.UtcDateTime, right.UtcDateTime);
39509                },
39510                op_LessThanOrEqual: function (left, right) {
39511                    return System.DateTime.lte(left.UtcDateTime, right.UtcDateTime);
39512                },
39513                op_GreaterThan: function (left, right) {
39514                    return System.DateTime.gt(left.UtcDateTime, right.UtcDateTime);
39515                },
39516                op_GreaterThanOrEqual: function (left, right) {
39517                    return System.DateTime.gte(left.UtcDateTime, right.UtcDateTime);
39518                },
39519                getDefaultValue: function () { return new System.DateTimeOffset(); }
39520            }
39521        },
39522        fields: {
39523            m_dateTime: null,
39524            m_offsetMinutes: 0
39525        },
39526        props: {
39527            DateTime: {
39528                get: function () {
39529                    return this.ClockDateTime;
39530                }
39531            },
39532            UtcDateTime: {
39533                get: function () {
39534                    return System.DateTime.specifyKind(this.m_dateTime, 1);
39535                }
39536            },
39537            LocalDateTime: {
39538                get: function () {
39539                    return System.DateTime.toLocalTime(this.UtcDateTime);
39540                }
39541            },
39542            ClockDateTime: {
39543                get: function () {
39544                    return System.DateTime.create$2(System.DateTime.getTicks((System.DateTime.adddt(this.m_dateTime, this.Offset))), 0);
39545                }
39546            },
39547            Date: {
39548                get: function () {
39549                    return System.DateTime.getDate(this.ClockDateTime);
39550                }
39551            },
39552            Day: {
39553                get: function () {
39554                    return System.DateTime.getDay(this.ClockDateTime);
39555                }
39556            },
39557            DayOfWeek: {
39558                get: function () {
39559                    return System.DateTime.getDayOfWeek(this.ClockDateTime);
39560                }
39561            },
39562            DayOfYear: {
39563                get: function () {
39564                    return System.DateTime.getDayOfYear(this.ClockDateTime);
39565                }
39566            },
39567            Hour: {
39568                get: function () {
39569                    return System.DateTime.getHour(this.ClockDateTime);
39570                }
39571            },
39572            Millisecond: {
39573                get: function () {
39574                    return System.DateTime.getMillisecond(this.ClockDateTime);
39575                }
39576            },
39577            Minute: {
39578                get: function () {
39579                    return System.DateTime.getMinute(this.ClockDateTime);
39580                }
39581            },
39582            Month: {
39583                get: function () {
39584                    return System.DateTime.getMonth(this.ClockDateTime);
39585                }
39586            },
39587            Offset: {
39588                get: function () {
39589                    return new System.TimeSpan(0, this.m_offsetMinutes, 0);
39590                }
39591            },
39592            Second: {
39593                get: function () {
39594                    return System.DateTime.getSecond(this.ClockDateTime);
39595                }
39596            },
39597            Ticks: {
39598                get: function () {
39599                    return System.DateTime.getTicks(this.ClockDateTime);
39600                }
39601            },
39602            UtcTicks: {
39603                get: function () {
39604                    return System.DateTime.getTicks(this.UtcDateTime);
39605                }
39606            },
39607            TimeOfDay: {
39608                get: function () {
39609                    return System.DateTime.getTimeOfDay(this.ClockDateTime);
39610                }
39611            },
39612            Year: {
39613                get: function () {
39614                    return System.DateTime.getYear(this.ClockDateTime);
39615                }
39616            }
39617        },
39618        alias: [
39619            "compareTo", ["System$IComparable$1$System$DateTimeOff
39619set$compareTo", "System$IComparable$1$compareTo"],
39620            "equalsT", "System$IEquatable$1$System$DateTimeOffset$equalsT",
39621            "format", "System$IFormattable$format"
39622        ],
39623        ctors: {
39624            init: function () {
39625                this.m_dateTime = System.DateTime.getDefaultValue();
39626            },
39627            $ctor5: function (ticks, offset) {
39628                this.$initialize();
39629                this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(offset);
39630                var dateTime = System.DateTime.create$2(ticks);
39631                this.m_dateTime = System.DateTimeOffset.ValidateDate(dateTime, offset);
39632            },
39633            $ctor1: function (dateTime) {
39634                this.$initialize();
39635                var offset;
39636
39637                offset = new System.TimeSpan(System.Int64(0));
39638                this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(offset);
39639                this.m_dateTime = System.DateTimeOffset.ValidateDate(dateTime, offset);
39640            },
39641            $ctor2: function (dateTime, offset) {
39642                this.$initialize();
39643                this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(offset);
39644                this.m_dateTime = System.DateTimeOffset.ValidateDate(dateTime, offset);
39645            },
39646            $ctor4: function (year, month, day, hour, minute, second, offset) {
39647                this.$initialize();
39648                this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(offset);
39649                this.m_dateTime = System.DateTimeOffset.ValidateDate(System.DateTime.create(year, month, day, hour, minute, second), offset);
39650            },
39651            $ctor3: function (year, month, day, hour, minute, second, millisecond, offset) {
39652                this.$initialize();
39653                this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(offset);
39654                this.m_dateTime = System.DateTimeOffset.ValidateDate(System.DateTime.create(year, month, day, hour, minute, second, millisecond), offset);
39655            },
39656            ctor: function () {
39657                this.$initialize();
39658            }
39659        },
39660        methods: {
39661            ToOffset: function (offset) {
39662                return new System.DateTimeOffset.$ctor5(System.DateTime.getTicks((System.DateTime.adddt(this.m_dateTime, offset))), offset);
39663            },
39664            Add: function (timeSpan) {
39665                return new System.DateTimeOffset.$ctor2(System.DateTime.add(this.ClockDateTime, timeSpan), this.Offset);
39666            },
39667            AddDays: function (days) {
39668                return new System.DateTimeOffset.$ctor2(System.DateTime.addDays(this.ClockDateTime, days), this.Offset);
39669            },
39670            AddHours: function (hours) {
39671                return new System.DateTimeOffset.$ctor2(System.DateTime.addHours(this.ClockDateTime, hours), this.Offset);
39672            },
39673            AddMilliseconds: function (milliseconds) {
39674                return new System.DateTimeOffset.$ctor2(System.DateTime.addMilliseconds(this.ClockDateTime, milliseconds), this.Offset);
39675            },
39676            AddMinutes: function (minutes) {
39677                return new System.DateTimeOffset.$ctor2(System.DateTime.addMinutes(this.ClockDateTime, minutes), this.Offset);
39678            },
39679            AddMonths: function (months) {
39680                return new System.DateTimeOffset.$ctor2(System.DateTime.addMonths(this.ClockDateTime, months), this.Offset);
39681            },
39682            AddSeconds: function (seconds) {
39683                return new System.DateTimeOffset.$ctor2(System.DateTime.addSeconds(this.ClockDateTime, seconds), this.Offset);
39684            },
39685            AddTicks: function (ticks) {
39686                return new System.DateTimeOffset.$ctor2(System.DateTime.addTicks(this.ClockDateTime, ticks), this.Offset);
39687            },
39688            AddYears: function (years) {
39689                return new System.DateTimeOffset.$ctor2(System.DateTime.addYears(this.ClockDateTime, years), this.Offset);
39690            },
39691            System$IComparable$compareTo: function (obj) {
39692                if (obj == null) {
39693                    return 1;
39694                }
39695                if (!(H5.is(obj, System.DateTimeOffset))) {
39696                    throw new System.ArgumentException.$ctor1(System.Environment.GetResourceString("Arg_MustBeDateTimeOffset"));
39697                }
39698
39699                var objUtc = System.Nullable.getValue(H5.cast(H5.unbox(obj, System.DateTimeOffset), System.DateTimeOffset)).UtcDateTime;
39700                var utc = this.UtcDateTime;
39701                if (System.DateTime.gt(utc, objUtc)) {
39702                    return 1;
39703                }
39704                if (System.DateTime.lt(utc, objUtc)) {
39705                    return -1;
39706                }
39707                return 0;
39708            },
39709            compareTo: function (other) {
39710                var otherUtc = other.UtcDateTime;
39711                var utc = this.UtcDateTime;
39712                if (System.DateTime.gt(utc, otherUtc)) {
39713                    return 1;
39714                }
39715                if (System.DateTime.lt(utc, otherUtc)) {
39716                    return -1;
39717                }
39718                return 0;
39719            },
39720            equals: function (obj) {
39721                var offset = new System.DateTimeOffset();
39722                if (System.Nullable.liftne(System.DateTimeOffset.op_Inequality, ((offset = H5.is(obj, System.DateTimeOffset) ? System.Nullable.getValue(H5.cast(H5.unbox(obj, System.DateTimeOffset), System.DateTimeOffset)) : null)), null)) {
39723                    return H5.equalsT(this.UtcDateTime, offset.UtcDateTime);
39724                }
39725                return false;
39726            },
39727            equalsT: function (other) {
39728                return H5.equalsT(this.UtcDateTime, other.UtcDateTime);
39729            },
39730            EqualsExact: function (other) {
39731                return (H5.equals(this.ClockDateTime, other.ClockDateTime) && System.TimeSpan.eq(this.Offset, other.Offset) && System.DateTime.getKind(this.ClockDateTime) === System.DateTime.getKind(other.ClockDateTime));
39732            },
39733            System$Runtime$Serialization$IDeserializationCallback$OnDeserialization: function (sender) {
39734                try {
39735                    this.m_offsetMinutes = System.DateTimeOffset.ValidateOffset(this.Offset);
39736                    this.m_dateTime = System.DateTimeOffset.ValidateDate(this.ClockDateTime, this.Offset);
39737                } catch ($e1) {
39738                    $e1 = System.Exception.create($e1);
39739                    var e;
39740                    if (H5.is($e1, System.ArgumentException)) {
39741                        e = $e1;
39742                        throw new System.Runtime.Serialization.SerializationException.$ctor2(System.Environment.GetResourceString("Serialization_InvalidData"), e);
39743                    } else {
39744                        throw $e1;
39745                    }
39746                }
39747            },
39748            getHashCode: function () {
39749                return H5.getHashCode(this.UtcDateTime);
39750            },
39751            Subtract$1: function (value) {
39752                return System.DateTime.subdd(this.UtcDateTime, value.UtcDateTime);
39753            },
39754            Subtract: function (value) {
39755                return new System.DateTimeOffset.$ctor2(System.DateTime.subtract(this.ClockDateTime, value), this.Offset);
39756            },
39757            ToFileTime: function () {
39758                return System.DateTime.ToFileTime(this.UtcDateTime);
39759            },
39760            ToUnixTimeSeconds: function () {
39761                var seconds = System.DateTime.getTicks(this.UtcDateTime).div(System.Int64(10000000));
39762                return seconds.sub(System.DateTimeOffset.UnixEpochSeconds);
39763            },
39764            ToUnixTimeMilliseconds: function () {
39765                var milliseconds = System.DateTime.getTicks(this.UtcDateTime).div(System.Int64(10000));
39766                return milliseconds.sub(System.DateTimeOffset.UnixEpochMilliseconds);
39767            },
39768            ToLocalTime: function () {
39769                return this.ToLocalTime$1(false);
39770            },
39771            ToLocalTime$1: function (throwOnOverflow) {
39772                return new System.DateTimeOffset.$ctor1(System.DateTime.toLocalTime(this.UtcDateTime, throwOnOverflow));
39773            },
39774            toString: function () {
39775                return System.DateTime.format(System.DateTime.specifyKind(this.ClockDateTime, 2));
39776
39777            },
39778            ToString$1: function (format) {
39779                return System.DateTime.format(System.DateTime.specifyKind(this.ClockDateTime, 2), format);
39780
39781            },
39782            ToString: function (formatProvider) {
39783                return System.DateTime.format(System.DateTime.specifyKind(this.ClockDateTime, 2), null, formatProvider);
39784
39785            },
39786            format: function (format, formatProvider) {
39787                return System.DateTime.format(System.DateTime.specifyKind(this.ClockDateTime, 2), format, formatProvider);
39788
39789            },
39790            ToUniversalTime: function () {
39791                return new System.DateTimeOffset.$ctor1(this.UtcDateTime);
39792            },
39793            $clone: function (to) {
39794                var s = to || new System.DateTimeOffset();
39795                s.m_dateTime = this.m_dateTime;
39796                s.m_offsetMinutes = this.m_offsetMinutes;
39797                return s;
39798            }
39799        }
39800    });
39801
39802    // @source DateTimeParse.js
39803
39804    H5.define("System.DateTimeParse", {
39805        statics: {
39806            methods: {
39807                TryParseExact: function (s, format, dtfi, style, result) {
39808                    return System.DateTime.tryParseExact(s, format, null, result);
39809
39810                },
39811                Parse: function (s, dtfi, styles) {
39812                    return System.DateTime.parse(s, dtfi);
39813                },
39814                Parse$1: function (s, dtfi, styles, offset) {
39815                    throw System.NotImplemented.ByDesign;
39816
39817                },
39818                TryParse: function (s, dtfi, styles, result) {
39819                    return System.DateTime.tryParse(s, null, result);
39820
39821                },
39822                TryParse$1: function (s, dtfi, styles, result, offset) {
39823                    throw System.NotImplemented.ByDesign;
39824                }
39825            }
39826        }
39827    });
39828
39829    // @source DateTimeResult.js
39830
39831    H5.define("System.DateTimeResult", {
39832        $kind: "struct",
39833        statics: {
39834            methods: {
39835                getDefaultValue: function () { return new System.DateTimeResult(); }
39836            }
39837        },
39838        fields: {
39839            Year: 0,
39840            Month: 0,
39841            Day: 0,
39842            Hour: 0,
39843            Minute: 0,
39844            Second: 0,
39845            fraction: 0,
39846            era: 0,
39847            flags: 0,
39848            timeZoneOffset: null,
39849            calendar: null,
39850            parsedDate: null,
39851            failure: 0,
39852            failureMessageID: null,
39853            failureMessageFormatArgument: null,
39854            failureArgumentName: null
39855        },
39856        ctors: {
39857            init: function () {
39858                this.timeZoneOffset = new System.TimeSpan();
39859                this.parsedDate = System.DateTime.getDefaultValue();
39860            },
39861            ctor: function () {
39862                this.$initialize();
39863            }
39864        },
39865        methods: {
39866            Init: function () {
39867                this.Year = -1;
39868                this.Month = -1;
39869                this.Day = -1;
39870                this.fraction = -1;
39871                this.era = -1;
39872            },
39873            SetDate: function (year, month, day) {
39874                this.Year = year;
39875                this.Month = month;
39876                this.Day = day;
39877            },
39878            SetFailure: function (failure, failureMessageID, failureMessageFormatArgument) {
39879                this.failure = failure;
39880                this.failureMessageID = failureMessageID;
39881                this.failureMessageFormatArgument = failureMessageFormatArgument;
39882            },
39883            SetFailure$1: function (failure, failureMessageID, failureMessageFormatArgument, failureArgumentName) {
39884                this.failure = failure;
39885                this.failureMessageID = failureMessageID;
39886                this.failureMessageFormatArgument = failureMessageFormatArgument;
39887                this.failureArgumentName = failureArgumentName;
39888            },
39889            getHashCode: function () {
39890                var h = H5.addHash([5374321750, this.Year, this.Month, this.Day, this.Hour, this.Minute, this.Second, this.fraction, this.era, this.flags, this.timeZoneOffset, this.calendar, this.parsedDate, this.failure, this.failureMessageID, this.failureMessageFormatArgument, this.failureArgumentName]);
39891                return h;
39892            },
39893            equals: function (o) {
39894                if (!H5.is(o, System.DateTimeResult)) {
39895                    return false;
39896                }
39897                return H5.equals(this.Year, o.Year) && H5.equals(this.Month, o.Month) && H5.equals(this.Day, o.Day) && H5.equals(this.Hour, o.Hour) && H5.equals(this.Minute, o.Minute) && H5.equals(this.Second, o.Second) && H5.equals(this.fraction, o.fraction) && H5.equals(this.era, o.era) && H5.equals(this.flags, o.flags) && H5.equals(this.timeZoneOffset, o.timeZoneOffset) && H5.equals(this.calendar, o.calendar) && H5.equals(this.parsedDate, o.parsedDate) && H5.equals(this.failure, o.failure) && H5.equals(this.failureMessageID, o.failureMessageID) && H5.equals(this.failureMessageFormatArgument, o.failureMessageFormatArgument) && H5.equals(this.failureArgumentName, o.failureArgumentName);
39898            },
39899            $clone: function (to) {
39900                var s = to || new System.DateTimeResult();
39901                s.Year = this.Year;
39902                s.Month = this.Month;
39903                s.Day = this.Day;
39904                s.Hour = this.Hour;
39905                s.Minute = this.Minute;
39906                s.Second = this.Second;
39907                s.fraction = this.fraction;
39908                s.era = this.era;
39909                s.flags = this.flags;
39910                s.timeZoneOffset = this.timeZoneOffset;
39911                s.calendar = this.calendar;
39912                s.parsedDate = this.parsedDate;
39913                s.failure = this.failure;
39914                s.failureMessageID = this.failureMessageID;
39915                s.failureMessageFormatArgument = this.failureMessageFormatArgument;
39916                s.failureArgumentName = this.failureArgumentName;
39917                return s;
39918            }
39919        }
39920    });
39921
39922    // @source DayOfWeek.js
39923
39924    H5.define("System.DayOfWeek", {
39925        $kind: "enum",
39926        statics: {
39927            fields: {
39928                Sunday: 0,
39929                Monday: 1,
39930                Tuesday: 2,
39931                Wednesday: 3,
39932                Thursday: 4,
39933                Friday: 5,
39934                Saturday: 6
39935            }
39936        }
39937    });
39938
39939    // @source DBNull.js
39940
39941    H5.define("System.DBNull", {
39942        inherits: [System.Runtime.Serialization.ISerializable,System.IConvertible],
39943        statics: {
39944            fields: {
39945                Value: null
39946            },
39947            ctors: {
39948                init: function () {
39949                    this.Value = new System.DBNull();
39950                }
39951            }
39952        },
39953        alias: [
39954            "ToString", "System$IConvertible$ToString",
39955            "GetTypeCode", "System$IConvertible$GetTypeCode"
39956        ],
39957        ctors: {
39958            ctor: function () {
39959                this.$initialize();
39960            }
39961        },
39962        methods: {
39963            toString: function () {
39964                return "";
39965            },
39966            ToString: function (provider) {
39967                return "";
39968            },
39969            GetTypeCode: function () {
39970                return System.TypeCode.DBNull;
39971            },
39972            System$IConvertible$ToBoolean: function (provider) {
39973                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39974            },
39975            System$IConvertible$ToChar: function (provider) {
39976                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39977            },
39978            System$IConvertible$ToSByte: function (provider) {
39979                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39980            },
39981            System$IConvertible$ToByte: function (provider) {
39982                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39983            },
39984            System$IConvertible$ToInt16: function (provider) {
39985                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39986            },
39987            System$IConvertible$ToUInt16: function (provider) {
39988                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39989            },
39990            System$IConvertible$ToInt32: function (provider) {
39991                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39992            },
39993            System$IConvertible$ToUInt32: function (provider) {
39994                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39995            },
39996            System$IConvertible$ToInt64: function (provider) {
39997                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
39998            },
39999            System$IConvertible$ToUInt64: function (provider) {
40000                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
40001            },
40002            System$IConvertible$ToSingle: function (provider) {
40003                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
40004            },
40005            System$IConvertible$ToDouble: function (provider) {
40006                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
40007            },
40008            System$IConvertible$ToDecimal: function (provider) {
40009                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
40010            },
40011            System$IConvertible$ToDateTime: function (provider) {
40012                throw new System.InvalidCastException.$ctor1("Object cannot be cast from DBNull to other types.");
40013            },
40014            System$IConvertible$ToType: function (type, provider) {
40015                return System.Convert.defaultToType(H5.cast(this, System.IConvertible), type, provider);
40016            }
40017        }
40018    });
40019
40020    // @source Empty.js
40021
40022    H5.define("System.Empty", {
40023        statics: {
40024            fields: {
40025                Value: null
40026            },
40027            ctors: {
40028                init: function () {
40029                    this.Value = new System.Empty();
40030                }
40031            }
40032        },
40033        ctors: {
40034            ctor: function () {
40035                this.$initialize();
40036            }
40037        },
40038        methods: {
40039            toString: function () {
40040                return "";
40041            }
40042        }
40043    });
40044
40045    // @source ApplicationException.js
40046
40047    H5.define("System.ApplicationException", {
40048        inherits: [System.Exception],
40049        ctors: {
40050            ctor: function () {
40051                this.$initialize();
40052                System.Exception.ctor.call(this, "Error in the application.");
40053                this.HResult = -2146232832;
40054            },
40055            $ctor1: function (message) {
40056                this.$initialize();
40057                System.Exception.ctor.call(this, message);
40058                this.HResult = -2146232832;
40059            },
40060            $ctor2: function (message, innerException) {
40061                this.$initialize();
40062                System.Exception.ctor.call(this, message, innerException);
40063                this.HResult = -2146232832;
40064            }
40065        }
40066    });
40067
40068    // @source ArgumentException.js
40069
40070    H5.define("System.ArgumentException", {
40071        inherits: [System.SystemException],
40072        fields: {
40073            _paramName: null
40074        },
40075        props: {
40076            Message: {
40077                get: function () {
40078                    var s = H5.ensureBaseProperty(this, "Message").$System$Exception$Message;
40079                    if (!System.String.isNullOrEmpty(this._paramName)) {
40080                        var resourceString = System.SR.Format("Parameter name: {0}", this._paramName);
40081                        return (s || "") + ("\n" || "") + (resourceString || "");
40082                    } else {
40083                        return s;
40084                    }
40085                }
40086            },
40087            ParamName: {
40088                get: function () {
40089                    return this._paramName;
40090                }
40091            }
40092        },
40093        ctors: {
40094            ctor: function () {
40095                this.$initialize();
40096                System.SystemException.$ctor1.call(this, "Value does not fall within the expected range.");
40097                this.HResult = -2147024809;
40098            },
40099            $ctor1: function (message) {
40100                this.$initialize();
40101                System.SystemException.$ctor1.call(this, message);
40102                this.HResult = -2147024809;
40103            },
40104            $ctor2: function (message, innerException) {
40105                this.$initialize();
40106                System.SystemException.$ctor2.call(this, message, innerException);
40107                this.HResult = -2147024809;
40108            },
40109            $ctor4: function (message, paramName, innerException) {
40110                this.$initialize();
40111                System.SystemException.$ctor2.call(this, message, innerException);
40112                this._paramName = paramName;
40113                this.HResult = -2147024809;
40114            },
40115            $ctor3: function (message, paramName) {
40116                this.$initialize();
40117                System.SystemException.$ctor1.call(this, message);
40118                this._paramName = paramName;
40119                this.HResult = -2147024809;
40120            }
40121        }
40122    });
40123
40124    // @source ArgumentNullException.js
40125
40126    H5.define("System.ArgumentNullException", {
40127        inherits: [System.ArgumentException],
40128        ctors: {
40129            ctor: function () {
40130                this.$initialize();
40131                System.ArgumentException.$ctor1.call(this, "Value cannot be null.");
40132                this.HResult = -2147467261;
40133            },
40134            $ctor1: function (paramName) {
40135                this.$initialize();
40136                System.ArgumentException.$ctor3.call(this, "Value cannot be null.", paramName);
40137                this.HResult = -2147467261;
40138            },
40139            $ctor2: function (message, innerException) {
40140                this.$initialize();
40141                System.ArgumentException.$ctor2.call(this, message, innerException);
40142                this.HResult = -2147467261;
40143            },
40144            $ctor3: function (paramName, message) {
40145                this.$initialize();
40146                System.ArgumentException.$ctor3.call(this, message, paramName);
40147                this.HResult = -2147467261;
40148            }
40149        }
40150    });
40151
40152    // @source ArgumentOutOfRangeException.js
40153
40154    H5.define("System.ArgumentOutOfRangeException", {
40155        inherits: [System.ArgumentException],
40156        fields: {
40157            _actualValue: null
40158        },
40159        props: {
40160            Message: {
40161                get: function () {
40162                    var s = H5.ensureBaseProperty(this, "Message").$System$ArgumentException$Message;
40163                    if (this._actualValue != null) {
40164                        var valueMessage = System.SR.Format("Actual value was {0}.", H5.toString(this._actualValue));
40165                        if (s == null) {
40166                            return valueMessage;
40167                        }
40168                        return (s || "") + ("\n" || "") + (valueMessage || "");
40169                    }
40170                    return s;
40171                }
40172            },
40173            ActualValue: {
40174                get: function () {
40175                    return this._actualValue;
40176                }
40177            }
40178        },
40179        ctors: {
40180            ctor: function () {
40181                this.$initialize();
40182                System.ArgumentException.$ctor1.call(this, "Specified argument was out of the range of valid values.");
40183                this.HResult = -2146233086;
40184            },
40185            $ctor1: function (paramName) {
40186                this.$initialize();
40187                System.ArgumentException.$ctor3.call(this, "Specified argument was out of the range of valid values.", paramName);
40188                this.HResult = -2146233086;
40189            },
40190            $ctor4: function (paramName, message) {
40191                this.$initialize();
40192                System.ArgumentException.$ctor3.call(this, message, paramName);
40193                this.HResult = -2146233086;
40194            },
40195            $ctor2: function (message, innerException) {
40196                this.$initialize();
40197                System.ArgumentException.$ctor2.call(this, message, innerException);
40198                this.HResult = -2146233086;
40199            },
40200            $ctor3: function (paramName, actualValue, message) {
40201                this.$initialize();
40202                System.ArgumentException.$ctor3.call(this, message, paramName);
40203                this._actualValue = actualValue;
40204                this.HResult = -2146233086;
40205            }
40206        }
40207    });
40208
40209    // @source ArithmeticException.js
40210
40211    H5.define("System.ArithmeticException", {
40212        inherits: [System.SystemException],
40213        ctors: {
40214            ctor: function () {
40215                this.$initialize();
40216                System.SystemException.$ctor1.call(this, "Overflow or underflow in the arithmetic operation.");
40217                this.HResult = -2147024362;
40218            },
40219            $ctor1: function (message) {
40220                this.$initialize();
40221                System.SystemException.$ctor1.call(this, message);
40222                this.HResult = -2147024362;
40223            },
40224            $ctor2: function (message, innerException) {
40225                this.$initialize();
40226                System.SystemException.$ctor2.call(this, message, innerException);
40227                this.HResult = -2147024362;
40228            }
40229        }
40230    });
40231
40232    // @source Base64FormattingOptions.js
40233
40234    H5.define("System.Base64FormattingOptions", {
40235        $kind: "enum",
40236        statics: {
40237            fields: {
40238                None: 0,
40239                InsertLineBreaks: 1
40240            }
40241        },
40242        $flags: true
40243    });
40244
40245    // @source DivideByZeroException.js
40246
40247    H5.define("System.DivideByZeroException", {
40248        inherits: [System.ArithmeticException],
40249        ctors: {
40250            ctor: function () {
40251                this.$initialize();
40252                System.ArithmeticException.$ctor1.call(this, "Attempted to divide by zero.");
40253                this.HResult = -2147352558;
40254            },
40255            $ctor1: function (message) {
40256                this.$initialize();
40257                System.ArithmeticException.$ctor1.call(this, message);
40258                this.HResult = -2147352558;
40259            },
40260            $ctor2: function (message, innerException) {
40261                this.$initialize();
40262                System.ArithmeticException.$ctor2.call(this, message, innerException);
40263                this.HResult = -2147352558;
40264            }
40265        }
40266    });
40267
40268    // @source ExceptionArgument.js
40269
40270    H5.define("System.ExceptionArgument", {
40271        $kind: "enum",
40272        statics: {
40273            fields: {
40274                obj: 0,
40275                dictionary: 1,
40276                array: 2,
40277                info: 3,
40278                key: 4,
40279                collection: 5,
40280                list: 6,
40281                match: 7,
40282                converter: 8,
40283                capacity: 9,
40284                index: 10,
40285                startIndex: 11,
40286                value: 12,
40287                count: 13,
40288                arrayIndex: 14,
40289                $name: 15,
40290                item: 16,
40291                options: 17,
40292                view: 18,
40293                sourceBytesToCopy: 19,
40294                action: 20,
40295                comparison: 21,
40296                offset: 22,
40297                newSize: 23,
40298                elementType: 24,
40299                $length: 25,
40300                length1: 26,
40301                length2: 27,
40302                length3: 28,
40303                lengths: 29,
40304                len: 30,
40305                lowerBounds: 31,
40306                sourceArray: 32,
40307                destinationArray: 33,
40308                sourceIndex: 34,
40309                destinationIndex: 35,
40310                indices: 36,
40311                index1: 37,
40312                index2: 38,
40313                index3: 39,
40314                other: 40,
40315                comparer: 41,
40316                endIndex: 42,
40317                keys: 43,
40318                creationOptions: 44,
40319                timeout: 45,
40320                tasks: 46,
40321                scheduler: 47,
40322                continuationFunction: 48,
40323                millisecondsTimeout: 49,
40324                millisecondsDelay: 50,
40325                function: 51,
40326                exceptions: 52,
40327                exception: 53,
40328                cancellationToken: 54,
40329                delay: 55,
40330                asyncResult: 56,
40331                endMethod: 57,
40332                endFunction: 58,
40333                beginMethod: 59,
40334                continuationOptions: 60,
40335                continuationAction: 61,
40336                concurrencyLevel: 62,
40337                text: 63,
40338                callBack: 64,
40339                type: 65,
40340                stateMachine: 66,
40341                pHandle: 67,
40342                values: 68,
40343                task: 69,
40344                s: 70,
40345                keyValuePair: 71,
40346                input: 72,
40347                ownedMemory: 73,
40348                pointer: 74,
40349                start: 75,
40350                format: 76,
40351                culture: 77,
40352                comparable: 78,
40353                source: 79,
40354                state: 80
40355            }
40356        }
40357    });
40358
40359    // @source ExceptionResource.js
40360
40361    H5.define("System.ExceptionResource", {
40362        $kind: "enum",
40363        statics: {
40364            fields: {
40365                Argument_ImplementIComparable: 0,
40366                Argument_InvalidType: 1,
40367                Argument_InvalidArgumentForComparison: 2,
40368                Argument_InvalidRegistryKeyPermissionCheck: 3,
40369                ArgumentOutOfRange_NeedNonNegNum: 4,
40370                Arg_ArrayPlusOffTooSmall: 5,
40371                Arg_NonZeroLowerBound: 6,
40372                Arg_RankMultiDimNotSupported: 7,
40373                Arg_RegKeyDelHive: 8,
40374                Arg_RegKeyStrLenBug: 9,
40375                Arg_RegSetStrArrNull: 10,
40376                Arg_RegSetMismatchedKind: 11,
40377                Arg_RegSubKeyAbsent: 12,
40378                Arg_RegSubKeyValueAbsent: 13,
40379                Argument_AddingDuplicate: 14,
40380                Serialization_InvalidOnDeser: 15,
40381                Serialization_MissingKeys: 16,
40382                Serialization_NullKey: 17,
40383                Argument_InvalidArrayType: 18,
40384                NotSupported_KeyCollectionSet: 19,
40385                NotSupported_ValueCollectionSet: 20,
40386                ArgumentOutOfRange_SmallCapacity: 21,
40387                ArgumentOutOfRange_Index: 22,
40388                Argument_InvalidOffLen: 23,
40389                Argument_ItemNotExist: 24,
40390                ArgumentOutOfRange_Count: 25,
40391                ArgumentOutOfRange_InvalidThreshold: 26,
40392                ArgumentOutOfRange_ListInsert: 27,
40393                NotSupported_ReadOnlyCollection: 28,
40394                InvalidOperation_CannotRemoveFromStackOrQueue: 29,
40395                InvalidOperation_EmptyQueue: 30,
40396                InvalidOperation_EnumOpCantHappen: 31,
40397                InvalidOperation_EnumFailedVersion: 32,
40398                InvalidOperation_EmptyStack: 33,
40399                ArgumentOutOfRange_BiggerThanCollection: 34,
40400                InvalidOperation_EnumNotStarted: 35,
40401                InvalidOperation_EnumEnded: 36,
40402                NotSupported_SortedListNestedWrite: 37,
40403                InvalidOperation_NoValue: 38,
40404                InvalidOperation_RegRemoveSubKey: 39,
40405                Security_RegistryPermission: 40,
40406                UnauthorizedAccess_RegistryNoWrite: 41,
40407                ObjectDisposed_RegKeyClosed: 42,
40408                NotSupported_InComparableType: 43,
40409                Argument_InvalidRegistryOptionsCheck: 44,
40410                Argument_InvalidRegistryViewCheck: 45,
40411                InvalidOperation_NullArray: 46,
40412                Arg_MustBeType: 47,
40413                Arg_NeedAtLeast1Rank: 48,
40414                ArgumentOutOfRange_HugeArrayNotSupported: 49,
40415                Arg_RanksAndBounds: 50,
40416                Arg_RankIndices: 51,
40417                Arg_Need1DArray: 52,
40418                Arg_Need2DArray: 53,
40419                Arg_Need3DArray: 54,
40420                NotSupported_FixedSizeCollection: 55,
40421                ArgumentException_OtherNotArrayOfCorrectLength: 56,
40422                Rank_MultiDimNotSupported: 57,
40423                InvalidOperation_IComparerFailed: 58,
40424                ArgumentOutOfRange_EndIndexStartIndex: 59,
40425                Arg_LowerBoundsMustMatch: 60,
40426                Arg_BogusIComparer: 61,
40427                Task_WaitMulti_NullTask: 62,
40428                Task_ThrowIfDisposed: 63,
40429                Task_Start_TaskCompleted: 64,
40430                Task_Start_Promise: 65,
40431                Task_Start_ContinuationTask: 66,
40432                Task_Start_AlreadyStarted: 67,
40433                Task_RunSynchronously_TaskCompleted: 68,
40434                Task_RunSynchronously_Continuation: 69,
40435                Task_RunSynchronously_Promise: 70,
40436                Task_RunSynchronously_AlreadyStarted: 71,
40437                Task_MultiTaskContinuation_NullTask: 72,
40438                Task_MultiTaskContinuation_EmptyTaskList: 73,
40439                Task_Dispose_NotCompleted: 74,
40440                Task_Delay_InvalidMillisecondsDelay: 75,
40441                Task_Delay_InvalidDelay: 76,
40442                Task_ctor_LRandSR: 77,
40443                Task_ContinueWith_NotOnAnything: 78,
40444                Task_ContinueWith_ESandLR: 79,
40445                TaskT_TransitionToFinal_AlreadyCompleted: 80,
40446                TaskCompletionSourceT_TrySetException_NullException: 81,
40447                TaskCompletionSourceT_TrySetException_NoExceptions: 82,
40448                MemoryDisposed: 83,
40449                Memory_OutstandingReferences: 84,
40450                InvalidOperation_WrongAsyncResultOrEndCalledMultiple: 85,
40451                ConcurrentDictionary_ConcurrencyLevelMustBePositive: 86,
40452                ConcurrentDictionary_CapacityMustNotBeNegative: 87,
40453                ConcurrentDictionary_TypeOfValueIncorrect: 88,
40454                ConcurrentDictionary_TypeOfKeyIncorrect: 89,
40455                ConcurrentDictionary_KeyAlreadyExisted: 90,
40456                ConcurrentDictionary_ItemKeyIsNull: 91,
40457                ConcurrentDictionary_IndexIsNegative: 92,
40458                ConcurrentDictionary_ArrayNotLargeEnough: 93,
40459                ConcurrentDictionary_ArrayIncorrectType: 94,
40460                ConcurrentCollection_SyncRoot_NotSupported: 95,
40461                ArgumentOutOfRange_Enum: 96,
40462                InvalidOperation_HandleIsNotInitialized: 97,
40463                AsyncMethodBuilder_InstanceNotInitialized: 98,
40464                ArgumentNull_SafeHandle: 99
40465            }
40466        }
40467    });
40468
40469    // @source FormatException.js
40470
40471    H5.define("System.FormatException", {
40472        inherits: [System.SystemException],
40473        ctors: {
40474            ctor: function () {
40475                this.$initialize();
40476                System.SystemException.$ctor1.call(this, "One of the identified items was in an invalid format.");
40477                this.HResult = -2146233033;
40478            },
40479            $ctor1: function (message) {
40480                this.$initialize();
40481                System.SystemException.$ctor1.call(this, message);
40482                this.HResult = -2146233033;
40483            },
40484            $ctor2: function (message, innerException) {
40485                this.$initialize();
40486                System.SystemException.$ctor2.call(this, message, innerException);
40487                this.HResult = -2146233033;
40488            }
40489        }
40490    });
40491
40492    // @source FormattableString.js
40493
40494    H5.define("System.FormattableString", {
40495        inherits: [System.IFormattable],
40496        statics: {
40497            methods: {
40498                Invariant: function (formattable) {
40499                    if (formattable == null) {
40500                        throw new System.ArgumentNullException.$ctor1("formattable");
40501                    }
40502
40503                    return formattable.ToString(System.Globalization.CultureInfo.invariantCulture);
40504                }
40505            }
40506        },
40507        methods: {
40508            System$IFormattable$format: function (ignored, formatProvider) {
40509                return this.ToString(formatProvider);
40510            },
40511            toString: function () {
40512                return this.ToString(System.Globalization.CultureInfo.getCurrentCulture());
40513            }
40514        }
40515    });
40516
40517    // @source ConcreteFormattableString.js
40518
40519    H5.define("System.Runtime.CompilerServices.FormattableStringFactory.ConcreteFormattableString", {
40520        inherits: [System.FormattableString],
40521        $kind: "nested class",
40522        fields: {
40523            _format: null,
40524            _arguments: null
40525        },
40526        props: {
40527            Format: {
40528                get: function () {
40529                    return this._format;
40530                }
40531            },
40532            ArgumentCount: {
40533                get: function () {
40534                    return this._arguments.length;
40535                }
40536            }
40537        },
40538        ctors: {
40539            ctor: function (format, $arguments) {
40540                this.$initialize();
40541                System.FormattableString.ctor.call(this);
40542                this._format = format;
40543                this._arguments = $arguments;
40544            }
40545        },
40546        methods: {
40547            GetArguments: function () {
40548                return this._arguments;
40549            },
40550            GetArgument: function (index) {
40551                return this._arguments[System.Array.index(index, this._arguments)];
40552            },
40553            ToString: function (formatProvider) {
40554                return System.String.formatProvider.apply(System.String, [formatProvider, this._format].concat(this._arguments));
40555            }
40556        }
40557    });
40558
40559    // @source FormattableStringFactory.js
40560
40561    H5.define("System.Runtime.CompilerServices.FormattableStringFactory", {
40562        statics: {
40563            methods: {
40564                Create: function (format, $arguments) {
40565                    if ($arguments === void 0) { $arguments = []; }
40566                    if (format == null) {
40567                        throw new System.ArgumentNullException.$ctor1("format");
40568                    }
40569
40570                    if ($arguments == null) {
40571                        throw new System.ArgumentNullException.$ctor1("arguments");
40572                    }
40573
40574                    return new System.Runtime.CompilerServices.FormattableStringFactory.ConcreteFormattableString(format, $arguments);
40575                }
40576            }
40577        }
40578    });
40579
40580    // @source Guid.js
40581
40582    H5.define("System.Guid", {
40583        inherits: function () { return [System.IEquatable$1(System.Guid),System.IComparable$1(System.Guid),System.IFormattable]; },
40584        $kind: "struct",
40585        statics: {
40586            fields: {
40587                error1: null,
40588                Valid: null,
40589                Split: null,
40590                NonFormat: null,
40591                Replace: null,
40592                Rnd: null,
40593                Empty: null
40594            },
40595            ctors: {
40596                init: function () {
40597                    this.Empty = new System.Guid();
40598                    this.error1 = "Byte array for GUID must be exactly {0} bytes long";
40599                    this.Valid = new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", "i");
40600                    this.Split = new RegExp("^(.{8})(.{4})(.{4})(.{4})(.{12})$");
40601                    this.NonFormat = new RegExp("^[{(]?([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})[)}]?$", "i");
40602                    this.Replace = new RegExp("-", "g");
40603                    this.Rnd = new System.Random.ctor();
40604                }
40605            },
40606            methods: {
40607                Parse: function (input) {
40608                    return System.Guid.ParseExact(input, null);
40609                },
40610                ParseExact: function (input, format) {
40611                    var r = new System.Guid.ctor();
40612                    r.ParseInternal(input, format, true);
40613                    return r;
40614                },
40615                TryParse: function (input, result) {
40616                    return System.Guid.TryParseExact(input, null, result);
40617                },
40618                TryParseExact: function (input, format, result) {
40619                    result.v = new System.Guid.ctor();
40620                    return result.v.ParseInternal(input, format, false);
40621                },
40622                NewGuid: function () {
40623                    var a = System.Array.init(16, 0, System.Byte);
40624
40625                    System.Guid.Rnd.NextBytes(a);
40626
40627                    a[System.Array.index(7, a)] = (a[System.Array.index(7, a)] & 15 | 64) & 255;
40628                    a[System.Array.index(8, a)] = (a[System.Array.index(8, a)] & 191 | 128) & 255;
40629
40630                    return new System.Guid.$ctor1(a);
40631                },
40632                ToHex$1: function (x, precision) {
40633                    var result = x.toString(16);
40634                    precision = (precision - result.length) | 0;
40635
40636                    for (var i = 0; i < precision; i = (i + 1) | 0) {
40637                        result = "0" + (result || "");
40638                    }
40639
40640                    return result;
40641                },
40642                ToHex: function (x) {
40643                    var result = x.toString(16);
40644
40645                    if (result.length === 1) {
40646                        result = "0" + (result || "");
40647                    }
40648
40649                    return result;
40650                },
40651                op_Equality: function (a, b) {
40652                    if (H5.referenceEquals(a, null)) {
40653                        return H5.referenceEquals(b, null);
40654                    }
40655
40656                    return a.equalsT(b);
40657                },
40658                op_Inequality: function (a, b) {
40659                    return !(System.Guid.op_Equality(a, b));
40660                },
40661                getDefaultValue: function () { return new System.Guid(); }
40662            }
40663        },
40664        fields: {
40665            _a: 0,
40666            _b: 0,
40667            _c: 0,
40668            _d: 0,
40669            _e: 0,
40670            _f: 0,
40671            _g: 0,
40672            _h: 0,
40673            _i: 0,
40674            _j: 0,
40675            _k: 0
40676        },
40677        alias: [
40678            "equalsT", "System$IEquatable$1$System$Guid$equalsT",
40679            "compareTo", ["System$IComparable$1$System$Guid$compareTo", "System$IComparable$1$compareTo"],
40680            "format", "System$IFormattable$format"
40681        ],
40682        ctors: {
40683            $ctor4: function (uuid) {
40684                this.$initialize();
40685                (new System.Guid.ctor()).$clone(this);
40686
40687                this.ParseInternal(uuid, null, true);
40688            },
40689            $ctor1: function (b) {
40690                this.$initialize();
40691                if (b == null) {
40692                    throw new System.ArgumentNullException.$ctor1("b");
40693                }
40694
40695                if (b.length !== 16) {
40696                    throw new System.ArgumentException.$ctor1(System.String.format(System.Guid.error1, [H5.box(16, System.Int32)]));
40697                }
40698
40699                this._a = (b[System.Array.index(3, b)] << 24) | (b[System.Array.index(2, b)] << 16) | (b[System.Array.index(1, b)] << 8) | b[System.Array.index(0, b)];
40700                this._b = H5.Int.sxs(((b[System.Array.index(5, b)] << 8) | b[System.Array.index(4, b)]) & 65535);
40701                this._c = H5.Int.sxs(((b[System.Array.index(7, b)] << 8) | b[System.Array.index(6, b)]) & 65535);
40702                this._d = b[System.Array.index(8, b)];
40703                this._e = b[System.Array.index(9, b)];
40704                this._f = b[System.Array.index(10, b)];
40705                this._g = b[System.Array.index(11, b)];
40706                this._h = b[System.Array.index(12, b)];
40707                this._i = b[System.Array.index(13, b)];
40708                this._j = b[System.Array.index(14, b)];
40709                this._k = b[System.Array.index(15, b)];
40710            },
40711            $ctor5: function (a, b, c, d, e, f, g, h, i, j, k) {
40712                this.$initialize();
40713                this._a = a | 0;
40714                this._b = H5.Int.sxs(b & 65535);
40715                this._c = H5.Int.sxs(c & 65535);
40716                this._d = d;
40717                this._e = e;
40718                this._f = f;
40719                this._g = g;
40720                this._h = h;
40721                this._i = i;
40722                this._j = j;
40723                this._k = k;
40724            },
40725            $ctor3: function (a, b, c, d) {
40726                this.$initialize();
40727                if (d == null) {
40728                    throw new System.ArgumentNullException.$ctor1("d");
40729                }
40730
40731                if (d.length !== 8) {
40732                    throw new System.ArgumentException.$ctor1(System.String.format(System.Guid.error1, [H5.box(8, System.Int32)]));
40733                }
40734
40735                this._a = a;
40736                this._b = b;
40737                this._c = c;
40738                this._d = d[System.Array.index(0, d)];
40739                this._e = d[System.Array.index(1, d)];
40740                this._f = d[System.Array.index(2, d)];
40741                this._g = d[System.Array.index(3, d)];
40742                this._h = d[System.Array.index(4, d)];
40743                this._i = d[System.Array.index(5, d)];
40744                this._j = d[System.Array.index(6, d)];
40745                this._k = d[System.Array.index(7, d)];
40746            },
40747            $ctor2: function (a, b, c, d, e, f, g, h, i, j, k) {
40748                this.$initialize();
40749                this._a = a;
40750                this._b = b;
40751                this._c = c;
40752                this._d = d;
40753                this._e = e;
40754                this._f = f;
40755                this._g = g;
40756                this._h = h;
40757                this._i = i;
40758                this._j = j;
40759                this._k = k;
40760            },
40761            ctor: function () {
40762                this.$initialize();
40763            }
40764        },
40765        methods: {
40766            getHashCode: function () {
40767                return this._a ^ ((this._b << 16) | (this._c & 65535)) ^ ((this._f << 24) | this._k);
40768            },
40769            equals: function (o) {
40770                if (!(H5.is(o, System.Guid))) {
40771                    return false;
40772                }
40773
40774                return this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(o, System.Guid), System.Guid)));
40775            },
40776            equalsT: function (o) {
40777                if ((this._a !== o._a) || (this._b !== o._b) || (this._c !== o._c) || (this._d !== o._d) || (this._e !== o._e) || (this._f !== o._f) || (this._g !== o._g) || (this._h !== o._h) || (this._i !== o._i) || (this._j !== o._j) || (this._k !== o._k)) {
40778                    return false;
40779                }
40780
40781                return true;
40782            },
40783            compareTo: function (value) {
40784                return System.String.compare(this.toString(), value.toString());
40785            },
40786            toString: function () {
40787                return this.Format(null);
40788            },
40789            ToString: function (format) {
40790                return this.Format(format);
40791            },
40792            format: function (format, formatProvider) {
40793                return this.Format(format);
40794            },
40795            ToByteArray: function () {
40796                var g = System.Array.init(16, 0, System.Byte);
40797
40798                g[System.Array.index(0, g)] = this._a & 255;
40799                g[System.Array.index(1, g)] = (this._a >> 8) & 255;
40800                g[System.Array.index(2, g)] = (this._a >> 16) & 255;
40801                g[System.Array.index(3, g)] = (this._a >> 24) & 255;
40802                g[System.Array.index(4, g)] = this._b & 255;
40803                g[System.Array.index(5, g)] = (this._b >> 8) & 255;
40804                g[System.Array.index(6, g)] = this._c & 255;
40805                g[System.Array.index(7, g)] = (this._c >> 8) & 255;
40806                g[System.Array.index(8, g)] = this._d;
40807                g[System.Array.index(9, g)] = this._e;
40808                g[System.Array.index(10, g)] = this._f;
40809                g[System.Array.index(11, g)] = this._g;
40810                g[System.Array.index(12, g)] = this._h;
40811                g[System.Array.index(13, g)] = this._i;
40812                g[System.Array.index(14, g)] = this._j;
40813                g[System.Array.index(15, g)] = this._k;
40814
40815                return g;
40816            },
40817            ParseInternal: function (input, format, check) {
40818                var r = null;
40819
40820                if (System.String.isNullOrEmpty(input)) {
40821                    if (check) {
40822                        throw new System.ArgumentNullException.$ctor1("input");
40823                    }
40824                    return false;
40825                }
40826
40827                if (System.String.isNullOrEmpty(format)) {
40828                    var m = System.Guid.NonFormat.exec(input);
40829
40830                    if (m != null) {
40831                        var list = new (System.Collections.Generic.List$1(System.String)).ctor();
40832                        for (var i = 1; i <= m.length; i = (i + 1) | 0) {
40833                            if (m[i] != null) {
40834                                list.add(m[i]);
40835                            }
40836                        }
40837
40838                        r = list.ToArray().join("-").toLowerCase();
40839                    }
40840                } else {
40841                    format = format.toUpperCase();
40842
40843                    var p = false;
40844
40845                    if (H5.referenceEquals(format, "N")) {
40846                        var m1 = System.Guid.Split.exec(input);
40847
40848                        if (m1 != null) {
40849                            var list1 = new (System.Collections.Generic.List$1(System.String)).ctor();
40850                            for (var i1 = 1; i1 <= m1.length; i1 = (i1 + 1) | 0) {
40851                                if (m1[i1] != null) {
40852                                    list1.add(m1[i1]);
40853                                }
40854                            }
40855
40856                            p = true;
40857                            input = list1.ToArray().join("-");
40858                        }
40859                    } else if (H5.referenceEquals(format, "B") || H5.referenceEquals(format, "P")) {
40860                        var b = H5.referenceEquals(format, "B") ? System.Array.init([123, 125], System.Char) : System.Array.init([40, 41], System.Char);
40861
40862                        if ((input.charCodeAt(0) === b[System.Array.index(0, b)]) && (input.charCodeAt(((input.length - 1) | 0)) === b[System.Array.index(1, b)])) {
40863                            p = true;
40864                            input = input.substr(1, ((input.length - 2) | 0));
40865                        }
40866                    } else {
40867                        p = true;
40868                    }
40869
40870                    if (p && System.Guid.Valid.test(input)) {
40871                        r = input.toLowerCase();
40872                    }
40873                }
40874
40875                if (r != null) {
40876                    this.FromString(r);
40877                    return true;
40878                }
40879
40880                if (check) {
40881                    throw new System.FormatException.$ctor1("input is not in a recognized format");
40882                }
40883
40884                return false;
40885            },
40886            Format: function (format) {
40887                var s = (System.Guid.ToHex$1((this._a >>> 0), 8) || "") + (System.Guid.ToHex$1((this._b & 65535), 4) || "") + (System.Guid.ToHex$1((this._c & 65535), 4) || "");
40888                s = (s || "") + ((System.Array.init([this._d, this._e, this._f, this._g, this._h, this._i, this._j, this._k], System.Byte)).map(System.Guid.ToHex).join("") || "");
40889
40890                var m = /^(.{8})(.{4})(.{4})(.{4})(.{12})$/.exec(s);
40891                var list = System.Array.init(0, null, System.String);
40892                for (var i = 1; i < m.length; i = (i + 1) | 0) {
40893                    if (m[System.Array.index(i, m)] != null) {
40894                        list.push(m[System.Array.index(i, m)]);
40895                    }
40896                }
40897                s = list.join("-");
40898
40899                switch (format) {
40900                    case "n": 
40901                    case "N": 
40902                        return s.replace(System.Guid.Replace, "");
40903                    case "b": 
40904                    case "B": 
40905                        return String.fromCharCode(123) + (s || "") + String.fromCharCode(125);
40906                    case "p": 
40907                    case "P": 
40908                        return String.fromCharCode(40) + (s || "") + String.fromCharCode(41);
40909                    default: 
40910                        return s;
40911                }
40912            },
40913            FromString: function (s) {
40914                if (System.String.isNullOrEmpty(s)) {
40915                    return;
40916                }
40917
40918                s = s.replace(System.Guid.Replace, "");
40919
40920                var r = System.Array.init(8, 0, System.Byte);
40921
40922                this._a = (System.UInt32.parse(s.substr(0, 8), 16)) | 0;
40923                this._b = H5.Int.sxs((System.UInt16.parse(s.substr(8, 4), 16)) & 65535);
40924                this._c = H5.Int.sxs((System.UInt16.parse(s.substr(12, 4), 16)) & 65535);
40925                for (var i = 8; i < 16; i = (i + 1) | 0) {
40926                    r[System.Array.index(((i - 8) | 0), r)] = System.Byte.parse(s.substr(H5.Int.mul(i, 2), 2), 16);
40927                }
40928
40929                this._d = r[System.Array.index(0, r)];
40930                this._e = r[System.Array.index(1, r)];
40931                this._f = r[System.Array.index(2, r)];
40932                this._g = r[System.Array.index(3, r)];
40933                this._h = r[System.Array.index(4, r)];
40934                this._i = r[System.Array.index(5, r)];
40935                this._j = r[System.Array.index(6, r)];
40936                this._k = r[System.Array.index(7, r)];
40937            },
40938            toJSON: function () {
40939                return this.toString();
40940            },
40941            $clone: function (to) { return this; }
40942        }
40943    });
40944
40945    // @source ITupleInternal.js
40946
40947    H5.define("System.ITupleInternal", {
40948        $kind: "interface"
40949    });
40950
40951    // @source Tuple.js
40952
40953    H5.define("System.Tuple");
40954
40955    H5.define("System.Tuple$1", function (T1) { return {
40956
40957    }; });
40958
40959    H5.define("System.Tuple$2", function (T1, T2) { return {
40960
40961    }; });
40962
40963    H5.define("System.Tuple$3", function (T1, T2, T3) { return {
40964
40965    }; });
40966
40967    H5.define("System.Tuple$4", function (T1, T2, T3, T4) { return {
40968
40969    }; });
40970
40971    H5.define("System.Tuple$5", function (T1, T2, T3, T4, T5) { return {
40972
40973    }; });
40974
40975    H5.define("System.Tuple$6", function (T1, T2, T3, T4, T5, T6) { return {
40976
40977    }; });
40978
40979    H5.define("System.Tuple$7", function (T1, T2, T3, T4, T5, T6, T7) { return {
40980
40981    }; });
40982
40983    H5.define("System.Tuple$8", function (T1, T2, T3, T4, T5, T6, T7, TRest) { return {
40984
40985    }; });
40986
40987    // @source ValueTuple.js
40988
40989    H5.define("System.ValueTuple", {
40990        inherits: function () { return [System.IEquatable$1(System.ValueTuple),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple)]; },
40991        $kind: "struct",
40992        statics: {
40993            methods: {
40994                Create: function () {
40995                    return new System.ValueTuple();
40996                },
40997                Create$1: function (T1, item1) {
40998                    return new (System.ValueTuple$1(T1)).$ctor1(item1);
40999                },
41000                Create$2: function (T1, T2, item1, item2) {
41001                    return new (System.ValueTuple$2(T1,T2)).$ctor1(item1, item2);
41002                },
41003                Create$3: function (T1, T2, T3, item1, item2, item3) {
41004                    return new (System.ValueTuple$3(T1,T2,T3)).$ctor1(item1, item2, item3);
41005                },
41006                Create$4: function (T1, T2, T3, T4, item1, item2, item3, item4) {
41007                    return new (System.ValueTuple$4(T1,T2,T3,T4)).$ctor1(item1, item2, item3, item4);
41008                },
41009                Create$5: function (T1, T2, T3, T4, T5, item1, item2, item3, item4, item5) {
41010                    return new (System.ValueTuple$5(T1,T2,T3,T4,T5)).$ctor1(item1, item2, item3, item4, item5);
41011                },
41012                Create$6: function (T1, T2, T3, T4, T5, T6, item1, item2, item3, item4, item5, item6) {
41013                    return new (System.ValueTuple$6(T1,T2,T3,T4,T5,T6)).$ctor1(item1, item2, item3, item4, item5, item6);
41014                },
41015                Create$7: function (T1, T2, T3, T4, T5, T6, T7, item1, item2, item3, item4, item5, item6, item7) {
41016                    return new (System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)).$ctor1(item1, item2, item3, item4, item5, item6, item7);
41017                },
41018                Create$8: function (T1, T2, T3, T4, T5, T6, T7, T8, item1, item2, item3, item4, item5, item6, item7, item8) {
41019                    return new (System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,System.ValueTuple$1(T8))).$ctor1(item1, item2, item3, item4, item5, item6, item7, System.ValueTuple.Create$1(T8, item8));
41020                },
41021                CombineHashCodes: function (h1, h2) {
41022                    return System.Collections.HashHelpers.Combine(System.Collections.HashHelpers.Combine(System.Collections.HashHelpers.RandomSeed, h1), h2);
41023                },
41024                CombineHashCodes$1: function (h1, h2, h3) {
41025                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes(h1, h2), h3);
41026                },
41027                CombineHashCodes$2: function (h1, h2, h3, h4) {
41028                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes$1(h1, h2, h3), h4);
41029                },
41030                CombineHashCodes$3: function (h1, h2, h3, h4, h5) {
41031                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes$2(h1, h2, h3, h4), h5);
41032                },
41033                CombineHashCodes$4: function (h1, h2, h3, h4, h5, h6) {
41034                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes$3(h1, h2, h3, h4, h5), h6);
41035                },
41036                CombineHashCodes$5: function (h1, h2, h3, h4, h5, h6, h7) {
41037                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes$4(h1, h2, h3, h4, h5, h6), h7);
41038                },
41039                CombineHashCodes$6: function (h1, h2, h3, h4, h5, h6, h7, h8) {
41040                    return System.Collections.HashHelpers.Combine(System.ValueTuple.CombineHashCodes$5(h1, h2, h3, h4, h5, h6, h7), h8);
41041                },
41042                getDefaultValue: function () { return new System.ValueTuple(); }
41043            }
41044        },
41045        alias: [
41046            "equalsT", "System$IEquatable$1$System$ValueTuple$equalsT",
41047            "compareTo", ["System$IComparable$1$System$ValueTuple$compareTo", "System$IComparable$1$compareTo"]
41048        ],
41049        ctors: {
41050            ctor: function () {
41051                this.$initialize();
41052            }
41053        },
41054        methods: {
41055            equals: function (obj) {
41056                return H5.is(obj, System.ValueTuple);
41057            },
41058            equalsT: function (other) {
41059                return true;
41060            },
41061            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41062                return H5.is(other, System.ValueTuple);
41063            },
41064            System$IComparable$compareTo: function (other) {
41065                if (other == null) {
41066                    return 1;
41067                }
41068
41069                if (!(H5.is(other, System.ValueTuple))) {
41070                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41071                }
41072
41073                return 0;
41074            },
41075            compareTo: function (other) {
41076                return 0;
41077            },
41078            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41079                if (other == null) {
41080                    return 1;
41081                }
41082
41083                if (!(H5.is(other, System.ValueTuple))) {
41084                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41085                }
41086
41087                return 0;
41088            },
41089            getHashCode: function () {
41090                return 0;
41091            },
41092            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41093                return 0;
41094            },
41095            toString: function () {
41096                return "()";
41097            },
41098            $clone: function (to) { return this; }
41099        }
41100    });
41101
41102    H5.define("System.ValueTuple$1", function (T1) { return {
41103        inherits: function () { return [System.IEquatable$1(System.ValueTuple$1(T1)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$1(T1)),System.ITupleInternal]; },
41104        $kind: "struct",
41105        statics: {
41106            props: {
41107                s_t1Comparer: {
41108                    get: function () {
41109                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41110                    }
41111                }
41112            },
41113            methods: {
41114                getDefaultValue: function () { return new (System.ValueTuple$1(T1))(); }
41115            }
41116        },
41117        fields: {
41118            Item1: H5.getDefaultValue(T1)
41119        },
41120        props: {
41121            System$ITupleInternal$Size: {
41122                get: function () {
41123                    return 1;
41124                }
41125            }
41126        },
41127        alias: [
41128            "equalsT", "System$IEquatable$1$System$ValueTuple$1$" + H5.getTypeAlias(T1) + "$equalsT",
41129            "compareTo", ["System$IComparable$1$System$ValueTuple$1$" + H5.getTypeAlias(T1) + "$compareTo", "System$IComparable$1$compareTo"]
41130        ],
41131        ctors: {
41132            $ctor1: function (item1) {
41133                this.$initialize();
41134                this.Item1 = item1;
41135            },
41136            ctor: function () {
41137                this.$initialize();
41138            }
41139        },
41140        methods: {
41141            equals: function (obj) {
41142                return H5.is(obj, System.ValueTuple$1(T1)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$1(T1)), System.ValueTuple$1(T1))));
41143            },
41144            equalsT: function (other) {
41145                return System.ValueTuple$1(T1).s_t1Comparer.equals2(this.Item1, other.Item1);
41146            },
41147            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41148                if (other == null || !(H5.is(other, System.ValueTuple$1(T1)))) {
41149                    return false;
41150                }
41151
41152                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$1(T1)), System.ValueTuple$1(T1)));
41153
41154                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1);
41155            },
41156            System$IComparable$compareTo: function (other) {
41157                if (other == null) {
41158                    return 1;
41159                }
41160
41161                if (!(H5.is(other, System.ValueTuple$1(T1)))) {
41162                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41163                }
41164
41165                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$1(T1)), System.ValueTuple$1(T1)));
41166
41167                return new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, objTuple.Item1);
41168            },
41169            compareTo: function (other) {
41170                return new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41171            },
41172            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41173                if (other == null) {
41174                    return 1;
41175                }
41176
41177                if (!(H5.is(other, System.ValueTuple$1(T1)))) {
41178                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41179                }
41180
41181                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$1(T1)), System.ValueTuple$1(T1)));
41182
41183                return comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41184            },
41185            getHashCode: function () {
41186                return System.ValueTuple$1(T1).s_t1Comparer.getHashCode2(this.Item1);
41187            },
41188            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41189                return comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1);
41190            },
41191            System$ITupleInternal$GetHashCode: function (comparer) {
41192                return comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1);
41193            },
41194            toString: function () {
41195                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ")";
41196            },
41197            System$ITupleInternal$ToStringEnd: function () {
41198                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ")";
41199            },
41200            $clone: function (to) {
41201                var s = to || new (System.ValueTuple$1(T1))();
41202                s.Item1 = this.Item1;
41203                return s;
41204            }
41205        }
41206    }; });
41207
41208    H5.define("System.ValueTuple$2", function (T1, T2) { return {
41209        inherits: function () { return [System.IEquatable$1(System.ValueTuple$2(T1,T2)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$2(T1,T2)),System.ITupleInternal]; },
41210        $kind: "struct",
41211        statics: {
41212            props: {
41213                s_t1Comparer: {
41214                    get: function () {
41215                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41216                    }
41217                },
41218                s_t2Comparer: {
41219                    get: function () {
41220                        return System.Collections.Generic.EqualityComparer$1(T2).def;
41221                    }
41222                }
41223            },
41224            methods: {
41225                getDefaultValue: function () { return new (System.ValueTuple$2(T1,T2))(); }
41226            }
41227        },
41228        fields: {
41229            Item1: H5.getDefaultValue(T1),
41230            Item2: H5.getDefaultValue(T2)
41231        },
41232        props: {
41233            System$ITupleInternal$Size: {
41234                get: function () {
41235                    return 2;
41236                }
41237            }
41238        },
41239        alias: [
41240            "equalsT", "System$IEquatable$1$System$ValueTuple$2$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$equalsT",
41241            "compareTo", ["System$IComparable$1$System$ValueTuple$2$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$compareTo", "System$IComparable$1$compareTo"]
41242        ],
41243        ctors: {
41244            $ctor1: function (item1, item2) {
41245                this.$initialize();
41246                this.Item1 = item1;
41247                this.Item2 = item2;
41248            },
41249            ctor: function () {
41250                this.$initialize();
41251            }
41252        },
41253        methods: {
41254            equals: function (obj) {
41255                return H5.is(obj, System.ValueTuple$2(T1,T2)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$2(T1,T2)), System.ValueTuple$2(T1,T2))));
41256            },
41257            equalsT: function (other) {
41258                return System.ValueTuple$2(T1,T2).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$2(T1,T2).s_t2Comparer.equals2(this.Item2, other.Item2);
41259            },
41260            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41261                if (other == null || !(H5.is(other, System.ValueTuple$2(T1,T2)))) {
41262                    return false;
41263                }
41264
41265                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$2(T1,T2)), System.ValueTuple$2(T1,T2)));
41266
41267                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2);
41268            },
41269            System$IComparable$compareTo: function (other) {
41270                if (other == null) {
41271                    return 1;
41272                }
41273
41274                if (!(H5.is(other, System.ValueTuple$2(T1,T2)))) {
41275                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41276                }
41277
41278                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$2(T1,T2)), System.ValueTuple$2(T1,T2))));
41279            },
41280            compareTo: function (other) {
41281                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41282                if (c !== 0) {
41283                    return c;
41284                }
41285
41286                return new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
41287            },
41288            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41289                if (other == null) {
41290                    return 1;
41291                }
41292
41293                if (!(H5.is(other, System.ValueTuple$2(T1,T2)))) {
41294                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41295                }
41296
41297                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$2(T1,T2)), System.ValueTuple$2(T1,T2)));
41298
41299                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41300                if (c !== 0) {
41301                    return c;
41302                }
41303
41304                return comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
41305            },
41306            getHashCode: function () {
41307                return System.ValueTuple.CombineHashCodes(System.ValueTuple$2(T1,T2).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$2(T1,T2).s_t2Comparer.getHashCode2(this.Item2));
41308            },
41309            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41310                return this.GetHashCodeCore(comparer);
41311            },
41312            System$ITupleInternal$GetHashCode: function (comparer) {
41313                return this.GetHashCodeCore(comparer);
41314            },
41315            GetHashCodeCore: function (comparer) {
41316                return System.ValueTuple.CombineHashCodes(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2));
41317            },
41318            toString: function () {
41319                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ")";
41320            },
41321            System$ITupleInternal$ToStringEnd: function () {
41322                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ")";
41323            },
41324            $clone: function (to) {
41325                var s = to || new (System.ValueTuple$2(T1,T2))();
41326                s.Item1 = this.Item1;
41327                s.Item2 = this.Item2;
41328                return s;
41329            }
41330        }
41331    }; });
41332
41333    H5.define("System.ValueTuple$3", function (T1, T2, T3) { return {
41334        inherits: function () { return [System.IEquatable$1(System.ValueTuple$3(T1,T2,T3)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$3(T1,T2,T3)),System.ITupleInternal]; },
41335        $kind: "struct",
41336        statics: {
41337            props: {
41338                s_t1Comparer: {
41339                    get: function () {
41340                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41341                    }
41342                },
41343                s_t2Comparer: {
41344                    get: function () {
41345                        return System.Collections.Generic.EqualityComparer$1(T2).def;
41346                    }
41347                },
41348                s_t3Comparer: {
41349                    get: function () {
41350                        return System.Collections.Generic.EqualityComparer$1(T3).def;
41351                    }
41352                }
41353            },
41354            methods: {
41355                getDefaultValue: function () { return new (System.ValueTuple$3(T1,T2,T3))(); }
41356            }
41357        },
41358        fields: {
41359            Item1: H5.getDefaultValue(T1),
41360            Item2: H5.getDefaultValue(T2),
41361            Item3: H5.getDefaultValue(T3)
41362        },
41363        props: {
41364            System$ITupleInternal$Size: {
41365                get: function () {
41366                    return 3;
41367                }
41368            }
41369        },
41370        alias: [
41371            "equalsT", "System$IEquatable$1$System$ValueTuple$3$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$equalsT",
41372            "compareTo", ["System$IComparable$1$System$ValueTuple$3$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$compareTo", "System$IComparable$1$compareTo"]
41373        ],
41374        ctors: {
41375            $ctor1: function (item1, item2, item3) {
41376                this.$initialize();
41377                this.Item1 = item1;
41378                this.Item2 = item2;
41379                this.Item3 = item3;
41380            },
41381            ctor: function () {
41382                this.$initialize();
41383            }
41384        },
41385        methods: {
41386            equals: function (obj) {
41387                return H5.is(obj, System.ValueTuple$3(T1,T2,T3)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$3(T1,T2,T3)), System.ValueTuple$3(T1,T2,T3))));
41388            },
41389            equalsT: function (other) {
41390                return System.ValueTuple$3(T1,T2,T3).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$3(T1,T2,T3).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$3(T1,T2,T3).s_t3Comparer.equals2(this.Item3, other.Item3);
41391            },
41392            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41393                if (other == null || !(H5.is(other, System.ValueTuple$3(T1,T2,T3)))) {
41394                    return false;
41395                }
41396
41397                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$3(T1,T2,T3)), System.ValueTuple$3(T1,T2,T3)));
41398
41399                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3);
41400            },
41401            System$IComparable$compareTo: function (other) {
41402                if (other == null) {
41403                    return 1;
41404                }
41405
41406                if (!(H5.is(other, System.ValueTuple$3(T1,T2,T3)))) {
41407                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41408                }
41409
41410                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$3(T1,T2,T3)), System.ValueTuple$3(T1,T2,T3))));
41411            },
41412            compareTo: function (other) {
41413                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41414                if (c !== 0) {
41415                    return c;
41416                }
41417
41418                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
41419                if (c !== 0) {
41420                    return c;
41421                }
41422
41423                return new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
41424            },
41425            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41426                if (other == null) {
41427                    return 1;
41428                }
41429
41430                if (!(H5.is(other, System.ValueTuple$3(T1,T2,T3)))) {
41431                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41432                }
41433
41434                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$3(T1,T2,T3)), System.ValueTuple$3(T1,T2,T3)));
41435
41436                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41437                if (c !== 0) {
41438                    return c;
41439                }
41440
41441                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
41442                if (c !== 0) {
41443                    return c;
41444                }
41445
41446                return comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
41447            },
41448            getHashCode: function () {
41449                return System.ValueTuple.CombineHashCodes$1(System.ValueTuple$3(T1,T2,T3).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$3(T1,T2,T3).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$3(T1,T2,T3).s_t3Comparer.getHashCode2(this.Item3));
41450            },
41451            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41452                return this.GetHashCodeCore(comparer);
41453            },
41454            System$ITupleInternal$GetHashCode: function (comparer) {
41455                return this.GetHashCodeCore(comparer);
41456            },
41457            GetHashCodeCore: function (comparer) {
41458                return System.ValueTuple.CombineHashCodes$1(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3));
41459            },
41460            toString: function () {
41461                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ")";
41462            },
41463            System$ITupleInternal$ToStringEnd: function () {
41464                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ")";
41465            },
41466            $clone: function (to) {
41467                var s = to || new (System.ValueTuple$3(T1,T2,T3))();
41468                s.Item1 = this.Item1;
41469                s.Item2 = this.Item2;
41470                s.Item3 = this.Item3;
41471                return s;
41472            }
41473        }
41474    }; });
41475
41476    H5.define("System.ValueTuple$4", function (T1, T2, T3, T4) { return {
41477        inherits: function () { return [System.IEquatable$1(System.ValueTuple$4(T1,T2,T3,T4)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$4(T1,T2,T3,T4)),System.ITupleInternal]; },
41478        $kind: "struct",
41479        statics: {
41480            props: {
41481                s_t1Comparer: {
41482                    get: function () {
41483                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41484                    }
41485                },
41486                s_t2Comparer: {
41487                    get: function () {
41488                        return System.Collections.Generic.EqualityComparer$1(T2).def;
41489                    }
41490                },
41491                s_t3Comparer: {
41492                    get: function () {
41493                        return System.Collections.Generic.EqualityComparer$1(T3).def;
41494                    }
41495                },
41496                s_t4Comparer: {
41497                    get: function () {
41498                        return System.Collections.Generic.EqualityComparer$1(T4).def;
41499                    }
41500                }
41501            },
41502            methods: {
41503                getDefaultValue: function () { return new (System.ValueTuple$4(T1,T2,T3,T4))(); }
41504            }
41505        },
41506        fields: {
41507            Item1: H5.getDefaultValue(T1),
41508            Item2: H5.getDefaultValue(T2),
41509            Item3: H5.getDefaultValue(T3),
41510            Item4: H5.getDefaultValue(T4)
41511        },
41512        props: {
41513            System$ITupleInternal$Size: {
41514                get: function () {
41515                    return 4;
41516                }
41517            }
41518        },
41519        alias: [
41520            "equalsT", "System$IEquatable$1$System$ValueTuple$4$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$equalsT",
41521            "compareTo", ["System$IComparable$1$System$ValueTuple$4$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$compareTo", "System$IComparable$1$compareTo"]
41522        ],
41523        ctors: {
41524            $ctor1: function (item1, item2, item3, item4) {
41525                this.$initialize();
41526                this.Item1 = item1;
41527                this.Item2 = item2;
41528                this.Item3 = item3;
41529                this.Item4 = item4;
41530            },
41531            ctor: function () {
41532                this.$initialize();
41533            }
41534        },
41535        methods: {
41536            equals: function (obj) {
41537                return H5.is(obj, System.ValueTuple$4(T1,T2,T3,T4)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$4(T1,T2,T3,T4)), System.ValueTuple$4(T1,T2,T3,T4))));
41538            },
41539            equalsT: function (other) {
41540                return System.ValueTuple$4(T1,T2,T3,T4).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$4(T1,T2,T3,T4).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$4(T1,T2,T3,T4).s_t3Comparer.equals2(this.Item3, other.Item3) && System.ValueTuple$4(T1,T2,T3,T4).s_t4Comparer.equals2(this.Item4, other.Item4);
41541            },
41542            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41543                if (other == null || !(H5.is(other, System.ValueTuple$4(T1,T2,T3,T4)))) {
41544                    return false;
41545                }
41546
41547                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$4(T1,T2,T3,T4)), System.ValueTuple$4(T1,T2,T3,T4)));
41548
41549                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3) && comparer.System$Collections$IEqualityComparer$equals(this.Item4, objTuple.Item4);
41550            },
41551            System$IComparable$compareTo: function (other) {
41552                if (other == null) {
41553                    return 1;
41554                }
41555
41556                if (!(H5.is(other, System.ValueTuple$4(T1,T2,T3,T4)))) {
41557                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41558                }
41559
41560                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$4(T1,T2,T3,T4)), System.ValueTuple$4(T1,T2,T3,T4))));
41561            },
41562            compareTo: function (other) {
41563                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41564                if (c !== 0) {
41565                    return c;
41566                }
41567
41568                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
41569                if (c !== 0) {
41570                    return c;
41571                }
41572
41573                c = new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
41574                if (c !== 0) {
41575                    return c;
41576                }
41577
41578                return new (System.Collections.Generic.Comparer$1(T4))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item4, other.Item4);
41579            },
41580            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41581                if (other == null) {
41582                    return 1;
41583                }
41584
41585                if (!(H5.is(other, System.ValueTuple$4(T1,T2,T3,T4)))) {
41586                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41587                }
41588
41589                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$4(T1,T2,T3,T4)), System.ValueTuple$4(T1,T2,T3,T4)));
41590
41591                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41592                if (c !== 0) {
41593                    return c;
41594                }
41595
41596                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
41597                if (c !== 0) {
41598                    return c;
41599                }
41600
41601                c = comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
41602                if (c !== 0) {
41603                    return c;
41604                }
41605
41606                return comparer.System$Collections$IComparer$compare(this.Item4, objTuple.Item4);
41607            },
41608            getHashCode: function () {
41609                return System.ValueTuple.CombineHashCodes$2(System.ValueTuple$4(T1,T2,T3,T4).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$4(T1,T2,T3,T4).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$4(T1,T2,T3,T4).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$4(T1,T2,T3,T4).s_t4Comparer.getHashCode2(this.Item4));
41610            },
41611            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41612                return this.GetHashCodeCore(comparer);
41613            },
41614            System$ITupleInternal$GetHashCode: function (comparer) {
41615                return this.GetHashCodeCore(comparer);
41616            },
41617            GetHashCodeCore: function (comparer) {
41618                return System.ValueTuple.CombineHashCodes$2(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4));
41619            },
41620            toString: function () {
41621                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 
41621!= null ? H5.toString(this.Item4) : null) || "") + ")";
41622            },
41623            System$ITupleInternal$ToStringEnd: function () {
41624                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ")";
41625            },
41626            $clone: function (to) {
41627                var s = to || new (System.ValueTuple$4(T1,T2,T3,T4))();
41628                s.Item1 = this.Item1;
41629                s.Item2 = this.Item2;
41630                s.Item3 = this.Item3;
41631                s.Item4 = this.Item4;
41632                return s;
41633            }
41634        }
41635    }; });
41636
41637    H5.define("System.ValueTuple$5", function (T1, T2, T3, T4, T5) { return {
41638        inherits: function () { return [System.IEquatable$1(System.ValueTuple$5(T1,T2,T3,T4,T5)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$5(T1,T2,T3,T4,T5)),System.ITupleInternal]; },
41639        $kind: "struct",
41640        statics: {
41641            props: {
41642                s_t1Comparer: {
41643                    get: function () {
41644                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41645                    }
41646                },
41647                s_t2Comparer: {
41648                    get: function () {
41649                        return System.Collections.Generic.EqualityComparer$1(T2).def;
41650                    }
41651                },
41652                s_t3Comparer: {
41653                    get: function () {
41654                        return System.Collections.Generic.EqualityComparer$1(T3).def;
41655                    }
41656                },
41657                s_t4Comparer: {
41658                    get: function () {
41659                        return System.Collections.Generic.EqualityComparer$1(T4).def;
41660                    }
41661                },
41662                s_t5Comparer: {
41663                    get: function () {
41664                        return System.Collections.Generic.EqualityComparer$1(T5).def;
41665                    }
41666                }
41667            },
41668            methods: {
41669                getDefaultValue: function () { return new (System.ValueTuple$5(T1,T2,T3,T4,T5))(); }
41670            }
41671        },
41672        fields: {
41673            Item1: H5.getDefaultValue(T1),
41674            Item2: H5.getDefaultValue(T2),
41675            Item3: H5.getDefaultValue(T3),
41676            Item4: H5.getDefaultValue(T4),
41677            Item5: H5.getDefaultValue(T5)
41678        },
41679        props: {
41680            System$ITupleInternal$Size: {
41681                get: function () {
41682                    return 5;
41683                }
41684            }
41685        },
41686        alias: [
41687            "equalsT", "System$IEquatable$1$System$ValueTuple$5$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$equalsT",
41688            "compareTo", ["System$IComparable$1$System$ValueTuple$5$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$compareTo", "System$IComparable$1$compareTo"]
41689        ],
41690        ctors: {
41691            $ctor1: function (item1, item2, item3, item4, item5) {
41692                this.$initialize();
41693                this.Item1 = item1;
41694                this.Item2 = item2;
41695                this.Item3 = item3;
41696                this.Item4 = item4;
41697                this.Item5 = item5;
41698            },
41699            ctor: function () {
41700                this.$initialize();
41701            }
41702        },
41703        methods: {
41704            equals: function (obj) {
41705                return H5.is(obj, System.ValueTuple$5(T1,T2,T3,T4,T5)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$5(T1,T2,T3,T4,T5)), System.ValueTuple$5(T1,T2,T3,T4,T5))));
41706            },
41707            equalsT: function (other) {
41708                return System.ValueTuple$5(T1,T2,T3,T4,T5).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$5(T1,T2,T3,T4,T5).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$5(T1,T2,T3,T4,T5).s_t3Comparer.equals2(this.Item3, other.Item3) && System.ValueTuple$5(T1,T2,T3,T4,T5).s_t4Comparer.equals2(this.Item4, other.Item4) && System.ValueTuple$5(T1,T2,T3,T4,T5).s_t5Comparer.equals2(this.Item5, other.Item5);
41709            },
41710            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41711                if (other == null || !(H5.is(other, System.ValueTuple$5(T1,T2,T3,T4,T5)))) {
41712                    return false;
41713                }
41714
41715                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$5(T1,T2,T3,T4,T5)), System.ValueTuple$5(T1,T2,T3,T4,T5)));
41716
41717                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3) && comparer.System$Collections$IEqualityComparer$equals(this.Item4, objTuple.Item4) && comparer.System$Collections$IEqualityComparer$equals(this.Item5, objTuple.Item5);
41718            },
41719            System$IComparable$compareTo: function (other) {
41720                if (other == null) {
41721                    return 1;
41722                }
41723
41724                if (!(H5.is(other, System.ValueTuple$5(T1,T2,T3,T4,T5)))) {
41725                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41726                }
41727
41728                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$5(T1,T2,T3,T4,T5)), System.ValueTuple$5(T1,T2,T3,T4,T5))));
41729            },
41730            compareTo: function (other) {
41731                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41732                if (c !== 0) {
41733                    return c;
41734                }
41735
41736                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
41737                if (c !== 0) {
41738                    return c;
41739                }
41740
41741                c = new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
41742                if (c !== 0) {
41743                    return c;
41744                }
41745
41746                c = new (System.Collections.Generic.Comparer$1(T4))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item4, other.Item4);
41747                if (c !== 0) {
41748                    return c;
41749                }
41750
41751                return new (System.Collections.Generic.Comparer$1(T5))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item5, other.Item5);
41752            },
41753            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41754                if (other == null) {
41755                    return 1;
41756                }
41757
41758                if (!(H5.is(other, System.ValueTuple$5(T1,T2,T3,T4,T5)))) {
41759                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41760                }
41761
41762                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$5(T1,T2,T3,T4,T5)), System.ValueTuple$5(T1,T2,T3,T4,T5)));
41763
41764                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41765                if (c !== 0) {
41766                    return c;
41767                }
41768
41769                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
41770                if (c !== 0) {
41771                    return c;
41772                }
41773
41774                c = comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
41775                if (c !== 0) {
41776                    return c;
41777                }
41778
41779                c = comparer.System$Collections$IComparer$compare(this.Item4, objTuple.Item4);
41780                if (c !== 0) {
41781                    return c;
41782                }
41783
41784                return comparer.System$Collections$IComparer$compare(this.Item5, objTuple.Item5);
41785            },
41786            getHashCode: function () {
41787                return System.ValueTuple.CombineHashCodes$3(System.ValueTuple$5(T1,T2,T3,T4,T5).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$5(T1,T2,T3,T4,T5).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$5(T1,T2,T3,T4,T5).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$5(T1,T2,T3,T4,T5).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$5(T1,T2,T3,T4,T5).s_t5Comparer.getHashCode2(this.Item5));
41788            },
41789            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41790                return this.GetHashCodeCore(comparer);
41791            },
41792            System$ITupleInternal$GetHashCode: function (comparer) {
41793                return this.GetHashCodeCore(comparer);
41794            },
41795            GetHashCodeCore: function (comparer) {
41796                return System.ValueTuple.CombineHashCodes$3(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5));
41797            },
41798            toString: function () {
41799                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 
41799!= null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ")";
41800            },
41801            System$ITupleInternal$ToStringEnd: function () {
41802                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ")";
41803            },
41804            $clone: function (to) {
41805                var s = to || new (System.ValueTuple$5(T1,T2,T3,T4,T5))();
41806                s.Item1 = this.Item1;
41807                s.Item2 = this.Item2;
41808                s.Item3 = this.Item3;
41809                s.Item4 = this.Item4;
41810                s.Item5 = this.Item5;
41811                return s;
41812            }
41813        }
41814    }; });
41815
41816    H5.define("System.ValueTuple$6", function (T1, T2, T3, T4, T5, T6) { return {
41817        inherits: function () { return [System.IEquatable$1(System.ValueTuple$6(T1,T2,T3,T4,T5,T6)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$6(T1,T2,T3,T4,T5,T6)),System.ITupleInternal]; },
41818        $kind: "struct",
41819        statics: {
41820            props: {
41821                s_t1Comparer: {
41822                    get: function () {
41823                        return System.Collections.Generic.EqualityComparer$1(T1).def;
41824                    }
41825                },
41826                s_t2Comparer: {
41827                    get: function () {
41828                        return System.Collections.Generic.EqualityComparer$1(T2).def;
41829                    }
41830                },
41831                s_t3Comparer: {
41832                    get: function () {
41833                        return System.Collections.Generic.EqualityComparer$1(T3).def;
41834                    }
41835                },
41836                s_t4Comparer: {
41837                    get: function () {
41838                        return System.Collections.Generic.EqualityComparer$1(T4).def;
41839                    }
41840                },
41841                s_t5Comparer: {
41842                    get: function () {
41843                        return System.Collections.Generic.EqualityComparer$1(T5).def;
41844                    }
41845                },
41846                s_t6Comparer: {
41847                    get: function () {
41848                        return System.Collections.Generic.EqualityComparer$1(T6).def;
41849                    }
41850                }
41851            },
41852            methods: {
41853                getDefaultValue: function () { return new (System.ValueTuple$6(T1,T2,T3,T4,T5,T6))(); }
41854            }
41855        },
41856        fields: {
41857            Item1: H5.getDefaultValue(T1),
41858            Item2: H5.getDefaultValue(T2),
41859            Item3: H5.getDefaultValue(T3),
41860            Item4: H5.getDefaultValue(T4),
41861            Item5: H5.getDefaultValue(T5),
41862            Item6: H5.getDefaultValue(T6)
41863        },
41864        props: {
41865            System$ITupleInternal$Size: {
41866                get: function () {
41867                    return 6;
41868                }
41869            }
41870        },
41871        alias: [
41872            "equalsT", "System$IEquatable$1$System$ValueTuple$6$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$equalsT",
41873            "compareTo", ["System$IComparable$1$System$ValueTuple$6$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$compareTo", "System$IComparable$1$compareTo"]
41874        ],
41875        ctors: {
41876            $ctor1: function (item1, item2, item3, item4, item5, item6) {
41877                this.$initialize();
41878                this.Item1 = item1;
41879                this.Item2 = item2;
41880                this.Item3 = item3;
41881                this.Item4 = item4;
41882                this.Item5 = item5;
41883                this.Item6 = item6;
41884            },
41885            ctor: function () {
41886                this.$initialize();
41887            }
41888        },
41889        methods: {
41890            equals: function (obj) {
41891                return H5.is(obj, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)), System.ValueTuple$6(T1,T2,T3,T4,T5,T6))));
41892            },
41893            equalsT: function (other) {
41894                return System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t3Comparer.equals2(this.Item3, other.Item3) && System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t4Comparer.equals2(this.Item4, other.Item4) && System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t5Comparer.equals2(this.Item5, other.Item5) && System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t6Comparer.equals2(this.Item6, other.Item6);
41895            },
41896            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
41897                if (other == null || !(H5.is(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)))) {
41898                    return false;
41899                }
41900
41901                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)), System.ValueTuple$6(T1,T2,T3,T4,T5,T6)));
41902
41903                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3) && comparer.System$Collections$IEqualityComparer$equals(this.Item4, objTuple.Item4) && comparer.System$Collections$IEqualityComparer$equals(this.Item5, objTuple.Item5) && comparer.System$Collections$IEqualityComparer$equals(this.Item6, objTuple.Item6);
41904            },
41905            System$IComparable$compareTo: function (other) {
41906                if (other == null) {
41907                    return 1;
41908                }
41909
41910                if (!(H5.is(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)))) {
41911                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41912                }
41913
41914                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)), System.ValueTuple$6(T1,T2,T3,T4,T5,T6))));
41915            },
41916            compareTo: function (other) {
41917                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
41918                if (c !== 0) {
41919                    return c;
41920                }
41921
41922                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
41923                if (c !== 0) {
41924                    return c;
41925                }
41926
41927                c = new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
41928                if (c !== 0) {
41929                    return c;
41930                }
41931
41932                c = new (System.Collections.Generic.Comparer$1(T4))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item4, other.Item4);
41933                if (c !== 0) {
41934                    return c;
41935                }
41936
41937                c = new (System.Collections.Generic.Comparer$1(T5))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item5, other.Item5);
41938                if (c !== 0) {
41939                    return c;
41940                }
41941
41942                return new (System.Collections.Generic.Comparer$1(T6))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item6, other.Item6);
41943            },
41944            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
41945                if (other == null) {
41946                    return 1;
41947                }
41948
41949                if (!(H5.is(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)))) {
41950                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
41951                }
41952
41953                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$6(T1,T2,T3,T4,T5,T6)), System.ValueTuple$6(T1,T2,T3,T4,T5,T6)));
41954
41955                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
41956                if (c !== 0) {
41957                    return c;
41958                }
41959
41960                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
41961                if (c !== 0) {
41962                    return c;
41963                }
41964
41965                c = comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
41966                if (c !== 0) {
41967                    return c;
41968                }
41969
41970                c = comparer.System$Collections$IComparer$compare(this.Item4, objTuple.Item4);
41971                if (c !== 0) {
41972                    return c;
41973                }
41974
41975                c = comparer.System$Collections$IComparer$compare(this.Item5, objTuple.Item5);
41976                if (c !== 0) {
41977                    return c;
41978                }
41979
41980                return comparer.System$Collections$IComparer$compare(this.Item6, objTuple.Item6);
41981            },
41982            getHashCode: function () {
41983                return System.ValueTuple.CombineHashCodes$4(System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$6(T1,T2,T3,T4,T5,T6).s_t6Comparer.getHashCode2(this.Item6));
41984            },
41985            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
41986                return this.GetHashCodeCore(comparer);
41987            },
41988            System$ITupleInternal$GetHashCode: function (comparer) {
41989                return this.GetHashCodeCore(comparer);
41990            },
41991            GetHashCodeCore: function (comparer) {
41992                return System.ValueTuple.CombineHashCodes$4(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6));
41993            },
41994            toString: function () {
41995                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 
41995!= null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ")";
41996            },
41997            System$ITupleInternal$ToStringEnd: function () {
41998                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ")";
41999            },
42000            $clone: function (to) {
42001                var s = to || new (System.ValueTuple$6(T1,T2,T3,T4,T5,T6))();
42002                s.Item1 = this.Item1;
42003                s.Item2 = this.Item2;
42004                s.Item3 = this.Item3;
42005                s.Item4 = this.Item4;
42006                s.Item5 = this.Item5;
42007                s.Item6 = this.Item6;
42008                return s;
42009            }
42010        }
42011    }; });
42012
42013    H5.define("System.ValueTuple$7", function (T1, T2, T3, T4, T5, T6, T7) { return {
42014        inherits: function () { return [System.IEquatable$1(System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)),System.ITupleInternal]; },
42015        $kind: "struct",
42016        statics: {
42017            props: {
42018                s_t1Comparer: {
42019                    get: function () {
42020                        return System.Collections.Generic.EqualityComparer$1(T1).def;
42021                    }
42022                },
42023                s_t2Comparer: {
42024                    get: function () {
42025                        return System.Collections.Generic.EqualityComparer$1(T2).def;
42026                    }
42027                },
42028                s_t3Comparer: {
42029                    get: function () {
42030                        return System.Collections.Generic.EqualityComparer$1(T3).def;
42031                    }
42032                },
42033                s_t4Comparer: {
42034                    get: function () {
42035                        return System.Collections.Generic.EqualityComparer$1(T4).def;
42036                    }
42037                },
42038                s_t5Comparer: {
42039                    get: function () {
42040                        return System.Collections.Generic.EqualityComparer$1(T5).def;
42041                    }
42042                },
42043                s_t6Comparer: {
42044                    get: function () {
42045                        return System.Collections.Generic.EqualityComparer$1(T6).def;
42046                    }
42047                },
42048                s_t7Comparer: {
42049                    get: function () {
42050                        return System.Collections.Generic.EqualityComparer$1(T7).def;
42051                    }
42052                }
42053            },
42054            methods: {
42055                getDefaultValue: function () { return new (System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7))(); }
42056            }
42057        },
42058        fields: {
42059            Item1: H5.getDefaultValue(T1),
42060            Item2: H5.getDefaultValue(T2),
42061            Item3: H5.getDefaultValue(T3),
42062            Item4: H5.getDefaultValue(T4),
42063            Item5: H5.getDefaultValue(T5),
42064            Item6: H5.getDefaultValue(T6),
42065            Item7: H5.getDefaultValue(T7)
42066        },
42067        props: {
42068            System$ITupleInternal$Size: {
42069                get: function () {
42070                    return 7;
42071                }
42072            }
42073        },
42074        alias: [
42075            "equalsT", "System$IEquatable$1$System$ValueTuple$7$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$" + H5.getTypeAlias(T7) + "$equalsT",
42076            "compareTo", ["System$IComparable$1$System$ValueTuple$7$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$" + H5.getTypeAlias(T7) + "$compareTo", "System$IComparable$1$compareTo"]
42077        ],
42078        ctors: {
42079            $ctor1: function (item1, item2, item3, item4, item5, item6, item7) {
42080                this.$initialize();
42081                this.Item1 = item1;
42082                this.Item2 = item2;
42083                this.Item3 = item3;
42084                this.Item4 = item4;
42085                this.Item5 = item5;
42086                this.Item6 = item6;
42087                this.Item7 = item7;
42088            },
42089            ctor: function () {
42090                this.$initialize();
42091            }
42092        },
42093        methods: {
42094            equals: function (obj) {
42095                return H5.is(obj, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7))));
42096            },
42097            equalsT: function (other) {
42098                return System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t3Comparer.equals2(this.Item3, other.Item3) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t4Comparer.equals2(this.Item4, other.Item4) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t5Comparer.equals2(this.Item5, other.Item5) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t6Comparer.equals2(this.Item6, other.Item6) && System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t7Comparer.equals2(this.Item7, other.Item7);
42099            },
42100            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
42101                if (other == null || !(H5.is(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)))) {
42102                    return false;
42103                }
42104
42105                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)));
42106
42107                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3) && comparer.System$Collections$IEqualityComparer$equals(this.Item4, objTuple.Item4) && comparer.System$Collections$IEqualityComparer$equals(this.Item5, objTuple.Item5) && comparer.System$Collections$IEqualityComparer$equals(this.Item6, objTuple.Item6) && comparer.System$Collections$IEqualityComparer$equals(this.Item7, objTuple.Item7);
42108            },
42109            System$IComparable$compareTo: function (other) {
42110                if (other == null) {
42111                    return 1;
42112                }
42113
42114                if (!(H5.is(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)))) {
42115                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
42116                }
42117
42118                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7))));
42119            },
42120            compareTo: function (other) {
42121                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
42122                if (c !== 0) {
42123                    return c;
42124                }
42125
42126                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
42127                if (c !== 0) {
42128                    return c;
42129                }
42130
42131                c = new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
42132                if (c !== 0) {
42133                    return c;
42134                }
42135
42136                c = new (System.Collections.Generic.Comparer$1(T4))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item4, other.Item4);
42137                if (c !== 0) {
42138                    return c;
42139                }
42140
42141                c = new (System.Collections.Generic.Comparer$1(T5))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item5, other.Item5);
42142                if (c !== 0) {
42143                    return c;
42144                }
42145
42146                c = new (System.Collections.Generic.Comparer$1(T6))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item6, other.Item6);
42147                if (c !== 0) {
42148                    return c;
42149                }
42150
42151                return new (System.Collections.Generic.Comparer$1(T7))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item7, other.Item7);
42152            },
42153            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
42154                if (other == null) {
42155                    return 1;
42156                }
42157
42158                if (!(H5.is(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)))) {
42159                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
42160                }
42161
42162                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7)));
42163
42164                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
42165                if (c !== 0) {
42166                    return c;
42167                }
42168
42169                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
42170                if (c !== 0) {
42171                    return c;
42172                }
42173
42174                c = comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
42175                if (c !== 0) {
42176                    return c;
42177                }
42178
42179                c = comparer.System$Collections$IComparer$compare(this.Item4, objTuple.Item4);
42180                if (c !== 0) {
42181                    return c;
42182                }
42183
42184                c = comparer.System$Collections$IComparer$compare(this.Item5, objTuple.Item5);
42185                if (c !== 0) {
42186                    return c;
42187                }
42188
42189                c = comparer.System$Collections$IComparer$compare(this.Item6, objTuple.Item6);
42190                if (c !== 0) {
42191                    return c;
42192                }
42193
42194                return comparer.System$Collections$IComparer$compare(this.Item7, objTuple.Item7);
42195            },
42196            getHashCode: function () {
42197                return System.ValueTuple.CombineHashCodes$5(System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7).s_t7Comparer.getHashCode2(this.Item7));
42198            },
42199            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
42200                return this.GetHashCodeCore(comparer);
42201            },
42202            System$ITupleInternal$GetHashCode: function (comparer) {
42203                return this.GetHashCodeCore(comparer);
42204            },
42205            GetHashCodeCore: function (comparer) {
42206                return System.ValueTuple.CombineHashCodes$5(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7));
42207            },
42208            toString: function () {
42209                return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 
42209!= null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ")";
42210            },
42211            System$ITupleInternal$ToStringEnd: function () {
42212                return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ")";
42213            },
42214            $clone: function (to) {
42215                var s = to || new (System.ValueTuple$7(T1,T2,T3,T4,T5,T6,T7))();
42216                s.Item1 = this.Item1;
42217                s.Item2 = this.Item2;
42218                s.Item3 = this.Item3;
42219                s.Item4 = this.Item4;
42220                s.Item5 = this.Item5;
42221                s.Item6 = this.Item6;
42222                s.Item7 = this.Item7;
42223                return s;
42224            }
42225        }
42226    }; });
42227
42228    H5.define("System.ValueTuple$8", function (T1, T2, T3, T4, T5, T6, T7, TRest) { return {
42229        inherits: function () { return [System.IEquatable$1(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)),System.Collections.IStructuralEquatable,System.Collections.IStructuralComparable,System.IComparable,System.IComparable$1(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)),System.ITupleInternal]; },
42230        $kind: "struct",
42231        statics: {
42232            props: {
42233                s_t1Comparer: {
42234                    get: function () {
42235                        return System.Collections.Generic.EqualityComparer$1(T1).def;
42236                    }
42237                },
42238                s_t2Comparer: {
42239                    get: function () {
42240                        return System.Collections.Generic.EqualityComparer$1(T2).def;
42241                    }
42242                },
42243                s_t3Comparer: {
42244                    get: function () {
42245                        return System.Collections.Generic.EqualityComparer$1(T3).def;
42246                    }
42247                },
42248                s_t4Comparer: {
42249                    get: function () {
42250                        return System.Collections.Generic.EqualityComparer$1(T4).def;
42251                    }
42252                },
42253                s_t5Comparer: {
42254                    get: function () {
42255                        return System.Collections.Generic.EqualityComparer$1(T5).def;
42256                    }
42257                },
42258                s_t6Comparer: {
42259                    get: function () {
42260                        return System.Collections.Generic.EqualityComparer$1(T6).def;
42261                    }
42262                },
42263                s_t7Comparer: {
42264                    get: function () {
42265                        return System.Collections.Generic.EqualityComparer$1(T7).def;
42266                    }
42267                },
42268                s_tRestComparer: {
42269                    get: function () {
42270                        return System.Collections.Generic.EqualityComparer$1(TRest).def;
42271                    }
42272                }
42273            },
42274            methods: {
42275                getDefaultValue: function () { return new (System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest))(); }
42276            }
42277        },
42278        fields: {
42279            Item1: H5.getDefaultValue(T1),
42280            Item2: H5.getDefaultValue(T2),
42281            Item3: H5.getDefaultValue(T3),
42282            Item4: H5.getDefaultValue(T4),
42283            Item5: H5.getDefaultValue(T5),
42284            Item6: H5.getDefaultValue(T6),
42285            Item7: H5.getDefaultValue(T7),
42286            Rest: H5.getDefaultValue(TRest)
42287        },
42288        props: {
42289            System$ITupleInternal$Size: {
42290                get: function () {
42291                    var rest = H5.as(this.Rest, System.ITupleInternal);
42292                    return rest == null ? 8 : ((7 + rest.System$ITupleInternal$Size) | 0);
42293                }
42294            }
42295        },
42296        alias: [
42297            "equalsT", "System$IEquatable$1$System$ValueTuple$8$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$" + H5.getTypeAlias(T7) + "$" + H5.getTypeAlias(TRest) + "$equalsT",
42298            "compareTo", ["System$IComparable$1$System$ValueTuple$8$" + H5.getTypeAlias(T1) + "$" + H5.getTypeAlias(T2) + "$" + H5.getTypeAlias(T3) + "$" + H5.getTypeAlias(T4) + "$" + H5.getTypeAlias(T5) + "$" + H5.getTypeAlias(T6) + "$" + H5.getTypeAlias(T7) + "$" + H5.getTypeAlias(TRest) + "$compareTo", "System$IComparable$1$compareTo"]
42299        ],
42300        ctors: {
42301            $ctor1: function (item1, item2, item3, item4, item5, item6, item7, rest) {
42302                this.$initialize();
42303                if (!(H5.is(rest, System.ITupleInternal))) {
42304                    throw new System.ArgumentException.$ctor1(System.SR.ArgumentException_ValueTupleLastArgumentNotAValueTuple);
42305                }
42306
42307                this.Item1 = item1;
42308                this.Item2 = item2;
42309                this.Item3 = item3;
42310                this.Item4 = item4;
42311                this.Item5 = item5;
42312                this.Item6 = item6;
42313                this.Item7 = item7;
42314                this.Rest = rest;
42315            },
42316            ctor: function () {
42317                this.$initialize();
42318            }
42319        },
42320        methods: {
42321            equals: function (obj) {
42322                return H5.is(obj, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)) && this.equalsT(System.Nullable.getValue(H5.cast(H5.unbox(obj, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest))));
42323            },
42324            equalsT: function (other) {
42325                return System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t1Comparer.equals2(this.Item1, other.Item1) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t2Comparer.equals2(this.Item2, other.Item2) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t3Comparer.equals2(this.Item3, other.Item3) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.equals2(this.Item4, other.Item4) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.equals2(this.Item5, other.Item5) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.equals2(this.Item6, other.Item6) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.equals2(this.Item7, other.Item7) && System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_tRestComparer.equals2(this.Rest, other.Rest);
42326            },
42327            System$Collections$IStructuralEquatable$Equals: function (other, comparer) {
42328                if (other == null || !(H5.is(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)))) {
42329                    return false;
42330                }
42331
42332                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)));
42333
42334                return comparer.System$Collections$IEqualityComparer$equals(this.Item1, objTuple.Item1) && comparer.System$Collections$IEqualityComparer$equals(this.Item2, objTuple.Item2) && comparer.System$Collections$IEqualityComparer$equals(this.Item3, objTuple.Item3) && comparer.System$Collections$IEqualityComparer$equals(this.Item4, objTuple.Item4) && comparer.System$Collections$IEqualityComparer$equals(this.Item5, objTuple.Item5) && comparer.System$Collections$IEqualityComparer$equals(this.Item6, objTuple.Item6) && comparer.System$Collections$IEqualityComparer$equals(this.Item7, objTuple.Item7) && comparer.System$Collections$IEqualityComparer$equals(this.Rest, objTuple.Rest);
42335            },
42336            System$IComparable$compareTo: function (other) {
42337                if (other == null) {
42338                    return 1;
42339                }
42340
42341                if (!(H5.is(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)))) {
42342                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
42343                }
42344
42345                return this.compareTo(System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest))));
42346            },
42347            compareTo: function (other) {
42348                var c = new (System.Collections.Generic.Comparer$1(T1))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item1, other.Item1);
42349                if (c !== 0) {
42350                    return c;
42351                }
42352
42353                c = new (System.Collections.Generic.Comparer$1(T2))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item2, other.Item2);
42354                if (c !== 0) {
42355                    return c;
42356                }
42357
42358                c = new (System.Collections.Generic.Comparer$1(T3))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item3, other.Item3);
42359                if (c !== 0) {
42360                    return c;
42361                }
42362
42363                c = new (System.Collections.Generic.Comparer$1(T4))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item4, other.Item4);
42364                if (c !== 0) {
42365                    return c;
42366                }
42367
42368                c = new (System.Collections.Generic.Comparer$1(T5))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item5, other.Item5);
42369                if (c !== 0) {
42370                    return c;
42371                }
42372
42373                c = new (System.Collections.Generic.Comparer$1(T6))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item6, other.Item6);
42374                if (c !== 0) {
42375                    return c;
42376                }
42377
42378                c = new (System.Collections.Generic.Comparer$1(T7))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Item7, other.Item7);
42379                if (c !== 0) {
42380                    return c;
42381                }
42382
42383                return new (System.Collections.Generic.Comparer$1(TRest))(System.Collections.Generic.Comparer$1.$default.fn).compare(this.Rest, other.Rest);
42384            },
42385            System$Collections$IStructuralComparable$CompareTo: function (other, comparer) {
42386                if (other == null) {
42387                    return 1;
42388                }
42389
42390                if (!(H5.is(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)))) {
42391                    throw new System.ArgumentException.$ctor3(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
42392                }
42393
42394                var objTuple = System.Nullable.getValue(H5.cast(H5.unbox(other, System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest)));
42395
42396                var c = comparer.System$Collections$IComparer$compare(this.Item1, objTuple.Item1);
42397                if (c !== 0) {
42398                    return c;
42399                }
42400
42401                c = comparer.System$Collections$IComparer$compare(this.Item2, objTuple.Item2);
42402                if (c !== 0) {
42403                    return c;
42404                }
42405
42406                c = comparer.System$Collections$IComparer$compare(this.Item3, objTuple.Item3);
42407                if (c !== 0) {
42408                    return c;
42409                }
42410
42411                c = comparer.System$Collections$IComparer$compare(this.Item4, objTuple.Item4);
42412                if (c !== 0) {
42413                    return c;
42414                }
42415
42416                c = comparer.System$Collections$IComparer$compare(this.Item5, objTuple.Item5);
42417                if (c !== 0) {
42418                    return c;
42419                }
42420
42421                c = comparer.System$Collections$IComparer$compare(this.Item6, objTuple.Item6);
42422                if (c !== 0) {
42423                    return c;
42424                }
42425
42426                c = comparer.System$Collections$IComparer$compare(this.Item7, objTuple.Item7);
42427                if (c !== 0) {
42428                    return c;
42429                }
42430
42431                return comparer.System$Collections$IComparer$compare(this.Rest, objTuple.Rest);
42432            },
42433            getHashCode: function () {
42434                var rest = H5.as(this.Rest, System.ITupleInternal);
42435                if (rest == null) {
42436                    return System.ValueTuple.CombineHashCodes$5(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7));
42437                }
42438
42439                var size = rest.System$ITupleInternal$Size;
42440                if (size >= 8) {
42441                    return H5.getHashCode(rest);
42442                }
42443
42444                var k = (8 - size) | 0;
42445                switch (k) {
42446                    case 1: 
42447                        return System.ValueTuple.CombineHashCodes(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42448                    case 2: 
42449                        return System.ValueTuple.CombineHashCodes$1(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42450                    case 3: 
42451                        return System.ValueTuple.CombineHashCodes$2(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42452                    case 4: 
42453                        return System.ValueTuple.CombineHashCodes$3(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42454                    case 5: 
42455                        return System.ValueTuple.CombineHashCodes$4(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42456                    case 6: 
42457                        return System.ValueTuple.CombineHashCodes$5(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42458                    case 7: 
42459                    case 8: 
42460                        return System.ValueTuple.CombineHashCodes$6(System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t1Comparer.getHashCode2(this.Item1), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t2Comparer.getHashCode2(this.Item2), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t3Comparer.getHashCode2(this.Item3), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t4Comparer.getHashCode2(this.Item4), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t5Comparer.getHashCode2(this.Item5), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t6Comparer.getHashCode2(this.Item6), System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest).s_t7Comparer.getHashCode2(this.Item7), H5.getHashCode(rest));
42461                }
42462
42463                return -1;
42464            },
42465            System$Collections$IStructuralEquatable$GetHashCode: function (comparer) {
42466                return this.GetHashCodeCore(comparer);
42467            },
42468            System$ITupleInternal$GetHashCode: function (comparer) {
42469                return this.GetHashCodeCore(comparer);
42470            },
42471            GetHashCodeCore: function (comparer) {
42472                var rest = H5.as(this.Rest, System.ITupleInternal);
42473                if (rest == null) {
42474                    return System.ValueTuple.CombineHashCodes$5(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7));
42475                }
42476
42477                var size = rest.System$ITupleInternal$Size;
42478                if (size >= 8) {
42479                    return rest.System$ITupleInternal$GetHashCode(comparer);
42480                }
42481
42482                var k = (8 - size) | 0;
42483                switch (k) {
42484                    case 1: 
42485                        return System.ValueTuple.CombineHashCodes(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42486                    case 2: 
42487                        return System.ValueTuple.CombineHashCodes$1(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42488                    case 3: 
42489                        return System.ValueTuple.CombineHashCodes$2(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42490                    case 4: 
42491                        return System.ValueTuple.CombineHashCodes$3(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42492                    case 5: 
42493                        return System.ValueTuple.CombineHashCodes$4(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42494                    case 6: 
42495                        return System.ValueTuple.CombineHashCodes$5(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42496                    case 7: 
42497                    case 8: 
42498                        return System.ValueTuple.CombineHashCodes$6(comparer.System$Collections$IEqualityComparer$getHashCode(this.Item1), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item2), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item3), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item4), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item5), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item6), comparer.System$Collections$IEqualityComparer$getHashCode(this.Item7), rest.System$ITupleInternal$GetHashCode(comparer));
42499                }
42500
42501                return -1;
42502            },
42503            toString: function () {
42504                var rest = H5.as(this.Rest, System.ITupleInternal);
42505                if (rest == null) {
42506                    return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 
42506!= null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ", " + (H5.toString(this.Rest) || "") + ")";
42507                } else {
42508                    return "(" + ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ", " + (rest.System$ITupleInternal$ToStringEnd() || "");
42509                }
42510            },
42511            System$ITupleInternal$ToStringEnd: function () {
42512                var rest = H5.as(this.Rest, System.ITupleInternal);
42513                if (rest == null) {
42514                    return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ", " + (H5.toString(this.Rest) || "") + ")";
42515                } else {
42516                    return ((this.Item1 != null ? H5.toString(this.Item1) : null) || "") + ", " + ((this.Item2 != null ? H5.toString(this.Item2) : null) || "") + ", " + ((this.Item3 != null ? H5.toString(this.Item3) : null) || "") + ", " + ((this.Item4 != null ? H5.toString(this.Item4) : null) || "") + ", " + ((this.Item5 != null ? H5.toString(this.Item5) : null) || "") + ", " + ((this.Item6 != null ? H5.toString(this.Item6) : null) || "") + ", " + ((this.Item7 != null ? H5.toString(this.Item7) : null) || "") + ", " + (rest.System$ITupleInternal$ToStringEnd() || "");
42517                }
42518            },
42519            $clone: function (to) {
42520                var s = to || new (System.ValueTuple$8(T1,T2,T3,T4,T5,T6,T7,TRest))();
42521                s.Item1 = this.Item1;
42522                s.Item2 = this.Item2;
42523                s.Item3 = this.Item3;
42524                s.Item4 = this.Item4;
42525                s.Item5 = this.Item5;
42526                s.Item6 = this.Item6;
42527                s.Item7 = this.Item7;
42528                s.Rest = this.Rest;
42529                return s;
42530            }
42531        }
42532    }; });
42533
42534    // @source IndexOutOfRangeException.js
42535
42536    H5.define("System.IndexOutOfRangeException", {
42537        inherits: [System.SystemException],
42538        ctors: {
42539            ctor: function () {
42540                this.$initialize();
42541                System.SystemException.$ctor1.call(this, "Index was outside the bounds of the array.");
42542                this.HResult = -2146233080;
42543            },
42544            $ctor1: function (message) {
42545                this.$initialize();
42546                System.SystemException.$ctor1.call(this, message);
42547                this.HResult = -2146233080;
42548            },
42549            $ctor2: function (message, innerException) {
42550                this.$initialize();
42551                System.SystemException.$ctor2.call(this, message, innerException);
42552                this.HResult = -2146233080;
42553            }
42554        }
42555    });
42556
42557    // @source InvalidCastException.js
42558
42559    H5.define("System.InvalidCastException", {
42560        inherits: [System.SystemException],
42561        ctors: {
42562            ctor: function () {
42563                this.$initialize();
42564                System.SystemException.$ctor1.call(this, "Specified cast is not valid.");
42565                this.HResult = -2147467262;
42566            },
42567            $ctor1: function (message) {
42568                this.$initialize();
42569                System.SystemException.$ctor1.call(this, message);
42570                this.HResult = -2147467262;
42571            },
42572            $ctor2: function (message, innerException) {
42573                this.$initialize();
42574                System.SystemException.$ctor2.call(this, message, innerException);
42575                this.HResult = -2147467262;
42576            },
42577            $ctor3: function (message, errorCode) {
42578                this.$initialize();
42579                System.SystemException.$ctor1.call(this, message);
42580                this.HResult = errorCode;
42581            }
42582        }
42583    });
42584
42585    // @source InvalidOperationException.js
42586
42587    H5.define("System.InvalidOperationException", {
42588        inherits: [System.SystemException],
42589        ctors: {
42590            ctor: function () {
42591                this.$initialize();
42592                System.SystemException.$ctor1.call(this, "Operation is not val
42592id due to the current state of the object.");
42593                this.HResult = -2146233079;
42594            },
42595            $ctor1: function (message) {
42596                this.$initialize();
42597                System.SystemException.$ctor1.call(this, message);
42598                this.HResult = -2146233079;
42599            },
42600            $ctor2: function (message, innerException) {
42601                this.$initialize();
42602                System.SystemException.$ctor2.call(this, message, innerException);
42603                this.HResult = -2146233079;
42604            }
42605        }
42606    });
42607
42608    // @source ObjectDisposedException.js
42609
42610    H5.define("System.ObjectDisposedException", {
42611        inherits: [System.InvalidOperationException],
42612        fields: {
42613            _objectName: null
42614        },
42615        props: {
42616            Message: {
42617                get: function () {
42618                    var name = this.ObjectName;
42619                    if (name == null || name.length === 0) {
42620                        return H5.ensureBaseProperty(this, "Message").$System$Exception$Message;
42621                    }
42622
42623                    var objectDisposed = System.SR.Format("Object name: '{0}'.", name);
42624                    return (H5.ensureBaseProperty(this, "Message").$System$Exception$Message || "") + ("\n" || "") + (objectDisposed || "");
42625                }
42626            },
42627            ObjectName: {
42628                get: function () {
42629                    if (this._objectName == null) {
42630                        return "";
42631                    }
42632                    return this._objectName;
42633                }
42634            }
42635        },
42636        ctors: {
42637            ctor: function () {
42638                System.ObjectDisposedException.$ctor3.call(this, null, "Cannot access a disposed object.");
42639            },
42640            $ctor1: function (objectName) {
42641                System.ObjectDisposedException.$ctor3.call(this, objectName, "Cannot access a disposed object.");
42642            },
42643            $ctor3: function (objectName, message) {
42644                this.$initialize();
42645                System.InvalidOperationException.$ctor1.call(this, message);
42646                this.HResult = -2146232798;
42647                this._objectName = objectName;
42648            },
42649            $ctor2: function (message, innerException) {
42650                this.$initialize();
42651                System.InvalidOperationException.$ctor2.call(this, message, innerException);
42652                this.HResult = -2146232798;
42653            }
42654        }
42655    });
42656
42657    // @source InvalidProgramException.js
42658
42659    H5.define("System.InvalidProgramException", {
42660        inherits: [System.SystemException],
42661        ctors: {
42662            ctor: function () {
42663                this.$initialize();
42664                System.SystemException.$ctor1.call(this, "Common Language Runtime detected an invalid program.");
42665                this.HResult = -2146233030;
42666            },
42667            $ctor1: function (message) {
42668                this.$initialize();
42669                System.SystemException.$ctor1.call(this, message);
42670                this.HResult = -2146233030;
42671            },
42672            $ctor2: function (message, inner) {
42673                this.$initialize();
42674                System.SystemException.$ctor2.call(this, message, inner);
42675                this.HResult = -2146233030;
42676            }
42677        }
42678    });
42679
42680    // @source MissingMethodException.js
42681
42682    H5.define("System.MissingMethodException", {
42683        inherits: [System.Exception],
42684        ctors: {
42685            ctor: function () {
42686                this.$initialize();
42687                System.Exception.ctor.call(this, "Attempted to access a missing method.");
42688            },
42689            $ctor1: function (message) {
42690                this.$initialize();
42691                System.Exception.ctor.call(this, message);
42692            },
42693            $ctor2: function (message, inner) {
42694                this.$initialize();
42695                System.Exception.ctor.call(this, message, inner);
42696            },
42697            $ctor3: function (className, methodName) {
42698                this.$initialize();
42699                System.Exception.ctor.call(this, (className || "") + "." + (methodName || "") + " Due to: Attempted to access a missing member.");
42700            }
42701        }
42702    });
42703
42704    // @source Calendar.js
42705
42706    H5.define("System.Globalization.Calendar", {
42707        inherits: [System.ICloneable],
42708        statics: {
42709            fields: {
42710                TicksPerMillisecond: System.Int64(0),
42711                TicksPerSecond: System.Int64(0),
42712                TicksPerMinute: System.Int64(0),
42713                TicksPerHour: System.Int64(0),
42714                TicksPerDay: System.Int64(0),
42715                MillisPerSecond: 0,
42716                MillisPerMinute: 0,
42717                MillisPerHour: 0,
42718                MillisPerDay: 0,
42719                DaysPerYear: 0,
42720                DaysPer4Years: 0,
42721                DaysPer100Years: 0,
42722                DaysPer400Years: 0,
42723                DaysTo10000: 0,
42724                MaxMillis: System.Int64(0),
42725                CurrentEra: 0
42726            },
42727            ctors: {
42728                init: function () {
42729                    this.TicksPerMillisecond = System.Int64(10000);
42730                    this.TicksPerSecond = System.Int64(10000000);
42731                    this.TicksPerMinute = System.Int64(600000000);
42732                    this.TicksPerHour = System.Int64([1640261632,8]);
42733                    this.TicksPerDay = System.Int64([711573504,201]);
42734                    this.MillisPerSecond = 1000;
42735                    this.MillisPerMinute = 60000;
42736                    this.MillisPerHour = 3600000;
42737                    this.MillisPerDay = 86400000;
42738                    this.DaysPerYear = 365;
42739                    this.DaysPer4Years = 1461;
42740                    this.DaysPer100Years = 36524;
42741                    this.DaysPer400Years = 146097;
42742                    this.DaysTo10000 = 3652059;
42743                    this.MaxMillis = System.Int64([-464735232,73466]);
42744                    this.CurrentEra = 0;
42745                }
42746            },
42747            methods: {
42748                ReadOnly: function (calendar) {
42749                    if (calendar == null) {
42750                        throw new System.ArgumentNullException.$ctor1("calendar");
42751                    }
42752                    if (calendar.IsReadOnly) {
42753                        return (calendar);
42754                    }
42755
42756                    var clonedCalendar = H5.cast((H5.clone(calendar)), System.Globalization.Calendar);
42757                    clonedCalendar.SetReadOnlyState(true);
42758
42759                    return (clonedCalendar);
42760                },
42761                CheckAddResult: function (ticks, minValue, maxValue) {
42762                    if (ticks.lt(System.DateTime.getTicks(minValue)) || ticks.gt(System.DateTime.getTicks(maxValue))) {
42763                        throw new System.ArgumentException.$ctor1(System.String.formatProvider(System.Globalization.CultureInfo.invariantCulture, System.SR.Format$1("The result is out of the supported range for this calendar. The result should be between {0} (Gregorian date) and {1} (Gregorian date), inclusive.", H5.box(minValue, System.DateTime, System.DateTime.format), H5.box(maxValue, System.DateTime, System.DateTime.format)), null));
42764                    }
42765                },
42766                GetSystemTwoDigitYearSetting: function (CalID, defaultYearValue) {
42767                    var twoDigitYearMax = 2029;
42768                    if (twoDigitYearMax < 0) {
42769                        twoDigitYearMax = defaultYearValue;
42770                    }
42771                    return (twoDigitYearMax);
42772                }
42773            }
42774        },
42775        fields: {
42776            _isReadOnly: false,
42777            twoDigitYearMax: 0
42778        },
42779        props: {
42780            MinSupportedDateTime: {
42781                get: function () {
42782                    return (System.DateTime.getMinValue());
42783                }
42784            },
42785            MaxSupportedDateTime: {
42786                get: function () {
42787                    return (System.DateTime.getMaxValue());
42788                }
42789            },
42790            AlgorithmType: {
42791                get: function () {
42792                    return 0;
42793                }
42794            },
42795            ID: {
42796                get: function () {
42797                    return 0;
42798                }
42799            },
42800            BaseCalendarID: {
42801                get: function () {
42802                    return this.ID;
42803                }
42804            },
42805            IsReadOnly: {
42806                get: function () {
42807                    return (this._isReadOnly);
42808                }
42809            },
42810            CurrentEraValue: {
42811                get: function () {
42812                    throw System.NotImplemented.ByDesign;
42813                }
42814            },
42815            DaysInYearBeforeMinSupportedYear: {
42816                get: function () {
42817                    return 365;
42818                }
42819            },
42820            TwoDigitYearMax: {
42821                get: function () {
42822                    return (this.twoDigitYearMax);
42823                },
42824                set: function (value) {
42825                    this.VerifyWritable();
42826                    this.twoDigitYearMax = value;
42827                }
42828            }
42829        },
42830        alias: ["clone", "System$ICloneable$clone"],
42831        ctors: {
42832            init: function () {
42833                this._isReadOnly = false;
42834                this.twoDigitYearMax = -1;
42835            },
42836            ctor: function () {
42837                this.$initialize();
42838            }
42839        },
42840        methods: {
42841            clone: function () {
42842                var o = H5.clone(this);
42843                H5.cast(o, System.Globalization.Calendar).SetReadOnlyState(false);
42844                return (o);
42845            },
42846            VerifyWritable: function () {
42847                if (this._isReadOnly) {
42848                    throw new System.InvalidOperationException.$ctor1("Instance is read-only.");
42849                }
42850            },
42851            SetReadOnlyState: function (readOnly) {
42852                this._isReadOnly = readOnly;
42853            },
42854            Add: function (time, value, scale) {
42855                var tempMillis = (value * scale + (value >= 0 ? 0.5 : -0.5));
42856                if (!((tempMillis > -315537897600000.0) && (tempMillis < 315537897600000.0))) {
42857                    throw new System.ArgumentOutOfRangeException.$ctor4("value", "Value to add was out of range.");
42858                }
42859
42860                var millis = H5.Int.clip64(tempMillis);
42861                var ticks = System.DateTime.getTicks(time).add(millis.mul(System.Globalization.Calendar.TicksPerMillisecond));
42862                System.Globalization.Calendar.CheckAddResult(ticks, this.MinSupportedDateTime, this.MaxSupportedDateTime);
42863                return (System.DateTime.create$2(ticks));
42864            },
42865            AddMilliseconds: function (time, milliseconds) {
42866                return (this.Add(time, milliseconds, 1));
42867            },
42868            AddDays: function (time, days) {
42869                return (this.Add(time, days, System.Globalization.Calendar.MillisPerDay));
42870            },
42871            AddHours: function (time, hours) {
42872                return (this.Add(time, hours, System.Globalization.Calendar.MillisPerHour));
42873            },
42874            AddMinutes: function (time, minutes) {
42875                return (this.Add(time, minutes, System.Globalization.Calendar.MillisPerMinute));
42876            },
42877            AddSeconds: function (time, seconds) {
42878                return this.Add(time, seconds, System.Globalization.Calendar.MillisPerSecond);
42879            },
42880            AddWeeks: function (time, weeks) {
42881                return (this.AddDays(time, H5.Int.mul(weeks, 7)));
42882            },
42883            GetDaysInMonth: function (year, month) {
42884                return (this.GetDaysInMonth$1(year, month, System.Globalization.Calendar.CurrentEra));
42885            },
42886            GetDaysInYear: function (year) {
42887                return (this.GetDaysInYear$1(year, System.Globalization.Calendar.CurrentEra));
42888            },
42889            GetHour: function (time) {
42890                return (System.Int64.clip32((System.DateTime.getTicks(time).div(System.Globalization.Calendar.TicksPerHour)).mod(System.Int64(24))));
42891            },
42892            GetMilliseconds: function (time) {
42893                return System.Int64.toNumber((System.DateTime.getTicks(time).div(System.Globalization.Calendar.TicksPerMillisecond)).mod(System.Int64(1000)));
42894            },
42895            GetMinute: function (time) {
42896                return (System.Int64.clip32((System.DateTime.getTicks(time).div(System.Globalization.Calendar.TicksPerMinute)).mod(System.Int64(60))));
42897            },
42898            GetMonthsInYear: function (year) {
42899                return (this.GetMonthsInYear$1(year, System.Globalization.Calendar.CurrentEra));
42900            },
42901            GetSecond: function (time) {
42902                return (System.Int64.clip32((System.DateTime.getTicks(time).div(System.Globalization.Calendar.TicksPerSecond)).mod(System.Int64(60))));
42903            },
42904            GetFirstDayWeekOfYear: function (time, firstDayOfWeek) {
42905                var dayOfYear = (this.GetDayOfYear(time) - 1) | 0;
42906                var dayForJan1 = (this.GetDayOfWeek(time) - (dayOfYear % 7)) | 0;
42907                var offset = (((((dayForJan1 - firstDayOfWeek) | 0) + 14) | 0)) % 7;
42908                return (((((H5.Int.div((((dayOfYear + offset) | 0)), 7)) | 0) + 1) | 0));
42909            },
42910            GetWeekOfYearFullDays: function (time, firstDayOfWeek, fullDays) {
42911                var dayForJan1;
42912                var offset;
42913                var day;
42914
42915                var dayOfYear = (this.GetDayOfYear(time) - 1) | 0;
42916
42917
42918
42919                dayForJan1 = (this.GetDayOfWeek(time) - (dayOfYear % 7)) | 0;
42920
42921                offset = (((((firstDayOfWeek - dayForJan1) | 0) + 14) | 0)) % 7;
42922                if (offset !== 0 && offset >= fullDays) {
42923                    offset = (offset - 7) | 0;
42924                }
42925                day = (dayOfYear - offset) | 0;
42926                if (day >= 0) {
42927                    return (((((H5.Int.div(day, 7)) | 0) + 1) | 0));
42928                }
42929                if (System.DateTime.lte(time, System.DateTime.addDays(this.MinSupportedDateTime, dayOfYear))) {
42930                    return this.GetWeekOfYearOfMinSupportedDateTime(firstDayOfWeek, fullDays);
42931                }
42932                return (this.GetWeekOfYearFullDays(System.DateTime.addDays(time, ((-(((dayOfYear + 1) | 0))) | 0)), firstDayOfWeek, fullDays));
42933            },
42934            GetWeekOfYearOfMinSupportedDateTime: function (firstDayOfWeek, minimumDaysInFirstWeek) {
42935                var dayOfYear = (this.GetDayOfYear(this.MinSupportedDateTime) - 1) | 0;
42936                var dayOfWeekOfFirstOfYear = (this.GetDayOfWeek(this.MinSupportedDateTime) - dayOfYear % 7) | 0;
42937
42938                var offset = (((((firstDayOfWeek + 7) | 0) - dayOfWeekOfFirstOfYear) | 0)) % 7;
42939                if (offset === 0 || offset >= minimumDaysInFirstWeek) {
42940                    return 1;
42941                }
42942
42943                var daysInYearBeforeMinSupportedYear = (this.DaysInYearBeforeMinSupportedYear - 1) | 0;
42944                var dayOfWeekOfFirstOfPreviousYear = (((dayOfWeekOfFirstOfYear - 1) | 0) - (daysInYearBeforeMinSupportedYear % 7)) | 0;
42945
42946                var daysInInitialPartialWeek = (((((firstDayOfWeek - dayOfWeekOfFirstOfPreviousYear) | 0) + 14) | 0)) % 7;
42947                var day = (daysInYearBeforeMinSupportedYear - daysInInitialPartialWeek) | 0;
42948                if (daysInInitialPartialWeek >= minimumDaysInFirstWeek) {
42949                    day = (day + 7) | 0;
42950                }
42951
42952                return (((((H5.Int.div(day, 7)) | 0) + 1) | 0));
42953            },
42954            GetWeekOfYear: function (time, rule, firstDayOfWeek) {
42955                if (firstDayOfWeek < 0 || firstDayOfWeek > 6) {
42956                    throw new System.ArgumentOutOfRangeException.$ctor4("firstDayOfWeek", System.SR.Format$1("Valid values are between {0} and {1}, inclusive.", H5.box(System.DayOfWeek.Sunday, System.DayOfWeek, System.Enum.toStringFn(System.DayOfWeek)), H5.box(System.DayOfWeek.Saturday, System.DayOfWeek, System.Enum.toStringFn(System.DayOfWeek))));
42957                }
42958                switch (rule) {
42959                    case 0: 
42960                        return (this.GetFirstDayWeekOfYear(time, firstDayOfWeek));
42961                    case 1: 
42962                        return (this.GetWeekOfYearFullDays(time, firstDayOfWeek, 7));
42963                    case 2: 
42964                        return (this.GetWeekOfYearFullDays(time, firstDayOfWeek, 4));
42965                }
42966                throw new System.ArgumentOutOfRangeException.$ctor4("rule", System.SR.Format$1("Valid values are between {0} and {1}, inclusive.", H5.box(0, System.Globalization.CalendarWeekRule, System.Enum.toStringFn(System.Globalization.CalendarWeekRule)), H5.box(2, System.Globalization.CalendarWeekRule, System.Enum.toStringFn(System.Globalization.CalendarWeekRule))));
42967            },
42968            IsLeapDay: function (year, month, day) {
42969                return (this.IsLeapDay$1(year, month, day, System.Globalization.Calendar.CurrentEra));
42970            },
42971            IsLeapMonth: function (year, month) {
42972                return (this.IsLeapMonth$1(year, month, System.Globalization.Calendar.CurrentEra));
42973            },
42974            GetLeapMonth: function (year) {
42975                return (this.GetLeapMonth$1(year, System.Globalization.Calendar.CurrentEra));
42976            },
42977            GetLeapMonth$1: function (year, era) {
42978                if (!this.IsLeapYear$1(year, era)) {
42979                    return 0;
42980                }
42981
42982                var monthsCount = this.GetMonthsInYear$1(year, era);
42983                for (var month = 1; month <= monthsCount; month = (month + 1) | 0) {
42984                    if (this.IsLeapMonth$1(year, month, era)) {
42985                        return month;
42986                    }
42987                }
42988
42989                return 0;
42990            },
42991            IsLeapYear: function (year) {
42992                return (this.IsLeapYear$1(year, System.Globalization.Calendar.CurrentEra));
42993            },
42994            ToDateTime: function (year, month, day, hour, minute, second, millisecond) {
42995                return (this.ToDateTime$1(year, month, day, hour, minute, second, millisecond, System.Globalization.Calendar.CurrentEra));
42996            },
42997            TryToDateTime: function (year, month, day, hour, minute, second, millisecond, era, result) {
42998                result.v = System.DateTime.getMinValue();
42999                try {
43000                    result.v = this.ToDateTime$1(year, month, day, hour, minute, second, millisecond, era);
43001                    return true;
43002                } catch ($e1) {
43003                    $e1 = System.Exception.create($e1);
43004                    if (H5.is($e1, System.ArgumentException)) {
43005                        return false;
43006                    } else {
43007                        throw $e1;
43008                    }
43009                }
43010            },
43011            IsValidYear: function (year, era) {
43012                return (year >= this.GetYear(this.MinSupportedDateTime) && year <= this.GetYear(this.MaxSupportedDateTime));
43013            },
43014            IsValidMonth: function (year, month, era) {
43015                return (this.IsValidYear(year, era) && month >= 1 && month <= this.GetMonthsInYear$1(year, era));
43016            },
43017            IsValidDay: function (year, month, day, era) {
43018                return (this.IsValidMonth(year, month, era) && day >= 1 && day <= this.GetDaysInMonth$1(year, month, era));
43019            },
43020            ToFourDigitYear: function (year) {
43021                if (year < 0) {
43022                    throw new System.ArgumentOutOfRangeException.$ctor4("year", "Non-negative number required.");
43023                }
43024                if (year < 100) {
43025                    return (((H5.Int.mul((((((H5.Int.div(this.TwoDigitYearMax, 100)) | 0) - (year > this.TwoDigitYearMax % 100 ? 1 : 0)) | 0)), 100) + year) | 0));
43026                }
43027                return (year);
43028            }
43029        }
43030    });
43031
43032    // @source CalendarAlgorithmType.js
43033
43034    H5.define("System.Globalization.CalendarAlgorithmType", {
43035        $kind: "enum",
43036        statics: {
43037            fields: {
43038                Unknown: 0,
43039                SolarCalendar: 1,
43040                LunarCalendar: 2,
43041                LunisolarCalendar: 3
43042            }
43043        }
43044    });
43045
43046    // @source CalendarId.js
43047
43048    H5.define("System.Globalization.CalendarId", {
43049        $kind: "enum",
43050        statics: {
43051            fields: {
43052                UNINITIALIZED_VALUE: 0,
43053                GREGORIAN: 1,
43054                GREGORIAN_US: 2,
43055                JAPAN: 3,
43056                TAIWAN: 4,
43057                KOREA: 5,
43058                HIJRI: 6,
43059                THAI: 7,
43060                HEBREW: 8,
43061                GREGORIAN_ME_FRENCH: 9,
43062                GREGORIAN_ARABIC: 10,
43063                GREGORIAN_XLIT_ENGLISH: 11,
43064                GREGORIAN_XLIT_FRENCH: 12,
43065                JULIAN: 13,
43066                JAPANESELUNISOLAR: 14,
43067                CHINESELUNISOLAR: 15,
43068                SAKA: 16,
43069                LUNAR_ETO_CHN: 17,
43070                LUNAR_ETO_KOR: 18,
43071                LUNAR_ETO_ROKUYOU: 19,
43072                KOREANLUNISOLAR: 20,
43073                TAIWANLUNISOLAR: 21,
43074                PERSIAN: 22,
43075                UMALQURA: 23,
43076                LAST_CALENDAR: 23
43077            }
43078        },
43079        $utype: System.UInt16
43080    });
43081
43082    // @source CalendarWeekRule.js
43083
43084    H5.define("System.Globalization.CalendarWeekRule", {
43085        $kind: "enum",
43086        statics: {
43087            fields: {
43088                FirstDay: 0,
43089                FirstFullWeek: 1,
43090                FirstFourDayWeek: 2
43091            }
43092        }
43093    });
43094
43095    // @source CultureNotFoundException.js
43096
43097    H5.define("System.Globalization.CultureNotFoundException", {
43098        inherits: [System.ArgumentException],
43099        statics: {
43100            props: {
43101                DefaultMessage: {
43102                    get: function () {
43103                        return "Culture is not supported.";
43104                    }
43105                }
43106            }
43107        },
43108        fields: {
43109            _invalidCultureName: null,
43110            _invalidCultureId: null
43111        },
43112        props: {
43113            InvalidCultureId: {
43114                get: function () {
43115                    return this._invalidCultureId;
43116                }
43117            },
43118            InvalidCultureName: {
43119                get: function () {
43120                    return this._invalidCultureName;
43121                }
43122            },
43123            FormatedInvalidCultureId: {
43124                get: function () {
43125                    return this.InvalidCultureId != null ? System.String.formatProvider(System.Globalization.CultureInfo.invariantCulture, "{0} (0x{0:x4})", [H5.box(System.Nullable.getValue(this.InvalidCultureId), System.Int32)]) : this.InvalidCultureName;
43126                }
43127            },
43128            Message: {
43129                get: function () {
43130                    var s = H5.ensureBaseProperty(this, "Message").$System$ArgumentException$Message;
43131                    if (this._invalidCultureId != null || this._invalidCultureName != null) {
43132                        var valueMessage = System.SR.Format("{0}
43132 is an invalid culture identifier.", this.FormatedInvalidCultureId);
43133                        if (s == null) {
43134                            return valueMessage;
43135                        }
43136
43137                        return (s || "") + ("\n" || "") + (valueMessage || "");
43138                    }
43139                    return s;
43140                }
43141            }
43142        },
43143        ctors: {
43144            ctor: function () {
43145                this.$initialize();
43146                System.ArgumentException.$ctor1.call(this, System.Globalization.CultureNotFoundException.DefaultMessage);
43147            },
43148            $ctor1: function (message) {
43149                this.$initialize();
43150                System.ArgumentException.$ctor1.call(this, message);
43151            },
43152            $ctor5: function (paramName, message) {
43153                this.$initialize();
43154                System.ArgumentException.$ctor3.call(this, message, paramName);
43155            },
43156            $ctor2: function (message, innerException) {
43157                this.$initialize();
43158                System.ArgumentException.$ctor2.call(this, message, innerException);
43159            },
43160            $ctor7: function (paramName, invalidCultureName, message) {
43161                this.$initialize();
43162                System.ArgumentException.$ctor3.call(this, message, paramName);
43163                this._invalidCultureName = invalidCultureName;
43164            },
43165            $ctor6: function (message, invalidCultureName, innerException) {
43166                this.$initialize();
43167                System.ArgumentException.$ctor2.call(this, message, innerException);
43168                this._invalidCultureName = invalidCultureName;
43169            },
43170            $ctor3: function (message, invalidCultureId, innerException) {
43171                this.$initialize();
43172                System.ArgumentException.$ctor2.call(this, message, innerException);
43173                this._invalidCultureId = invalidCultureId;
43174            },
43175            $ctor4: function (paramName, invalidCultureId, message) {
43176                this.$initialize();
43177                System.ArgumentException.$ctor3.call(this, message, paramName);
43178                this._invalidCultureId = invalidCultureId;
43179            }
43180        }
43181    });
43182
43183    // @source DateTimeFormatInfoScanner.js
43184
43185    H5.define("System.Globalization.DateTimeFormatInfoScanner", {
43186        statics: {
43187            fields: {
43188                MonthPostfixChar: 0,
43189                IgnorableSymbolChar: 0,
43190                CJKYearSuff: null,
43191                CJKMonthSuff: null,
43192                CJKDaySuff: null,
43193                KoreanYearSuff: null,
43194                KoreanMonthSuff: null,
43195                KoreanDaySuff: null,
43196                KoreanHourSuff: null,
43197                KoreanMinuteSuff: null,
43198                KoreanSecondSuff: null,
43199                CJKHourSuff: null,
43200                ChineseHourSuff: null,
43201                CJKMinuteSuff: null,
43202                CJKSecondSuff: null,
43203                s_knownWords: null
43204            },
43205            props: {
43206                KnownWords: {
43207                    get: function () {
43208                        if (System.Globalization.DateTimeFormatInfoScanner.s_knownWords == null) {
43209                            var temp = new (System.Collections.Generic.Dictionary$2(System.String,System.String)).ctor();
43210
43211                            temp.add("/", "");
43212                            temp.add("-", "");
43213                            temp.add(".", "");
43214                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKYearSuff, "");
43215                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKMonthSuff, "");
43216                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKDaySuff, "");
43217                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanYearSuff, "");
43218                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanMonthSuff, "");
43219                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanDaySuff, "");
43220                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanHourSuff, "");
43221                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanMinuteSuff, "");
43222                            temp.add(System.Globalization.DateTimeFormatInfoScanner.KoreanSecondSuff, "");
43223                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKHourSuff, "");
43224                            temp.add(System.Globalization.DateTimeFormatInfoScanner.ChineseHourSuff, "");
43225                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKMinuteSuff, "");
43226                            temp.add(System.Globalization.DateTimeFormatInfoScanner.CJKSecondSuff, "");
43227
43228                            System.Globalization.DateTimeFormatInfoScanner.s_knownWords = temp;
43229                        }
43230                        return (System.Globalization.DateTimeFormatInfoScanner.s_knownWords);
43231                    }
43232                }
43233            },
43234            ctors: {
43235                init: function () {
43236                    this.MonthPostfixChar = 57344;
43237                    this.IgnorableSymbolChar = 57345;
43238                    this.CJKYearSuff = "\u5e74";
43239                    this.CJKMonthSuff = "\u6708";
43240                    this.CJKDaySuff = "\u65e5";
43241                    this.KoreanYearSuff = "\ub144";
43242                    this.KoreanMonthSuff = "\uc6d4";
43243                    this.KoreanDaySuff = "\uc77c";
43244                    this.KoreanHourSuff = "\uc2dc";
43245                    this.KoreanMinuteSuff = "\ubd84";
43246                    this.KoreanSecondSuff = "\ucd08";
43247                    this.CJKHourSuff = "\u6642";
43248                    this.ChineseHourSuff = "\u65f6";
43249                    this.CJKMinuteSuff = "\u5206";
43250                    this.CJKSecondSuff = "\u79d2";
43251                }
43252            },
43253            methods: {
43254                SkipWhiteSpacesAndNonLetter: function (pattern, currentIndex) {
43255                    while (currentIndex < pattern.length) {
43256                        var ch = pattern.charCodeAt(currentIndex);
43257                        if (ch === 92) {
43258                            currentIndex = (currentIndex + 1) | 0;
43259                            if (currentIndex < pattern.length) {
43260                                ch = pattern.charCodeAt(currentIndex);
43261                                if (ch === 39) {
43262                                    continue;
43263                                }
43264                            } else {
43265                                break;
43266                            }
43267                        }
43268                        if (System.Char.isLetter(ch) || ch === 39 || ch === 46) {
43269                            break;
43270                        }
43271                        currentIndex = (currentIndex + 1) | 0;
43272                    }
43273                    return (currentIndex);
43274                },
43275                ScanRepeatChar: function (pattern, ch, index, count) {
43276                    count.v = 1;
43277                    while (((index = (index + 1) | 0)) < pattern.length && pattern.charCo
43277deAt(index) === ch) {
43278                        count.v = (count.v + 1) | 0;
43279                    }
43280                    return (index);
43281                },
43282                GetFormatFlagGenitiveMonth: function (monthNames, genitveMonthNames, abbrevMonthNames, genetiveAbbrevMonthNames) {
43283                    return ((!System.Globalization.DateTimeFormatInfoScanner.EqualStringArrays(monthNames, genitveMonthNames) || !System.Globalization.DateTimeFormatInfoScanner.EqualStringArrays(abbrevMonthNames, genetiveAbbrevMonthNames)) ? 1 : 0);
43284                },
43285                GetFormatFlagUseSpaceInMonthNames: function (monthNames, genitveMonthNames, abbrevMonthNames, genetiveAbbrevMonthNames) {
43286                    var formatFlags = 0;
43287                    formatFlags |= (System.Globalization.DateTimeFormatInfoScanner.ArrayElementsBeginWithDigit(monthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsBeginWithDigit(genitveMonthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsBeginWithDigit(abbrevMonthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsBeginWithDigit(genetiveAbbrevMonthNames) ? 32 : 0);
43288
43289                    formatFlags |= (System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(monthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(genitveMonthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(abbrevMonthNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(genetiveAbbrevMonthNames) ? 4 : 0);
43290                    return (formatFlags);
43291                },
43292                GetFormatFlagUseSpaceInDayNames: function (dayNames, abbrevDayNames) {
43293                    return ((System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(dayNames) || System.Globalization.DateTimeFormatInfoScanner.ArrayElementsHaveSpace(abbrevDayNames)) ? 16 : 0);
43294                },
43295                GetFormatFlagUseHebrewCalendar: function (calID) {
43296                    return (calID === 8 ? 10 : 0);
43297                },
43298                EqualStringArrays: function (array1, array2) {
43299                    if (H5.referenceEquals(array1, array2)) {
43300                        return true;
43301                    }
43302
43303                    if (array1.length !== array2.length) {
43304                        return false;
43305                    }
43306
43307                    for (var i = 0; i < array1.length; i = (i + 1) | 0) {
43308                        if (!System.String.equals(array1[System.Array.index(i, array1)], array2[System.Array.index(i, array2)])) {
43309                            return false;
43310                        }
43311                    }
43312
43313                    return true;
43314                },
43315                ArrayElementsHaveSpace: function (array) {
43316                    for (var i = 0; i < array.length; i = (i + 1) | 0) {
43317                        for (var j = 0; j < array[System.Array.index(i, array)].length; j = (j + 1) | 0) {
43318                            if (System.Char.isWhiteSpace(String.fromCharCode(array[System.Array.index(i, array)].charCodeAt(j)))) {
43319                                return true;
43320                            }
43321                        }
43322                    }
43323
43324                    return false;
43325                },
43326                ArrayElementsBeginWithDigit: function (array) {
43327                    for (var i = 0; i < array.length; i = (i + 1) | 0) {
43328                        if (array[System.Array.index(i, array)].length > 0 && array[System.Array.index(i, array)].charCodeAt(0) >= 48 && array[System.Array.index(i, array)].charCodeAt(0) <= 57) {
43329                            var index = 1;
43330                            while (index < array[System.Array.index(i, array)].length && array[System.Array.index(i, array)].charCodeAt(index) >= 48 && array[System.Array.index(i, array)].charCodeAt(index) <= 57) {
43331                                index = (index + 1) | 0;
43332                            }
43333                            if (index === array[System.Array.index(i, array)].length) {
43334                                return (false);
43335                            }
43336
43337                            if (index === ((array[System.Array.index(i, array)].length - 1) | 0)) {
43338                                switch (array[System.Array.index(i, array)].charCo
43338deAt(index)) {
43339                                    case 26376: 
43340                                    case 50900: 
43341                                        return (false);
43342                                }
43343                            }
43344
43345                            if (index === ((array[System.Array.index(i, array)].length - 4) | 0)) {
43346                                if (array[System.Array.index(i, array)].charCodeAt(index) === 39 && array[System.Array.index(i, array)].charCodeAt(((index + 1) | 0)) === 32 && array[System.Array.index(i, array)].charCodeAt(((index + 2) | 0)) === 26376 && array[System.Array.index(i, array)].charCodeAt(((index + 3) | 0)) === 39) {
43347                                    return (false);
43348                                }
43349                            }
43350                            return (true);
43351                        }
43352                    }
43353
43354                    return false;
43355                }
43356            }
43357        },
43358        fields: {
43359            m_dateWords: null,
43360            _ymdFlags: 0
43361        },
43362        ctors: {
43363            init: function () {
43364                this.m_dateWords = new (System.Collections.Generic.List$1(System.String)).ctor();
43365                this._ymdFlags = System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.None;
43366            }
43367        },
43368        methods: {
43369            AddDateWordOrPostfix: function (formatPostfix, str) {
43370                if (str.length > 0) {
43371                    if (System.String.equals(str, ".")) {
43372                        this.AddIgnorableSymbols(".");
43373                        return;
43374                    }
43375                    var words = { };
43376                    if (System.Globalization.DateTimeFormatInfoScanner.KnownWords.tryGetValue(str, words) === false) {
43377                        if (this.m_dateWords == null) {
43378                            this.m_dateWords = new (System.Collections.Generic.List$1(System.String)).ctor();
43379                        }
43380                        if (H5.referenceEquals(formatPostfix, "MMMM")) {
43381                            var temp = String.fromCharCode(System.Globalization.DateTimeFormatInfoScanner.MonthPostfixChar) + (str || "");
43382                            if (!this.m_dateWords.contains(temp)) {
43383                                this.m_dateWords.add(temp);
43384                            }
43385                        } else {
43386                            if (!this.m_dateWords.contains(str)) {
43387                                this.m_dateWords.add(str);
43388                            }
43389                            if (str.charCodeAt(((str.length - 1) | 0)) === 46) {
43390                                var strWithoutDot = str.substr(0, ((str.length - 1) | 0));
43391                                if (!this.m_dateWords.contains(strWithoutDot)) {
43392                                    this.m_dateWords.add(strWithoutDot);
43393                                }
43394                            }
43395                        }
43396                    }
43397                }
43398            },
43399            AddDateWords: function (pattern, index, formatPostfix) {
43400                var newIndex = System.Globalization.DateTimeFormatInfoScanner.SkipWhiteSpacesAndNonLetter(pattern, index);
43401                if (newIndex !== index && formatPostfix != null) {
43402                    formatPostfix = null;
43403                }
43404                index = newIndex;
43405
43406                var dateWord = new System.Text.StringBuilder();
43407
43408                while (index < pattern.length) {
43409                    var ch = pattern.charCodeAt(index);
43410                    if (ch === 39) {
43411                        this.AddDateWordOrPostfix(formatPostfix, dateWord.toString());
43412                        index = (index + 1) | 0;
43413                        break;
43414                    } else if (ch === 92) {
43415
43416                        index = (index + 1) | 0;
43417                        if (index < pattern.length) {
43418                            dateWord.append(String.fromCharCode(pattern.charCodeAt(index)));
43419                            index = (index + 1) | 0;
43420                        }
43421                    } else if (System.Char.isWhiteSpace(String.fromCharCode(ch))) {
43422                        this.AddDateWordOrPostfix(formatPostfix, dateWord.toString());
43423                        if (formatPostfix != null) {
43424                            formatPostfix = null;
43425                        }
43426                        dateWord.setLength(0);
43427                        index = (index + 1) | 0;
43428                    } else {
43429                        dateWord.append(String.fromCharCode(ch));
43430                        index = (index + 1) | 0;
43431                    }
43432                }
43433                return (index);
43434            },
43435            AddIgnorableSymbols: function (text) {
43436                if (this.m_dateWords == null) {
43437                    this.m_dateWords = new (System.Collections.Generic.List$1(System.String)).ctor();
43438                }
43439                var temp = String.fromCharCode(System.Globalization.DateTimeFormatInfoScanner.IgnorableSymbolChar) + (text || "");
43440                if (!this.m_dateWords.contains(temp)) {
43441                    this.m_dateWords.add(temp);
43442                }
43443            },
43444            ScanDateWord: function (pattern) {
43445                this._ymdFlags = System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.None;
43446
43447                var i = 0;
43448                while (i < pattern.length) {
43449                    var ch = pattern.charCodeAt(i);
43450                    var chCount = { };
43451
43452                    switch (ch) {
43453                        case 39: 
43454                            i = this.AddDateWords(pattern, ((i + 1) | 0), null);
43455                            break;
43456                        case 77: 
43457                            i = System.Globalization.DateTimeFormatInfoScanner.ScanRepeatChar(pattern, 77, i, chCount);
43458                            if (chCount.v >= 4) {
43459                                if (i < pattern.length && pattern.charCodeAt(i) === 39) {
43460                                    i = this.AddDateWords(pattern, ((i + 1) | 0), "MMMM");
43461                                }
43462                            }
43463                            this._ymdFlags |= System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.FoundMonthPatternFlag;
43464                            break;
43465                        case 121: 
43466                            i = System.Globalization.DateTimeFormatInfoScanner.ScanRepeatChar(pattern, 121, i, chCount);
43467                            this._ymdFlags |= System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.FoundYearPatternFlag;
43468                            break;
43469                        case 100: 
43470                            i = System.Globalization.DateTimeFormatInfoScanner.ScanRepeatChar(pattern, 100, i, chCount);
43471                            if (chCount.v <= 2) {
43472                                this._ymdFlags |= System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.FoundDayPatternFlag;
43473                            }
43474                            break;
43475                        case 92: 
43476                            i = (i + 2) | 0;
43477                            break;
43478                        case 46: 
43479                            if (this._ymdFlags === System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.FoundYMDPatternFlag) {
43480                                this.AddIgnorableSymbols(".");
43481                                this._ymdFlags = System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.None;
43482                            }
43483                            i = (i + 1) | 0;
43484                            break;
43485                        default: 
43486                            if (this._ymdFlags === System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.FoundYMDPatternFlag && !System.Char.isWhiteSpace(String.fromCharCode(ch))) {
43487                                this._ymdFlags = System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern.None;
43488                            }
43489                            i = (i + 1) | 0;
43490                            break;
43491                    }
43492                }
43493            },
43494            GetDateWordsOfDTFI: function (dtfi) {
43495                var datePatterns = dtfi.getAllDateTimePatterns(68);
43496                var i;
43497
43498                for (i = 0; i < datePatterns.length; i = (i + 1) | 0) {
43499                    this.ScanDateWord(datePatterns[System.Array.index(i, datePatterns)]);
43500                }
43501
43502                datePatterns = dtfi.getAllDateTimePatterns(100);
43503                for (i = 0; i < datePatterns.length; i = (i + 1) | 0) {
43504                    this.ScanDateWord(datePatterns[System.Array.index(i, datePatterns)]);
43505                }
43506                datePatterns = dtfi.getAllDateTimePatterns(121);
43507                for (i = 0; i < datePatterns.length; i = (i + 1) | 0) {
43508                    this.ScanDateWord(datePatterns[System.Array.index(i, datePatterns)]);
43509                }
43510
43511                this.ScanDateWord(dtfi.monthDayPattern);
43512
43513                datePatterns = dtfi.getAllDateTimePatterns(84);
43514                for (i = 0; i < datePatterns.length; i = (i + 1) | 0) {
43515                    this.ScanDateWord(datePatterns[System.Array.index(i, datePatterns)]);
43516                }
43517
43518                datePatterns = dtfi.getAllDateTimePatterns(116);
43519                for (i = 0; i < datePatterns.length; i = (i + 1) | 0) {
43520                    this.ScanDateWord(datePatterns[System.Array.index(i, datePatterns)]);
43521                }
43522
43523                var result = null;
43524                if (this.m_dateWords != null && this.m_dateWords.Count > 0) {
43525                    result = System.Array.init(this.m_dateWords.Count, null, System.String);
43526                    for (i = 0; i < this.m_dateWords.Count; i = (i + 1) | 0) {
43527                        result[System.Array.index(i, result)] = this.m_dateWords.getItem(i);
43528                    }
43529                }
43530                return (result);
43531            }
43532        }
43533    });
43534
43535    // @source DateTimeStyles.js
43536
43537    H5.define("System.Globalization.DateTimeStyles", {
43538        $kind: "enum",
43539        statics: {
43540            fields: {
43541                None: 0,
43542                AllowLeadingWhite: 1,
43543                AllowTrailingWhite: 2,
43544                AllowInnerWhite: 4,
43545                AllowWhiteSpaces: 7,
43546                NoCurrentDateDefault: 8,
43547                AdjustToUniversal: 16,
43548                AssumeLocal: 32,
43549                AssumeUniversal: 64,
43550                RoundtripKind: 128
43551            }
43552        },
43553        $flags: true
43554    });
43555
43556    // @source FORMATFLAGS.js
43557
43558    H5.define("System.Globalization.FORMATFLAGS", {
43559        $kind: "enum",
43560        statics: {
43561            fields: {
43562                None: 0,
43563                UseGenitiveMonth: 1,
43564                UseLeapYearMonth: 2,
43565                UseSpacesInMonthNames: 4,
43566                UseHebrewParsing: 8,
43567                UseSpacesInDayNames: 16,
43568                UseDigitPrefixInTokens: 32
43569            }
43570        }
43571    });
43572
43573    // @source GlobalizationMode.js
43574
43575    H5.define("System.Globalization.GlobalizationMode", {
43576        statics: {
43577            props: {
43578                Invariant: false
43579            },
43580            ctors: {
43581                init: function () {
43582                    this.Invariant = System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode();
43583                }
43584            },
43585            methods: {
43586                GetInvariantSwitchValue: function () {
43587                    return true;
43588
43589
43590                },
43591                GetGlobalizationInvariantMode: function () {
43592                    return System.Globalization.GlobalizationMode.GetInvariantSwitchValue();
43593                }
43594            }
43595        }
43596    });
43597
43598    // @source FoundDatePattern.js
43599
43600    H5.define("System.Globalization.DateTimeFormatInfoScanner.FoundDatePattern", {
43601        $kind: "nested enum",
43602        statics: {
43603            fields: {
43604                None: 0,
43605                FoundYearPatternFlag: 1,
43606                FoundMonthPatternFlag: 2,
43607                FoundDayPatternFlag: 4,
43608                FoundYMDPatternFlag: 7
43609            }
43610        }
43611    });
43612
43613    // @source NotImplemented.js
43614
43615    H5.define("System.NotImplemented", {
43616        statics: {
43617            props: {
43618                ByDesign: {
43619                    get: function () {
43620                        return new System.NotImplementedException.ctor();
43621                    }
43622                }
43623            },
43624            methods: {
43625                ByDesignWithMessage: function (message) {
43626                    return new System.NotImplementedException.$ctor1(message);
43627                }
43628            }
43629        }
43630    });
43631
43632    // @source NotImplementedException.js
43633
43634    H5.define("System.NotImplementedException", {
43635        inherits: [System.SystemException],
43636        ctors: {
43637            ctor: function () {
43638                this.$initialize();
43639                System.SystemException.$ctor1.call(this, "The method or operation is not implemented.");
43640                this.HResult = -2147467263;
43641            },
43642            $ctor1: function (message) {
43643                this.$initialize();
43644                System.SystemException.$ctor1.call(this, message);
43645                this.HResult = -2147467263;
43646            },
43647            $ctor2: function (message, inner) {
43648                this.$initialize();
43649                System.SystemException.$ctor2.call(this, message, inner);
43650                this.HResult = -2147467263;
43651            }
43652        }
43653    });
43654
43655    // @source NotSupportedException.js
43656
43657    H5.define("System.NotSupportedException", {
43658        inherits: [System.SystemException],
43659        ctors: {
43660            ctor: function () {
43661                this.$initialize();
43662                System.SystemException.$ctor1.call(this, "Specified method is not supported.");
43663                this.HResult = -2146233067;
43664            },
43665            $ctor1: function (message) {
43666                this.$initialize();
43667                System.SystemException.$ctor1.call(this, message);
43668                this.HResult = -2146233067;
43669            },
43670            $ctor2: function (message, innerException) {
43671                this.$initialize();
43672                System.SystemException.$ctor2.call(this, message, innerException);
43673                this.HResult = -2146233067;
43674            }
43675        }
43676    });
43677
43678    // @source NullReferenceException.js
43679
43680    H5.define("System.NullReferenceException", {
43681        inherits: [System.SystemException],
43682        ctors: {
43683            ctor: function () {
43684                this.$initialize();
43685                System.SystemException.$ctor1.call(this, "Object reference not set to an instance of an object.");
43686                this.HResult = -2147467261;
43687            },
43688            $ctor1: function (message) {
43689                this.$initialize();
43690                System.SystemException.$ctor1.call(this, message);
43691                this.HResult = -2147467261;
43692            },
43693            $ctor2: function (message, innerException) {
43694                this.$initialize();
43695                System.SystemException.$ctor2.call(this, message, innerException);
43696                this.HResult = -2147467261;
43697            }
43698        }
43699    });
43700
43701    // @source OperationCanceledException.js
43702
43703    H5.define("System.OperationCanceledException", {
43704        inherits: [System.SystemException],
43705        fields: {
43706            _cancellationToken: null
43707        },
43708        props: {
43709            CancellationToken: {
43710                get: function () {
43711                    return this._cancellationToken;
43712                },
43713                set: function (value) {
43714                    this._cancellationToken = value;
43715                }
43716            }
43717        },
43718        ctors: {
43719            init: function () {
43720                this._cancellationToken = new System.Threading.CancellationToken();
43721            },
43722            ctor: function () {
43723                this.$initialize();
43724                System.SystemException.$ctor1.call(this, "The operation was canceled.");
43725                this.HResult = -2146233029;
43726            },
43727            $ctor1: function (message) {
43728                this.$initialize();
43729                System.SystemException.$ctor1.call(this, message);
43730                this.HResult = -2146233029;
43731            },
43732            $ctor2: function (message, innerException) {
43733                this.$initialize();
43734                System.SystemException.$ctor2.call(this, message, innerException);
43735                this.HResult = -2146233029;
43736            },
43737            $ctor5: function (token) {
43738                System.OperationCanceledException.ctor.call(this);
43739                this.CancellationToken = token;
43740            },
43741            $ctor4: function (message, token) {
43742                System.OperationCanceledException.$ctor1.call(this, message);
43743                this.CancellationToken = token;
43744            },
43745            $ctor3: function (message, innerException, token) {
43746                System.OperationCanceledException.$ctor2.call(this, message, innerException);
43747                this.CancellationToken = token;
43748            }
43749        }
43750    });
43751
43752    // @source OverflowException.js
43753
43754    H5.define("System.OverflowException", {
43755        inherits: [System.ArithmeticException],
43756        ctors: {
43757            ctor: function () {
43758                this.$initialize();
43759                System.ArithmeticException.$ctor1.call(this, "Arithmetic operation resulted in an overflow.");
43760                this.HResult = -2146233066;
43761            },
43762            $ctor1: function (message) {
43763                this.$initialize();
43764                System.ArithmeticException.$ctor1.call(this, message);
43765                this.HResult = -2146233066;
43766            },
43767            $ctor2: function (message, innerException) {
43768                this.$initialize();
43769                System.ArithmeticException.$ctor2.call(this, message, innerException);
43770                this.HResult = -2146233066;
43771            }
43772        }
43773    });
43774
43775    // @source ParseFailureKind.js
43776
43777    H5.define("System.ParseFailureKind", {
43778        $kind: "enum",
43779        statics: {
43780            fields: {
43781                None: 0,
43782                ArgumentNull: 1,
43783                Format: 2,
43784                FormatWithParameter: 3,
43785                FormatBadDateTimeCalendar: 4
43786            }
43787        }
43788    });
43789
43790    // @source ParseFlags.js
43791
43792    H5.define("System.ParseFlags", {
43793        $kind: "enum",
43794        statics: {
43795            fields: {
43796                HaveYear: 1,
43797                HaveMonth: 2,
43798                HaveDay: 4,
43799                HaveHour: 8,
43800                HaveMinute: 16,
43801                HaveSecond: 32,
43802                HaveTime: 64,
43803                HaveDate: 128,
43804                TimeZoneUsed: 256,
43805                TimeZoneUtc: 512,
43806                ParsedMonthName: 1024,
43807                CaptureOffset: 2048,
43808                YearDefault: 4096,
43809                Rfc1123Pattern: 8192,
43810                UtcSortPattern: 16384
43811            }
43812        },
43813        $flags: true
43814    });
43815
43816    // @source StringBuilderCache.js
43817
43818    H5.define("System.Text.StringBuilderCache", {
43819        statics: {
43820            fields: {
43821                MAX_BUILDER_SIZE: 0,
43822                DEFAULT_CAPACITY: 0,
43823                t_cachedInstance: null
43824            },
43825            ctors: {
43826                init: function () {
43827                    this.MAX_BUILDER_SIZE = 260;
43828                    this.DEFAULT_CAPACITY = 16;
43829                }
43830            },
43831            methods: {
43832                Acquire: function (capacity) {
43833                    if (capacity === void 0) { capacity = 16; }
43834                    if (capacity <= System.Text.StringBuilderCache.MAX_BUILDER_SIZE) {
43835                        var sb = System.Text.StringBuilderCache.t_cachedInstance;
43836                        if (sb != null) {
43837                            if (capacity <= sb.getCapacity()) {
43838                                System.Text.StringBuilderCache.t_cachedInstance = null;
43839                                sb.clear();
43840                                return sb;
43841                            }
43842                        }
43843                    }
43844                    return new System.Text.StringBuilder("", capacity);
43845                },
43846                Release: function (sb) {
43847                    if (sb.getCapacity() <= System.Text.StringBuilderCache.MAX_BUILDER_SIZE) {
43848                        System.Text.StringBuilderCache.t_cachedInstance = sb;
43849                    }
43850                },
43851                GetStringAndRelease: function (sb) {
43852                    var result = sb.toString();
43853                    System.Text.StringBuilderCache.Release(sb);
43854                    return result;
43855                }
43856            }
43857        }
43858    });
43859
43860    // @source BinaryReader.js
43861
43862    H5.define("System.IO.BinaryReader", {
43863        inherits: [System.IDisposable],
43864        statics: {
43865            fields: {
43866                MaxCharBytesSize: 0
43867            },
43868            ctors: {
43869                init: function () {
43870                    this.MaxCharBytesSize = 128;
43871                }
43872            }
43873        },
43874        fields: {
43875            m_stream: null,
43876            m_buffer: null,
43877            m_encoding: null,
43878            m_charBytes: null,
43879            m_singleChar: null,
43880            m_charBuffer: null,
43881            m_maxCharsSize: 0,
43882            m_2BytesPerChar: false,
43883            m_isMemoryStream: false,
43884            m_leaveOpen: false,
43885            lastCharsRead: 0
43886        },
43887        props: {
43888            BaseStream: {
43889                get: function () {
43890                    return this.m_stream;
43891                }
43892            }
43893        },
43894        alias: ["Dispose", "System$IDisposable$Dispose"],
43895        ctors: {
43896            init: function () {
43897                this.lastCharsRead = 0;
43898            },
43899            ctor: function (input) {
43900                System.IO.BinaryReader.$ctor2.call(this, input, new System.Text.UTF8Encoding.ctor(), false);
43901            },
43902            $ctor1: function (input, encoding) {
43903                System.IO.BinaryReader.$ctor2.call(this, input, encoding, false);
43904            },
43905            $ctor2: function (input, encoding, leaveOpen) {
43906                this.$initialize();
43907                if (input == null) {
43908                    throw new System.ArgumentNullException.$ctor1("input");
43909                }
43910                if (encoding == null) {
43911                    throw new System.ArgumentNullException.$ctor1("encoding");
43912                }
43913                if (!input.CanRead) {
43914                    throw new System.ArgumentException.$ctor1("Argument_StreamNotReadable");
43915                }
43916                this.m_stream = input;
43917                this.m_encoding = encoding;
43918                this.m_maxCharsSize = encoding.GetMaxCharCount(System.IO.BinaryReader.MaxCharBytesSize);
43919                var minBufferSize = encoding.GetMaxByteCount(1);
43920                if (minBufferSize < 23) {
43921                    minBufferSize = 23;
43922                }
43923                this.m_buffer = System.Array.init(minBufferSize, 0, System.Byte);
43924
43925                this.m_2BytesPerChar = H5.is(encoding, System.Text.UnicodeEncoding);
43926                this.m_isMemoryStream = (H5.referenceEquals(H5.getType(this.m_stream), System.IO.MemoryStream));
43927                this.m_leaveOpen = leaveOpen;
43928
43929            }
43930        },
43931        methods: {
43932            Close: function () {
43933                this.Dispose$1(true);
43934            },
43935            Dispose$1: function (disposing) {
43936                if (disposing) {
43937                    var copyOfStream = this.m_stream;
43938                    this.m_stream = null;
43939                    if (copyOfStream != null && !this.m_leaveOpen) {
43940                        copyOfStream.Close();
43941                    }
43942                }
43943                this.m_stream = null;
43944                this.m_buffer = null;
43945                this.m_encoding = null;
43946                this.m_charBytes = null;
43947                this.m_singleChar = null;
43948                this.m_charBuffer = null;
43949            },
43950            Dispose: function () {
43951                this.Dispose$1(true);
43952            },
43953            PeekChar: function () {
43954
43955                if (this.m_stream == null) {
43956                    System.IO.__Error.FileNotOpen();
43957                }
43958
43959                if (!this.m_stream.CanSeek) {
43960                    return -1;
43961                }
43962                var origPos = this.m_stream.Position;
43963                var ch = this.Read();
43964                this.m_stream.Position = origPos;
43965                return ch;
43966            },
43967            Read: function () {
43968
43969                if (this.m_stream == null) {
43970                    System.IO.__Error.FileNotOpen();
43971                }
43972                return this.InternalReadOneChar();
43973            },
43974            Read$2: function (buffer, index, count) {
43975                if (buffer == null) {
43976                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
43977                }
43978                if (index < 0) {
43979                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "ArgumentOutOfRange_NeedNonNegNum");
43980                }
43981                if (count < 0) {
43982                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
43983                }
43984                if (((buffer.length - index) | 0) < count) {
43985                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
43986                }
43987
43988                if (this.m_stream == null) {
43989                    System.IO.__Error.FileNotOpen();
43990                }
43991
43992                return this.InternalReadChars(buffer, index, count);
43993            },
43994            Read$1: function (buffer, index, count) {
43995                if (buffer == null) {
43996                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
43997                }
43998                if (index < 0) {
43999                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "ArgumentOutOfRange_NeedNonNegNum");
44000                }
44001                if (count < 0) {
44002                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
44003                }
44004                if (((buffer.length - index) | 0) < count) {
44005                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
44006                }
44007
44008                if (this.m_stream == null) {
44009                    System.IO.__Error.FileNotOpen();
44010                }
44011                return this.m_stream.Read(buffer, index, count);
44012            },
44013            ReadBoolean: function () {
44014                this.FillBuffer(1);
44015                return (this.m_buffer[System.Array.index(0, this.m_buffer)] !== 0);
44016            },
44017            ReadByte: function () {
44018                if (this.m_stream == null) {
44019                    System.IO.__Error.FileNotOpen();
44020                }
44021
44022                var b = this.m_stream.ReadByte();
44023                if (b === -1) {
44024                    System.IO.__Error.EndOfFile();
44025                }
44026                return (b & 255);
44027            },
44028            ReadSByte: function () {
44029                this.FillBuffer(1);
44030                return H5.Int.sxb((this.m_buffer[System.Array.index(0, this.m_buffer)]) & 255);
44031            },
44032            ReadChar: function () {
44033                var value = this.Read();
44034                if (value === -1) {
44035                    System.IO.__Error.EndOfFile();
44036                }
44037                return (value & 65535);
44038            },
44039            ReadInt16: function () {
44040                this.FillBuffer(2);
44041                return H5.Int.sxs((this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8) & 65535);
44042            },
44043            ReadUInt16: function () {
44044                this.FillBuffer(2);
44045                return ((this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8) & 65535);
44046            },
44047            ReadInt32: function () {
44048                if (this.m_isMemoryStream) {
44049                    if (this.m_stream == null) {
44050                        System.IO.__Error.FileNotOpen();
44051                    }
44052                    var mStream = H5.as(this.m_stream, System.IO.MemoryStream);
44053
44054                    return mStream.InternalReadInt32();
44055                } else {
44056                    this.FillBuffer(4);
44057                    return this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24;
44058                }
44059            },
44060            ReadUInt32: function () {
44061                this.FillBuffer(4);
44062                return ((this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24) >>> 0);
44063            },
44064            ReadInt64: function () {
44065                this.FillBuffer(8);
44066                var lo = (this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24) >>> 0;
44067                var hi = (this.m_buffer[System.Array.index(4, this.m_buffer)] | this.m_buffer[System.Array.index(5, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(6, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(7, this.m_buffer)] << 24) >>> 0;
44068                return System.Int64.clip64(System.UInt64(hi)).shl(32).or(System.Int64(lo));
44069            },
44070            ReadUInt64: function () {
44071                this.FillBuffer(8);
44072                var lo = (this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24) >>> 0;
44073                var hi = (this.m_buffer[System.Array.index(4, this.m_buffer)] | this.m_buffer[System.Array.index(5, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(6, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(7, this.m_buffer)] << 24) >>> 0;
44074                return System.UInt64(hi).shl(32).or(System.UInt64(lo));
44075            },
44076            ReadSingle: function () {
44077                this.FillBuffer(4);
44078                var tmpBuffer = (this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24) >>> 0;
44079                return System.BitConverter.toSingle(System.BitConverter.getBytes$8(tmpBuffer), 0);
44080            },
44081            ReadDouble: function () {
44082                this.FillBuffer(8);
44083                var lo = (this.m_buffer[System.Array.index(0, this.m_buffer)] | this.m_buffer[System.Array.index(1, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(2, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(3, this.m_buffer)] << 24) >>> 0;
44084                var hi = (this.m_buffer[System.Array.index(4, this.m_buffer)] | this.m_buffer[System.Array.index(5, this.m_buffer)] << 8 | this.m_buffer[System.Array.index(6, this.m_buffer)] << 16 | this.m_buffer[System.Array.index(7, this.m_buffer)] << 24) >>> 0;
44085
44086                var tmpBuffer = System.UInt64(hi).shl(32).or(System.UInt64(lo));
44087                return System.BitConverter.toDouble(System.BitConverter.getBytes$9(tmpBuffer), 0);
44088            },
44089            ReadDecimal: function () {
44090                this.FillBuffer(23);
44091                try {
44092                    return System.Decimal.fromBytes(this.m_buffer);
44093                } catch ($e1) {
44094                    $e1 = System.Exception.create($e1);
44095                    var e;
44096                    if (H5.is($e1, System.ArgumentException)) {
44097                        e = $e1;
44098                        throw new System.IO.IOException.$ctor2("Arg_DecBitCtor", e);
44099                    } else {
44100                        throw $e1;
44101                    }
44102                }
44103            },
44104            ReadString: function () {
44105
44106                if (this.m_stream == null) {
44107                    System.IO.__Error.FileNotOpen();
44108                }
44109
44110                var currPos = 0;
44111                var n;
44112                var stringLength;
44113                var readLength;
44114                var charsRead;
44115
44116                stringLength = this.Read7BitEncodedInt();
44117                if (stringLength < 0) {
44118                    throw new System.IO.IOException.$ctor1("IO.IO_InvalidStringLen_Len");
44119                }
44120
44121                if (stringLength === 0) {
44122                    return "";
44123                }
44124
44125                if (this.m_charBytes == null) {
44126                    this.m_charBytes = System.Array.init(System.IO.BinaryReader.MaxCharBytesSize, 0, System.Byte);
44127                }
44128
44129                if (this.m_charBuffer == null) {
44130                    this.m_charBuffer = System.Array.init(this.m_maxCharsSize, 0, System.Char);
44131                }
44132
44133                var sb = null;
44134                do {
44135                    readLength = ((((stringLength - currPos) | 0)) > System.IO.BinaryReader.MaxCharBytesSize) ? System.IO.BinaryReader.MaxCharBytesSize : (((stringLength - currPos) | 0));
44136
44137                    n = this.m_stream.Read(this.m_charBytes, 0, readLength);
44138                    if (n === 0) {
44139                        System.IO.__Error.EndOfFile();
44140                    }
44141
44142                    charsRead = this.m_encoding.GetChars$2(this.m_charBytes, 0, n, this.m_charBuffer, 0);
44143
44144                    if (currPos === 0 && n === stringLength) {
44145                        return System.String.fromCharArray(this.m_charBuffer, 0, charsRead);
44146                    }
44147
44148                    if (sb == null) {
44149                        sb = new System.Text.StringBuilder("", stringLength);
44150                    }
44151
44152                    for (var i = 0; i < charsRead; i = (i + 1) | 0) {
44153                        sb.append(String.fromCharCode(this.m_charBuffer[System.Array.index(i, this.m_charBuffer)]));
44154                    }
44155
44156                    currPos = (currPos + n) | 0;
44157
44158                } while (currPos < stringLength);
44159
44160                return sb.toString();
44161            },
44162            InternalReadChars: function (buffer, index, count) {
44163
44164                var charsRemaining = count;
44165
44166                if (this.m_charBytes == null) {
44167                    this.m_charBytes = System.Array.init(System.IO.BinaryReader.MaxCharBytesSize, 0, System.Byte);
44168                }
44169
44170                if (index < 0 || charsRemaining < 0 || ((index + charsRemaining) | 0) > buffer.length) {
44171                    throw new System.ArgumentOutOfRangeException.$ctor1("charsRemaining");
44172                }
44173
44174                while (charsRemaining > 0) {
44175
44176                    var ch = this.InternalReadOneChar(true);
44177
44178                    if (ch === -1) {
44179                        break;
44180                    }
44181
44182                    buffer[System.Array.index(index, buffer)] = ch & 65535;
44183
44184                    if (this.lastCharsRead === 2) {
44185                        buffer[System.Array.index(((index = (index + 1) | 0)), buffer)] = this.m_singleChar[System.Array.index(1, this.m_singleChar)];
44186                        charsRemaining = (charsRemaining - 1) | 0;
44187                    }
44188
44189                    charsRemaining = (charsRemaining - 1) | 0;
44190                    index = (index + 1) | 0;
44191                }
44192
44193
44194                return (((count - charsRemaining) | 0));
44195            },
44196            InternalReadOneChar: function (allowSurrogate) {
44197                if (allowSurrogate === void 0) { allowSurrogate = false; }
44198                var charsRead = 0;
44199                var numBytes = 0;
44200                var posSav = System.Int64(0);
44201
44202                if (this.m_stream.CanSeek) {
44203                    posSav = this.m_stream.Position;
44204                }
44205
44206                if (this.m_charBytes == null) {
44207                    this.m_charBytes = System.Array.init(System.IO.BinaryReader.MaxCharBytesSize, 0, System.Byte);
44208                }
44209                if (this.m_singleChar == null) {
44210                    this.m_singleChar = System.Array.init(2, 0, System.Char);
44211                }
44212
44213                var addByte = false;
44214                var internalPos = 0;
44215                while (charsRead === 0) {
44216                    numBytes = this.m_2BytesPerChar ? 2 : 1;
44217
44218                    if (H5.is(this.m_encoding, System.Text.UTF32Encoding)) {
44219                        numBytes = 4;
44220                    }
44221
44222                    if (addByte) {
44223                        var r = this.m_stream.ReadByte();
44224                        this.m_charBytes[System.Array.index(((internalPos = (internalPos + 1) | 0)), this.m_charBytes)] = r & 255;
44225                        if (r === -1) {
44226                            numBytes = 0;
44227                        }
44228
44229                        if (numBytes === 2) {
44230                            r = this.m_stream.ReadByte();
44231                            this.m_charBytes[System.Array.index(((internalPos = (internalPos + 1) | 0)), this.m_charBytes)] = r & 255;
44232                            if (r === -1) {
44233                                numBytes = 1;
44234                            }
44235                        }
44236                    } else {
44237                        var r1 = this.m_stream.ReadByte();
44238                        this.m_charBytes[System.Array.index(0, this.m_charBytes)] = r1 & 255;
44239                        internalPos = 0;
44240                        if (r1 === -1) {
44241                            numBytes = 0;
44242                        }
44243
44244                        if (numBytes === 2) {
44245                            r1 = this.m_stream.ReadByte();
44246                            this.m_charBytes[System.Array.index(1, this.m_charBytes)] = r1 & 255;
44247                            if (r1 === -1) {
44248                                numBytes = 1;
44249                            }
44250                            internalPos = 1;
44251                        } else if (numBytes === 4) {
44252                            r1 = this.m_stream.ReadByte();
44253                            this.m_charBytes[System.Array.index(1, this.m_charBytes)] = r1 & 255;
44254                            if (r1 === -1) {
44255                                return -1;
44256                            }
44257
44258                            r1 = this.m_stream.ReadByte();
44259                            this.m_charBytes[System.Array.index(2, this.m_charBytes)] = r1 & 255;
44260                            if (r1 === -1) {
44261                                return -1;
44262                            }
44263
44264                            r1 = this.m_stream.ReadByte();
44265                            this.m_charBytes[System.Array.index(3, this.m_charBytes)] = r1 & 255;
44266                            if (r1 === -1) {
44267                                return -1;
44268                            }
44269
44270                            internalPos = 3;
44271                        }
44272                    }
44273
44274
44275                    if (numBytes === 0) {
44276                        return -1;
44277                    }
44278
44279                    addByte = false;
44280                    try {
44281                        charsRead = this.m_encoding.GetChars$2(this.m_charBytes, 0, ((internalPos + 1) | 0), this.m_singleChar, 0);
44282
44283                        if (!allowSurrogate && charsRead === 2) {
44284                            throw new System.ArgumentException.ctor();
44285                        }
44286                    } catch ($e1) {
44287                        $e1 = System.Exception.create($e1);
44288
44289                        if (this.m_stream.CanSeek) {
44290                            this.m_stream.Seek((posSav.sub(this.m_stream.Position)), 1);
44291                        }
44292
44293                        throw $e1;
44294                    }
44295
44296                    if (this.m_encoding._hasError) {
44297                        charsRead = 0;
44298                        addByte = true;
44299                    }
44300
44301                    if (!allowSurrogate) {
44302                    }
44303                }
44304
44305                this.lastCharsRead = charsRead;
44306
44307                if (charsRead === 0) {
44308                    return -1;
44309                }
44310
44311                return this.m_singleChar[System.Array.index(0, this.m_singleChar)];
44312            },
44313            ReadChars: function (count) {
44314                if (count < 0) {
44315                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
44316                }
44317                if (this.m_stream == null) {
44318                    System.IO.__Error.FileNotOpen();
44319                }
44320
44321                if (count === 0) {
44322                    return System.Array.init(0, 0, System.Char);
44323                }
44324
44325                var chars = System.Array.init(count, 0, System.Char);
44326                var n = this.InternalReadChars(chars, 0, count);
44327                if (n !== count) {
44328                    var copy = System.Array.init(n, 0, System.Char);
44329                    System.Array.copy(chars, 0, copy, 0, H5.Int.mul(2, n));
44330                    chars = copy;
44331                }
44332
44333                return chars;
44334            },
44335            ReadBytes: function (count) {
44336                if (count < 0) {
44337                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
44338                }
44339                if (this.m_stream == null) {
44340                    System.IO.__Error.FileNotOpen();
44341                }
44342
44343                if (count === 0) {
44344                    return System.Array.init(0, 0, System.Byte);
44345                }
44346
44347                var result = System.Array.init(count, 0, System.Byte);
44348
44349                var numRead = 0;
44350                do {
44351                    var n = this.m_stream.Read(result, numRead, count);
44352                    if (n === 0) {
44353                        break;
44354                    }
44355                    numRead = (numRead + n) | 0;
44356                    count = (count - n) | 0;
44357                } while (count > 0);
44358
44359                if (numRead !== result.length) {
44360                    var copy = System.Array.init(numRead, 0, System.Byte);
44361                    System.Array.copy(result, 0, copy, 0, numRead);
44362                    result = copy;
44363                }
44364
44365                return result;
44366            },
44367            FillBuffer: function (numBytes) {
44368                if (this.m_buffer != null && (numBytes < 0 || numBytes > this.m_buffer.length)) {
44369                    throw new System.ArgumentOutOfRangeException.$ctor4("numBytes", "ArgumentOutOfRange_BinaryReaderFillBuffer");
44370                }
44371                var bytesRead = 0;
44372                var n = 0;
44373
44374                if (this.m_stream == null) {
44375                    System.IO.__Error.FileNotOpen();
44376                }
44377
44378                if (numBytes === 1) {
44379                    n = this.m_stream.ReadByte();
44380                    if (n === -1) {
44381                        System.IO.__Error.EndOfFile();
44382                    }
44383                    this.m_buffer[System.Array.index(0, this.m_buffer)] = n & 255;
44384                    return;
44385                }
44386
44387                do {
44388                    n = this.m_stream.Read(this.m_buffer, bytesRead, ((numBytes - bytesRead) | 0));
44389                    if (n === 0) {
44390                        System.IO.__Error.EndOfFile();
44391                    }
44392                    bytesRead = (bytesRead + n) | 0;
44393                } while (bytesRead < numBytes);
44394            },
44395            Read7BitEncodedInt: function () {
44396                var count = 0;
44397                var shift = 0;
44398                var b;
44399                do {
44400                    if (shift === 35) {
44401                        throw new System.FormatException.$ctor1("Format_Bad7BitInt32");
44402                    }
44403
44404                    b = this.ReadByte();
44405                    count = count | ((b & 127) << shift);
44406                    shift = (shift + 7) | 0;
44407                } while ((b & 128) !== 0);
44408                return count;
44409            }
44410        }
44411    });
44412
44413    // @source BinaryWriter.js
44414
44415    H5.define("System.IO.BinaryWriter", {
44416        inherits: [System.IDisposable],
44417        statics: {
44418            fields: {
44419                LargeByteBufferSize: 0,
44420                Null: null
44421            },
44422            ctors: {
44423                init: function () {
44424                    this.LargeByteBufferSize = 256;
44425                    this.Null = new System.IO.BinaryWriter.ctor();
44426                }
44427            }
44428        },
44429        fields: {
44430            OutStream: null,
44431            _buffer: null,
44432            _encoding: null,
44433            _leaveOpen: false,
44434            _tmpOneCharBuffer: null
44435        },
44436        props: {
44437            BaseStream: {
44438                get: function () {
44439                    this.Flush();
44440                    return this.OutStream;
44441                }
44442            }
44443        },
44444        alias: ["Dispose", "System$IDisposable$Dispose"],
44445        ctors: {
44446            ctor: function () {
44447                this.$initialize();
44448                this.OutStream = System.IO.Stream.Null;
44449                this._buffer = System.Array.init(16, 0, System.Byte);
44450                this._encoding = new System.Text.UTF8Encoding.$ctor2(false, true);
44451            },
44452            $ctor1: function (output) {
44453                System.IO.BinaryWriter.$ctor3.call(this, output, new System.Text.UTF8Encoding.$ctor2(false, true), false);
44454            },
44455            $ctor2: function (output, encoding) {
44456                System.IO.BinaryWriter.$ctor3.call(this, output, encoding, false);
44457            },
44458            $ctor3: function (output, encoding, leaveOpen) {
44459                this.$initialize();
44460                if (output == null) {
44461                    throw new System.ArgumentNullException.$ctor1("output");
44462                }
44463                if (encoding == null) {
44464                    throw new System.ArgumentNullException.$ctor1("encoding");
44465                }
44466                if (!output.CanWrite) {
44467                    throw new System.ArgumentException.$ctor1("Argument_StreamNotWritable");
44468                }
44469
44470                this.OutStream = output;
44471                this._buffer = System.Array.init(16, 0, System.Byte);
44472                this._encoding = encoding;
44473                this._leaveOpen = leaveOpen;
44474            }
44475        },
44476        methods: {
44477            Close: function () {
44478                this.Dispose$1(true);
44479            },
44480            Dispose$1: function (disposing) {
44481                if (disposing) {
44482                    if (this._leaveOpen) {
44483                        this.OutStream.Flush();
44484                    } else {
44485                        this.OutStream.Close();
44486                    }
44487                }
44488            },
44489            Dispose: function () {
44490                this.Dispose$1(true);
44491            },
44492            Flush: function () {
44493                this.OutStream.Flush();
44494            },
44495            Seek: function (offset, origin) {
44496                return this.OutStream.Seek(System.Int64(offset), origin);
44497            },
44498            Write: function (value) {
44499                this._buffer[System.Array.index(0, this._buffer)] = (value ? 1 : 0) & 255;
44500                this.OutStream.Write(this._buffer, 0, 1);
44501            },
44502            Write$1: function (value) {
44503                this.OutStream.WriteByte(value);
44504            },
44505            Write$12: function (value) {
44506                this.OutStream.WriteByte((value & 255));
44507            },
44508            Write$2: function (buffer) {
44509                if (buffer == null) {
44510                    throw new System.ArgumentNullException.$ctor1("buffer");
44511                }
44512                this.OutStream.Write(buffer, 0, buffer.length);
44513            },
44514            Write$3: function (buffer, index, count) {
44515                this.OutStream.Write(buffer, index, count);
44516            },
44517            Write$4: function (ch) {
44518                if (System.Char.isSurrogate(ch)) {
44519                    throw new System.ArgumentException.$ctor1("Arg_SurrogatesNotAllowedAsSingleChar");
44520                }
44521
44522                var numBytes = 0;
44523                numBytes = this._encoding.GetBytes$3(System.Array.init([ch], System.Char), 0, 1, this._buffer, 0);
44524
44525                this.OutStream.Write(this._buffer, 0, numBytes);
44526            },
44527            Write$5: function (chars) {
44528                if (chars == null) {
44529                    throw new System.ArgumentNullException.$ctor1("chars");
44530                }
44531
44532                var bytes = this._encoding.GetBytes$1(chars, 0, chars.length);
44533                this.OutStream.Write(bytes, 0, bytes.length);
44534            },
44535            Write$6: function (chars, index, count) {
44536                var bytes = this._encoding.GetBytes$1(chars, index, count);
44537                this.OutStream.Write(bytes, 0, bytes.length);
44538            },
44539            Write$8: function (value) {
44540                var TmpValue = System.Int64.clipu64(System.BitConverter.doubleToInt64Bits(value));
44541                this._buffer[System.Array.index(0, this._buffer)] = System.Int64.clipu8(TmpValue);
44542                this._buffer[System.Array.index(1, this._buffer)] = System.Int64.clipu8(TmpValue.shru(8));
44543                this._buffer[System.Array.index(2, this._buffer)] = System.Int64.clipu8(TmpValue.shru(16));
44544                this._buffer[System.Array.index(3, this._buffer)] = System.Int64.clipu8(TmpValue.shru(24));
44545                this._buffer[System.Array.index(4, this._buffer)] = System.Int64.clipu8(TmpValue.shru(32));
44546                this._buffer[System.Array.index(5, this._buffer)] = System.Int64.clipu8(TmpValue.shru(40));
44547                this._buffer[System.Array.index(6, this._buffer)] = System.Int64.clipu8(TmpValue.shru(48));
44548                this._buffer[System.Array.index(7, this._buffer)] = System.Int64.clipu8(TmpValue.shru(56));
44549                this.OutStream.Write(this._buffer, 0, 8);
44550            },
44551            Write$7: function (value) {
44552                var buf = value.getBytes();
44553                this.OutStream.Write(buf, 0, 23);
44554            },
44555            Write$9: function (value) {
44556                this._buffer[System.Array.index(0, this._buffer)] = value & 255;
44557                this._buffer[System.Array.index(1, this._buffer)] = (value >> 8) & 255;
44558                this.OutStream.Write(this._buffer, 0, 2);
44559            },
44560            Write$15: function (value) {
44561                this._buffer[System.Array.index(0, this._buffer)] = value & 255;
44562                this._buffer[System.Array.index(1, this._buffer)] = (value >> 8) & 255;
44563                this.OutStream.Write(this._buffer, 0, 2);
44564            },
44565            Write$10: function (value) {
44566                this._buffer[System.Array.index(0, this._buffer)] = value & 255;
44567                this._buffer[System.Array.index(1, this._buffer)] = (value >> 8) & 255;
44568                this._buffer[System.Array.index(2, this._buffer)] = (value >> 16) & 255;
44569                this._buffer[System.Array.index(3, this._buffer)] = (value >> 24) & 255;
44570                this.OutStream.Write(this._buffer, 0, 4);
44571            },
44572            Write$16: function (value) {
44573                this._buffer[System.Array.index(0, this._buffer)] = value & 255;
44574                this._buffer[System.Array.index(1, this._buffer)] = (value >>> 8) & 255;
44575                this._buffer[System.Array.index(2, this._buffer)] = (value >>> 16) & 255;
44576                this._buffer[System.Array.index(3, this._buffer)] = (value >>> 24) & 255;
44577                this.OutStream.Write(this._buffer, 0, 4);
44578            },
44579            Write$11: function (value) {
44580                this._buffer[System.Array.index(0, this._buffer)] = System.Int64.clipu8(value);
44581                this._buffer[System.Array.index(1, this._buffer)] = System.Int64.clipu8(value.shr(8));
44582                this._buffer[System.Array.index(2, this._buffer)] = System.Int64.clipu8(value.shr(16));
44583                this._buffer[System.Array.index(3, this._buffer)] = System.Int64.clipu8(value.shr(24));
44584                this._buffer[System.Array.index(4, this._buffer)] = System.Int64.clipu8(value.shr(32));
44585                this._buffer[System.Array.index(5, this._buffer)] = System.Int64.clipu8(value.shr(40));
44586                this._buffer[System.Array.index(6, this._buffer)] = System.Int64.clipu8(value.shr(48));
44587                this._buffer[System.Array.index(7, this._buffer)] = System.Int64.clipu8(value.shr(56));
44588                this.OutStream.Write(this._buffer, 0, 8);
44589            },
44590            Write$17: function (value) {
44591                this._buffer[System.Array.index(0, this._buffer)] = System.Int64.clipu8(value);
44592                this._buffer[System.Array.index(1, this._buffer)] = System.Int64.clipu8(value.shru(8));
44593                this._buffer[System.Array.index(2, this._buffer)] = System.Int64.clipu8(value.shru(16));
44594                this._buffer[System.Array.index(3, this._buffer)] = System.Int64.clipu8(value.shru(24));
44595                this._buffer[System.Array.index(4, this._buffer)] = System.Int64.clipu8(value.shru(32));
44596                this._buffer[System.Array.index(5, this._buffer)] = System.Int64.clipu8(value.shru(40));
44597                this._buffer[System.Array.index(6, this._buffer)] = System.Int64.clipu8(value.shru(48));
44598                this._buffer[System.Array.index(7, this._buffer)] = System.Int64.clipu8(value.shru(56));
44599                this.OutStream.Write(this._buffer, 0, 8);
44600            },
44601            Write$13: function (value) {
44602                var TmpValue = System.BitConverter.toUInt32(System.BitConverter.getBytes$6(value), 0);
44603                this._buffer[System.Array.index(0, this._buffer)] = TmpValue & 255;
44604                this._buffer[System.Array.index(1, this._buffer)] = (TmpValue >>
44604> 8) & 255;
44605                this._buffer[System.Array.index(2, this._buffer)] = (TmpValue >>> 16) & 255;
44606                this._buffer[System.Array.index(3, this._buffer)] = (TmpValue >>> 24) & 255;
44607                this.OutStream.Write(this._buffer, 0, 4);
44608            },
44609            Write$14: function (value) {
44610                if (value == null) {
44611                    throw new System.ArgumentNullException.$ctor1("value");
44612                }
44613
44614                var buffer = this._encoding.GetBytes$2(value);
44615                var len = buffer.length;
44616                this.Write7BitEncodedInt(len);
44617                this.OutStream.Write(buffer, 0, len);
44618            },
44619            Write7BitEncodedInt: function (value) {
44620                var v = value >>> 0;
44621                while (v >= 128) {
44622                    this.Write$1(((((v | 128) >>> 0)) & 255));
44623                    v = v >>> 7;
44624                }
44625                this.Write$1((v & 255));
44626            }
44627        }
44628    });
44629
44630    // @source Stream.js
44631
44632    H5.define("System.IO.Stream", {
44633        inherits: [System.IDisposable],
44634        statics: {
44635            fields: {
44636                _DefaultCopyBufferSize: 0,
44637                Null: null
44638            },
44639            ctors: {
44640                init: function () {
44641                    this._DefaultCopyBufferSize = 81920;
44642                    this.Null = new System.IO.Stream.NullStream();
44643                }
44644            },
44645            methods: {
44646                Synchronized: function (stream) {
44647                    if (stream == null) {
44648                        throw new System.ArgumentNullException.$ctor1("stream");
44649                    }
44650
44651                    return stream;
44652                },
44653                BlockingEndRead: function (asyncResult) {
44654
44655                    return System.IO.Stream.SynchronousAsyncResult.EndRead(asyncResult);
44656                },
44657                BlockingEndWrite: function (asyncResult) {
44658                    System.IO.Stream.SynchronousAsyncResult.EndWrite(asyncResult);
44659                }
44660            }
44661        },
44662        props: {
44663            CanTimeout: {
44664                get: function () {
44665                    return false;
44666                }
44667            },
44668            ReadTimeout: {
44669                get: function () {
44670                    throw new System.InvalidOperationException.ctor();
44671                },
44672                set: function (value) {
44673                    throw new System.InvalidOperationException.ctor();
44674                }
44675            },
44676            WriteTimeout: {
44677                get: function () {
44678                    throw new System.InvalidOperationException.ctor();
44679                },
44680                set: function (value) {
44681                    throw new System.InvalidOperationException.ctor();
44682                }
44683            }
44684        },
44685        alias: ["Dispose", "System$IDisposable$Dispose"],
44686        methods: {
44687            CopyTo: function (destination) {
44688                if (destination == null) {
44689                    throw new System.ArgumentNullException.$ctor1("destination");
44690                }
44691                if (!this.CanRead && !this.CanWrite) {
44692                    throw new System.Exception();
44693                }
44694                if (!destination.CanRead && !destination.CanWrite) {
44695                    throw new System.Exception("destination");
44696                }
44697                if (!this.CanRead) {
44698                    throw new System.NotSupportedException.ctor();
44699                }
44700                if (!destination.CanWrite) {
44701                    throw new System.NotSupportedException.ctor();
44702                }
44703
44704                this.InternalCopyTo(destination, System.IO.Stream._DefaultCopyBufferSize);
44705            },
44706            CopyTo$1: function (destination, bufferSize) {
44707                if (destination == null) {
44708                    throw new System.ArgumentNullException.$ctor1("destination");
44709                }
44710                if (bufferSize <= 0) {
44711                    throw new System.ArgumentOutOfRangeException.$ctor1("bufferSize");
44712                }
44713                if (!this.CanRead && !this.CanWrite) {
44714                    throw new System.Exception();
44715                }
44716                if (!destination.CanRead && !destination.CanWrite) {
44717                    throw new System.Exception("destination");
44718                }
44719                if (!this.CanRead) {
44720                    throw new System.NotSupportedException.ctor();
44721                }
44722                if (!destination.CanWrite) {
44723                    throw new System.NotSupportedException.ctor();
44724                }
44725
44726                this.InternalCopyTo(destination, bufferSize);
44727            },
44728            InternalCopyTo: function (destination, bufferSize) {
44729
44730                var buffer = System.Array.init(bufferSize, 0, System.Byte);
44731                var read;
44732                while (((read = this.Read(buffer, 0, buffer.length))) !== 0) {
44733                    destination.Write(buffer, 0, read);
44734                }
44735            },
44736            Close: function () {
44737                /* These are correct, but we'd have to fix PipeStream & NetworkStream very carefully.
44738                Contract.Ensures(CanRead == false);
44739                Contract.Ensures(CanWrite == false);
44740                Contract.Ensures(CanSeek == false);
44741                */
44742
44743                this.Dispose$1(true);
44744            },
44745            Dispose: function () {
44746                /* These are correct, but we'd have to fix PipeStream & NetworkStream very carefully.
44747                Contract.Ensures(CanRead == false);
44748                Contract.Ensures(CanWrite == false);
44749                Contract.Ensures(CanSeek == false);
44750                */
44751
44752                this.Close();
44753            },
44754            Dispose$1: function (disposing) { },
44755            BeginRead: function (buffer, offset, count, callback, state) {
44756                return this.BeginReadInternal(buffer, offset, count, callback, state, false);
44757            },
44758            BeginReadInternal: function (buffer, offset, count, callback, state, serializeAsynchronously) {
44759                if (!this.CanRead) {
44760                    System.IO.__Error.ReadNotSupported();
44761                }
44762
44763                return this.BlockingBeginRead(buffer, offset, count, callback, state);
44764            },
44765            EndRead: function (asyncResult) {
44766                if (asyncResult == null) {
44767                    throw new System.ArgumentNullException.$ctor1("asyncResult");
44768                }
44769
44770                return System.IO.Stream.BlockingEndRead(asyncResult);
44771            },
44772            BeginWrite: function (buffer, offset, count, callback, state) {
44773                return this.BeginWriteInternal(buffer, offset, count, callback, state, false);
44774            },
44775            BeginWriteInternal: function (buffer, offset, count, callback, state, serializeAsynchronously) {
44776                if (!this.CanWrite) {
44777                    System.IO.__Error.WriteNotSupported();
44778                }
44779                return this.BlockingBeginWrite(buffer, offset, count, callback, state);
44780            },
44781            EndWrite: function (asyncResult) {
44782                if (asyncResult == null) {
44783                    throw new System.ArgumentNullException.$ctor1("asyncResult");
44784                }
44785
44786                System.IO.Stream.BlockingEndWrite(asyncResult);
44787            },
44788            ReadByte: function () {
44789
44790                var oneByteArray = System.Array.init(1, 0, System.Byte);
44791                var r = this.Read(oneByteArray, 0, 1);
44792                if (r === 0) {
44793                    return -1;
44794                }
44795                return oneByteArray[System.Array.index(0, oneByteArray)];
44796            },
44797            WriteByte: function (value) {
44798                var oneByteArray = System.Array.init(1, 0, System.Byte);
44799                oneByteArray[System.Array.index(0, oneByteArray)] = value;
44800                this.Write(oneByteArray, 0, 1);
44801            },
44802            BlockingBeginRead: function (buffer, offset, count, callback, state) {
44803
44804                var asyncResult;
44805                try {
44806                    var numRead = this.Read(buffer, offset, count);
44807                    asyncResult = new System.IO.Stream.SynchronousAsyncResult.$ctor1(numRead, state);
44808                } catch ($e1) {
44809                    $e1 = System.Exception.create($e1);
44810                    var ex;
44811                    if (H5.is($e1, System.IO.IOException)) {
44812                        ex = $e1;
44813                        asyncResult = new System.IO.Stream.SynchronousAsyncResult.ctor(ex, state, false);
44814                    } else {
44815                        throw $e1;
44816                    }
44817                }
44818
44819                if (!H5.staticEquals(callback, null)) {
44820                    callback(asyncResult);
44821                }
44822
44823                return asyncResult;
44824            },
44825            BlockingBeginWrite: function (buffer, offset, count, callback, state) {
44826
44827                var asyncResult;
44828                try {
44829                    this.Write(buffer, offset, count);
44830                    asyncResult = new System.IO.Stream.SynchronousAsyncResult.$ctor2(state);
44831                } catch ($e1) {
44832                    $e1 = System.Exception.create($e1);
44833                    var ex;
44834                    if (H5.is($e1, System.IO.IOException)) {
44835                        ex = $e1;
44836                        asyncResult = new System.IO.Stream.SynchronousAsyncResult.ctor(ex, state, true);
44837                    } else {
44838                        throw $e1;
44839                    }
44840                }
44841
44842                if (!H5.staticEquals(callback, null)) {
44843                    callback(asyncResult);
44844                }
44845
44846                return asyncResult;
44847            }
44848        }
44849    });
44850
44851    // @source BufferedStream.js
44852
44853    H5.define("System.IO.BufferedStream", {
44854        inherits: [System.IO.Stream],
44855        statics: {
44856            fields: {
44857                _DefaultBufferSize: 0,
44858                MaxShadowBufferSize: 0
44859            },
44860            ctors: {
44861                init: function () {
44862                    this._DefaultBufferSize = 4096;
44863                    this.MaxShadowBufferSize = 81920;
44864                }
44865            }
44866        },
44867        fields: {
44868            _stream: null,
44869            _buffer: null,
44870            _bufferSize: 0,
44871            _readPos: 0,
44872            _readLen: 0,
44873            _writePos: 0
44874        },
44875        props: {
44876            UnderlyingStream: {
44877                get: function () {
44878                    return this._stream;
44879                }
44880            },
44881            BufferSize: {
44882                get: function () {
44883                    return this._bufferSize;
44884                }
44885            },
44886            CanRead: {
44887                get: function () {
44888                    return this._stream != null && this._stream.CanRead;
44889                }
44890            },
44891            CanWrite: {
44892                get: function () {
44893                    return this._stream != null && this._stream.CanWrite;
44894                }
44895            },
44896            CanSeek: {
44897                get: function () {
44898                    return this._stream != null && this._stream.CanSeek;
44899                }
44900            },
44901            Length: {
44902                get: function () {
44903                    this.EnsureNotClosed();
44904
44905                    if (this._writePos > 0) {
44906                        this.FlushWrite();
44907                    }
44908
44909                    return this._stream.Length;
44910                }
44911            },
44912            Position: {
44913                get: function () {
44914                    this.EnsureNotClosed();
44915                    this.EnsureCanSeek();
44916
44917                    return this._stream.Position.add(System.Int64((((((this._readPos - this._readLen) | 0) + this._writePos) | 0))));
44918                },
44919                set: function (value) {
44920                    if (value.lt(System.Int64(0))) {
44921                        throw new System.ArgumentOutOfRangeException.$ctor1("value");
44922                    }
44923
44924                    this.EnsureNotClosed();
44925                    this.EnsureCanSeek();
44926
44927                    if (this._writePos > 0) {
44928                        this.FlushWrite();
44929                    }
44930
44931                    this._readPos = 0;
44932                    this._readLen = 0;
44933                    this._stream.Seek(value, 0);
44934                }
44935            }
44936        },
44937        ctors: {
44938            ctor: function () {
44939                this.$initialize();
44940                System.IO.Stream.ctor.call(this);
44941            },
44942            $ctor1: function (stream) {
44943                System.IO.BufferedStream.$ctor2.call(this, stream, System.IO.BufferedStream._DefaultBufferSize);
44944            },
44945            $ctor2: function (stream, bufferSize) {
44946                this.$initialize();
44947                System.IO.Stream.ctor.call(this);
44948
44949                if (stream == null) {
44950                    throw new System.ArgumentNullException.$ctor1("stream");
44951                }
44952
44953                if (bufferSize <= 0) {
44954                    throw new System.ArgumentOutOfRangeException.$ctor1("bufferSize");
44955                }
44956
44957                this._stream = stream;
44958                this._bufferSize = bufferSize;
44959
44960
44961                if (!this._stream.CanRead && !this._stream.CanWrite) {
44962                    System.IO.__Error.StreamIsClosed();
44963                }
44964            }
44965        },
44966        methods: {
44967            EnsureNotClosed: function () {
44968
44969                if (this._stream == null) {
44970                    System.IO.__Error.StreamIsClosed();
44971                }
44972            },
44973            EnsureCanSeek: function () {
44974
44975
44976                if (!this._stream.CanSeek) {
44977                    System.IO.__Error.SeekNotSupported();
44978                }
44979            },
44980            EnsureCanRead: function () {
44981
44982
44983                if (!this._stream.CanRead) {
44984                    System.IO.__Error.ReadNotSupported();
44985                }
44986            },
44987            EnsureCanWrite: function () {
44988
44989
44990                if (!this._stream.CanWrite) {
44991                    System.IO.__Error.WriteNotSupported();
44992                }
44993            },
44994            EnsureShadowBufferAllocated: function () {
44995
44996
44997                if (this._buffer.length !== this._bufferSize || this._bufferSize >= System.IO.BufferedStream.MaxShadowBufferSize) {
44998                    return;
44999                }
45000
45001                var shadowBuffer = System.Array.init(Math.min(((this._bufferSize + this._bufferSize) | 0), System.IO.BufferedStream.MaxShadowBufferSize), 0, System.Byte);
45002                System.Array.copy(this._buffer, 0, shadowBuffer, 0, this._writePos);
45003                this._buffer = shadowBuffer;
45004            },
45005            EnsureBufferAllocated: function () {
45006
45007
45008                if (this._buffer == null) {
45009                    this._buffer = System.Array.init(this._bufferSize, 0, System.Byte);
45010                }
45011            },
45012            Dispose$1: function (disposing) {
45013
45014                try {
45015                    if (disposing && this._stream != null) {
45016                        try {
45017                            this.Flush();
45018                        } finally {
45019                            this._stream.Close();
45020                        }
45021                    }
45022                } finally {
45023                    this._stream = null;
45024                    this._buffer = null;
45025
45026                    System.IO.Stream.prototype.Dispose$1.call(this, disposing);
45027                }
45028            },
45029            Flush: function () {
45030
45031                this.EnsureNotClosed();
45032
45033                if (this._writePos > 0) {
45034
45035                    this.FlushWrite();
45036                    return;
45037                }
45038
45039                if (this._readPos < this._readLen) {
45040
45041                    if (!this._stream.CanSeek) {
45042                        return;
45043                    }
45044
45045                    this.FlushRead();
45046
45047                    if (this._stream.CanWrite || H5.is(this._stream, System.IO.BufferedStream)) {
45048                        this._stream.Flush();
45049                    }
45050
45051                    return;
45052                }
45053
45054                if (this._stream.CanWrite || H5.is(this._stream, System.IO.BufferedStream)) {
45055                    this._stream.Flush();
45056                }
45057
45058                this._writePos = (this._readPos = (this._readLen = 0));
45059            },
45060            FlushRead: function () {
45061
45062
45063                if (((this._readPos - this._readLen) | 0) !== 0) {
45064                    this._stream.Seek(System.Int64(this._readPos - this._readLen), 1);
45065                }
45066
45067                this._readPos = 0;
45068                this._readLen = 0;
45069            },
45070            ClearReadBufferBeforeWrite: function () {
45071
45072
45073
45074                if (this._readPos === this._readLen) {
45075
45076                    this._readPos = (this._readLen = 0);
45077                    return;
45078                }
45079
45080
45081                if (!this._stream.CanSeek) {
45082                    throw new System.NotSupportedException.ctor();
45083                }
45084
45085                this.FlushRead();
45086            },
45087            FlushWrite: function () {
45088
45089
45090                this._stream.Write(this._buffer, 0, this._writePos);
45091                this._writePos = 0;
45092                this._stream.Flush();
45093            },
45094            ReadFromBuffer: function (array, offset, count) {
45095
45096                var readBytes = (this._readLen - this._readPos) | 0;
45097
45098                if (readBytes === 0) {
45099                    return 0;
45100                }
45101
45102
45103                if (readBytes > count) {
45104                    readBytes = count;
45105                }
45106
45107                System.Array.copy(this._buffer, this._readPos, array, offset, readBytes);
45108                this._readPos = (this._readPos + readBytes) | 0;
45109
45110                return readBytes;
45111            },
45112            ReadFromBuffer$1: function (array, offset, count, error) {
45113
45114                try {
45115
45116                    error.v = null;
45117                    return this.ReadFromBuffer(array, offset, count);
45118
45119                } catch (ex) {
45120                    ex = System.Exception.create(ex);
45121                    error.v = ex;
45122                    return 0;
45123                }
45124            },
45125            Read: function (array, offset, count) {
45126
45127                if (array == null) {
45128                    throw new System.ArgumentNullException.$ctor1("array");
45129                }
45130                if (offset < 0) {
45131                    throw new System.ArgumentOutOfRangeException.$ctor1("offset");
45132                }
45133                if (count < 0) {
45134                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
45135                }
45136                if (((array.length - offset) | 0) < count) {
45137                    throw new System.ArgumentException.ctor();
45138                }
45139
45140                this.EnsureNotClosed();
45141                this.EnsureCanRead();
45142
45143                var bytesFromBuffer = this.ReadFromBuffer(array, offset, count);
45144
45145
45146                if (bytesFromBuffer === count) {
45147                    return bytesFromBuffer;
45148                }
45149
45150                var alreadySatisfied = bytesFromBuffer;
45151                if (bytesFromBuffer > 0) {
45152                    count = (count - bytesFromBuffer) | 0;
45153                    offset = (offset + bytesFromBuffer) | 0;
45154                }
45155
45156                this._readPos = (this._readLen = 0);
45157
45158                if (this._writePos > 0) {
45159                    this.FlushWrite();
45160                }
45161
45162                if (count >= this._bufferSize) {
45163
45164                    return ((this._stream.Read(array, offset, count) + alreadySatisfied) | 0);
45165                }
45166
45167                this.EnsureBufferAllocated();
45168                this._readLen = this._stream.Read(this._buffer, 0, this._bufferSize);
45169
45170                bytesFromBuffer = this.ReadFromBuffer(array, offset, count);
45171
45172
45173                return ((bytesFromBuffer + alreadySatisfied) | 0);
45174            },
45175            ReadByte: function () {
45176
45177                this.EnsureNotClosed();
45178                this.EnsureCanRead();
45179
45180                if (this._readPos === this._readLen) {
45181
45182                    if (this._writePos > 0) {
45183                        this.FlushWrite();
45184                    }
45185
45186                    this.EnsureBufferAllocated();
45187                    this._readLen = this._stream.Read(this._buffer, 0, this._bufferSize);
45188                    this._readPos = 0;
45189                }
45190
45191                if (this._readPos === this._readLen) {
45192                    return -1;
45193                }
45194
45195                var b = this._buffer[System.Array.index(H5.identity(this._readPos, ((this._readPos = (this._readPos + 1) | 0))), this._buffer)];
45196                return b;
45197            },
45198            WriteToBuffer: function (array, offset, count) {
45199
45200                var bytesToWrite = Math.min(((this._bufferSize - this._writePos) | 0), count.v);
45201
45202                if (bytesToWrite <= 0) {
45203                    return;
45204                }
45205
45206                this.EnsureBufferAllocated();
45207                System.Array.copy(array, offset.v, this._buffer, this._writePos, bytesToWrite);
45208
45209                this._writePos = (this._writePos + bytesToWrite) | 0;
45210                count.v = (count.v - bytesToWrite) | 0;
45211                offset.v = (offset.v + bytesToWrite) | 0;
45212            },
45213            WriteToBuffer$1: function (array, offset, count, error) {
45214
45215                try {
45216
45217                    error.v = null;
45218                    this.WriteToBuffer(array, offset, count);
45219
45220                } catch (ex) {
45221                    ex = System.Exception.create(ex);
45222                    error.v = ex;
45223                }
45224            },
45225            Write: function (array, offset, count) {
45226                offset = {v:offset};
45227                count = {v:count};
45228
45229                if (array == null) {
45230                    throw new System.ArgumentNullException.$ctor1("array");
45231                }
45232                if (offset.v < 0) {
45233                    throw new System.ArgumentOutOfRangeException.$ctor1("offset");
45234                }
45235                if (count.v < 0) {
45236                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
45237                }
45238                if (((array.length - offset.v) | 0) < count.v) {
45239                    throw new System.ArgumentException.ctor();
45240                }
45241
45242                this.EnsureNotClosed();
45243                this.EnsureCanWrite();
45244
45245                if (this._writePos === 0) {
45246                    this.ClearReadBufferBeforeWrite();
45247                }
45248
45249
45250
45251                var totalUserBytes;
45252                var useBuffer;
45253                totalUserBytes = H5.Int.check(this._writePos + count.v, System.Int32);
45254                useBuffer = (H5.Int.check(totalUserBytes + count.v, System.Int32) < (H5.Int.check(this._bufferSize + this._bufferSize, System.Int32)));
45255
45256                if (useBuffer) {
45257
45258                    this.WriteToBuffer(array, offset, count);
45259
45260                    if (this._writePos < this._bufferSize) {
45261
45262                        return;
45263                    }
45264
45265
45266                    this._stream.Write(this._buffer, 0, this._writePos);
45267                    this._writePos = 0;
45268
45269                    this.WriteToBuffer(array, offset, count);
45270
45271
45272                } else {
45273
45274                    if (this._writePos > 0) {
45275
45276
45277                        if (totalUserBytes <= (((this._bufferSize + this._bufferSize) | 0)) && totalUserBytes <= System.IO.BufferedStream.MaxShadowBufferSize) {
45278
45279                            this.EnsureShadowBufferAllocated();
45280                            System.Array.copy(array, offset.v, this._buffer, this._writePos, c
45280ount.v);
45281                            this._stream.Write(this._buffer, 0, totalUserBytes);
45282                            this._writePos = 0;
45283                            return;
45284                        }
45285
45286                        this._stream.Write(this._buffer, 0, this._writePos);
45287                        this._writePos = 0;
45288                    }
45289
45290                    this._stream.Write(array, offset.v, count.v);
45291                }
45292            },
45293            WriteByte: function (value) {
45294
45295                this.EnsureNotClosed();
45296
45297                if (this._writePos === 0) {
45298
45299                    this.EnsureCanWrite();
45300                    this.ClearReadBufferBeforeWrite();
45301                    this.EnsureBufferAllocated();
45302                }
45303
45304                if (this._writePos >= ((this._bufferSize - 1) | 0)) {
45305                    this.FlushWrite();
45306                }
45307
45308                this._buffer[System.Array.index(H5.identity(this._writePos, ((this._writePos = (this._writePos + 1) | 0))), this._buffer)] = value;
45309
45310            },
45311            Seek: function (offset, origin) {
45312
45313                this.EnsureNotClosed();
45314                this.EnsureCanSeek();
45315
45316                if (this._writePos > 0) {
45317
45318                    this.FlushWrite();
45319                    return this._stream.Seek(offset, origin);
45320                }
45321
45322
45323                if (((this._readLen - this._readPos) | 0) > 0 && origin === 1) {
45324
45325                    offset = offset.sub(System.Int64((((this._readLen - this._readPos) | 0))));
45326                }
45327
45328                var oldPos = this.Position;
45329
45330                var newPos = this._stream.Seek(offset, origin);
45331
45332
45333                this._readPos = System.Int64.clip32(newPos.sub((oldPos.sub(System.Int64(this._readPos)))));
45334
45335                if (0 <= this._readPos && this._readPos < this._readLen) {
45336
45337                    this._stream.Seek(System.Int64(this._readLen - this._readPos), 1);
45338
45339                } else {
45340
45341                    this._readPos = (this._readLen = 0);
45342                }
45343
45344                return newPos;
45345            },
45346            SetLength: function (value) {
45347
45348                if (value.lt(System.Int64(0))) {
45349                    throw new System.ArgumentOutOfRangeException.$ctor1("value");
45350                }
45351
45352                this.EnsureNotClosed();
45353                this.EnsureCanSeek();
45354                this.EnsureCanWrite();
45355
45356                this.Flush();
45357                this._stream.SetLength(value);
45358            }
45359        }
45360    });
45361
45362    // @source IOException.js
45363
45364    H5.define("System.IO.IOException", {
45365        inherits: [System.SystemException],
45366        ctors: {
45367            ctor: function () {
45368                this.$initialize();
45369                System.SystemException.$ctor1.call(this, "I/O error occurred.");
45370                this.HResult = -2146232800;
45371            },
45372            $ctor1: function (message) {
45373                this.$initialize();
45374                System.SystemException.$ctor1.call(this, message);
45375                this.HResult = -2146232800;
45376            },
45377            $ctor3: function (message, hresult) {
45378                this.$initialize();
45379                System.SystemException.$ctor1.call(this, message);
45380                this.HResult = hresult;
45381            },
45382            $ctor2: function (message, innerException) {
45383                this.$initialize();
45384                System.SystemException.$ctor2.call(this, message, innerException);
45385                this.HResult = -2146232800;
45386            }
45387        }
45388    });
45389
45390    // @source EndOfStreamException.js
45391
45392    H5.define("System.IO.EndOfStreamException", {
45393        inherits: [System.IO.IOException],
45394        ctors: {
45395            ctor: function () {
45396                this.$initialize();
45397                System.IO.IOException.$ctor1.call(this, "Arg_EndOfStreamException");
45398            },
45399            $ctor1: function (message) {
45400                this.$initialize();
45401                System.IO.IOException.$ctor1.call(this, message);
45402            },
45403            $ctor2: function (message, innerException) {
45404                this.$initialize();
45405                System.IO.IOException.$ctor2.call(this, message, innerException);
45406            }
45407        }
45408    });
45409
45410    // @source File.js
45411
45412    H5.define("System.IO.File", {
45413        statics: {
45414            methods: {
45415                OpenText: function (path) {
45416                    if (path == null) {
45417                        throw new System.ArgumentNullException.$ctor1("path");
45418                    }
45419                    return new System.IO.StreamReader.$ctor7(path);
45420                },
45421                OpenRead: function (path) {
45422                    return new System.IO.FileStream.$ctor1(path, 3);
45423                },
45424                ReadAllText: function (path) {
45425                    if (path == null) {
45426                        throw new System.ArgumentNullException.$ctor1("path");
45427                    }
45428                    if (path.length === 0) {
45429                        throw new System.ArgumentException.$ctor1("Argument_EmptyPath");
45430                    }
45431
45432                    return System.IO.File.InternalReadAllText(path, System.Text.Encoding.UTF8, true);
45433                },
45434                ReadAllText$1: function (path, encoding) {
45435                    if (path == null) {
45436                        throw new System.ArgumentNullException.$ctor1("path");
45437                    }
45438                    if (encoding == null) {
45439                        throw new System.ArgumentNullException.$ctor1("encoding");
45440                    }
45441                    if (path.length === 0) {
45442                        throw new System.ArgumentException.$ctor1("Argument_EmptyPath");
45443                    }
45444
45445                    return System.IO.File.InternalReadAllText(path, encoding, true);
45446                },
45447                InternalReadAllText: function (path, encoding, checkHost) {
45448
45449                    var sr = new System.IO.StreamReader.$ctor12(path, encoding, true, System.IO.StreamReader.DefaultBufferSize, checkHost);
45450                    try {
45451                        return sr.ReadToEnd();
45452                    }
45453                    finally {
45454                        if (H5.hasValue(sr)) {
45455                            sr.System$IDisposable$Dispose();
45456                        }
45457                    }
45458                },
45459                ReadAllBytes: function (path) {
45460                    return System.IO.File.InternalReadAllBytes(path, true);
45461                },
45462                InternalReadAllBytes: function (path, checkHost) {
45463                    var bytes;
45464                    var fs = new System.IO.FileStream.$ctor1(path, 3);
45465                    try {
45466                        var index = 0;
45467                        var fileLength = fs.Length;
45468                        if (fileLength.gt(System.Int64(2147483647))) {
45469                            throw new System.IO.IOException.$ctor1("IO.IO_FileTooLong2GB");
45470                        }
45471                        var count = System.Int64.clip32(fileLength);
45472                        bytes = System.Array.init(count, 0, System.Byte);
45473                        while (count > 0) {
45474                            var n = fs.Read(bytes, index, count);
45475                            if (n === 0) {
45476                                System.IO.__Error.EndOfFile();
45477                            }
45478                            index = (index + n) | 0;
45479                            count = (count - n) | 0;
45480                        }
45481                    }
45482                    finally {
45483                        if (H5.hasValue(fs)) {
45484                            fs.System$IDisposable$Dispose();
45485                        }
45486                    }
45487                    return bytes;
45488                },
45489                ReadAllLines: function (path) {
45490                    if (path == null) {
45491                        throw new System.ArgumentNullException.$ctor1("path");
45492                    }
45493                    if (path.length === 0) {
45494                        throw new System.ArgumentException.$ctor1("Argument_EmptyPath");
45495                    }
45496
45497                    return System.IO.File.InternalReadAllLines(path, System.Text.Encoding.UTF8);
45498                },
45499                ReadAllLines$1: function (path, encoding) {
45500                    if (path == null) {
45501                        throw new System.ArgumentNullException.$ctor1("path");
45502                    }
45503                    if (encoding == null) {
45504                        throw new System.ArgumentNullException.$ctor1("encoding");
45505                    }
45506                    if (path.length === 0) {
45507                        throw new System.ArgumentException.$ctor1("Argument_EmptyPath");
45508                    }
45509
45510                    return System.IO.File.InternalReadAllLines(path, encoding);
45511                },
45512                InternalReadAllLines: function (path, encoding) {
45513
45514                    var line;
45515                    var lines = new (System.Collections.Generic.List$1(System.String)).ctor();
45516
45517                    var sr = new System.IO.StreamReader.$ctor9(path, encoding);
45518                    try {
45519                        while (((line = sr.ReadLine())) != null) {
45520                            lines.add(line);
45521                        }
45522                    }
45523                    finally {
45524                        if (H5.hasValue(sr)) {
45525                            sr.System$IDisposable$Dispose();
45526                        }
45527                    }
45528
45529                    return lines.ToArray();
45530                },
45531                ReadLines: function (path) {
45532                    if (path == null) {
45533                        throw new System.ArgumentNullException.$ctor1("path");
45534                    }
45535                    if (path.length === 0) {
45536                        throw new System.ArgumentException.$ctor3("Argument_EmptyPath", "path");
45537                    }
45538
45539                    return System.IO.ReadLinesIterator.CreateIterator(path, System.Text.Encoding.UTF8);
45540                },
45541                ReadLines$1: function (path, encoding) {
45542                    if (path == null) {
45543                        throw new System.ArgumentNullException.$ctor1("path");
45544                    }
45545                    if (encoding == null) {
45546                        throw new System.ArgumentNullException.$ctor1("encoding");
45547                    }
45548                    if (path.length === 0) {
45549                        throw new System.ArgumentException.$ctor3("Argument_EmptyPath", "path");
45550                    }
45551
45552                    return System.IO.ReadLinesIterator.CreateIterator(path, encoding);
45553                }
45554            }
45555        }
45556    });
45557
45558    // @source FileMode.js
45559
45560    H5.define("System.IO.FileMode", {
45561        $kind: "enum",
45562        statics: {
45563            fields: {
45564                CreateNew: 1,
45565                Create: 2,
45566                Open: 3,
45567                OpenOrCreate: 4,
45568                Truncate: 5,
45569                Append: 6
45570            }
45571        }
45572    });
45573
45574    // @source FileOptions.js
45575
45576    H5.define("System.IO.FileOptions", {
45577        $kind: "enum",
45578        statics: {
45579            fields: {
45580                None: 0,
45581                WriteThrough: -2147483648,
45582                Asynchronous: 1073741824,
45583                RandomAccess: 268435456,
45584                DeleteOnClose: 67108864,
45585                SequentialScan: 134217728,
45586                Encrypted: 16384
45587            }
45588        },
45589        $flags: true
45590    });
45591
45592    // @source FileShare.js
45593
45594    H5.define("System.IO.FileShare", {
45595        $kind: "enum",
45596        statics: {
45597            fields: {
45598                None: 0,
45599                Read: 1,
45600                Write: 2,
45601                ReadWrite: 3,
45602                Delete: 4,
45603                Inheritable: 16
45604            }
45605        },
45606        $flags: true
45607    });
45608
45609    // @source FileStream.js
45610
45611    H5.define("System.IO.FileStream", {
45612        inherits: [System.IO.Stream],
45613        statics: {
45614            methods: {
45615                FromFile: function (file) {
45616                    var completer = new System.Threading.Tasks.TaskCompletionSource();
45617                    var fileReader = new FileReader();
45618                    fileReader.onload = function () {
45619                        completer.setResult(new System.IO.FileStream.ctor(fileReader.result, file.name));
45620                    };
45621                    fileReader.onerror = function (e) {
45622                        completer.setException(new System.SystemException.$ctor1(H5.unbox(e).target.error.As()));
45623                    };
45624                    fileReader.readAsArrayBuffer(file);
45625
45626                    return completer.task;
45627                },
45628                ReadBytes: function (path) {
45629                    if (H5.isNode) {
45630                        var fs = require("fs");
45631                        return H5.cast(fs.readFileSync(path), ArrayBuffer);
45632                    } else {
45633                        var req = new XMLHttpRequest();
45634                        req.open("GET", path, false);
45635                        req.overrideMimeType("text/plain;
45635 charset=x-user-defined");
45636                        req.send(null);
45637                        if (req.status !== 200) {
45638                            throw new System.IO.IOException.$ctor1(System.String.concat("Status of request to " + (path || "") + " returned status: ", req.status));
45639                        }
45640
45641                        var text = req.responseText;
45642                        var resultArray = new Uint8Array(text.length);
45643                        System.String.toCharArray(text, 0, text.length).forEach(function (v, index, array) {
45644                                var $t;
45645                                return ($t = (v & 255) & 255, resultArray[index] = $t, $t);
45646                            });
45647                        return resultArray.buffer;
45648                    }
45649                },
45650                ReadBytesAsync: function (path) {
45651                    var tcs = new System.Threading.Tasks.TaskCompletionSource();
45652
45653                    if (H5.isNode) {
45654                        var fs = require("fs");
45655                        fs.readFile(path, H5.fn.$build([function (err, data) {
45656                            if (err != null) {
45657                                throw new System.IO.IOException.ctor();
45658                            }
45659
45660                            tcs.setResult(data);
45661                        }]));
45662                    } else {
45663                        var req = new XMLHttpRequest();
45664                        req.open("GET", path, true);
45665                        req.overrideMimeType("text/plain; charset=binary-data");
45666                        req.send(null);
45667
45668                        req.onreadystatechange = function () {
45669                        if (req.readyState !== 4) {
45670                            return;
45671                        }
45672
45673                        if (req.status !== 200) {
45674                            throw new System.IO.IOException.$ctor1(System.String.concat("Status of request to " + (path || "") + " returned status: ", req.status));
45675                        }
45676
45677                        var text = req.responseText;
45678                        var resultArray = new Uint8Array(text.length);
45679                        System.String.toCharArray(text, 0, text.length).forEach(function (v, index, array) {
45680                                var $t;
45681                                return ($t = (v & 255) & 255, resultArray[index] = $t, $t);
45682                            });
45683                        tcs.setResult(resultArray.buffer);
45684                        };
45685                    }
45686
45687                    return tcs.task;
45688                }
45689            }
45690        },
45691        fields: {
45692            name: null,
45693            _buffer: null
45694        },
45695        props: {
45696            CanRead: {
45697                get: function () {
45698                    return true;
45699                }
45700            },
45701            CanWrite: {
45702                get: function () {
45703                    return false;
45704                }
45705            },
45706            CanSeek: {
45707                get: function () {
45708                    return false;
45709                }
45710            },
45711            IsAsync: {
45712                get: function () {
45713                    return false;
45714                }
45715            },
45716            Name: {
45717                get: function () {
45718                    return this.name;
45719                }
45720            },
45721            Length: {
45722                get: function () {
45723                    return System.Int64(this.GetInternalBuffer().byteLength);
45724                }
45725            },
45726            Position: System.Int64(0)
45727        },
45728        ctors: {
45729            $ctor1: function (path, mode) {
45730                this.$initialize();
45731                System.IO.Stream.ctor.call(this);
45732                this.name = path;
45733            },
45734            ctor: function (buffer, name) {
45735                this.$initialize();
45736                System.IO.Stream.ctor.call(this);
45737                this._buffer = buffer;
45738                this.name = name;
45739            }
45740        },
45741        methods: {
45742            Flush: function () { },
45743            Seek: function (offset, origin) {
45744                throw new System.NotImplementedException.ctor();
45745            },
45746            SetLength: function (value) {
45747                throw new System.NotImplementedException.ctor();
45748            },
45749            Write: function (buffer, offset, count) {
45750                throw new System.NotImplementedException.ctor();
45751            },
45752            GetInternalBuffer: function () {
45753                if (this._buffer == null) {
45754                    this._buffer = System.IO.FileStream.ReadBytes(this.name);
45755
45756                }
45757
45758                return this._buffer;
45759            },
45760            EnsureBufferAsync: function () {
45761                var $s = 0,
45762                    $t1, 
45763                    $tr1, 
45764                    $jff, 
45765                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
45766                    $rv, 
45767                    $ae, 
45768                    $asyncBody = H5.fn.bind(this, function () {
45769                        try {
45770                            for (;;) {
45771                                $s = System.Array.min([0,1,2,3], $s);
45772                                switch ($s) {
45773                                    case 0: {
45774                                        if (this._buffer == null) {
45775                                            $s = 1;
45776                                            continue;
45777                                        } 
45778                                        $s = 3;
45779                                        continue;
45780                                    }
45781                                    case 1: {
45782                                        $t1 = System.IO.FileStream.ReadBytesAsync(this.name);
45783                                        $s = 2;
45784                                        if ($t1.isCompleted()) {
45785                                            continue;
45786                                        }
45787                                        $t1.continue($asyncBody);
45788                                        return;
45789                                    }
45790                                    case 2: {
45791                                        $tr1 = $t1.getAwaitedResult();
45792                                        this._buffer = $tr1;
45793                                        $s = 3;
45794                                        continue;
45795                                    }
45796                                    case 3: {
45797                                        $tcs.setResult(null);
45798                                        return;
45799                                    }
45800                                    default: {
45801                                        $tcs.setResult(null);
45802                                        return;
45803                                    }
45804                                }
45805                            }
45806                        } catch($ae1) {
45807                            $ae = System.Exception.create($ae1);
45808                            $tcs.setException($ae);
45809                        }
45810                    }, arguments);
45811
45812                $asyncBody();
45813                return $tcs.task;
45814            },
45815            Read: function (buffer, offset, count) {
45816                if (buffer == null) {
45817                    throw new System.ArgumentNullException.$ctor1("buffer");
45818                }
45819
45820                if (offset < 0) {
45821                    throw new System.ArgumentOutOfRangeException.$ctor1("offset");
45822                }
45823
45824                if (count < 0) {
45825                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
45826                }
45827
45828                if ((((buffer.length - offset) | 0)) < count) {
45829                    throw new System.ArgumentException.ctor();
45830                }
45831
45832                var num = this.Length.sub(this.Position);
45833                if (num.gt(System.Int64(count))) {
45834                    num = System.Int64(count);
45835                }
45836
45837                if (num.lte(System.Int64(0))) {
45838                    return 0;
45839                }
45840
45841                var byteBuffer = new Uint8Array(this.GetInternalBuffer());
45842                if (num.gt(System.Int64(8))) {
45843                    for (var n = 0; System.Int64(n).lt(num); n = (n + 1) | 0) {
45844                        buffer[System.Array.index(((n + offset) | 0), buffer)] = byteBuffer[this.Position.add(System.Int64(n))];
45845                    }
45846                } else {
45847                    var num1 = num;
45848                    while (true) {
45849                        var num2 = num1.sub(System.Int64(1));
45850                        num1 = num2;
45851                        if (num2.lt(System.Int64(0))) {
45852                            break;
45853                        }
45854                        buffer[System.Array.index(System.Int64.toNumber(System.Int64(offset).add(num1)), buffer)] = byteBuffer[this.Position.add(num1)];
45855                    }
45856                }
45857                this.Position = this.Position.add(num);
45858                return System.Int64.clip32(num);
45859            }
45860        }
45861    });
45862
45863    // @source Iterator.js
45864
45865    H5.define("System.IO.Iterator$1", function (TSource) { return {
45866        inherits: [System.Collections.Generic.IEnumerable$1(TSource),System.Collections.Generic.IEnumerator$1(TSource)],
45867        fields: {
45868            state: 0,
45869            current: H5.getDefaultValue(TSource)
45870        },
45871        props: {
45872            Current: {
45873                get: function () {
45874                    return this.current;
45875                }
45876            },
45877            System$Collections$IEnumerator$Current: {
45878                get: function () {
45879                    return this.Current;
45880                }
45881            }
45882        },
45883        alias: [
45884            "Current", ["System$Collections$Generic$IEnumerator$1$" + H5.getTypeAlias(TSource) + "$Current$1", "System$Collections$Generic$IEnumerator$1$Current$1"],
45885            "Dispose", "System$IDisposable$Dispose",
45886            "GetEnumerator", ["System$Collections$Generic$IEnumerable$1$" + H5.getTypeAlias(TSource) + "$GetEnumerator", "System$Collections$Generic$IEnumerable$1$GetEnumerator"]
45887        ],
45888        ctors: {
45889            ctor: function () {
45890                this.$initialize();
45891            }
45892        },
45893        methods: {
45894            Dispose: function () {
45895                this.Dispose$1(true);
45896            },
45897            Dispose$1: function (disposing) {
45898                this.current = H5.getDefaultValue(TSource);
45899                this.state = -1;
45900            },
45901            GetEnumerator: function () {
45902                if (this.state === 0) {
45903                    this.state = 1;
45904                    return this;
45905                }
45906
45907                var duplicate = this.Clone();
45908                duplicate.state = 1;
45909                return duplicate;
45910            },
45911            System$Collections$IEnumerable$GetEnumerator: function () {
45912                return this.GetEnumerator();
45913            },
45914            System$Collections$IEnumerator$reset: function () {
45915                throw new System.NotSupportedException.ctor();
45916            }
45917        }
45918    }; });
45919
45920    // @source MemoryStream.js
45921
45922    H5.define("System.IO.MemoryStream", {
45923        inherits: [System.IO.Stream],
45924        statics: {
45925            fields: {
45926                MemStreamMaxLength: 0
45927            },
45928            ctors: {
45929                init: function () {
45930                    this.MemStreamMaxLength = 2147483647;
45931                }
45932            }
45933        },
45934        fields: {
45935            _buffer: null,
45936            _origin: 0,
45937            _position: 0,
45938            _length: 0,
45939            _capacity: 0,
45940            _expandable: false,
45941            _writable: false,
45942            _exposable: false,
45943            _isOpen: false
45944        },
45945        props: {
45946            CanRead: {
45947                get: function () {
45948                    return this._isOpen;
45949                }
45950            },
45951            CanSeek: {
45952                get: function () {
45953                    return this._isOpen;
45954                }
45955            },
45956            CanWrite: {
45957                get: function () {
45958                    return this._writable;
45959                }
45960            },
45961            Capacity: {
45962                get: function () {
45963                    if (!this._isOpen) {
45964                        System.IO.__Error.StreamIsClosed();
45965                    }
45966                    return ((this._capacity - this._origin) | 0);
45967                },
45968                set: function (value) {
45969                    if (System.Int64(value).lt(this.Length)) {
45970                        throw new System.ArgumentOutOfRangeException.$ctor4("value", "ArgumentOutOfRange_SmallCapacity");
45971                    }
45972
45973                    if (!this._isOpen) {
45974                        System.IO.__Error.StreamIsClosed();
45975                    }
45976                    if (!this._expandable && (value !== this.Capacity)) {
45977                        System.IO.__Error.MemoryStreamNotExpandable();
45978                    }
45979
45980                    if (this._expandable && value !== this._capacity) {
45981                        if (value > 0) {
45982                            var newBuffer = System.Array.init(value, 0, System.Byte);
45983                            if (this._length > 0) {
45984                                System.Array.copy(this._buffer, 0, newBuffer, 0, this._length);
45985                            }
45986                            this._buffer = newBuffer;
45987                        } else {
45988                            this._buffer = null;
45989                        }
45990                        this._capacity = value;
45991                    }
45992                }
45993            },
45994            Length: {
45995                get: function () {
45996                    if (!this._isOpen) {
45997                        System.IO.__Error.StreamIsClosed();
45998                    }
45999                    return System.Int64(this._length - this._origin);
46000                }
46001            },
46002            Position: {
46003                get: function () {
46004                    if (!this._isOpen) {
46005                        System.IO.__Error.StreamIsClosed();
46006                    }
46007                    return System.Int64(this._position - this._origin);
46008                },
46009                set: function (value) {
46010                    if (value.lt(System.Int64(0))) {
46011                        throw new System.ArgumentOutOfRangeException.$ctor4("value", "ArgumentOutOfRange_NeedNonNegNum");
46012                    }
46013
46014                    if (!this._isOpen) {
46015                        System.IO.__Error.StreamIsClosed();
46016                    }
46017
46018                    if (value.gt(System.Int64(System.IO.MemoryStream.MemStreamMaxLength))) {
46019                        throw new System.ArgumentOutOfRangeException.$ctor4("value", "ArgumentOutOfRange_StreamLength");
46020                    }
46021                    this._position = (this._origin + System.Int64.clip32(value)) | 0;
46022                }
46023            }
46024        },
46025        ctors: {
46026            ctor: function () {
46027                System.IO.MemoryStream.$ctor6.call(this, 0);
46028            },
46029            $ctor6: function (capacity) {
46030                this.$initialize();
46031                System.IO.Stream.ctor.call(this);
46032                if (capacity < 0) {
46033                    throw new System.ArgumentOutOfRangeException.$ctor4("capacity", "ArgumentOutOfRange_NegativeCapacity");
46034                }
46035
46036                this._buffer = System.Array.init(capacity, 0, System.Byte);
46037                this._capacity = capacity;
46038                this._expandable = true;
46039                this._writable = true;
46040                this._exposable = true;
46041                this._origin = 0;
46042                this._isOpen = true;
46043            },
46044            $ctor1: function (buffer) {
46045                System.IO.MemoryStream.$ctor2.call(this, buffer, true);
46046            },
46047            $ctor2: function (buffer, writable) {
46048                this.$initialize();
46049                System.IO.Stream.ctor.call(this);
46050                if (buffer == null) {
46051                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
46052                }
46053                this._buffer = buffer;
46054                this._length = (this._capacity = buffer.length);
46055                this._writable = writable;
46056                this._exposable = false;
46057                this._origin = 0;
46058                this._isOpen = true;
46059            },
46060            $ctor3: function (buffer, index, count) {
46061                System.IO.MemoryStream.$ctor5.call(this, buffer, index, count, true, false);
46062            },
46063            $ctor4: function (buffer, index, count, writable) {
46064                System.IO.MemoryStream.$ctor5.call(this, buffer, index, count, writable, false);
46065            },
46066            $ctor5: function (buffer, index, count, writable, publiclyVisible) {
46067                this.$initialize();
46068                System.IO.Stream.ctor.call(this);
46069                if (buffer == null) {
46070                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
46071                }
46072                if (index < 0) {
46073                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "ArgumentOutOfRange_NeedNonNegNum");
46074                }
46075                if (count < 0) {
46076                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
46077                }
46078                if (((buffer.length - index) | 0) < count) {
46079                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
46080                }
46081
46082                this._buffer = buffer;
46083                this._origin = (this._position = index);
46084                this._length = (this._capacity = (index + count) | 0);
46085                this._writable = writable;
46086                this._exposable = publiclyVisible;
46087                this._expandable = false;
46088                this._isOpen = true;
46089            }
46090        },
46091        methods: {
46092            EnsureWriteable: function () {
46093                if (!this.CanWrite) {
46094                    System.IO.__Error.WriteNotSupported();
46095                }
46096            },
46097            Dispose$1: function (disposing) {
46098                try {
46099                    if (disposing) {
46100                        this._isOpen = false;
46101                        this._writable = false;
46102                        this._expandable = false;
46103                    }
46104                } finally {
46105                    System.IO.Stream.prototype.Dispose$1.call(this, disposing);
46106                }
46107            },
46108            EnsureCapacity: function (value) {
46109                if (value < 0) {
46110                    throw new System.IO.IOException.$ctor1("IO.IO_StreamTooLong");
46111                }
46112                if (value > this._capacity) {
46113                    var newCapacity = value;
46114                    if (newCapacity < 256) {
46115                        newCapacity = 256;
46116                    }
46117                    if (newCapacity < H5.Int.mul(this._capacity, 2)) {
46118                        newCapacity = H5.Int.mul(this._capacity, 2);
46119                    }
46120                    if ((((H5.Int.mul(this._capacity, 2))) >>> 0) > 2147483591) {
46121                        newCapacity = value > 2147483591 ? value : 2147483591;
46122                    }
46123
46124                    this.Capacity = newCapacity;
46125                    return true;
46126                }
46127                return false;
46128            },
46129            Flush: function () { },
46130            GetBuffer: function () {
46131                if (!this._exposable) {
46132                    throw new System.Exception("UnauthorizedAccess_MemStreamBuffer");
46133                }
46134                return this._buffer;
46135            },
46136            TryGetBuffer: function (buffer) {
46137                if (!this._exposable) {
46138                    buffer.v = H5.getDefaultValue(System.ArraySegment);
46139                    return false;
46140                }
46141
46142                buffer.v = new System.ArraySegment(this._buffer, this._origin, (((this._length - this._origin) | 0)));
46143                return true;
46144            },
46145            InternalGetBuffer: function () {
46146                return this._buffer;
46147            },
46148            InternalGetPosition: function () {
46149                if (!this._isOpen) {
46150                    System.IO.__Error.StreamIsClosed();
46151                }
46152                return this._position;
46153            },
46154            InternalReadInt32: function () {
46155                if (!this._isOpen) {
46156                    System.IO.__Error.StreamIsClosed();
46157                }
46158
46159                var pos = ((this._position = (this._position + 4) | 0));
46160                if (pos > this._length) {
46161                    this._position = this._length;
46162                    System.IO.__Error.EndOfFile();
46163                }
46164                return this._buffer[System.Array.index(((pos - 4) | 0), this._buffer)] | this._buffer[System.Array.index(((pos - 3) | 0), this._buffer)] << 8 | this._buffer[System.Array.index(((pos - 2) | 0), this._buffer)] << 16 | this._buffer[System.Array.index(((pos - 1) | 0), this._buffer)] << 24;
46165            },
46166            InternalEmulateRead: function (count) {
46167                if (!this._isOpen) {
46168                    System.IO.__Error.StreamIsClosed();
46169                }
46170
46171                var n = (this._length - this._position) | 0;
46172                if (n > count) {
46173                    n = count;
46174                }
46175                if (n < 0) {
46176                    n = 0;
46177                }
46178
46179                this._position = (this._position + n) | 0;
46180                return n;
46181            },
46182            Read: function (buffer, offset, count) {
46183                if (buffer == null) {
46184                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
46185                }
46186                if (offset < 0) {
46187                    throw new System.ArgumentOutOfRangeException.$ctor4("offset", "ArgumentOutOfRange_NeedNonNegNum");
46188                }
46189                if (count < 0) {
46190                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
46191                }
46192                if (((buffer.length - offset) | 0) < count) {
46193                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
46194                }
46195
46196                if (!this._isOpen) {
46197                    System.IO.__Error.StreamIsClosed();
46198                }
46199
46200                var n = (this._length - this._position) | 0;
46201                if (n > count) {
46202                    n = count;
46203                }
46204                if (n <= 0) {
46205                    return 0;
46206                }
46207
46208
46209                if (n <= 8) {
46210                    var byteCount = n;
46211                    while (((byteCount = (byteCount - 1) | 0)) >= 0) {
46212                        buffer[System.Array.index(((offset + byteCount) | 0), buffer)] = this._buffer[System.Array.index(((this._position + byteCount) | 0), this._buffer)];
46213                    }
46214                } else {
46215                    System.Array.copy(this._buffer, this._position, buffer, offset, n);
46216                }
46217                this._position = (this._position + n) | 0;
46218
46219                return n;
46220            },
46221            ReadByte: function () {
46222                if (!this._isOpen) {
46223                    System.IO.__Error.StreamIsClosed();
46224                }
46225
46226                if (this._position >= this._length) {
46227                    return -1;
46228                }
46229
46230                return this._buffer[System.Array.index(H5.identity(this._position, ((this._position = (this._position + 1) | 0))), this._buffer)];
46231            },
46232            Seek: function (offset, loc) {
46233                if (!this._isOpen) {
46234                    System.IO.__Error.StreamIsClosed();
46235                }
46236
46237                if (offset.gt(System.Int64(System.IO.MemoryStream.MemStreamMaxLength))) {
46238                    throw new System.ArgumentOutOfRangeException.$ctor4("offset", "ArgumentOutOfRange_StreamLength");
46239                }
46240                switch (loc) {
46241                    case 0: 
46242                        {
46243                            var tempPosition = ((this._origin + System.Int64.clip32(offset)) | 0);
46244                            if (offset.lt(System.Int64(0)) || tempPosition < this._origin) {
46245                                throw new System.IO.IOException.$ctor1("IO.IO_SeekBeforeBegin");
46246                            }
46247                            this._position = tempPosition;
46248                            break;
46249                        }
46250                    case 1: 
46251                        {
46252                            var tempPosition1 = ((this._position + System.Int64.clip32(offset)) | 0);
46253                            if (System.Int64(this._position).add(offset).lt(System.Int64(this._origin)) || tempPosition1 < this._origin) {
46254                                throw new System.IO.IOException.$ctor1("IO.IO_SeekBeforeBegin");
46255                            }
46256                            this._position = tempPosition1;
46257                            break;
46258                        }
46259                    case 2: 
46260                        {
46261                            var tempPosition2 = ((this._length + System.Int64.clip32(offset)) | 0);
46262                            if (System.Int64(this._length).add(offset).lt(System.Int64(this._origin)) || tempPosition2 < this._origin) {
46263                                throw new System.IO.IOException.$ctor1("IO.IO_SeekBeforeBegin");
46264                            }
46265                            this._position = tempPosition2;
46266                            break;
46267                        }
46268                    default: 
46269                        throw new System.ArgumentException.$ctor1("Argument_InvalidSeekOrigin");
46270                }
46271
46272                return System.Int64(this._position);
46273            },
46274            SetLength: function (value) {
46275                if (value.lt(System.Int64(0)) || value.gt(System.Int64(2147483647))) {
46276                    throw new System.ArgumentOutOfRangeException.$ctor4("value", "ArgumentOutOfRange_StreamLength");
46277                }
46278                this.EnsureWriteable();
46279
46280                if (value.gt(System.Int64((((2147483647 - this._origin) | 0))))) {
46281                    throw new System.ArgumentOutOfRangeException.$ctor4("value", "ArgumentOutOfRange_StreamLength");
46282                }
46283
46284                var newLength = (this._origin + System.Int64.clip32(value)) | 0;
46285                var allocatedNewArray = this.EnsureCapacity(newLength);
46286                if (!allocatedNewArray && newLength > this._length) {
46287                    System.Array.fill(this._buffer, 0, this._length, ((newLength - this._length) | 0));
46288                }
46289                this._length = newLength;
46290                if (this._position > newLength) {
46291                    this._position = newLength;
46292                }
46293
46294            },
46295            ToArray: function () {
46296                var copy = System.Array.init(((this._length - this._origin) | 0), 0, System.Byte);
46297                System.Array.copy(this._buffer, this._origin, copy, 0, ((this._length - this._origin) | 0));
46298                return copy;
46299            },
46300            Write: function (buffer, offset, count) {
46301                if (buffer == null) {
46302                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
46303                }
46304                if (offset < 0) {
46305                    throw new System.ArgumentOutOfRangeException.$ctor4("offset", "ArgumentOutOfRange_NeedNonNegNum");
46306                }
46307                if (count < 0) {
46308                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
46309                }
46310                if (((buffer.length - offset) | 0) < count) {
46311                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
46312                }
46313
46314                if (!this._isOpen) {
46315                    System.IO.__Error.StreamIsClosed();
46316                }
46317                this.EnsureWriteable();
46318
46319                var i = (this._position + count) | 0;
46320                if (i < 0) {
46321                    throw new System.IO.IOException.$ctor1("IO.IO_StreamTooLong");
46322                }
46323
46324                if (i > this._length) {
46325                    var mustZero = this._position > this._length;
46326                    if (i > this._capacity) {
46327                        var allocatedNewArray = this.EnsureCapacity(i);
46328                        if (allocatedNewArray) {
46329                            mustZero = false;
46330                        }
46331                    }
46332                    if (mustZero) {
46333                        System.Array.fill(this._buffer, 0, this._length, ((i - this._length) | 0));
46334                    }
46335                    this._length = i;
46336                }
46337                if ((count <= 8) && (!H5.referenceEquals(buffer, this._buffer))) {
46338                    var byteCount = count;
46339                    while (((byteCount = (byteCount - 1) | 0)) >= 0) {
46340                        this._buffer[System.Array.index(((this._position + byteCount) | 0), this._buffer)] = buffer[System.Array.index(((offset + byteCount) | 0), buffer)];
46341                    }
46342                } else {
46343                    System.Array.copy(buffer, offset, this._buffer, this._position, count);
46344                }
46345                this._position = i;
46346
46347            },
46348            WriteByte: function (value) {
46349                if (!this._isOpen) {
46350                    System.IO.__Error.StreamIsClosed();
46351                }
46352                this.EnsureWriteable();
46353
46354                if (this._position >= this._length) {
46355                    var newLength = (this._position + 1) | 0;
46356                    var mustZero = this._position > this._length;
46357                    if (newLength >= this._capacity) {
46358                        var allocatedNewArray = this.EnsureCapacity(newLength);
46359                        if (allocatedNewArray) {
46360                            mustZero = false;
46361                        }
46362                    }
46363                    if (mustZero) {
46364                        System.Array.fill(this._buffer, 0, this._length, ((this._position - this._length) | 0));
46365                    }
46366                    this._length = newLength;
46367                }
46368                this._buffer[System.Array.index(H5.identity(this._position, ((this._position = (this._position + 1) | 0))), this._buffer)] = value;
46369
46370            },
46371            WriteTo: function (stream) {
46372                if (stream == null) {
46373                    throw new System.ArgumentNullException.$ctor3("stream", "ArgumentNull_Stream");
46374                }
46375
46376                if (!this._isOpen) {
46377                    System.IO.__Error.StreamIsClosed();
46378                }
46379                stream.Write(this._buffer, this._origin, ((this._length - this._origin) | 0));
46380            }
46381        }
46382    });
46383
46384    // @source ReadLinesIterator.js
46385
46386    H5.define("System.IO.ReadLinesIterator", {
46387        inherits: [System.IO.Iterator$1(System.String)],
46388        statics: {
46389            methods: {
46390                CreateIterator: function (path, encoding) {
46391                    return System.IO.ReadLinesIterator.CreateIterator$1(path, encoding, null);
46392                },
46393                CreateIterator$1: function (path, encoding, reader) {
46394                    return new System.IO.ReadLinesIterator(path, encoding, reader || new System.IO.StreamReader.$ctor9(path, encoding));
46395                }
46396            }
46397        },
46398        fields: {
46399            _path: null,
46400            _encoding: null,
46401            _reader: null
46402        },
46403        alias: ["moveNext", "System$Collections$IEnumerator$moveNext"],
46404        ctors: {
46405            ctor: function (path, encoding, reader) {
46406                this.$initialize();
46407                System.IO.Iterator$1(System.String).ctor.call(this);
46408
46409                this._path = path;
46410                this._encoding = encoding;
46411                this._reader = reader;
46412            }
46413        },
46414        methods: {
46415            moveNext: function () {
46416                if (this._reader != null) {
46417                    this.current = this._reader.ReadLine();
46418                    if (this.current != null) {
46419                        return true;
46420                    }
46421
46422                    this.Dispose();
46423                }
46424
46425                return false;
46426            },
46427            Clone: function () {
46428                return System.IO.ReadLinesIterator.CreateIterator$1(this._path, this._encoding, this._reader);
46429            },
46430            Dispose$1: function (disposing) {
46431                try {
46432                    if (disposing) {
46433                        if (this._reader != null) {
46434                            this._reader.Dispose();
46435                        }
46436                    }
46437                } finally {
46438                    this._reader = null;
46439                    System.IO.Iterator$1(System.String).prototype.Dispose$1.call(this, disposing);
46440                }
46441            }
46442        }
46443    });
46444
46445    // @source SeekOrigin.js
46446
46447    H5.define("System.IO.SeekOrigin", {
46448        $kind: "enum",
46449        statics: {
46450            fields: {
46451                Begin: 0,
46452                Current: 1,
46453                End: 2
46454            }
46455        }
46456    });
46457
46458    // @source NullStream.js
46459
46460    H5.define("System.IO.Stream.NullStream", {
46461        inherits: [System.IO.Stream],
46462        $kind: "nested class",
46463        props: {
46464            CanRead: {
46465                get: function () {
46466                    return true;
46467                }
46468            },
46469            CanWrite: {
46470                get: function () {
46471                    return true;
46472                }
46473            },
46474            CanSeek: {
46475                get: function () {
46476                    return true;
46477                }
46478            },
46479            Length: {
46480                get: function () {
46481                    return System.Int64(0);
46482                }
46483            },
46484            Position: {
46485                get: function () {
46486                    return System.Int64(0);
46487                },
46488                set: function (value) { }
46489            }
46490        },
46491        ctors: {
46492            ctor: function () {
46493                this.$initialize();
46494                System.IO.Stream.ctor.call(this);
46495            }
46496        },
46497        methods: {
46498            Dispose$1: function (disposing) { },
46499            Flush: function () { },
46500            BeginRead: function (buffer, offset, count, callback, state) {
46501                if (!this.CanRead) {
46502                    System.IO.__Error.ReadNotSupported();
46503                }
46504
46505                return this.BlockingBeginRead(buffer, offset, count, callback, state);
46506            },
46507            EndRead: function (asyncResult) {
46508                if (asyncResult == null) {
46509                    throw new System.ArgumentNullException.$ctor1("asyncResult");
46510                }
46511
46512                return System.IO.Stream.BlockingEndRead(asyncResult);
46513            },
46514            BeginWrite: function (buffer, offset, count, callback, state) {
46515                if (!this.CanWrite) {
46516                    System.IO.__Error.WriteNotSupported();
46517                }
46518
46519                return this.BlockingBeginWrite(buffer, offset, count, callback, state);
46520            },
46521            EndWrite: function (asyncResult) {
46522                if (asyncResult == null) {
46523                    throw new System.ArgumentNullException.$ctor1("asyncResult");
46524                }
46525
46526                System.IO.Stream.BlockingEndWrite(asyncResult);
46527            },
46528            Read: function (buffer, offset, count) {
46529                return 0;
46530            },
46531            ReadByte: function () {
46532                return -1;
46533            },
46534            Write: function (buffer, offset, count) { },
46535            WriteByte: function (value) { },
46536            Seek: function (offset, origin) {
46537                return System.Int64(0);
46538            },
46539            SetLength: function (length) { }
46540        }
46541    });
46542
46543    // @source SynchronousAsyncResult.js
46544
46545    H5.define("System.IO.Stream.SynchronousAsyncResult", {
46546        inherits: [System.IAsyncResult],
46547        $kind: "nested class",
46548        statics: {
46549            methods: {
46550                EndRead: function (asyncResult) {
46551
46552                    var ar = H5.as(asyncResult, System.IO.Stream.SynchronousAsyncResult);
46553                    if (ar == null || ar._isWrite) {
46554                        System.IO.__Error.WrongAsyncResult();
46555                    }
46556
46557                    if (ar._endXxxCalled) {
46558                        System.IO.__Error.EndReadCalledTwice();
46559                    }
46560
46561                    ar._endXxxCalled = true;
46562
46563                    ar.ThrowIfError();
46564                    return ar._bytesRead;
46565                },
46566                EndWrite: function (asyncResult) {
46567
46568                    var ar = H5.as(asyncResult, System.IO.Stream.SynchronousAsyncResult);
46569                    if (ar == null || !ar._isWrite) {
46570                        System.IO.__Error.WrongAsyncResult();
46571                    }
46572
46573                    if (ar._endXxxCalled) {
46574                        System.IO.__Error.EndWriteCalledTwice();
46575                    }
46576
46577                    ar._endXxxCalled = true;
46578
46579                    ar.ThrowIfError();
46580                }
46581            }
46582        },
46583        fields: {
46584            _stateObject: null,
46585            _isWrite: false,
46586            _exceptionInfo: null,
46587            _endXxxCalled: false,
46588            _bytesRead: 0
46589        },
46590        props: {
46591            IsCompleted: {
46592                get: function () {
46593                    return true;
46594                }
46595            },
46596            AsyncState: {
46597                get: function () {
46598                    return this._stateObject;
46599                }
46600            },
46601            CompletedSynchronously: {
46602                get: function () {
46603                    return true;
46604                }
46605            }
46606        },
46607        alias: [
46608            "IsCompleted", "System$IAsyncResult$IsCompleted",
46609            "AsyncState", "System$IAsyncResult$AsyncState",
46610            "CompletedSynchronously", "System$IAsyncResult$CompletedSynchronously"
46611        ],
46612        ctors: {
46613            $ctor1: function (bytesRead, asyncStateObject) {
46614                this.$initialize();
46615                this._bytesRead = bytesRead;
46616                this._stateObject = asyncStateObject;
46617            },
46618            $ctor2: function (asyncStateObject) {
46619                this.$initialize();
46620                this._stateObject = asyncStateObject;
46621                this._isWrite = true;
46622            },
46623            ctor: function (ex, asyncStateObject, isWrite) {
46624                this.$initialize();
46625                this._exceptionInfo = ex;
46626                this._stateObject = asyncStateObject;
46627                this._isWrite = isWrite;
46628            }
46629        },
46630        methods: {
46631            ThrowIfError: function () {
46632                if (this._exceptionInfo != null) {
46633                    throw this._exceptionInfo;
46634                }
46635            }
46636        }
46637    });
46638
46639    // @source TextReader.js
46640
46641    H5.define("System.IO.TextReader", {
46642        inherits: [System.IDisposable],
46643        statics: {
46644            fields: {
46645                Null: null
46646            },
46647            ctors: {
46648                init: function () {
46649                    this.Null = new System.IO.TextReader.NullTextReader();
46650                }
46651            },
46652            methods: {
46653                Synchronized: function (reader) {
46654                    if (reader == null) {
46655                        throw new System.ArgumentNullException.$ctor1("reader");
46656                    }
46657
46658                    return reader;
46659                }
46660            }
46661        },
46662        alias: ["Dispose", "System$IDisposable$Dispose"],
46663        ctors: {
46664            ctor: function () {
46665                this.$initialize();
46666            }
46667        },
46668        methods: {
46669            Close: function () {
46670                this.Dispose$1(true);
46671            },
46672            Dispose: function () {
46673                this.Dispose$1(true);
46674            },
46675            Dispose$1: function (disposing) { },
46676            Peek: function () {
46677
46678                return -1;
46679            },
46680            Read: function () {
46681                return -1;
46682            },
46683            Read$1: function (buffer, index, count) {
46684                if (buffer == null) {
46685                    throw new System.ArgumentNullException.$ctor1("buffer");
46686                }
46687                if (index < 0) {
46688                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
46689                }
46690                if (count < 0) {
46691                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
46692                }
46693                if (((buffer.length - index) | 0) < count) {
46694                    throw new System.ArgumentException.ctor();
46695                }
46696
46697                var n = 0;
46698                do {
46699                    var ch = this.Read();
46700                    if (ch === -1) {
46701                        break;
46702                    }
46703                    buffer[System.Array.index(((index + H5.identity(n, ((n = (n + 1) | 0)))) | 0), buffer)] = ch & 65535;
46704                } while (n < count);
46705                return n;
46706            },
46707            ReadToEndAsync: function () {
46708                return System.Threading.Tasks.Task.fromResult(this.ReadToEnd(), System.String);
46709            },
46710            ReadToEnd: function () {
46711
46712                var chars = System.Array.init(4096, 0, System.Char);
46713                var len;
46714                var sb = new System.Text.StringBuilder("", 4096);
46715                while (((len = this.Read$1(chars, 0, chars.length))) !== 0) {
46716                    sb.append(System.String.fromCharArray(chars, 0, len));
46717                }
46718                return sb.toString();
46719            },
46720            ReadBlock: function (buffer, index, count) {
46721
46722                var i, n = 0;
46723                do {
46724                    n = (n + ((i = this.Read$1(buffer, ((index + n) | 0), ((count - n) | 0))))) | 0;
46725                } while (i > 0 && n < count);
46726                return n;
46727            },
46728            ReadLine: function () {
46729                var sb = new System.Text.StringBuilder();
46730                while (true) {
46731                    var ch = this.Read();
46732                    if (ch === -1) {
46733                        break;
46734                    }
46735                    if (ch === 13 || ch === 10) {
46736                        if (ch === 13 && this.Peek() === 10) {
46737                            this.Read();
46738                        }
46739                        return sb.toString();
46740                    }
46741                    sb.append(String.fromCharCode((ch & 65535)));
46742                }
46743                if (sb.getLength() > 0) {
46744                    return sb.toString();
46745                }
46746                return null;
46747            }
46748        }
46749    });
46750
46751    // @source StreamReader.js
46752
46753    H5.define("System.IO.StreamReader", {
46754        inherits: [System.IO.TextReader],
46755        statics: {
46756            fields: {
46757                DefaultFileStreamBufferSize: 0,
46758                MinBufferSize: 0,
46759                Null: null
46760            },
46761            props: {
46762                DefaultBufferSize: {
46763                    get: function () {
46764                        return 1024;
46765                    }
46766                }
46767            },
46768            ctors: {
46769                init: function () {
46770                    this.DefaultFileStreamBufferSize = 4096;
46771                    this.MinBufferSize = 128;
46772                    this.Null = new System.IO.StreamReader.NullStreamReader();
46773                }
46774            }
46775        },
46776        fields: {
46777            stream: null,
46778            encoding: null,
46779            byteBuffer: null,
46780            charBuffer: null,
46781            charPos: 0,
46782            charLen: 0,
46783            byteLen: 0,
46784            bytePos: 0,
46785            _maxCharsPerBuffer: 0,
46786            _detectEncoding: false,
46787            _isBlocked: false,
46788            _closable: false
46789        },
46790        props: {
46791            CurrentEncoding: {
46792                get: function () {
46793                    return this.encoding;
46794                }
46795            },
46796            BaseStream: {
46797                get: function () {
46798                    return this.stream;
46799                }
46800            },
46801            LeaveOpen: {
46802                get: function () {
46803                    return !this._closable;
46804                }
46805            },
46806            EndOfStream: {
46807                get: function () {
46808                    if (this.stream == null) {
46809                        System.IO.__Error.ReaderClosed();
46810                    }
46811
46812
46813                    if (this.charPos < this.charLen) {
46814                        return false;
46815                    }
46816
46817                    var numRead = this.ReadBuffer();
46818                    return numRead === 0;
46819                }
46820            }
46821        },
46822        ctors: {
46823            ctor: function () {
46824                this.$initialize();
46825                System.IO.TextReader.ctor.call(this);
46826            },
46827            $ctor1: function (stream) {
46828                System.IO.StreamReader.$ctor2.call(this, stream, true);
46829            },
46830            $ctor2: function (stream, detectEncodingFromByteOrderMarks) {
46831                System.IO.StreamReader.$ctor6.call(this, stream, System.Text.Encoding.UTF8, detectEncodingFromByteOrderMarks, System.IO.StreamReader.DefaultBufferSize, false);
46832            },
46833            $ctor3: function (stream, encoding) {
46834                System.IO.StreamReader.$ctor6.call(this, stream, encoding, true, System.IO.StreamReader.DefaultBufferSize, false);
46835            },
46836            $ctor4: function (stream, encoding, detectEncodingFromByteOrderMarks) {
46837                System.IO.StreamReader.$ctor6.call(this, stream, encoding, detectEncodingFromByteOrderMarks, System.IO.StreamReader.DefaultBufferSize, false);
46838            },
46839            $ctor5: function (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) {
46840                System.IO.StreamReader.$ctor6.call(this, stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, false);
46841            },
46842            $ctor6: function (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) {
46843                this.$initialize();
46844                System.IO.TextReader.ctor.call(this);
46845                if (stream == null || encoding == null) {
46846                    throw new System.ArgumentNullException.$ctor1((stream == null ? "stream" : "encoding"));
46847                }
46848                if (!stream.CanRead) {
46849                    throw new System.ArgumentException.ctor();
46850                }
46851                if (bufferSize <= 0) {
46852                    throw new System.ArgumentOutOfRangeException.$ctor1("bufferSize");
46853                }
46854
46855                this.Init$1(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen);
46856            },
46857            $ctor7: function (path) {
46858                System.IO.StreamReader.$ctor8.call(this, path, true);
46859            },
46860            $ctor8: function (path, detectEncodingFromByteOrderMarks) {
46861                System.IO.StreamReader.$ctor11.call(this, path, System.Text.Encoding.UTF8, detectEncodingFromByteOrderMarks, System.IO.StreamReader.DefaultBufferSize);
46862            },
46863            $ctor9: function (path, encoding) {
46864                System.IO.StreamReader.$ctor11.call(this, path, encoding, true, System.IO.StreamReader.DefaultBufferSize);
46865            },
46866            $ctor10: function (path, encoding, detectEncodingFromByteOrderMarks) {
46867                System.IO.StreamReader.$ctor11.call(this, path, encoding, detectEncodingFromByteOrderMarks, System.IO.StreamReader.DefaultBufferSize);
46868            },
46869            $ctor11: function (path, encoding, detectEncodingFromByteOrderMarks, bufferSize) {
46870                System.IO.StreamReader.$ctor12.call(this, path, encoding, detectEncodingFromByteOrderMarks, bufferSize, true);
46871            },
46872            $ctor12: function (path, encoding, detectEncodingFromByteOrderMarks, bufferSize, checkHost) {
46873                this.$initialize();
46874                System.IO.TextReader.ctor.call(this);
46875                if (path == null || encoding == null) {
46876                    throw new System.ArgumentNullException.$ctor1((path == null ? "path" : "encoding"));
46877                }
46878                if (path.length === 0) {
46879                    throw new System.ArgumentException.ctor();
46880                }
46881                if (bufferSize <= 0) {
46882                    throw new System.ArgumentOutOfRangeException.$ctor1("bufferSize");
46883                }
46884
46885                var stream = new System.IO.FileStream.$ctor1(path, 3);
46886                this.Init$1(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, false);
46887            }
46888        },
46889        methods: {
46890            Init$1: function (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) {
46891                this.stream = stream;
46892                this.encoding = encoding;
46893                if (bufferSize < System.IO.StreamReader.MinBufferSize) {
46894                    bufferSize = System.IO.StreamReader.MinBufferSize;
46895                }
46896                this.byteBuffer = System.Array.init(bufferSize, 0, System.Byte);
46897                this._maxCharsPerBuffer = encoding.GetMaxCharCount(bufferSize);
46898                this.charBuffer = System.Array.init(this._maxCharsPerBuffer, 0, System.Char);
46899                this.byteLen = 0;
46900                this.bytePos = 0;
46901                this._detectEncoding = detectEncodingFromByteOrderMarks;
46902                this._isBlocked = false;
46903                this._closable = !leaveOpen;
46904            },
46905            Init: function (stream) {
46906                this.stream = stream;
46907                this._closable = true;
46908            },
46909            Close: function () {
46910                this.Dispose$1(true);
46911            },
46912            Dispose$1: function (disposing) {
46913                try {
46914                    if (!this.LeaveOpen && disposing && (this.stream != null)) {
46915                        this.stream.Close();
46916                    }
46917                } finally {
46918                    if (!this.LeaveOpen && (this.stream != null)) {
46919                        this.stream = null;
46920                        this.encoding = null;
46921                        this.byteBuffer = null;
46922                        this.charBuffer = null;
46923                        this.charPos = 0;
46924                        this.charLen = 0;
46925                        System.IO.TextReader.prototype.Dispose$1.call(this, disposing);
46926                    }
46927                }
46928            },
46929            DiscardBufferedData: function () {
46930
46931                this.byteLen = 0;
46932                this.charLen = 0;
46933                this.charPos = 0;
46934                this._isBlocked = false;
46935            },
46936            Peek: function () {
46937                if (this.stream == null) {
46938                    System.IO.__Error.ReaderClosed();
46939                }
46940
46941                if (this.charPos === this.charLen) {
46942                    if (this._isBlocked || this.ReadBuffer() === 0) {
46943                        return -1;
46944                    }
46945                }
46946                return this.charBuffer[System.Array.index(this.charPos, this.charBuffer)];
46947            },
46948            Read: function () {
46949                if (this.stream == null) {
46950                    System.IO.__Error.ReaderClosed();
46951                }
46952
46953
46954                if (this.charPos === this.charLen) {
46955                    if (this.ReadBuffer() === 0) {
46956                        return -1;
46957                    }
46958                }
46959                var result = this.charBuffer[System.Array.index(this.charPos, this.charBuffer)];
46960                this.charPos = (this.charPos + 1) | 0;
46961                return result;
46962            },
46963            Read$1: function (buffer, index, count) {
46964                if (buffer == null) {
46965                    throw new System.ArgumentNullException.$ctor1("buffer");
46966                }
46967                if (index < 0 || count < 0) {
46968                    throw new System.ArgumentOutOfRangeException.$ctor1((index < 0 ? "index" : "count"));
46969                }
46970                if (((buffer.length - index) | 0) < count) {
46971                    throw new System.ArgumentException.ctor();
46972                }
46973
46974                if (this.stream == null) {
46975                    System.IO.__Error.ReaderClosed();
46976                }
46977
46978
46979                var charsRead = 0;
46980                var readToUserBuffer = { v : false };
46981                while (count > 0) {
46982                    var n = (this.charLen - this.charPos) | 0;
46983                    if (n === 0) {
46984                        n = this.ReadBuffer$1(buffer, ((index + charsRead) | 0), count, readToUserBuffer);
46985                    }
46986                    if (n === 0) {
46987                        break;
46988                    }
46989                    if (n > count) {
46990                        n = count;
46991                    }
46992                    if (!readToUserBuffer.v) {
46993                        System.Array.copy(this.charBuffer, this.charPos, buffer, (((index + charsRead) | 0)), n);
46994                        this.charPos = (this.charPos + n) | 0;
46995                    }
46996                    charsRead = (charsRead + n) | 0;
46997                    count = (count - n) | 0;
46998                    if (this._isBlocked) {
46999                        break;
47000                    }
47001                }
47002
47003                return charsRead;
47004            },
47005            ReadToEndAsync: function () {
47006                var $s = 0,
47007                    $t1, 
47008                    $t2, 
47009                    $tr2, 
47010                    $jff, 
47011                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
47012                    $rv, 
47013                    $ae, 
47014                    $asyncBody = H5.fn.bind(this, function () {
47015                        try {
47016                            for (;;) {
47017                                $s = System.Array.min([0,1,2,3,4], $s
47017);
47018                                switch ($s) {
47019                                    case 0: {
47020                                        if (H5.is(this.stream, System.IO.FileStream)) {
47021                                            $s = 1;
47022                                            continue;
47023                                        } 
47024                                        $s = 3;
47025                                        continue;
47026                                    }
47027                                    case 1: {
47028                                        $t1 = this.stream.EnsureBufferAsync();
47029                                        $s = 2;
47030                                        if ($t1.isCompleted()) {
47031                                            continue;
47032                                        }
47033                                        $t1.continue($asyncBody);
47034                                        return;
47035                                    }
47036                                    case 2: {
47037                                        $t1.getAwaitedResult();
47038                                        $s = 3;
47039                                        continue;
47040                                    }
47041                                    case 3: {
47042                                        $t2 = System.IO.TextReader.prototype.ReadToEndAsync.call(this);
47043                                        $s = 4;
47044                                        if ($t2.isCompleted()) {
47045                                            continue;
47046                                        }
47047                                        $t2.continue($asyncBody);
47048                                        return;
47049                                    }
47050                                    case 4: {
47051                                        $tr2 = $t2.getAwaitedResult();
47052                                        $tcs.setResult($tr2);
47053                                        return;
47054                                    }
47055                                    default: {
47056                                        $tcs.setResult(null);
47057                                        return;
47058                                    }
47059                                }
47060                            }
47061                        } catch($ae1) {
47062                            $ae = System.Exception.create($ae1);
47063                            $tcs.setException($ae);
47064                        }
47065                    }, arguments);
47066
47067                $asyncBody();
47068                return $tcs.task;
47069            },
47070            ReadToEnd: function () {
47071                if (this.stream == null) {
47072                    System.IO.__Error.ReaderClosed();
47073                }
47074
47075                var sb = new System.Text.StringBuilder("", ((this.charLen - this.charPos) | 0));
47076                do {
47077                    sb.append(System.String.fromCharArray(this.charBuffer, this.charPos, ((this.charLen - this.charPos) | 0)));
47078                    this.charPos = this.charLen;
47079                    this.ReadBuffer();
47080                } while (this.charLen > 0);
47081                return sb.toString();
47082            },
47083            ReadBlock: function (buffer, index, count) {
47084                if (buffer == null) {
47085                    throw new System.ArgumentNullException.$ctor1("buffer");
47086                }
47087                if (index < 0 || count < 0) {
47088                    throw new System.ArgumentOutOfRangeException.$ctor1((index < 0 ? "index" : "count"));
47089                }
47090                if (((buffer.length - index) | 0) < count) {
47091                    throw new System.ArgumentException.ctor();
47092                }
47093
47094                if (this.stream == null) {
47095                    System.IO.__Error.ReaderClosed();
47096                }
47097
47098                return System.IO.TextReader.prototype.ReadBlock.call(this, buffer, index, count);
47099            },
47100            CompressBuffer: function (n) {
47101                System.Array.copy(this.byteBuffer, n, this.byteBuffer, 0, ((this.byteLen - n) | 0));
47102                this.byteLen = (this.byteLen - n) | 0;
47103            },
47104            DetectEncoding: function () {
47105                if (this.byteLen < 2) {
47106                    return;
47107                }
47108                this._detectEncoding = false;
47109                var changedEncoding = false;
47110                if (this.byteBuffer[System.Array.index(0, this.byteBuffer)] === 254 && this.byteBuffer[System.Array.index(1, this.byteBuffer)] === 255) {
47111
47112                    this.encoding = new System.Text.UnicodeEncoding.$ctor1(true, true);
47113                    this.CompressBuffer(2);
47114                    changedEncoding = true;
47115                } else if (this.byteBuffer[System.Array.index(0, this.byteBuffer)] === 255 && this.byteBuffer[System.Array.index(1, this.byteBuffer)] === 254) {
47116                    if (this.byteLen < 4 || this.byteBuffer[System.Array.index(2, this.byteBuffer)] !== 0 || this.byteBuffer[System.Array.index(3, this.byteBuffer)] !== 0) {
47117                        this.encoding = new System.Text.UnicodeEncoding.$ctor1(false, true);
47118                        this.CompressBuffer(2);
47119                        changedEncoding = true;
47120                    } else {
47121                        this.encoding = new System.Text.UTF32Encoding.$ctor1(false, true);
47122                        this.CompressBuffer(4);
47123                        changedEncoding = true;
47124                    }
47125                } else if (this.byteLen >= 3 && this.byteBuffer[System.Array.index(0, this.byteBuffer)] === 239 && this.byteBuffer[System.Array.index(1, this.byteBuffer)] === 187 && this.byteBuffer[System.Array.index(2, this.byteBuffer)] === 191) {
47126                    this.encoding = System.Text.Encoding.UTF8;
47127                    this.CompressBuffer(3);
47128                    changedEncoding = true;
47129                } else if (this.byteLen >= 4 && this.byteBuffer[System.Array.index(0, this.byteBuffer)] === 0 && this.byteBuffer[System.Array.index(1, this.byteBuffer)] === 0 && this.byteBuffer[System.Array.index(2, this.byteBuffer)] === 254 && this.byteBuffer[System.Array.index(3, this.byteBuffer)] === 255) {
47130                    this.encoding = new System.Text.UTF32Encoding.$ctor1(true, true);
47131                    this.CompressBuffer(4);
47132                    changedEncoding = true;
47133                } else if (this.byteLen === 2) {
47134                    this._detectEncoding = true;
47135                }
47136
47137                if (changedEncoding) {
47138                    this._maxCharsPerBuffer = this.encoding.GetMaxCharCount(this.byteBuffer.length);
47139                    this.charBuffer = System.Array.init(this._maxCharsPerBuffer, 0, System.Char);
47140                }
47141            },
47142            IsPreamble: function () {
47143                return false;
47144            },
47145            ReadBuffer: function () {
47146                this.charLen = 0;
47147                this.charPos = 0;
47148
47149                this.byteLen = 0;
47150                do {
47151                    this.byteLen = this.stream.Read(this.byteBuffer, 0, this.byteBuffer.length);
47152
47153                    if (this.byteLen === 0) {
47154                        return this.charLen;
47155                    }
47156
47157                    this._isBlocked = (this.byteLen < this.byteBuffer.length);
47158
47159                    if (this.IsPreamble()) {
47160                        continue;
47161                    }
47162
47163                    if (this._detectEncoding && this.byteLen >= 2) {
47164                        this.DetectEncoding();
47165                    }
47166
47167                    this.charLen = (this.charLen + (this.encoding.GetChars$2(this.byteBuffer, 0, this.byteLen, this.charBuffer, this.charLen))) | 0;
47168                } while (this.charLen === 0);
47169                return this.charLen;
47170            },
47171            ReadBuffer$1: function (userBuffer, userOffset, desiredChars, readToUserBuffer) {
47172                this.charLen = 0;
47173                this.charPos = 0;
47174
47175                this.byteLen = 0;
47176
47177                var charsRead = 0;
47178
47179                readToUserBuffer.v = desiredChars >= this._maxCharsPerBuffer;
47180
47181                do {
47182
47183
47184                    this.byteLen = this.stream.Read(this.byteBuffer, 0, this.byteBuffer.length);
47185
47186
47187                    if (this.byteLen === 0) {
47188                        break;
47189                    }
47190
47191                    this._isBlocked = (this.byteLen < this.byteBuffer.length);
47192
47193                    if (this.IsPreamble()) {
47194                        continue;
47195                    }
47196
47197                    if (this._detectEncoding && this.byteLen >= 2) {
47198                        this.DetectEncoding();
47199                        readToUserBuffer.v = desiredChars >= this._maxCharsPerBuffer;
47200                    }
47201
47202                    this.charPos = 0;
47203                    if (readToUserBuffer.v) {
47204                        charsRead = (charsRead + (this.encoding.GetChars$2(this.byteBuffer, 0, this.byteLen, userBuffer, ((userOffset + charsRead) | 0)))) | 0;
47205                        this.charLen = 0;
47206                    } else {
47207                        charsRead = this.encoding.GetChars$2(this.byteBuffer, 0, this.byteLen, this.charBuffer, charsRead);
47208                        this.charLen = (this.charLen + charsRead) | 0;
47209                    }
47210                } while (charsRead === 0);
47211
47212                this._isBlocked = !!(this._isBlocked & charsRead < desiredChars);
47213
47214                return charsRead;
47215            },
47216            ReadLine: function () {
47217                if (this.stream == null) {
47218                    System.IO.__Error.ReaderClosed();
47219                }
47220
47221                if (this.charPos === this.charLen) {
47222                    if (this.ReadBuffer() === 0) {
47223                        return null;
47224                    }
47225                }
47226
47227                var sb = null;
47228                do {
47229                    var i = this.charPos;
47230                    do {
47231                        var ch = this.charBuffer[System.Array.index(i, this.charBuffer)];
47232                        if (ch === 13 || ch === 10) {
47233                            var s;
47234                            if (sb != null) {
47235                                sb.append(System.String.fromCharArray(this.charBuffer, this.charPos, ((i - this.charPos) | 0)));
47236                                s = sb.toString();
47237                            } else {
47238                                s = System.String.fromCharArray(this.charBuffer, this.charPos, ((i - this.charPos) | 0));
47239                            }
47240                            this.charPos = (i + 1) | 0;
47241                            if (ch === 13 && (this.charPos < this.charLen || this.ReadBuffer() > 0)) {
47242                                if (this.charBuffer[System.Array.index(this.charPos, this.charBuffer)] === 10) {
47243                                    this.charPos = (this.charPos + 1) | 0;
47244                                }
47245                            }
47246                            return s;
47247                        }
47248                        i = (i + 1) | 0;
47249                    } while (i < this.charLen);
47250                    i = (this.charLen - this.charPos) | 0;
47251                    if (sb == null) {
47252                        sb = new System.Text.StringBuilder("", ((i + 80) | 0));
47253                    }
47254                    sb.append(System.String.fromCharArray(this.charBuffer, this.charPos, i));
47255                } while (this.ReadBuffer() > 0);
47256                return sb.toString();
47257            }
47258        }
47259    });
47260
47261    // @source NullStreamReader.js
47262
47263    H5.define("System.IO.StreamReader.NullStreamReader", {
47264        inherits: [System.IO.StreamReader],
47265        $kind: "nested class",
47266        props: {
47267            BaseStream: {
47268                get: function () {
47269                    return System.IO.Stream.Null;
47270                }
47271            },
47272            CurrentEncoding: {
47273                get: function () {
47274                    return System.Text.Encoding.Unicode;
47275                }
47276            }
47277        },
47278        ctors: {
47279            ctor: function () {
47280                this.$initialize();
47281                System.IO.StreamReader.ctor.call(this);
47282                this.Init(System.IO.Stream.Null);
47283            }
47284        },
47285        methods: {
47286            Dispose$1: function (disposing) { },
47287            Peek: function () {
47288                return -1;
47289            },
47290            Read: function () {
47291                return -1;
47292            },
47293            Read$1: function (buffer, index, count) {
47294                return 0;
47295            },
47296            ReadLine: function () {
47297                return null;
47298            },
47299            ReadToEnd: function () {
47300                return "";
47301            },
47302            ReadBuffer: function () {
47303                return 0;
47304            }
47305        }
47306    });
47307
47308    // @source TextWriter.js
47309
47310    H5.define("System.IO.TextWriter", {
47311        inherits: [System.IDisposable],
47312        statics: {
47313            fields: {
47314                InitialNewLine: null,
47315                Null: null
47316            },
47317            ctors: {
47318                init: function () {
47319                    this.InitialNewLine = "\r\n";
47320                    this.Null = new System.IO.TextWriter.NullTextWriter();
47321                }
47322            },
47323            methods: {
47324                Synchronized: function (writer) {
47325                    if (writer == null) {
47326                        throw new System.ArgumentNullException.$ctor1("writer");
47327                    }
47328
47329                    return writer;
47330                }
47331            }
47332        },
47333        fields: {
47334            CoreNewLine: null,
47335            InternalFormatProvider: null
47336        },
47337        props: {
47338            FormatProvider: {
47339                get: function () {
47340                    if (this.InternalFormatProvider == null) {
47341                        return System.Globalization.CultureInfo.getCurrentCulture();
47342                    } else {
47343                        return this.InternalFormatProvider;
47344                    }
47345                }
47346            },
47347            NewLine: {
47348                get: function () {
47349                    return System.String.fromCharArray(this.CoreNewLine);
47350                },
47351                set: function (value) {
47352                    if (value == null) {
47353                        value = System.IO.TextWriter.InitialNewLine;
47354                    }
47355                    this.CoreNewLine = System.String.toCharArray(value, 0, value.length);
47356                }
47357            }
47358        },
47359        alias: ["Dispose", "System$IDisposable$Dispose"],
47360        ctors: {
47361            init: function () {
47362                this.CoreNewLine = System.Array.init([13, 10], System.Char);
47363            },
47364            ctor: function () {
47365                this.$initialize();
47366                this.InternalFormatProvider = null;
47367            },
47368            $ctor1: function (formatProvider) {
47369                this.$initialize();
47370                this.InternalFormatProvider = formatProvider;
47371            }
47372        },
47373        methods: {
47374            Close: function () {
47375                this.Dispose$1(true);
47376            },
47377            Dispose$1: function (disposing) { },
47378            Dispose: function () {
47379                this.Dispose$1(true);
47380            },
47381            Flush: function () { },
47382            Write$1: function (value) { },
47383            Write$2: function (buffer) {
47384                if (buffer != null) {
47385                    this.Write$3(buffer, 0, buffer.length);
47386                }
47387            },
47388            Write$3: function (buffer, index, count) {
47389                if (buffer == null) {
47390                    throw new System.ArgumentNullException.$ctor1("buffer");
47391                }
47392                if (index < 0) {
47393                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
47394                }
47395                if (count < 0) {
47396                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
47397                }
47398                if (((buffer.length - index) | 0) < count) {
47399                    throw new System.ArgumentException.ctor();
47400                }
47401
47402                for (var i = 0; i < count; i = (i + 1) | 0) {
47403                    this.Write$1(buffer[System.Array.index(((index + i) | 0), buffer)]);
47404                }
47405            },
47406            Write: function (value) {
47407                this.Write$10(value ? System.Boolean.trueString : System.Boolean.falseString);
47408            },
47409            Write$6: function (value) {
47410                this.Write$10(System.Int32.format(value, "G", this.FormatProvider));
47411            },
47412            Write$15: function (value) {
47413                this.Write$10(System.UInt32.format(value, "G", this.FormatProvider));
47414            },
47415            Write$7: function (value) {
47416                this.Write$10(value.format("G", this.FormatProvider));
47417            },
47418            Write$16: function (value) {
47419                this.Write$10(value.format("G", this.FormatProvider));
47420            },
47421            Write$9: function (value) {
47422                this.Write$10(System.Single.format(value, "G", this.FormatProvider));
47423            },
47424            Write$5: function (value) {
47425                this.Write$10(System.Double.format(value, "G", this.FormatProvider));
47426            },
47427            Write$4: function (value) {
47428                this.Write$10(H5.Int.format(value, "G", this.FormatProvider));
47429            },
47430            Write$10: function (value) {
47431                if (value != null) {
47432                    this.Write$2(System.String.toCharArray(value, 0, value.length));
47433                }
47434            },
47435            Write$8: function (value) {
47436                if (value != null) {
47437                    var f;
47438                    if (((f = H5.as(value, System.IFormattable))) != null) {
47439                        this.Write$10(H5.format(f, null, this.FormatProvider));
47440                    } else {
47441                        this.Write$10(H5.toString(value));
47442                    }
47443                }
47444            },
47445            Write$11: function (format, arg0) {
47446                this.Write$10(System.String.formatProvider(this.FormatProvider, format, [arg0]));
47447            },
47448            Write$12: function (format, arg0, arg1) {
47449                this.Write$10(System.String.formatProvider(this.FormatProvider, format, arg0, arg1));
47450            },
47451            Write$13: function (format, arg0, arg1, arg2) {
47452                this.Write$10(System.String.formatProvider(this.FormatProvider, format, arg0, arg1, arg2));
47453            },
47454            Write$14: function (format, arg) {
47455                if (arg === void 0) { arg = []; }
47456                this.Write$10(System.String.formatProvider.apply(System.String, [this.FormatProvider, format].concat(arg)));
47457            },
47458            WriteLine: function () {
47459                this.Write$2(this.CoreNewLine);
47460            },
47461            WriteLine$2: function (value) {
47462                this.Write$1(value);
47463                this.WriteLine();
47464            },
47465            WriteLine$3: function (buffer) {
47466                this.Write$2(buffer);
47467                this.WriteLine();
47468            },
47469            WriteLine$4: function (buffer, index, count) {
47470                this.Write$3(buffer, index, count);
47471                this.WriteLine();
47472            },
47473            WriteLine$1: function (value) {
47474                this.Write(value);
47475                this.WriteLine();
47476            },
47477            WriteLine$7: function (value) {
47478                this.Write$6(value);
47479                this.WriteLine();
47480            },
47481            WriteLine$16: function (value) {
47482                this.Write$15(value);
47483                this.WriteLine();
47484            },
47485            WriteLine$8: function (value) {
47486                this.Write$7(value);
47487                this.WriteLine();
47488            },
47489            WriteLine$17: function (value) {
47490                this.Write$16(value);
47491                this.WriteLine();
47492            },
47493            WriteLine$10: function (value) {
47494                this.Write$9(value);
47495                this.WriteLine();
47496            },
47497            WriteLine$6: function (value) {
47498                this.Write$5(value);
47499                this.WriteLine();
47500            },
47501            WriteLine$5: function (value) {
47502                this.Write$4(value);
47503                this.WriteLine();
47504            },
47505            WriteLine$11: function (value) {
47506
47507                if (value == null) {
47508                    this.WriteLine();
47509                } else {
47510                    var vLen = value.length;
47511                    var nlLen = this.CoreNewLine.length;
47512                    var chars = System.Array.init(((vLen + nlLen) | 0), 0, System.Char);
47513                    System.String.copyTo(value, 0, chars, 0, vLen);
47514                    if (nlLen === 2) {
47515                        chars[System.Array.index(vLen, chars)] = this.CoreNewLine[System.Array.index(0, this.CoreNewLine)];
47516                        chars[System.Array.index(((vLen + 1) | 0), chars)] = this.CoreNewLine[System.Array.index(1, this.CoreNewLine)];
47517                    } else if (nlLen === 1) {
47518                        chars[System.Array.index(vLen, chars)] = this.CoreNewLine[System.Array.index(0, this.CoreNewLine)];
47519                    } else {
47520                        System.Array.copy(this.CoreNewLine, 0, chars, H5.Int.mul(vLen, 2), H5.Int.mul(nlLen, 2));
47521                    }
47522                    this.Write$3(chars, 0, ((vLen + nlLen) | 0));
47523                }
47524                /* 
47525                Write(value);  // We could call Write(String) on StreamWriter...
47526                WriteLine();
47527                */
47528            },
47529            WriteLine$9: function (value) {
47530                if (value == null) {
47531                    this.WriteLine();
47532                } else {
47533                    var f;
47534                    if (((f = H5.as(value, System.IFormattable))) != null) {
47535                        this.WriteLine$11(H5.format(f, null, this.FormatProvider));
47536                    } else {
47537                        this.WriteLine$11(H5.toString(value));
47538                    }
47539                }
47540            },
47541            WriteLine$12: function (format, arg0) {
47542                this.WriteLine$11(System.String.formatProvider(this.FormatProvider, format, [arg0]));
47543            },
47544            WriteLine$13: function (format, arg0, arg1) {
47545                this.WriteLine$11(System.String.formatProvider(this.FormatProvider, format, arg0, arg1));
47546            },
47547            WriteLine$14: function (format, arg0, arg1, arg2) {
47548                this.WriteLine$11(System.String.formatProvider(this.FormatProvider, format, arg0, arg1, arg2));
47549            },
47550            WriteLine$15: function (format, arg) {
47551                if (arg === void 0) { arg = []; }
47552                this.WriteLine$11(System.String.formatProvider.apply(System.String, [this.FormatProvider, format].concat(arg)));
47553            }
47554        }
47555    });
47556
47557    // @source StreamWriter.js
47558
47559    H5.define("System.IO.StreamWriter", {
47560        inherits: [System.IO.TextWriter],
47561        statics: {
47562            fields: {
47563                DefaultBufferSize: 0,
47564                DefaultFileStreamBufferSize: 0,
47565                MinBufferSize: 0,
47566                Null: null,
47567                _UTF8NoBOM: null
47568            },
47569            props: {
47570                UTF8NoBOM: {
47571                    get: function () {
47572                        if (System.IO.StreamWriter._UTF8NoBOM == null) {
47573                            var noBOM = new System.Text.UTF8Encoding.$ctor2(false, true);
47574                            System.IO.StreamWriter._UTF8NoBOM = noBOM;
47575                        }
47576                        return System.IO.StreamWriter._UTF8NoBOM;
47577                    }
47578                }
47579            },
47580            ctors: {
47581                init: function () {
47582                    this.DefaultBufferSize = 1024;
47583                    this.DefaultFileStreamBufferSize = 4096;
47584                    this.MinBufferSize = 128;
47585                    this.Null = new System.IO.StreamWriter.$ctor4(System.IO.Stream.Null, new System.Text.UTF8Encoding.$ctor2(false, true), System.IO.StreamWriter.MinBufferSize, true);
47586                }
47587            }
47588        },
47589        fields: {
47590            stream: null,
47591            encoding: null,
47592            byteBuffer: null,
47593            charBuffer: null,
47594            charPos: 0,
47595            charLen: 0,
47596            autoFlush: false,
47597            haveWrittenPreamble: false,
47598            closable: false
47599        },
47600        props: {
47601            AutoFlush: {
47602                get: function () {
47603                    return this.autoFlush;
47604                },
47605                set: function (value) {
47606                    this.autoFlush = value;
47607                    if (value) {
47608                        this.Flush$1(true, false);
47609                    }
47610                }
47611            },
47612            BaseStream: {
47613                get: function () {
47614                    return this.stream;
47615                }
47616            },
47617            LeaveOpen: {
47618                get: function () {
47619                    return !this.closable;
47620                }
47621            },
47622            HaveWrittenPreamble: {
47623                set: function (value) {
47624                    this.haveWrittenPreamble = value;
47625                }
47626            },
47627            Encoding: {
47628                get: function () {
47629                    return this.encoding;
47630                }
47631            }
47632        },
47633        ctors: {
47634            ctor: function () {
47635                this.$initialize();
47636                System.IO.TextWriter.$ctor1.call(this, null);
47637            },
47638            $ctor1: function (stream) {
47639                System.IO.StreamWriter.$ctor4.call(this, stream, System.IO.StreamWriter.UTF8NoBOM, System.IO.StreamWriter.DefaultBufferSize, false);
47640            },
47641            $ctor2: function (stream, encoding) {
47642                System.IO.StreamWriter.$ctor4.call(this, stream, encoding, System.IO.StreamWriter.DefaultBufferSize, false);
47643            },
47644            $ctor3: function (stream, encoding, bufferSize) {
47645                System.IO.StreamWriter.$ctor4.call(this, stream, encoding, bufferSize, false);
47646            },
47647            $ctor4: function (stream, encoding, bufferSize, leaveOpen) {
47648                this.$initialize();
47649                System.IO.TextWriter.$ctor1.call(this, null);
47650                if (stream == null || encoding == null) {
47651                    throw new System.ArgumentNullException.$ctor1((stream == null ? "stream" : "encoding"));
47652                }
47653                if (!stream.CanWrite) {
47654                    throw new System.ArgumentException.$ctor1("Argument_StreamNotWritable");
47655                }
47656                if (bufferSize <= 0) {
47657                    throw new System.ArgumentOutOfRangeException.$ctor4("bufferSize", "ArgumentOutOfRange_NeedPosNum");
47658                }
47659
47660                this.Init(stream, encoding, bufferSize, leaveOpen);
47661            },
47662            $ctor5: function (path) {
47663                System.IO.StreamWriter.$ctor8.call(this, path, false, System.IO.StreamWriter.UTF8NoBOM, System.IO.StreamWriter.DefaultBufferSize);
47664            },
47665            $ctor6: function (path, append) {
47666                System.IO.StreamWriter.$ctor8.call(this, path, append, System.IO.StreamWriter.UTF8NoBOM, System.IO.StreamWriter.DefaultBufferSize);
47667            },
47668            $ctor7: function (path, append, encoding) {
47669                System.IO.StreamWriter.$ctor8.call(this, path, append, encoding, System.IO.StreamWriter.DefaultBufferSize);
47670            },
47671            $ctor8: function (path, append, encoding, bufferSize) {
47672                System.IO.StreamWriter.$ctor9.call(this, path, append, encoding, bufferSize, true);
47673            },
47674            $ctor9: function (path, append, encoding, bufferSize, checkHost) {
47675                this.$initialize();
47676                System.IO.TextWriter.$ctor1.call(this, null);
47677                throw new System.NotSupportedException.ctor();
47678            }
47679        },
47680        methods: {
47681            Init: function (streamArg, encodingArg, bufferSize, shouldLeaveOpen) {
47682                this.stream = streamArg;
47683                this.encoding = encodingArg;
47684                if (bufferSize < System.IO.StreamWriter.MinBufferSize) {
47685                    bufferSize = System.IO.StreamWriter.MinBufferSize;
47686                }
47687                this.charBuffer = System.Array.init(bufferSize, 0, System.Char);
47688                this.byteBuffer = System.Array.init(this.encoding.GetMaxByteCount(bufferSize), 0, System.Byte);
47689                this.charLen = bufferSize;
47690                if (this.stream.CanSeek && this.stream.Position.gt(System.Int64(0))) {
47691                    this.haveWrittenPreamble = true;
47692                }
47693                this.closable = !shouldLeaveOpen;
47694            },
47695            Close: function () {
47696                this.Dispose$1(true);
47697            },
47698            Dispose$1: function (disposing) {
47699                try {
47700                    if (this.stream != null) {
47701                        if (disposing) {
47702                            this.Flush$1(true, true);
47703                        }
47704                    }
47705                } finally {
47706                    if (!this.LeaveOpen && this.stream != null) {
47707                        try {
47708                            if (disposing) {
47709                                this.stream.Close();
47710                            }
47711                        } finally {
47712                            this.stream = null;
47713                            this.byteBuffer = null;
47714                            this.charBuffer = null;
47715                            this.encoding = null;
47716                            this.charLen = 0;
47717                            System.IO.TextWriter.prototype.Dispose$1.call(this, disposing);
47718                        }
47719                    }
47720                }
47721            },
47722            Flush: function () {
47723                this.Flush$1(true, true);
47724            },
47725            Flush$1: function (flushStream, flushEncoder) {
47726                if (this.stream == null) {
47727                    System.IO.__Error.WriterClosed();
47728                }
47729
47730                if (this.charPos === 0 && (!flushStream && !flushEncoder)) {
47731                    return;
47732                }
47733
47734                /* if (!haveWrittenPreamble) {
47735                   haveWrittenPreamble = true;
47736                   byte[] preamble = encoding.GetPreamble();
47737                   if (preamble.Length > 0)
47738                       stream.Write(preamble, 0, preamble.Length);
47739                }*/
47740
47741                var count = this.encoding.GetBytes$3(this.charBuffer, 0, this.charPos, this.byteBuffer, 0);
47742                this.charPos = 0;
47743                if (count > 0) {
47744                    this.stream.Write(this.
47744byteBuffer, 0, count);
47745                }
47746                if (flushStream) {
47747                    this.stream.Flush();
47748                }
47749            },
47750            Write$1: function (value) {
47751                if (this.charPos === this.charLen) {
47752                    this.Flush$1(false, false);
47753                }
47754                this.charBuffer[System.Array.index(this.charPos, this.charBuffer)] = value;
47755                this.charPos = (this.charPos + 1) | 0;
47756                if (this.autoFlush) {
47757                    this.Flush$1(true, false);
47758                }
47759            },
47760            Write$2: function (buffer) {
47761                if (buffer == null) {
47762                    return;
47763                }
47764
47765                var index = 0;
47766                var count = buffer.length;
47767                while (count > 0) {
47768                    if (this.charPos === this.charLen) {
47769                        this.Flush$1(false, false);
47770                    }
47771                    var n = (this.charLen - this.charPos) | 0;
47772                    if (n > count) {
47773                        n = count;
47774                    }
47775                    System.Array.copy(buffer, index, this.charBuffer, this.charPos, n);
47776                    this.charPos = (this.charPos + n) | 0;
47777                    index = (index + n) | 0;
47778                    count = (count - n) | 0;
47779                }
47780                if (this.autoFlush) {
47781                    this.Flush$1(true, false);
47782                }
47783            },
47784            Write$3: function (buffer, index, count) {
47785                if (buffer == null) {
47786                    throw new System.ArgumentNullException.$ctor3("buffer", "ArgumentNull_Buffer");
47787                }
47788                if (index < 0) {
47789                    throw new System.ArgumentOutOfRangeException.$ctor4("index", "ArgumentOutOfRange_NeedNonNegNum");
47790                }
47791                if (count < 0) {
47792                    throw new System.ArgumentOutOfRangeException.$ctor4("count", "ArgumentOutOfRange_NeedNonNegNum");
47793                }
47794                if (((buffer.length - index) | 0) < count) {
47795                    throw new System.ArgumentException.$ctor1("Argument_InvalidOffLen");
47796                }
47797
47798                while (count > 0) {
47799                    if (this.charPos === this.charLen) {
47800                        this.Flush$1(false, false);
47801                    }
47802                    var n = (this.charLen - this.charPos) | 0;
47803                    if (n > count) {
47804                        n = count;
47805                    }
47806                    System.Array.copy(buffer, index, this.charBuffer, this.charPos, n);
47807                    this.charPos = (this.charPos + n) | 0;
47808                    index = (index + n) | 0;
47809                    count = (count - n) | 0;
47810                }
47811                if (this.autoFlush) {
47812                    this.Flush$1(true, false);
47813                }
47814            },
47815            Write$10: function (value) {
47816                if (value != null) {
47817                    var count = value.length;
47818                    var index = 0;
47819                    while (count > 0) {
47820                        if (this.charPos === this.charLen) {
47821                            this.Flush$1(false, false);
47822                        }
47823                        var n = (this.charLen - this.charPos) | 0;
47824                        if (n > count) {
47825                            n = count;
47826                        }
47827                        System.String.copyTo(value, index, this.charBuffer, this.charPos, n);
47828                        this.charPos = (this.charPos + n) | 0;
47829                        index = (index + n) | 0;
47830                        count = (count - n) | 0;
47831                    }
47832                    if (this.autoFlush) {
47833                        this.Flush$1(true, false);
47834                    }
47835                }
47836            }
47837        }
47838    });
47839
47840    // @source StringReader.js
47841
47842    H5.define("System.IO.StringReader", {
47843        inherits: [System.IO.TextReader],
47844        fields: {
47845            _s: null,
47846            _pos: 0,
47847            _length: 0
47848        },
47849        ctors: {
47850            ctor: function (s) {
47851                this.$initialize();
47852                System.IO.TextReader.ctor.call(this);
47853                if (s == null) {
47854                    throw new System.ArgumentNullException.$ctor1("s");
47855                }
47856                this._s = s;
47857                this._length = s == null ? 0 : s.length;
47858            }
47859        },
47860        methods: {
47861            Close: function () {
47862                this.Dispose$1(true);
47863            },
47864            Dispose$1: function (disposing) {
47865                this._s = null;
47866                this._pos = 0;
47867                this._length = 0;
47868                System.IO.TextReader.prototype.Dispose$1.call(this, disposing);
47869            },
47870            Peek: function () {
47871                if (this._s == null) {
47872                    System.IO.__Error.ReaderClosed();
47873                }
47874                if (this._pos === this._length) {
47875                    return -1;
47876                }
47877                return this._s.charCodeAt(this._pos);
47878            },
47879            Read: function () {
47880                if (this._s == null) {
47881                    System.IO.__Error.ReaderClosed();
47882                }
47883                if (this._pos === this._length) {
47884                    return -1;
47885                }
47886                return this._s.charCodeAt(H5.identity(this._pos, ((this._pos = (this._pos + 1) | 0))));
47887            },
47888            Read$1: function (buffer, index, count) {
47889                if (buffer == null) {
47890                    throw new System.ArgumentNullException.$ctor1("buffer");
47891                }
47892                if (index < 0) {
47893                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
47894                }
47895                if (count < 0) {
47896                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
47897                }
47898                if (((buffer.length - index) | 0) < count) {
47899                    throw new System.ArgumentException.ctor();
47900                }
47901                if (this._s == null) {
47902                    System.IO.__Error.ReaderClosed();
47903                }
47904
47905                var n = (this._length - this._pos) | 0;
47906                if (n > 0) {
47907                    if (n > count) {
47908                        n = count;
47909                    }
47910                    System.String.copyTo(this._s, this._pos, buffer, index, n);
47911                    this._pos = (this._pos + n) | 0;
47912                }
47913                return n;
47914            },
47915            ReadToEnd: function () {
47916                if (this._s == null) {
47917                    System.IO.__Error.ReaderClosed();
47918                }
47919                var s;
47920                if (this._pos === 0) {
47921                    s = this._s;
47922                } else {
47923                    s = this._s.substr(this._pos, ((this._length - this._pos) | 0));
47924                }
47925                this._pos = this._length;
47926                return s;
47927            },
47928            ReadLine: function () {
47929                if (this._s == null) {
47930                    System.IO.__Error.ReaderClosed();
47931                }
47932                var i = this._pos;
47933                while (i < this._length) {
47934                    var ch = this._s.charCodeAt(i);
47935                    if (ch === 13 || ch === 10) {
47936                        var result = this._s.substr(this._pos, ((i - this._pos) | 0));
47937                        this._pos = (i + 1) | 0;
47938                        if (ch === 13 && this._pos < this._length && this._s.charCodeAt(this._pos) === 10) {
47939                            this._pos = (this._pos + 1) | 0;
47940                        }
47941                        return result;
47942                    }
47943                    i = (i + 1) | 0;
47944                }
47945                if (i > this._pos) {
47946                    var result1 = this._s.substr(this._pos, ((i - this._pos) | 0));
47947                    this._pos = i;
47948                    return result1;
47949                }
47950                return null;
47951            }
47952        }
47953    });
47954
47955    // @source StringWriter.js
47956
47957    H5.define("System.IO.StringWriter", {
47958        inherits: [System.IO.TextWriter],
47959        statics: {
47960            fields: {
47961                m_encoding: null
47962            }
47963        },
47964        fields: {
47965            _sb: null,
47966            _isOpen: false
47967        },
47968        props: {
47969            Encoding: {
47970                get: function () {
47971                    if (System.IO.StringWriter.m_encoding == null) {
47972                        System.IO.StringWriter.m_encoding = new System.Text.UnicodeEncoding.$ctor1(false, false);
47973                    }
47974                    return System.IO.StringWriter.m_encoding;
47975                }
47976            }
47977        },
47978        ctors: {
47979            ctor: function () {
47980                System.IO.StringWriter.$ctor3.call(this, new System.Text.StringBuilder(), System.Globalization.CultureInfo.getCurrentCulture());
47981            },
47982            $ctor1: function (formatProvider) {
47983                System.IO.StringWriter.$ctor3.call(this, new System.Text.StringBuilder(), formatProvider);
47984            },
47985            $ctor2: function (sb) {
47986                System.IO.StringWriter.$ctor3.call(this, sb, System.Globalization.CultureInfo.getCurrentCulture());
47987            },
47988            $ctor3: function (sb, formatProvider) {
47989                this.$initialize();
47990                System.IO.TextWriter.$ctor1.call(this, formatProvider);
47991                if (sb == null) {
47992                    throw new System.ArgumentNullException.$ctor1("sb");
47993                }
47994                this._sb = sb;
47995                this._isOpen = true;
47996            }
47997        },
47998        methods: {
47999            Close: function () {
48000                this.Dispose$1(true);
48001            },
48002            Dispose$1: function (disposing) {
48003                this._isOpen = false;
48004                System.IO.TextWriter.prototype.Dispose$1.call(this, disposing);
48005            },
48006            GetStringBuilder: function () {
48007                return this._sb;
48008            },
48009            Write$1: function (value) {
48010                if (!this._isOpen) {
48011                    System.IO.__Error.WriterClosed();
48012                }
48013                this._sb.append(String.fromCharCode(value));
48014            },
48015            Write$3: function (buffer, index, count) {
48016                if (buffer == null) {
48017                    throw new System.ArgumentNullException.$ctor1("buffer");
48018                }
48019                if (index < 0) {
48020                    throw new System.ArgumentOutOfRangeException.$ctor1("index");
48021                }
48022                if (count < 0) {
48023                    throw new System.ArgumentOutOfRangeException.$ctor1("count");
48024                }
48025                if (((buffer.length - index) | 0) < count) {
48026                    throw new System.ArgumentException.ctor();
48027                }
48028
48029                if (!this._isOpen) {
48030                    System.IO.__Error.WriterClosed();
48031                }
48032
48033                this._sb.append(System.String.fromCharArray(buffer, index, count));
48034            },
48035            Write$10: function (value) {
48036                if (!this._isOpen) {
48037                    System.IO.__Error.WriterClosed();
48038                }
48039                if (value != null) {
48040                    this._sb.append(value);
48041                }
48042            },
48043            toString: function () {
48044                return this._sb.toString();
48045            }
48046        }
48047    });
48048
48049    // @source NullTextReader.js
48050
48051    H5.define("System.IO.TextReader.NullTextReader", {
48052        inherits: [System.IO.TextReader],
48053        $kind: "nested class",
48054        ctors: {
48055            ctor: function () {
48056                this.$initialize();
48057                System.IO.TextReader.ctor.call(this);
48058            }
48059        },
48060        methods: {
48061            Read$1: function (buffer, index, count) {
48062                return 0;
48063            },
48064            ReadLine: function () {
48065                return null;
48066            }
48067        }
48068    });
48069
48070    // @source NullTextWriter.js
48071
48072    H5.define("System.IO.TextWriter.NullTextWriter", {
48073        inherits: [System.IO.TextWriter],
48074        $kind: "nested class",
48075        props: {
48076            Encoding: {
48077                get: function () {
48078                    return System.Text.Encoding.Default;
48079                }
48080            }
48081        },
48082        ctors: {
48083            ctor: function () {
48084                this.$initialize();
48085                System.IO.TextWriter.$ctor1.call(this, System.Globalization.CultureInfo.invariantCulture);
48086            }
48087        },
48088        methods: {
48089            Write$3: function (buffer, index, count) { },
48090            Write$10: function (value) { },
48091            WriteLine: function () { },
48092            WriteLine$11: function (value) { },
48093            WriteLine$9: function (value) { }
48094        }
48095    });
48096
48097    // @source __Error.js
48098
48099    H5.define("System.IO.__Error", {
48100        statics: {
48101            methods: {
48102                EndOfFile: function () {
48103                    throw new System.IO.EndOfStreamException.$ctor1("IO.EOF_ReadBeyondEOF");
48104                },
48105                FileNotOpen: function () {
48106                    throw new System.Exception("ObjectDisposed_FileClosed");
48107                },
48108                StreamIsClosed: function () {
48109                    throw new System.Exception("ObjectDisposed_StreamClosed");
48110                },
48111                MemoryStreamNotExpandable: function () {
48112                    throw new System.NotSupportedException.$ctor1("NotSupported_MemStreamNotExpandable");
48113                },
48114                ReaderClosed: function () {
48115                    throw new System.Exception("ObjectDisposed_ReaderClosed");
48116                },
48117                ReadNotSupported: function () {
48118                    throw new System.NotSupportedException.$ctor1("NotSupported_UnreadableStream");
48119                },
48120                SeekNotSupported: function () {
48121                    throw new System.NotSupportedException.$ctor1("NotSupported_UnseekableStream");
48122                },
48123                WrongAsyncResult: function () {
48124                    throw new System.ArgumentException.$ctor1("Arg_WrongAsyncResult");
48125                },
48126                EndReadCalledTwice: function () {
48127                    throw new System.ArgumentException.$ctor1("InvalidOperation_EndReadCalledMultiple");
48128                },
48129                EndWriteCalledTwice: function () {
48130                    throw new System.ArgumentException.$ctor1("InvalidOperation_EndWriteCalledMultiple");
48131                },
48132                WriteNotSupported: function () {
48133                    throw new System.NotSupportedException.$ctor1("NotSupported_UnwritableStream");
48134                },
48135                WriterClosed: function () {
48136                    throw new System.Exception("ObjectDisposed_WriterClosed");
48137                }
48138            }
48139        }
48140    });
48141
48142    // @source AmbiguousMatchException.js
48143
48144    H5.define("System.Reflection.AmbiguousMatchException", {
48145        inherits: [System.SystemException],
48146        ctors: {
48147            ctor: function () {
48148                this.$initialize();
48149                System.SystemException.$ctor1.call(this, "Ambiguous match found.");
48150                this.HResult = -2147475171;
48151            },
48152            $ctor1: function (message) {
48153                this.$initialize();
48154                System.SystemException.$ctor1.call(this, message);
48155                this.HResult = -2147475171;
48156            },
48157            $ctor2: function (message, inner) {
48158                this.$initialize();
48159                System.SystemException.$ctor2.call(this, message, inner);
48160                this.HResult = -2147475171;
48161            }
48162        }
48163    });
48164
48165    // @source Binder.js
48166
48167    H5.define("System.Reflection.Binder", {
48168        ctors: {
48169            ctor: function () {
48170                this.$initialize();
48171            }
48172        }
48173    });
48174
48175    // @source BindingFlags.js
48176
48177    H5.define("System.Reflection.BindingFlags", {
48178        $kind: "enum",
48179        statics: {
48180            fields: {
48181                Default: 0,
48182                IgnoreCase: 1,
48183                DeclaredOnly: 2,
48184                Instance: 4,
48185                Static: 8,
48186                Public: 16,
48187                NonPublic: 32,
48188                FlattenHierarchy: 64,
48189                InvokeMethod: 256,
48190                CreateInstance: 512,
48191                GetField: 1024,
48192                SetField: 2048,
48193                GetProperty: 4096,
48194                SetProperty: 8192,
48195                PutDispProperty: 16384,
48196                PutRefDispProperty: 32768,
48197                ExactBinding: 65536,
48198                SuppressChangeType: 131072,
48199                OptionalParamBinding: 262144,
48200                IgnoreReturn: 16777216,
48201                DoNotWrapExceptions: 33554432
48202            }
48203        },
48204        $flags: true
48205    });
48206
48207    // @source CallingConventions.js
48208
48209    H5.define("System.Reflection.CallingConventions", {
48210        $kind: "enum",
48211        statics: {
48212            fields: {
48213                Standard: 1,
48214                VarArgs: 2,
48215                Any: 3,
48216                HasThis: 32,
48217                ExplicitThis: 64
48218            }
48219        },
48220        $flags: true
48221    });
48222
48223    // @source ICustomAttributeProvider.js
48224
48225    H5.define("System.Reflection.ICustomAttributeProvider", {
48226        $kind: "interface"
48227    });
48228
48229    // @source InvalidFilterCriteriaException.js
48230
48231    H5.define("System.Reflection.InvalidFilterCriteriaException", {
48232        inherits: [System.ApplicationException],
48233        ctors: {
48234            ctor: function () {
48235                System.Reflection.InvalidFilterCriteriaException.$ctor1.call(this, "Specified filter criteria was invali
48235d.");
48236            },
48237            $ctor1: function (message) {
48238                System.Reflection.InvalidFilterCriteriaException.$ctor2.call(this, message, null);
48239            },
48240            $ctor2: function (message, inner) {
48241                this.$initialize();
48242                System.ApplicationException.$ctor2.call(this, message, inner);
48243                this.HResult = -2146232831;
48244            }
48245        }
48246    });
48247
48248    // @source IReflect.js
48249
48250    H5.define("System.Reflection.IReflect", {
48251        $kind: "interface"
48252    });
48253
48254    // @source MemberTypes.js
48255
48256    H5.define("System.Reflection.MemberTypes", {
48257        $kind: "enum",
48258        statics: {
48259            fields: {
48260                Constructor: 1,
48261                Event: 2,
48262                Field: 4,
48263                Method: 8,
48264                Property: 16,
48265                TypeInfo: 32,
48266                Custom: 64,
48267                NestedType: 128,
48268                All: 191
48269            }
48270        },
48271        $flags: true
48272    });
48273
48274    // @source Module.js
48275
48276    H5.define("System.Reflection.Module", {
48277        inherits: [System.Reflection.ICustomAttributeProvider,System.Runtime.Serialization.ISerializable],
48278        statics: {
48279            fields: {
48280                DefaultLookup: 0,
48281                FilterTypeName: null,
48282                FilterTypeNameIgnoreCase: null
48283            },
48284            ctors: {
48285                init: function () {
48286                    this.DefaultLookup = 28;
48287                    this.FilterTypeName = System.Reflection.Module.FilterTypeNameImpl;
48288                    this.FilterTypeNameIgnoreCase = System.Reflection.Module.FilterTypeNameIgnoreCaseImpl;
48289                }
48290            },
48291            methods: {
48292                FilterTypeNameImpl: function (cls, filterCriteria) {
48293                    if (filterCriteria == null || !(H5.is(filterCriteria, System.String))) {
48294                        throw new System.Reflection.InvalidFilterCriteriaException.$ctor1("A String must be provided for the filter criteria.");
48295                    }
48296
48297                    var str = H5.cast(filterCriteria, System.String);
48298
48299                    if (str.length > 0 && str.charCodeAt(((str.length - 1) | 0)) === 42) {
48300                        str = str.substr(0, ((str.length - 1) | 0));
48301                        return System.String.startsWith(H5.Reflection.getTypeName(cls), str, 4);
48302                    }
48303
48304                    return System.String.equals(H5.Reflection.getTypeName(cls), str);
48305                },
48306                FilterTypeNameIgnoreCaseImpl: function (cls, filterCriteria) {
48307                    var $t;
48308                    if (filterCriteria == null || !(H5.is(filterCriteria, System.String))) {
48309                        throw new System.Reflection.InvalidFilterCriteriaException.$ctor1("A String must be provided for the filter criteria.");
48310                    }
48311
48312                    var str = H5.cast(filterCriteria, System.String);
48313
48314                    if (str.length > 0 && str.charCodeAt(((str.length - 1) | 0)) === 42) {
48315                        str = str.substr(0, ((str.length - 1) | 0));
48316                        var name = H5.Reflection.getTypeName(cls);
48317                        if (name.length >= str.length) {
48318                            return (($t = str.length, System.String.compare(name.substr(0, $t), str.substr(0, $t), 5)) === 0);
48319                        } else {
48320                            return false;
48321                        }
48322                    }
48323                    return (System.String.compare(str, H5.Reflection.getTypeName(cls), 5) === 0);
48324                },
48325                op_Equality: function (left, right) {
48326                    if (H5.referenceEquals(left, right)) {
48327                        return true;
48328                    }
48329
48330                    if (left == null || right == null) {
48331                        return false;
48332                    }
48333
48334                    return left.equals(right);
48335                },
48336                op_Inequality: function (left, right) {
48337                    return !(System.Reflection.Module.op_Equality(left, right));
48338                }
48339            }
48340        },
48341        props: {
48342            Assembly: {
48343                get: function () {
48344                    throw System.NotImplemented.ByDesign;
48345                }
48346            },
48347            FullyQualifiedName: {
48348                get: function () {
48349                    throw System.NotImplemented.ByDesign;
48350                }
48351            },
48352            Name: {
48353                get: function () {
48354                    throw System.NotImplemented.ByDesign;
48355                }
48356            },
48357            MDStreamVersion: {
48358                get: function () {
48359                    throw System.NotImplemented.ByDesign;
48360                }
48361            },
48362            ModuleVersionId: {
48363                get: function () {
48364                    throw System.NotImplemented.ByDesign;
48365                }
48366            },
48367            ScopeName: {
48368                get: function () {
48369                    throw System.NotImplemented.ByDesign;
48370                }
48371            },
48372            MetadataToken: {
48373                get: function () {
48374                    throw System.NotImplemented.ByDesign;
48375                }
48376            }
48377        },
48378        alias: [
48379            "IsDefined", "System$Reflection$ICustomAttributeProvider$IsDef
48379ined",
48380            "GetCustomAttributes", "System$Reflection$ICustomAttributeProvider$GetCustomAttributes",
48381            "GetCustomAttributes$1", "System$Reflection$ICustomAttributeProvider$GetCustomAttributes$1"
48382        ],
48383        ctors: {
48384            ctor: function () {
48385                this.$initialize();
48386            }
48387        },
48388        methods: {
48389            IsResource: function () {
48390                throw System.NotImplemented.ByDesign;
48391            },
48392            IsDefined: function (attributeType, inherit) {
48393                throw System.NotImplemented.ByDesign;
48394            },
48395            GetCustomAttributes: function (inherit) {
48396                throw System.NotImplemented.ByDesign;
48397            },
48398            GetCustomAttributes$1: function (attributeType, inherit) {
48399                throw System.NotImplemented.ByDesign;
48400            },
48401            GetMethod: function (name) {
48402                if (name == null) {
48403                    throw new System.ArgumentNullException.$ctor1("name");
48404                }
48405
48406                return this.GetMethodImpl(name, System.Reflection.Module.DefaultLookup, null, 3, null, null);
48407            },
48408            GetMethod$2: function (name, types) {
48409                return this.GetMethod$1(name, System.Reflection.Module.DefaultLookup, null, 3, types, null);
48410            },
48411            GetMethod$1: function (name, bindingAttr, binder, callConvention, types, modifiers) {
48412                if (name == null) {
48413                    throw new System.ArgumentNullException.$ctor1("name");
48414                }
48415                if (types == null) {
48416                    throw new System.ArgumentNullException.$ctor1("types");
48417                }
48418                for (var i = 0; i < types.length; i = (i + 1) | 0) {
48419                    if (types[System.Array.index(i, types)] == null) {
48420                        throw new System.ArgumentNullException.$ctor1("types");
48421                    }
48422                }
48423                return this.GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
48424            },
48425            GetMethodImpl: function (name, bindingAttr, binder, callConvention, types, modifiers) {
48426                throw System.NotImplemented.ByDesign;
48427            },
48428            GetMethods: function () {
48429                return this.GetMethods$1(System.Reflection.Module.DefaultLookup);
48430            },
48431            GetMethods$1: function (bindingFlags) {
48432                throw System.NotImplemented.ByDesign;
48433            },
48434            GetField: function (name) {
48435                return this.GetField$1(name, System.Reflection.Module.DefaultLookup);
48436            },
48437            GetField$1: function (name, bindingAttr) {
48438                throw System.NotImplemented.ByDesign;
48439            },
48440            GetFields: function () {
48441                return this.GetFields$1(System.Reflection.Module.DefaultLookup);
48442            },
48443            GetFields$1: function (bindingFlags) {
48444                throw System.NotImplemented.ByDesign;
48445            },
48446            GetTypes: function () {
48447                throw System.NotImplemented.ByDesign;
48448            },
48449            GetType: function (className) {
48450                return this.GetType$2(className, false, false);
48451            },
48452            GetType$1: function (className, ignoreCase) {
48453                return this.GetType$2(className, false, ignoreCase);
48454            },
48455            GetType$2: function (className, throwOnError, ignoreCase) {
48456                throw System.NotImplemented.ByDesign;
48457            },
48458            FindTypes: function (filter, filterCriteria) {
48459                var c = this.GetTypes();
48460                var cnt = 0;
48461                for (var i = 0; i < c.length; i = (i + 1) | 0) {
48462                    if (!H5.staticEquals(filter, null) && !filter(c[System.Array.index(i, c)], filterCriteria)) {
48463                        c[System.Array.index(i, c)] = null;
48464                    } else {
48465                        cnt = (cnt + 1) | 0;
48466                    }
48467                }
48468                if (cnt === c.length) {
48469                    return c;
48470                }
48471
48472                var ret = System.Array.init(cnt, null, System.Type);
48473                cnt = 0;
48474                for (var i1 = 0; i1 < c.length; i1 = (i1 + 1) | 0) {
48475                    if (c[System.Array.index(i1, c)] != null) {
48476                        ret[System.Array.index(H5.identity(cnt, ((cnt = (cnt + 1) | 0))), ret)] = c[System.Array.index(i1, c)];
48477                    }
48478                }
48479                return ret;
48480            },
48481            ResolveField: function (metadataToken) {
48482                return this.ResolveField$1(metadataToken, null, null);
48483            },
48484            ResolveField$1: function (metadataToken, genericTypeArguments, genericMethodArguments) {
48485                throw System.NotImplemented.ByDesign;
48486            },
48487            ResolveMember: function (metadataToken) {
48488                return this.ResolveMember$1(metadataToken, null, null);
48489            },
48490            ResolveMember$1: function (metadataToken, genericTypeArguments, genericMethodArguments) {
48491                throw System.NotImplemented.ByDesign;
48492            },
48493            ResolveMethod: function (metadataToken) {
48494                return this.ResolveMethod$1(metadataToken, null, null);
48495            },
48496            ResolveMethod$1: function (metadataToken, genericTypeArguments, genericMethodArguments) {
48497                throw System.NotImplemented.ByDesign;
48498            },
48499            ResolveSignature: function (metadataToken) {
48500                throw System.NotImplemented.ByDesign;
48501            },
48502            ResolveString: function (metadataToken) {
48503                throw System.NotImplemented.ByDesign;
48504            },
48505            ResolveType: function (metadataToken) {
48506                return this.ResolveType$1(metadataToken, null, null);
48507            },
48508            ResolveType$1: function (metadataToken, genericTypeArguments, genericMethodArguments) {
48509                throw System.NotImplemented.ByDesign;
48510            },
48511            equals: function (o) {
48512                return H5.equals(this, o);
48513            },
48514            getHashCode: function () {
48515                return H5.getHashCode(this);
48516            },
48517            toString: function () {
48518                return this.ScopeName;
48519            }
48520        }
48521    });
48522
48523    // @source ParameterModifier.js
48524
48525    H5.define("System.Reflection.ParameterModifier", {
48526        $kind: "struct",
48527        statics: {
48528            methods: {
48529                getDefaultValue: function () { return new System.Reflection.ParameterModifier(); }
48530            }
48531        },
48532        fields: {
48533            _byRef: null
48534        },
48535        ctors: {
48536            $ctor1: function (parameterCount) {
48537                this.$initialize();
48538                if (parameterCount <= 0) {
48539                    throw new System.ArgumentException.$ctor1("Must specify one or more parameters.");
48540                }
48541
48542                this._byRef = System.Array.init(parameterCount, false, System.Boolean);
48543            },
48544            ctor: function () {
48545                this.$initialize();
48546            }
48547        },
48548        methods: {
48549            getItem: function (index) {
48550                return this._byRef[System.Array.index(index, this._byRef)];
48551            },
48552            setItem: function (index, value) {
48553                this._byRef[System.Array.index(index, this._byRef)] = value;
48554            },
48555            getHashCode: function () {
48556                var h = H5.addHash([6723435274, this._byRef]);
48557                return h;
48558            },
48559            equals: function (o) {
48560                if (!H5.is(o, System.Reflection.ParameterModifier)) {
48561                    return false;
48562                }
48563                return H5.equals(this._byRef, o._byRef);
48564            },
48565            $clone: function (to) {
48566                var s = to || new System.Reflection.ParameterModifier();
48567                s._byRef = this._byRef;
48568                return s;
48569            }
48570        }
48571    });
48572
48573    // @source TypeAttributes.js
48574
48575    H5.define("System.Reflection.TypeAttributes", {
48576        $kind: "enum",
48577        statics: {
48578            fields: {
48579                VisibilityMask: 7,
48580                NotPublic: 0,
48581                Public: 1,
48582                NestedPublic: 2,
48583                NestedPrivate: 3,
48584                NestedFamily: 4,
48585                NestedAssembly: 5,
48586                NestedFamANDAssem: 6,
48587                NestedFamORAssem: 7,
48588                LayoutMask: 24,
48589                AutoLayout: 0,
48590                SequentialLayout: 8,
48591                ExplicitLayout: 16,
48592                ClassSemanticsMask: 32,
48593                Class: 0,
48594                Interface: 32,
48595                Abstract: 128,
48596                Sealed: 256,
48597                SpecialName: 1024,
48598                Import: 4096,
48599                Serializable: 8192,
48600                WindowsRuntime: 16384,
48601                StringFormatMask: 196608,
48602                AnsiClass: 0,
48603                UnicodeClass: 65536,
48604                AutoClass: 131072,
48605                CustomFormatClass: 196608,
48606                CustomFormatMask: 12582912,
48607                BeforeFieldInit: 1048576,
48608                RTSpecialName: 2048,
48609                HasSecurity: 262144,
48610                ReservedMask: 264192
48611            }
48612        },
48613        $flags: true
48614    });
48615
48616    // @source Random.js
48617
48618    H5.define("System.Random", {
48619        statics: {
48620            fields: {
48621                MBIG: 0,
48622                MSEED: 0,
48623                MZ: 0
48624            },
48625            ctors: {
48626                init: function () {
48627                    this.MBIG = 2147483647;
48628                    this.MSEED = 161803398;
48629                    this.MZ = 0;
48630                }
48631            }
48632        },
48633        fields: {
48634            inext: 0,
48635            inextp: 0,
48636            SeedArray: null
48637        },
48638        ctors: {
48639            init: function () {
48640                this.SeedArray = System.Array.init(56, 0, System.Int32);
48641            },
48642            ctor: function () {
48643                System.Random.$ctor1.call(this, System.Int64.clip32(System.DateTime.getTicks(System.DateTime.getNow())));
48644            },
48645            $ctor1: function (seed) {
48646                this.$initialize();
48647                var ii;
48648                var mj, mk;
48649
48650                var subtraction = (seed === -2147483648) ? 2147483647 : Math.abs(seed);
48651                mj = (System.Random.MSEED - subtraction) | 0;
48652                this.SeedArray[System.Array.index(55, this.SeedArray)] = mj;
48653                mk = 1;
48654                for (var i = 1; i < 55; i = (i + 1) | 0) {
48655                    ii = (H5.Int.mul(21, i)) % 55;
48656                    this.SeedArray[System.Array.index(ii, this.SeedArray)] = mk;
48657                    mk = (mj - mk) | 0;
48658                    if (mk < 0) {
48659                        mk = (mk + System.Random.MBIG) | 0;
48660                    }
48661                    mj = this.SeedArray[System.Array.index(ii, this.SeedArray)];
48662                }
48663                for (var k = 1; k < 5; k = (k + 1) | 0) {
48664                    for (var i1 = 1; i1 < 56; i1 = (i1 + 1) | 0) {
48665                        this.SeedArray[System.Array.index(i1, this.SeedArray)] = (this.SeedArray[System.Array.index(i1, this.SeedArray)] - this.SeedArray[System.Array.index(((1 + (((i1 + 30) | 0)) % 55) | 0), this.SeedArray)]) | 0;
48666                        if (this.SeedArray[System.Array.index(i1, this.SeedArray)] < 0) {
48667                            this.SeedArray[System.Array.index(i1, this.SeedArray)] = (this.SeedArray[System.Array.index(i1, this.SeedArray)] + System.Random.MBIG) | 0;
48668                        }
48669                    }
48670                }
48671                this.inext = 0;
48672                this.inextp = 21;
48673                seed = 1;
48674            }
48675        },
48676        methods: {
48677            Sample: function () {
48678                return (this.InternalSample() * (4.656612875245797E-10));
48679            },
48680            InternalSample: function () {
48681                var retVal;
48682                var locINext = this.inext;
48683                var locINextp = this.inextp;
48684
48685                if (((locINext = (locINext + 1) | 0)) >= 56) {
48686                    locINext = 1;
48687                }
48688
48689                if (((locINextp = (locINextp + 1) | 0)) >= 56) {
48690                    locINextp = 1;
48691                }
48692
48693                retVal = (this.SeedArray[System.Array.index(locINext, this.SeedArray)] - this.SeedArray[System.Array.index(locINextp, this.SeedArray)]) | 0;
48694
48695                if (retVal === System.Random.MBIG) {
48696                    retVal = (retVal - 1) | 0;
48697                }
48698
48699                if (retVal < 0) {
48700                    retVal = (retVal + System.Random.MBIG) | 0;
48701                }
48702
48703                this.SeedArray[System.Array.index(locINext, this.SeedArray)] = retVal;
48704
48705                this.inext = locINext;
48706                this.inextp = locINextp;
48707
48708                return retVal;
48709            },
48710            Next: function () {
48711                return this.InternalSample();
48712            },
48713            Next$2: function (minValue, maxValue) {
48714                if (minValue > maxValue) {
48715                    throw new System.ArgumentOutOfRangeException.$ctor4("minValue", "'minValue' cannot be greater than maxValue.");
48716                }
48717
48718                var range = System.Int64(maxValue).sub(System.Int64(minValue));
48719                if (range.lte(System.Int64(2147483647))) {
48720                    return (((H5.Int.clip32((this.Sample() * System.Int64.toNumber(range))) + minValue) | 0));
48721                } else {
48722                    return System.Int64.clip32(H5.Int.clip64((this.GetSampleForLargeRange() * System.Int64.toNumber(range))).add(System.Int64(minValue)));
48723                }
48724            },
48725            Next$1: function (maxValue) {
48726                if (maxValue < 0) {
48727                    throw new System.ArgumentOutOfRangeException.$ctor4("maxValue", "'maxValue' must be greater than zero.");
48728                }
48729                return H5.Int.clip32(this.Sample() * maxValue);
48730            },
48731            GetSampleForLargeRange: function () {
48732
48733                var result = this.InternalSample();
48734                var negative = (this.InternalSample() % 2 === 0) ? true : false;
48735                if (negative) {
48736                    result = (-result) | 0;
48737                }
48738                var d = result;
48739                d += (2147483646);
48740                d /= 4294967293;
48741                return d;
48742            },
48743            NextDouble: function () {
48744                return this.Sample();
48745            },
48746            NextBytes: function (buffer) {
48747                if (buffer == null) {
48748                    throw new System.ArgumentNullException.$ctor1("buffer");
48749                }
48750                for (var i = 0; i < buffer.length; i = (i + 1) | 0) {
48751                    buffer[System.Array.index(i, buffer)] = (this.InternalSample() % (256)) & 255;
48752                }
48753            }
48754        }
48755    });
48756
48757    // @source RankException.js
48758
48759    H5.define("System.RankException", {
48760        inherits: [System.SystemException],
48761        ctors: {
48762            ctor: function () {
48763                this.$initialize();
48764                System.SystemException.$ctor1.call(this, "Attempted to operate on an array with the incorrect number of dimensions.");
48765                this.HResult = -2146233065;
48766            },
48767            $ctor1: function (message) {
48768                this.$initialize();
48769                System.SystemException.$ctor1.call(this, message);
48770                this.HResult = -2146233065;
48771            },
48772            $ctor2: function (message, innerException) {
48773                this.$initialize();
48774                System.SystemException.$ctor2.call(this, message, innerException);
48775                this.HResult = -2146233065;
48776            }
48777        }
48778    });
48779
48780    // @source SR.js
48781
48782    H5.define("System.SR", {
48783        statics: {
48784            fields: {
48785                ArgumentException_ValueTupleIncorrectType: null,
48786                ArgumentException_ValueTupleLastArgumentNotAValueTuple: null
48787            },
48788            props: {
48789                ResourceManager: null
48790            },
48791            ctors: {
48792                init: function () {
48793                    this.ArgumentException_ValueTupleIncorrectType = "Argument must be of type {0}.";
48794                    this.ArgumentException_ValueTupleLastArgumentNotAValueTuple = "The last element of an eight element ValueTuple must be a ValueTuple.";
48795                }
48796            },
48797            methods: {
48798                UsingResourceKeys: function () {
48799                    return false;
48800                },
48801                GetResourceString: function (resourceKey) {
48802                    return System.SR.GetResourceString$1(resourceKey, null);
48803                },
48804                GetResourceString$1: function (resourceKey, defaultString) {
48805                    var resourceString = null;
48806                    try {
48807                        resourceString = System.SR.InternalGetResourceString(resourceKey);
48808                    } catch ($e1) {
48809                        $e1 = System.Exception.create($e1);
48810                        if (H5.is($e1, System.Resources.MissingManifestResourceException)) {
48811                        } else {
48812                            throw $e1;
48813                        }
48814                    }
48815
48816                    if (defaultString != null && System.String.equals(resourceKey, resourceString, 4)) {
48817                        return defaultString;
48818                    }
48819
48820                    return resourceString;
48821                },
48822                InternalGetResourceString: function (key) {
48823                    if (key == null || key.length === 0) {
48824                        return key;
48825                    }
48826
48827                    return key;
48828                },
48829                Format$3: function (resourceFormat, args) {
48830                    if (args === void 0) { args = []; }
48831                    if (args != null) {
48832                        if (System.SR.UsingResourceKeys()) {
48833                            return (resourceFormat || "") + ((args).join(", ") || "");
48834                        }
48835
48836                        return System.String.format.apply(System.String, [resourceFormat].concat(args));
48837                    }
48838
48839                    return resourceFormat;
48840                },
48841                Format: function (resourceFormat, p1) {
48842                    if (System.SR.UsingResourceKeys()) {
48843                        return ([resourceFormat, p1]).join(", ");
48844                    }
48845
48846                    return System.String.format(resourceFormat, [p1]);
48847                },
48848                Format$1: function (resourceFormat, p1, p2) {
48849                    if (System.SR.UsingResourceKeys()) {
48850                        return ([resourceFormat, p1, p2]).join(", ");
48851                    }
48852
48853                    return System.String.format(resourceFormat, p1, p2);
48854                },
48855                Format$2: function (resourceFormat, p1, p2, p3) {
48856                    if (System.SR.UsingResourceKeys()) {
48857                        return ([resourceFormat, p1, p2, p3]).join(", ");
48858                    }
48859                    return System.String.format(resourceFormat, p1, p2, p3);
48860                }
48861            }
48862        }
48863    });
48864
48865    // @source StringComparison.js
48866
48867    H5.define("System.StringComparison", {
48868        $kind: "enum",
48869        statics: {
48870            fields: {
48871                CurrentCulture: 0,
48872                CurrentCultureIgnoreCase: 1,
48873                InvariantCulture: 2,
48874                InvariantCultureIgnoreCase: 3,
48875                Ordinal: 4,
48876                OrdinalIgnoreCase: 5
48877            }
48878        }
48879    });
48880
48881    // @source AggregateException.js
48882
48883    H5.define("System.AggregateException", {
48884        inherits: [System.Exception],
48885
48886        ctor: function (message, innerExceptions) {
48887            this.$initialize();
48888            this.innerExceptions = new(System.Collections.ObjectModel.ReadOnlyCollection$1(System.Exception))(H5.hasValue(innerExceptions) ? H5.toArray(innerExceptions) : []);
48889            System.Exception.ctor.call(this, message || 'One or more errors occurred.', this.innerExceptions.Count > 0 ? this.innerExceptions.getItem(0) : null);
48890        },
48891
48892        handle: function (predicate) {
48893            if (!H5.hasValue(predicate)) {
48894                throw new System.ArgumentNullException.$ctor1("predicate");
48895            }
48896
48897            var count = this.innerExceptions.Count,
48898                unhandledExceptions = [];
48899
48900            for (var i = 0; i < count; i++) {
48901                if (!predicate(this.innerExceptions.get(i))) {
48902                    unhandledExceptions.push(this.innerExceptions.getItem(i));
48903                }
48904            }
48905
48906            if (unhandledExceptions.length > 0) {
48907                throw new System.AggregateException(this.Message, unhandledExceptions);
48908            }
48909        },
48910
48911        getBaseException: function () {
48912            var back = this;
48913            var backAsAggregate = this;
48914
48915            while (backAsAggregate != null && backAsAggregate.innerExceptions.Count === 1)
48916            {
48917                back = back.InnerException;
48918                backAsAggregate = H5.as(back, System.AggregateException);
48919            }
48920
48921            return back;
48922        },
48923
48924        hasTaskCanceledException: function () {
48925            for (var i = 0; i < this.innerExceptions.Count; i++) {
48926                var e = this.innerExceptions.getItem(i);
48927                if (H5.is(e, System.Threading.Tasks.TaskCanceledException) || (H5.is(e, System.AggregateException) && e.hasTaskCanceledException())) {
48928                    return true;
48929                }
48930            }
48931            return false;
48932        },
48933
48934        flatten: function () {
48935            // Initialize a collection to contain the flattened exceptions.
48936            var flattenedExceptions = new(System.Collections.Generic.List$1(System.Exception))();
48937
48938            // Create a list to remember all aggregates to be flattened, this will be accessed like a FIFO queue
48939            var exceptionsToFlatten = new(System.Collections.Generic.List$1(System.AggregateException))();
48940            exceptionsToFlatten.add(this);
48941            var nDequeueIndex = 0;
48942
48943            // Continue removing and recursively flattening exceptions, until there are no more.
48944            while (exceptionsToFlatten.Count > nDequeueIndex) {
48945                // dequeue one from exceptionsToFlatten
48946                var currentInnerExceptions = exceptionsToFlatten.getItem(nDequeueIndex++).innerExceptions,
48947                    count = currentInnerExceptions.Count;
48948
48949                for (var i = 0; i < count; i++) {
48950                    var currentInnerException = currentInnerExceptions.getItem(i);
48951
48952                    if (!H5.hasValue(currentInnerException)) {
48953                        continue;
48954                    }
48955
48956                    var currentInnerAsAggregate = H5.as(currentInnerException, System.AggregateException);
48957
48958                    // If this exception is an aggregate, keep it around for later.  Otherwise,
48959                    // simply add it to the list of flattened exceptions to be returned.
48960                    if (H5.hasValue(currentInnerAsAggregate)) {
48961                        exceptionsToFlatten.add(currentInnerAsAggregate);
48962                    } else {
48963                        flattenedExceptions.add(currentInnerException);
48964                    }
48965                }
48966            }
48967
48968            return new System.AggregateException(this.Message, flattenedExceptions);
48969        }
48970    });
48971
48972
48973    // @source PromiseException.js
48974
48975    H5.define("H5.PromiseException", {
48976        inherits: [System.Exception],
48977
48978        ctor: function (args, message, innerException) {
48979            this.$initialize();
48980            this.arguments = System.Array.clone(args);
48981
48982            if (message == null) {
48983                message = "Promise exception: [";
48984                message += this.arguments.map(function (item) { return item == null ? "null" : item.toString(); }).join(", ");
48985                message += "]";
48986            }
48987
48988            System.Exception.ctor.call(this, message, innerException);
48989        },
48990
48991        getArguments: function () {
48992            return this.arguments;
48993        }
48994    });
48995
48996    // @source ThrowHelper.js
48997
48998    H5.define("System.ThrowHelper", {
48999        statics: {
49000            methods: {
49001                ThrowArrayTypeMismatchException: function () {
49002                    throw new System.ArrayTypeMismatchException.ctor();
49003                },
49004                ThrowInvalidTypeWithPointersNotSupported: function (targetType) {
49005                    throw new System.ArgumentException.$ctor1(System.SR.Format("Cannot use type '{0}'. Only value types without pointers or references are supported.", targetType));
49006                },
49007                ThrowIndexOutOfRangeException: function () {
49008                    throw new System.IndexOutOfRangeException.ctor();
49009                },
49010                ThrowArgumentOutOfRangeException: function () {
49011                    throw new System.ArgumentOutOfRangeException.ctor();
49012                },
49013                ThrowArgumentOutOfRangeException$1: function (argument) {
49014                    throw new System.ArgumentOutOfRangeException.$ctor1(System.ThrowHelper.GetArgumentName(argument));
49015                },
49016                ThrowArgumentOutOfRangeException$2: function (argument, resource) {
49017                    throw System.ThrowHelper.GetArgumentOutOfRangeException(argument, resource);
49018                },
49019                ThrowArgumentOutOfRangeException$3: function (argument, paramNumber, resource) {
49020                    throw System.ThrowHelper.GetArgumentOutOfRangeException$1(argument, paramNumber, resource);
49021                },
49022                ThrowArgumentException_DestinationTooShort: function () {
49023                    throw new System.ArgumentException.$ctor1("Destination is too short.");
49024                },
49025                ThrowArgumentException_OverlapAlignmentMismatch: function () {
49026                    throw new System.ArgumentException.$ctor1("Overlapping spans have mismatching alignment.");
49027                },
49028                ThrowArgumentOutOfRange_IndexException: function () {
49029                    throw System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_Index);
49030                },
49031                ThrowIndexArgumentOutOfRange_NeedNonNegNumException: function () {
49032                    throw System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
49033                },
49034                ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum: function () {
49035                    throw System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.$length, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
49036                },
49037                ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index: function () {
49038                    throw System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.startIndex, System.ExceptionResource.ArgumentOutOfRange_Index);
49039                },
49040                ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count: function () {
49041                    throw System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.count, System.ExceptionResource.ArgumentOutOfRange_Count);
49042                },
49043                ThrowWrongKeyTypeArgumentException: function (T, key, targetType) {
49044                    throw System.ThrowHelper.GetWrongKeyTypeArgumentException(key, targetType);
49045                },
49046                ThrowWrongValueTypeArgumentException: function (T, value, targetType) {
49047                    throw System.ThrowHelper.GetWrongValueTypeArgumentException(value, targetType);
49048                },
49049                GetAddingDuplicateWithKeyArgumentException: function (key) {
49050                    return new System.ArgumentException.$ctor1(System.SR.Format("An item with the same key has already been added. Key: {0}", key));
49051                },
49052                ThrowAddingDuplicateWithKeyArgumentException: function (T, key) {
49053                    throw System.ThrowHelper.GetAddingDuplicateWithKeyArgumentException(key);
49054                },
49055                ThrowKeyNotFoundException: function (T, key) {
49056                    throw System.ThrowHelper.GetKeyNotFoundException(key);
49057                },
49058                ThrowArgumentException: function (resource) {
49059                    throw System.ThrowHelper.GetArgumentException(resource);
49060                },
49061                ThrowArgumentException$1: function (resource, argument) {
49062                    throw System.ThrowHelper.GetArgumentException$1(resource, argument);
49063                },
49064                GetArgumentNullException: function (argument) {
49065                    return new System.ArgumentNullException.$ctor1(System.ThrowHelper.GetArgumentName(argument));
49066                },
49067                ThrowArgumentNullException: function (argument) {
49068                    throw System.ThrowHelper.GetArgumentNullException(argument);
49069                },
49070                ThrowArgumentNullException$2: function (resource) {
49071                    throw new System.ArgumentNullException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49072                },
49073                ThrowArgumentNullException$1: function (argument, resource) {
49074                    throw new System.ArgumentNullException.$ctor3(System.ThrowHelper.GetArgumentName(argument), System.ThrowHelper.GetResourceString(resource));
49075                },
49076                ThrowInvalidOperationException: function (resource) {
49077                    throw System.ThrowHelper.GetInvalidOperationException(resource);
49078                },
49079                ThrowInvalidOperationException$1: function (resource, e) {
49080                    throw new System.InvalidOperationException.$ctor2(System.ThrowHelper.GetResourceString(resource), e);
49081                },
49082                ThrowInvalidOperationException_OutstandingReferences: function () {
49083                    System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource.Memory_OutstandingReferences);
49084                },
49085                ThrowSerializationException: function (resource) {
49086                    throw new System.Runtime.Serialization.SerializationException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49087                },
49088                ThrowSecurityException: function (resource) {
49089                    throw new System.Security.SecurityException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49090                },
49091                ThrowRankException: function (resource) {
49092                    throw new System.RankException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49093                },
49094                ThrowNotSupportedException$1: function (resource) {
49095                    throw new System.NotSupportedException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49096                },
49097                ThrowNotSupportedException: function () {
49098                    throw new System.NotSupportedException.ctor();
49099                },
49100                ThrowUnauthorizedAccessException: function (resource) {
49101                    throw new System.UnauthorizedAccessException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49102                },
49103                ThrowObjectDisposedException$1: function (objectName, resource) {
49104                    throw new System.ObjectDisposedException.$ctor3(objectName, System.ThrowHelper.GetResourceString(resource));
49105                },
49106                ThrowObjectDisposedException: function (resource) {
49107                    throw new System.ObjectDisposedException.$ctor3(null, System.ThrowHelper.GetResourceString(resource));
49108                },
49109                ThrowObjectDisposedException_MemoryDisposed: function () {
49110                    throw new System.ObjectDisposedException.$ctor3("OwnedMemory<T>
49110", System.ThrowHelper.GetResourceString(System.ExceptionResource.MemoryDisposed));
49111                },
49112                ThrowAggregateException: function (exceptions) {
49113                    throw new System.AggregateException(null, exceptions);
49114                },
49115                ThrowOutOfMemoryException: function () {
49116                    throw new System.OutOfMemoryException.ctor();
49117                },
49118                ThrowArgumentException_Argument_InvalidArrayType: function () {
49119                    throw System.ThrowHelper.GetArgumentException(System.ExceptionResource.Argument_InvalidArrayType);
49120                },
49121                ThrowInvalidOperationException_InvalidOperation_EnumNotStarted: function () {
49122                    throw System.ThrowHelper.GetInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumNotStarted);
49123                },
49124                ThrowInvalidOperationException_InvalidOperation_EnumEnded: function () {
49125                    throw System.ThrowHelper.GetInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumEnded);
49126                },
49127                ThrowInvalidOperationException_EnumCurrent: function (index) {
49128                    throw System.ThrowHelper.GetInvalidOperationException_EnumCurrent(index);
49129                },
49130                ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion: function () {
49131                    throw System.ThrowHelper.GetInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumFailedVersion);
49132                },
49133                ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen: function () {
49134                    throw System.ThrowHelper.GetInvalidOperationException(System.ExceptionResource.InvalidOperation_EnumOpCantHappen);
49135                },
49136                ThrowInvalidOperationException_InvalidOperation_NoValue: function () {
49137                    throw System.ThrowHelper.GetInvalidOperationException(System.ExceptionResource.InvalidOperation_NoValue);
49138                },
49139                ThrowArraySegmentCtorValidationFailedExceptions: function (array, offset, count) {
49140                    throw System.ThrowHelper.GetArraySegmentCtorValidationFailedException(array, offset, count);
49141                },
49142                GetArraySegmentCtorValidationFailedException: function (array, offset, count) {
49143                    if (array == null) {
49144                        return System.ThrowHelper.GetArgumentNullException(System.ExceptionArgument.array);
49145                    }
49146                    if (offset < 0) {
49147                        return System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.offset, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
49148                    }
49149                    if (count < 0) {
49150                        return System.ThrowHelper.GetArgumentOutOfRangeException(System.ExceptionArgument.count, System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
49151                    }
49152
49153                    return System.ThrowHelper.GetArgumentException(System.ExceptionResource.Argument_InvalidOffLen);
49154                },
49155                GetArgumentException: function (resource) {
49156                    return new System.ArgumentException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49157                },
49158                GetArgumentException$1: function (resource, argument) {
49159                    return new System.ArgumentException.$ctor3(System.ThrowHelper.GetResourceString(resource), System.ThrowHelper.GetArgumentName(argument));
49160                },
49161                GetInvalidOperationException: function (resource) {
49162                    return new System.InvalidOperationException.$ctor1(System.ThrowHelper.GetResourceString(resource));
49163                },
49164                GetWrongKeyTypeArgumentException: function (key, targetType) {
49165                    return new System.ArgumentException.$ctor3(System.SR.Format$1("The value \"{0}\" is not of type \"{1}\" and cannot be used in this generic collection.", key, targetType), "key");
49166                },
49167                GetWrongValueTypeArgumentException: function (value, targetType) {
49168                    return new System.ArgumentException.$ctor3(System.SR.Format$1("The value \"{0}\" is not of type \"{1}\" and cannot be used in this generic collection.", value, targetType), "value");
49169                },
49170                GetKeyNotFoundException: function (key) {
49171                    return new System.Collections.Generic.KeyNotFoundException.$ctor1(System.SR.Format("The given key '{0}' was not present in the dictionary.", H5.toString(key)));
49172                },
49173                GetArgumentOutOfRangeException: function (argument, resource) {
49174                    return new System.ArgumentOutOfRangeException.$ctor4(System.ThrowHelper.GetArgumentName(argument), System.ThrowHelper.GetResourceString(resource));
49175                },
49176                GetArgumentOutOfRangeException$1: function (argument, paramNumber, resource) {
49177                    return new System.ArgumentOutOfRangeException.$ctor4((System.ThrowHelper.GetArgumentName(argument) || "") + "[" + (H5.toString(paramNumber) || "") + "]", System.ThrowHelper.GetResourceString(resource));
49178                },
49179                GetInvalidOperationException_EnumCurrent: function (index) {
49180                    return System.ThrowHelper.GetInvalidOperationException(index < 0 ? System.ExceptionResource.InvalidOperation_EnumNotStarted : System.ExceptionResource.InvalidOperation_EnumEnded);
49181                },
49182                IfNullAndNullsAreIllegalThenThrow: function (T, value, argName) {
49183                    if (!(H5.getDefaultValue(T) == null) && value == null) {
49184                        System.ThrowHelper.ThrowArgumentNullException(argName);
49185                    }
49186                },
49187                GetArgumentName: function (argument) {
49188
49189                    return System.Enum.toString(System.ExceptionArgument, argument);
49190                },
49191                GetResourceString: function (resource) {
49192
49193                    return System.SR.GetResourceString(System.Enum.toString(System.ExceptionResource, resource));
49194                },
49195                ThrowNotSupportedExceptionIfNonNumericType: function (T) {
49196                    if (!H5.referenceEquals(T, System.Byte) && !H5.referenceEquals(T, System.SByte) && !H5.referenceEquals(T, System.Int16) && !H5.referenceEquals(T, System.UInt16) && !H5.referenceEquals(T, System.Int32) && !H5.referenceEquals(T, System.UInt32) && !H5.referenceEquals(T, System.Int64) && !H5.referenceEquals(T, System.UInt64) && !H5.referenceEquals(T, System.Single) && !H5.referenceEquals(T, System.Double)) {
49197                        throw new System.NotSupportedException.$ctor1("Specified type is not supported");
49198                    }
49199                }
49200            }
49201        }
49202    });
49203
49204    // @source TimeoutException.js
49205
49206    H5.define("System.TimeoutException", {
49207        inherits: [System.SystemException],
49208        ctors: {
49209            ctor: function () {
49210                this.$initialize();
49211                System.SystemException.$ctor1.call(this, "The operation has timed out.");
49212                this.HResult = -2146233083;
49213            },
49214            $ctor1: function (message) {
49215                this.$initialize();
49216                System.SystemException.$ctor1.call(this, message);
49217                this.HResult = -2146233083;
49218            },
49219            $ctor2: function (message, innerException) {
49220                this.$initialize();
49221                System.SystemException.$ctor2.call(this, message, innerException);
49222                this.HResult = -2146233083;
49223            }
49224        }
49225    });
49226
49227    // @source RegexMatchTimeoutException.js
49228
49229    H5.define("System.RegexMatchTimeoutException", {
49230        inherits: [System.TimeoutException],
49231
49232        _regexInput: "",
49233
49234        _regexPattern: "",
49235
49236        _matchTimeout: null,
49237
49238        config: {
49239            init: function () {
49240                this._matchTimeout = System.TimeSpan.fromTicks(-1);
49241            }
49242        },
49243
49244        ctor: function (message, innerException, matchTimeout) {
49245            this.$initialize();
49246
49247            if (arguments.length == 3) {
49248                this._regexInput = message;
49249                this._regexPattern = innerException;
49250                this._matchTimeout = matchTimeout;
49251
49252                message = "The RegEx engine has timed out while trying to match a pattern to an input string. This can occur for many reasons, including very large inputs or excessive backtracking caused by nested quantifiers, back-references and other factors.";
49253                innerException = null;
49254            }
49255
49256            System.TimeoutException.ctor.call(this, message, innerException);
49257        },
49258
49259        getPattern: function () {
49260            return this._regexPattern;
49261        },
49262
49263        getInput: function () {
49264            return this._regexInput;
49265        },
49266
49267        getMatchTimeout: function () {
49268            return this._matchTimeout;
49269        }
49270    });
49271
49272    // @source Encoding.js
49273
49274    H5.define("System.Text.Encoding", {
49275        statics: {
49276            fields: {
49277                _encodings: null
49278            },
49279            props: {
49280                Default: null,
49281                Unicode: null,
49282                ASCII: null,
49283                BigEndianUnicode: null,
49284                UTF7: null,
49285                UTF8: null,
49286                UTF32: null
49287            },
49288            ctors: {
49289                init: function () {
49290                    this.Default = new System.Text.UnicodeEncoding.$ctor1(false, true);
49291                    this.Unicode = new System.Text.UnicodeEncoding.$ctor1(false, true);
49292                    this.ASCII = new System.Text.ASCIIEncoding();
49293                    this.BigEndianUnicode = new System.Text.UnicodeEncoding.$ctor1(true, true);
49294                    this.UTF7 = new System.Text.UTF7Encoding.ctor();
49295                    this.UTF8 = new System.Text.UTF8Encoding.ctor();
49296                    this.UTF32 = new System.Text.UTF32Encoding.$ctor1(false, true);
49297                }
49298            },
49299            methods: {
49300                Convert: function (srcEncoding, dstEncoding, bytes) {
49301                    return System.Text.Encoding.Convert$1(srcEncoding, dstEncoding, bytes, 0, bytes.length);
49302                },
49303                Convert$1: function (srcEncoding, dstEncoding, bytes, index, count) {
49304                    if (srcEncoding == null || dstEncoding == null) {
49305                        throw new System.ArgumentNullException.$ctor1(srcEncoding == null ? "srcEncoding" : "dstEncoding");
49306                    }
49307
49308                    if (bytes == null) {
49309                        throw new System.ArgumentNullException.$ctor1("bytes");
49310                    }
49311
49312                    return dstEncoding.GetBytes(srcEncoding.GetChars$1(bytes, index, count));
49313                },
49314                GetEncoding: function (codepage) {
49315                    switch (codepage) {
49316                        case 1200: 
49317                            return System.Text.Encoding.Unicode;
49318                        case 20127: 
49319                            return System.Text.Encoding.ASCII;
49320                        case 1201: 
49321                            return System.Text.Encoding.BigEndianUnicode;
49322                        case 65000: 
49323                            return System.Text.Encoding.UTF7;
49324                        case 65001: 
49325                            return System.Text.Encoding.UTF8;
49326                        case 12000: 
49327                            return System.Text.Encoding.UTF32;
49328                    }
49329                    throw new System.NotSupportedException.ctor();
49330                },
49331                GetEncoding$1: function (codepage) {
49332                    switch (codepage) {
49333                        case "utf-16": 
49334                            return System.Text.Encoding.Unicode;
49335                        case "us-ascii": 
49336                            return System.Text.Encoding.ASCII;
49337                        case "utf-16BE": 
49338                            return System.Text.Encoding.BigEndianUnicode;
49339                        case "utf-7": 
49340                            return System.Text.Encoding.UTF7;
49341                        case "utf-8": 
49342                            return System.Text.Encoding.UTF8;
49343                        case "utf-32": 
49344                            return System.Text.Encoding.UTF32;
49345                    }
49346                    throw new System.NotSupportedException.ctor();
49347                },
49348                GetEncodings: function () {
49349                    if (System.Text.Encoding._encodings != null) {
49350                        return System.Text.Encoding._encodings;
49351                    }
49352                    System.Text.Encoding._encodings = System.Array.init(6, null, System.Text.EncodingInfo);
49353                    var result = System.Text.Encoding._encodings;
49354
49355                    result[System.Array.index(0, result)] = new System.Text.EncodingInfo(20127, "us-ascii", "US-ASCII");
49356                    result[System.Array.index(1, result)] = new System.Text.EncodingInfo(1200, "utf-16", "Unicode");
49357                    result[System.Array.index(2, result)] = new System.Text.EncodingInfo(1201, "utf-16BE", "Unicode (Big-Endian)");
49358                    result[System.Array.index(3, result)] = new System.Text.EncodingInfo(65000, "utf-7", "
49358Unicode (UTF-7)");
49359                    result[System.Array.index(4, result)] = new System.Text.EncodingInfo(65001, "utf-8", "Unicode (UTF-8)");
49360                    result[System.Array.index(5, result)] = new System.Text.EncodingInfo(1200, "utf-32", "Unicode (UTF-32)");
49361                    return result;
49362                }
49363            }
49364        },
49365        fields: {
49366            _hasError: false,
49367            fallbackCharacter: 0
49368        },
49369        props: {
49370            CodePage: {
49371                get: function () {
49372                    return 0;
49373                }
49374            },
49375            EncodingName: {
49376                get: function () {
49377                    return null;
49378                }
49379            }
49380        },
49381        ctors: {
49382            init: function () {
49383                this.fallbackCharacter = 63;
49384            }
49385        },
49386        methods: {
49387            Encode$1: function (chars, index, count) {
49388                var writtenCount = { };
49389                return this.Encode$3(System.String.fromCharArray(chars, index, count), null, 0, writtenCount);
49390            },
49391            Encode$5: function (s, index, count, outputBytes, outputIndex) {
49392                var writtenBytes = { };
49393                this.Encode$3(s.substr(index, count), outputBytes, outputIndex, writtenBytes);
49394                return writtenBytes.v;
49395            },
49396            Encode$4: function (chars, index, count, outputBytes, outputIndex) {
49397                var writtenBytes = { };
49398                this.Encode$3(System.String.fromCharArray(chars, index, count), outputBytes, outputIndex, writtenBytes);
49399                return writtenBytes.v;
49400            },
49401            Encode: function (chars) {
49402                var count = { };
49403                return this.Encode$3(System.String.fromCharArray(chars), null, 0, count);
49404            },
49405            Encode$2: function (str) {
49406                var count = { };
49407                return this.Encode$3(str, null, 0, count);
49408            },
49409            Decode$1: function (bytes, index, count) {
49410                return this.Decode$2(bytes, index, count, null, 0);
49411            },
49412            Decode: function (bytes) {
49413                return this.Decode$2(bytes, 0, bytes.length, null, 0);
49414            },
49415            GetByteCount: function (chars) {
49416                return this.GetByteCount$1(chars, 0, chars.length);
49417            },
49418            GetByteCount$2: function (s) {
49419                return this.Encode$2(s).length;
49420            },
49421            GetByteCount$1: function (chars, index, count) {
49422                return this.Encode$1(chars, index, count).length;
49423            },
49424            GetBytes: function (chars) {
49425                return this.GetBytes$1(chars, 0, chars.length);
49426            },
49427            GetBytes$1: function (chars, index, count) {
49428                return this.Encode$2(System.String.fromCharArray(chars, index, count));
49429            },
49430            GetBytes$3: function (chars, charIndex, charCount, bytes, byteIndex) {
49431                return this.Encode$4(chars, charIndex, charCount, bytes, byteIndex);
49432            },
49433            GetBytes$2: function (s) {
49434                return this.Encode$2(s);
49435            },
49436            GetBytes$4: function (s, charIndex, charCount, bytes, byteIndex) {
49437                return this.Encode$5(s, charIndex, charCount, bytes, byteIndex);
49438            },
49439            GetCharCount: function (bytes) {
49440                return this.Decode(bytes).length;
49441            },
49442            GetCharCount$1: function (bytes, index, count) {
49443                return this.Decode$1(bytes, index, count).length;
49444            },
49445            GetChars: function (bytes) {
49446                var $t;
49447                return ($t = this.Decode(bytes), System.String.toCharArray($t, 0, $t.length));
49448            },
49449            GetChars$1: function (bytes, index, count) {
49450                var $t;
49451                return ($t = this.Decode$1(bytes, index, count), System.String.toCharArray($t, 0, $t.length));
49452            },
49453            GetChars$2: function (bytes, byteIndex, byteCount, chars, charIndex) {
49454                var s = this.Decode$1(bytes, byteIndex, byteCount);
49455                var arr = System.String.toCharArray(s, 0, s.length);
49456
49457                if (chars.length < (((arr.length + charIndex) | 0))) {
49458                    throw new System.ArgumentException.$ctor3(null, "chars");
49459                }
49460
49461                for (var i = 0; i < arr.length; i = (i + 1) | 0) {
49462                    chars[System.Array.index(((charIndex + i) | 0), chars)] = arr[System.Array.index(i, arr)];
49463                }
49464
49465                return arr.length;
49466            },
49467            GetString: function (bytes) {
49468                return this.Decode(bytes);
49469            },
49470            GetString$1: function (bytes, index, count) {
49471                return this.Decode$1(bytes, index, count);
49472            }
49473        }
49474    });
49475
49476    // @source ASCIIEncoding.js
49477
49478    H5.define("System.Text.ASCIIEncoding", {
49479        inherits: [System.Text.Encoding],
49480        props: {
49481            CodePage: {
49482                get: function () {
49483                    return 20127;
49484                }
49485            },
49486            EncodingName: {
49487                get: function () {
49488                    return "US-ASCII";
49489                }
49490            }
49491        },
49492        methods: {
49493            Encode$3: function (s, outputBytes, outputIndex, writtenBytes) {
49494                var hasBuffer = outputBytes != null;
49495
49496                if (!hasBuffer) {
49497                    outputBytes = System.Array.init(0, 0, System.Byte);
49498                }
49499
49500                var recorded = 0;
49501                for (var i = 0; i < s.length; i = (i + 1) | 0) {
49502                    var ch = s.charCodeAt(i);
49503                    var byteCode = (ch <= 127 ? ch : this.fallbackCharacter) & 255;
49504
49505                    if (hasBuffer) {
49506                        if ((((i + outputIndex) | 0)) >= outputBytes.length) {
49507                            throw new System.ArgumentException.$ctor1("bytes");
49508                        }
49509                        outputBytes[System.Array.index(((i + outputIndex) | 0), outputBytes)] = byteCode;
49510                    } else {
49511                        outputBytes.push(byteCode);
49512                    }
49513                    recorded = (recorded + 1) | 0;
49514                }
49515
49516                writtenBytes.v = recorded;
49517
49518                if (hasBuffer) {
49519                    return null;
49520                }
49521
49522                return outputBytes;
49523            },
49524            Decode$2: function (bytes, index, count, chars, charIndex) {
49525                var position = index;
49526                var result = "";
49527                var endpoint = (position + count) | 0;
49528
49529                for (; position < endpoint; position = (position + 1) | 0) {
49530                    var byteCode = bytes[System.Array.index(position, bytes)];
49531
49532                    if (byteCode > 127) {
49533                        result = (result || "") + String.fromCharCode(this.fallbackCharacter);
49534                    } else {
49535                        result = (result || "") + ((String.fromCharCode(byteCode)) || "");
49536                    }
49537                }
49538
49539                return result;
49540            },
49541            GetMaxByteCount: function (charCount) {
49542                if (charCount < 0) {
49543                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
49544                }
49545
49546                var byteCount = System.Int64(charCount).add(System.Int64(1));
49547
49548                if (byteCount.gt(System.Int64(2147483647))) {
49549                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
49550                }
49551
49552                return System.Int64.clip32(byteCount);
49553            },
49554            GetMaxCharCount: function (byteCount) {
49555                if (byteCount < 0) {
49556                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
49557                }
49558
49559                var charCount = System.Int64(byteCount);
49560
49561                if (charCount.gt(System.Int64(2147483647))) {
49562                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
49563                }
49564
49565                return System.Int64.clip32(charCount);
49566            }
49567        }
49568    });
49569
49570    // @source EncodingInfo.js
49571
49572    H5.define("System.Text.EncodingInfo", {
49573        props: {
49574            CodePage: 0,
49575            Name: null,
49576            DisplayName: null
49577        },
49578        ctors: {
49579            ctor: function (codePage, name, displayName) {
49580                var $t;
49581                this.$initialize();
49582                this.CodePage = codePage;
49583                this.Name = name;
49584                this.DisplayName = ($t = displayName, $t != null ? $t : name);
49585            }
49586        },
49587        methods: {
49588            GetEncoding: function () {
49589                return System.Text.Encoding.GetEncoding(this.CodePage);
49590            },
49591            getHashCode: function () {
49592                return this.CodePage;
49593            },
49594            equals: function (o) {
49595                var that = H5.as(o, System.Text.EncodingInfo);
49596                return System.Nullable.eq(this.CodePage, (that != null ? that.CodePage : null));
49597            }
49598        }
49599    });
49600
49601    // @source UnicodeEncoding.js
49602
49603    H5.define("System.Text.UnicodeEncoding", {
49604        inherits: [System.Text.Encoding],
49605        fields: {
49606            bigEndian: false,
49607            byteOrderMark: false,
49608            throwOnInvalid: false
49609        },
49610        props: {
49611            CodePage: {
49612                get: function () {
49613                    return this.bigEndian ? 1201 : 1200;
49614                }
49615            },
49616            EncodingName: {
49617                get: function () {
49618                    return this.bigEndian ? "Unicode (Big-Endian)" : "Unicode";
49619                }
49620            }
49621        },
49622        ctors: {
49623            ctor: function () {
49624                System.Text.UnicodeEncoding.$ctor1.call(this, false, true);
49625            },
49626            $ctor1: function (bigEndian, byteOrderMark) {
49627                System.Text.UnicodeEncoding.$ctor2.call(this, bigEndian, byteOrderMark, false);
49628            },
49629            $ctor2: function (bigEndian, byteOrderMark, throwOnInvalidBytes) {
49630                this.$initialize();
49631                System.Text.Encoding.ctor.call(this);
49632                this.bigEndian = bigEndian;
49633                this.byteOrderMark = byteOrderMark;
49634                this.throwOnInvalid = throwOnInvalidBytes;
49635                this.fallbackCharacter = 65533;
49636            }
49637        },
49638        methods: {
49639            Encode$3: function (s, outputBytes, outputIndex, writtenBytes) {
49640                var hasBuffer = outputBytes != null;
49641                var recorded = 0;
49642                var surrogate_1st = 0;
49643                var fallbackCharacterCode = this.fallbackCharacter;
49644
49645                var write = function (ch) {
49646                    if (hasBuffer) {
49647                        if (outputIndex >= outputBytes.length) {
49648                            throw new System.ArgumentException.$ctor1("bytes");
49649                        }
49650
49651                        outputBytes[System.Array.index(H5.identity(outputIndex, ((outputIndex = (outputIndex + 1) | 0))), outputBytes)] = ch;
49652                    } else {
49653                        outputBytes.push(ch);
49654                    }
49655                    recorded = (recorded + 1) | 0;
49656                };
49657
49658                var writePair = function (a, b) {
49659                    write(a);
49660                    write(b);
49661                };
49662
49663                var swap = $asm.$.System.Text.UnicodeEncoding.f1;
49664
49665                var fallback = H5.fn.bind(this, function () {
49666                    if (this.throwOnInvalid) {
49667                        throw new System.Exception("Invalid character in UTF16 text");
49668                    }
49669
49670                    writePair((fallbackCharacterCode & 255), ((fallbackCharacterCode >> 8) & 255));
49671                });
49672
49673                if (!hasBuffer) {
49674                    outputBytes = System.Array.init(0, 0, System.Byte);
49675                }
49676
49677                if (this.bigEndian) {
49678                    fallbackCharacterCode = swap(fallbackCharacterCode);
49679                }
49680
49681                for (var i = 0; i < s.length; i = (i + 1) | 0) {
49682                    var ch = s.charCodeAt(i);
49683
49684                    if (surrogate_1st !== 0) {
49685                        if (ch >= 56320 && ch <= 57343) {
49686                            if (this.bigEndian) {
49687                                surrogate_1st = swap(surrogate_1st);
49688                                ch = swap(ch);
49689                            }
49690                            writePair((surrogate_1st & 255), ((surrogate_1st >> 8) & 255));
49691                            writePair((ch & 255), ((ch >> 8) & 255));
49692                            surrogate_1st = 0;
49693                            continue;
49694                        }
49695                        fallback();
49696                        surrogate_1st = 0;
49697                    }
49698
49699                    if (55296 <= ch && ch <= 56319) {
49700                        surrogate_1st = ch;
49701                        continue;
49702                    } else if (56320 <= ch && ch <= 57343) {
49703                        fallback();
49704                        surrogate_1st = 0;
49705                        continue;
49706                    }
49707
49708                    if (ch < 65536) {
49709                        if (this.bigEndian) {
49710                            ch = swap(ch);
49711                        }
49712                        writePair((ch & 255), ((ch >> 8) & 255));
49713                    } else if (ch <= 1114111) {
49714                        ch = ch - 0x10000;
49715
49716                        var lowBits = ((ch & 1023) | 56320) & 65535;
49717                        var highBits = (((ch >> 10) & 1023) | 55296) & 65535;
49718
49719                        if (this.bigEndian) {
49720                            highBits = swap(highBits);
49721                            lowBits = swap(lowBits);
49722                        }
49723                        writePair((highBits & 255), ((highBits >> 8) & 255));
49724                        writePair((lowBits & 255), ((lowBits >> 8) & 255));
49725                    } else {
49726                        fallback();
49727                    }
49728                }
49729
49730                if (surrogate_1st !== 0) {
49731                    fallback();
49732                }
49733
49734                writtenBytes.v = recorded;
49735
49736                if (hasBuffer) {
49737                    return null;
49738                }
49739
49740                return outputBytes;
49741            },
49742            Decode$2: function (bytes, index, count, chars, charIndex) {
49743                var position = index;
49744                var result = "";
49745                var endpoint = (position + count) | 0;
49746                this._hasError = false;
49747
49748                var fallback = H5.fn.bind(this, function () {
49749                    if (this.throwOnInvalid) {
49750                        throw new System.Exception("Invalid character in UTF16 text");
49751                    }
49752
49753                    result = (result || "") + String.fromCharCode(this.fallbackCharacter);
49754                });
49755
49756                var swap = $asm.$.System.Text.UnicodeEncoding.f2;
49757
49758                var readPair = H5.fn.bind(this, function () {
49759                    if ((((position + 2) | 0)) > endpoint) {
49760                        position = (position + 2) | 0;
49761                        return null;
49762                    }
49763
49764                    var a = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
49765                    var b = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
49766
49767                    var point = ((a << 8) | b) & 65535;
49768                    if (!this.bigEndian) {
49769                        point = swap(point);
49770                    }
49771
49772                    return point;
49773                });
49774
49775                while (position < endpoint) {
49776                    var firstWord = readPair();
49777
49778                    if (!System.Nullable.hasValue(firstWord)) {
49779                        fallback();
49780                        this._hasError = true;
49781                    } else if ((System.Nullable.lt(firstWord, 55296)) || (System.Nullable.gt(firstWord, 57343))) {
49782                        result = (result || "") + ((System.String.fromCharCode(System.Nullable.getValue(firstWord))) || "");
49783                    } else if ((System.Nullable.gte(firstWord, 55296)) && (System.Nullable.lte(firstWord, 56319))) {
49784                        var end = position >= endpoint;
49785                        var secondWord = readPair();
49786                        if (end) {
49787                            fallback();
49788                            this._hasError = true;
49789                        } else if (!System.Nullable.hasValue(secondWord)) {
49790                            fallback();
49791                            fallback();
49792                        } else if ((System.Nullable.gte(secondWord, 56320)) && (System.Nullable.lte(secondWord, 57343))) {
49793                            var highBits = System.Nullable.band(firstWord, 1023);
49794                            var lowBits = System.Nullable.band(secondWord, 1023);
49795
49796                            var charCode = H5.Int.clip32(System.Nullable.add((System.Nullable.bor((System.Nullable.sl(highBits, 10)), lowBits)), 65536));
49797
49798                            result = (result || "") + ((System.String.fromCharCode(System.Nullable.getValue(charCode))) || "");
49799                        } else {
49800                            fallback();
49801                            position = (position - 2) | 0;
49802                        }
49803                    } else {
49804                        fallback();
49805                    }
49806                }
49807
49808                return result;
49809            },
49810            GetMaxByteCount: function (charCount) {
49811                if (charCount < 0) {
49812                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
49813                }
49814
49815                var byteCount = System.Int64(charCount).add(System.Int64(1));
49816                byteCount = byteCount.shl(1);
49817
49818                if (byteCount.gt(System.Int64(2147483647))) {
49819                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
49820                }
49821
49822                return System.Int64.clip32(byteCount);
49823            },
49824            GetMaxCharCount: function (byteCount) {
49825                if (byteCount < 0) {
49826                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
49827                }
49828
49829                var charCount = System.Int64((byteCount >> 1)).add(System.Int64((byteCount & 1))).add(System.Int64(1));
49830
49831                if (charCount.gt(System.Int64(2147483647))) {
49832                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
49833                }
49834
49835                return System.Int64.clip32(charCount);
49836            }
49837        }
49838    });
49839
49840    H5.ns("System.Text.UnicodeEncoding", $asm.$);
49841
49842    H5.apply($asm.$.System.Text.UnicodeEncoding, {
49843        f1: function (ch) {
49844            return ((((ch & 255) << 8) | ((ch >> 8) & 255)) & 65535);
49845        },
49846        f2: function (ch) {
49847            return ((((ch & 255) << 8) | (((ch >> 8)) & 255)) & 65535);
49848        }
49849    });
49850
49851    // @source UTF32Encoding.js
49852
49853    H5.define("System.Text.UTF32Encoding", {
49854        inherits: [System.Text.Encoding],
49855        fields: {
49856            bigEndian: false,
49857            byteOrderMark: false,
49858            throwOnInvalid: false
49859        },
49860        props: {
49861            CodePage: {
49862                get: function () {
49863                    return this.bigEndian ? 1201 : 1200;
49864                }
49865            },
49866            EncodingName: {
49867                get: function () {
49868                    return this.bigEndian ? "Unicode (UTF-32 Big-Endian)" : "Unicode (UTF-32)";
49869                }
49870            }
49871        },
49872        ctors: {
49873            ctor: function () {
49874                System.Text.UTF32Encoding.$ctor2.call(this, false, true, false);
49875            },
49876            $ctor1: function (bigEndian, byteOrderMark) {
49877                System.Text.UTF32Encoding.$ctor2.call(this, bigEndian, byteOrderMark, false);
49878            },
49879            $ctor2: function (bigEndian, byteOrderMark, throwOnInvalidBytes) {
49880                this.$initialize();
49881                System.Text.Encoding.ctor.call(this);
49882                this.bigEndian = bigEndian;
49883                this.byteOrderMark = byteOrderMark;
49884                this.throwOnInvalid = throwOnInvalidBytes;
49885                this.fallbackCharacter = 65533;
49886            }
49887        },
49888        methods: {
49889            ToCodePoints: function (str) {
49890                var surrogate_1st = 0;
49891                var unicode_codes = System.Array.init(0, 0, System.Char);
49892                var fallback = H5.fn.bind(this, function () {
49893                    if (this.throwOnInvalid) {
49894                        throw new System.Exception("Invalid character in UTF32 text");
49895                    }
49896                    unicode_codes.push(this.fallbackCharacter);
49897                });
49898
49899                for (var i = 0; i < str.length; i = (i + 1) | 0) {
49900                    var utf16_code = str.charCodeAt(i);
49901
49902                    if (surrogate_1st !== 0) {
49903                        if (utf16_code >= 56320 && utf16_code <= 57343) {
49904                            var surrogate_2nd = utf16_code;
49905                            var unicode_code = (((H5.Int.mul((((surrogate_1st - 55296) | 0)), (1024)) + (65536)) | 0) + (((surrogate_2nd - 56320) | 0))) | 0;
49906                            unicode_codes.push(unicode_code);
49907                        } else {
49908                            fallback();
49909                            i = (i - 1) | 0;
49910                        }
49911                        surrogate_1st = 0;
49912                    } else if (utf16_code >= 55296 && utf16_code <= 56319) {
49913                        surrogate_1st = utf16_code;
49914                    } else if ((utf16_code >= 56320) && (utf16_code <= 57343)) {
49915                        fallback();
49916                    } else {
49917                        unicode_codes.push(utf16_code);
49918                    }
49919                }
49920
49921                if (surrogate_1st !== 0) {
49922                    fallback();
49923                }
49924
49925                return unicode_codes;
49926            },
49927            Encode$3: function (s, outputBytes, outputIndex, writtenBytes) {
49928                var hasBuffer = outputBytes != null;
49929                var recorded = 0;
49930
49931                var write = function (ch) {
49932                    if (hasBuffer) {
49933                        if (outputIndex >= outputBytes.length) {
49934                            throw new System.ArgumentException.$ctor1("bytes");
49935                        }
49936
49937                        outputBytes[System.Array.index(H5.identity(outputIndex, ((outputIndex = (outputIndex + 1) | 0))), outputBytes)] = ch;
49938                    } else {
49939                        outputBytes.push(ch);
49940                    }
49941                    recorded = (recorded + 1) | 0;
49942                };
49943
49944                var write32 = H5.fn.bind(this, function (a) {
49945                    var r = System.Array.init(4, 0, System.Byte);
49946                    r[System.Array.index(0, r)] = (((a & 255) >>> 0));
49947                    r[System.Array.index(1, r)] = ((((a & 65280) >>> 0)) >>> 8);
49948                    r[System.Array.index(2, r)] = ((((a & 16711680) >>> 0)) >>> 16);
49949                    r[System.Array.index(3, r)] = ((((a & 4278190080) >>> 0)) >>> 24);
49950
49951                    if (this.bigEndian) {
49952                        r.reverse();
49953                    }
49954
49955                    write(r[System.Array.index(0, r)]);
49956                    write(r[System.Array.index(1, r)]);
49957                    write(r[System.Array.index(2, r)]);
49958                    write(r[System.Array.index(3, r)]);
49959                });
49960
49961                if (!hasBuffer) {
49962                    outputBytes = System.Array.init(0, 0, System.Byte);
49963                }
49964
49965                var unicode_codes = this.ToCodePoints(s);
49966                for (var i = 0; i < unicode_codes.length; i = (i + 1) | 0) {
49967                    write32(unicode_codes[System.Array.index(i, unicode_codes)]);
49968                }
49969
49970                writtenBytes.v = recorded;
49971
49972                if (hasBuffer) {
49973                    return null;
49974                }
49975
49976                return outputBytes;
49977            },
49978            Decode$2: function (bytes, index, count, chars, charIndex) {
49979                var position = index;
49980                var result = "";
49981                var endpoint = (position + count) | 0;
49982                this._hasError = false;
49983
49984                var fallback = H5.fn.bind(this, function () {
49985                    if (this.throwOnInvalid) {
49986                        throw new System.Exception("Invalid character in UTF32 text");
49987                    }
49988
49989                    result = (result || "") + ((String.fromCharCode(this.fallbackCharacter)) || "");
49990                });
49991
49992                var read32 = H5.fn.bind(this, function () {
49993                    if ((((position + 4) | 0)) > endpoint) {
49994                        position = (position + 4) | 0;
49995                        return null;
49996                    }
49997
49998                    var a = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
49999                    var b = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
50000                    var c = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
50001                    var d = bytes[System.Array.index(H5.identity(position, ((position = (position + 1) | 0))), bytes)];
50002
50003                    if (this.bigEndian) {
50004                        var tmp = b;
50005                        b = c;
50006                        c = tmp;
50007
50008                        tmp = a;
50009                        a = d;
50010                        d = tmp;
50011                    }
50012
50013                    return ((d << 24) | (c << 16) | (b << 8) | a);
50014                });
50015
50016                while (position < endpoint) {
50017                    var unicode_code = read32();
50018
50019                    if (unicode_code == null) {
50020                        fallback();
50021                        this._hasError = true;
50022                        continue;
50023                    }
50024
50025                    if (System.Nullable.lt(unicode_code, 65536) || System.Nullable.gt(unicode_code, 1114111)) {
50026                        if (System.Nullable.lt(unicode_code, 0) || System.Nullable.gt(unicode_code, 1114111) || (System.Nullable.gte(unicode_code, 55296) && System.Nullable.lte(unicode_code, 57343))) {
50027                            fallback();
50028                        } else {
50029                            result = (result || "") + ((String.fromCharCode(unicode_code)) || "");
50030                        }
50031                    } else {
50032                        result = (result || "") + ((String.fromCharCode((H5.Int.clipu32(System.Nullable.add((H5.Int.clipu32(H5.Int.div((H5.Int.clipu32(System.Nullable.sub(unicode_code, (65536)))), (1024)))), 55296))))) || "");
50033                        result = (result || "") + ((String.fromCharCode((H5.Int.clipu32(System.Nullable.add((System.Nullable.mod(unicode_code, (1024))), 56320))))) || "");
50034                    }
50035                }
50036
50037                return result;
50038            },
50039            GetMaxByteCount: function (charCount) {
50040                if (charCount < 0) {
50041                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50042                }
50043
50044                var byteCount = System.Int64(charCount).add(System.Int64(1));
50045                byteCount = byteCount.mul(System.Int64(4));
50046
50047                if (byteCount.gt(System.Int64(2147483647))) {
50048                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50049                }
50050
50051                return System.Int64.clip32(byteCount);
50052            },
50053            GetMaxCharCount: function (byteCount) {
50054                if (byteCount < 0) {
50055                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
50056                }
50057
50058                var charCount = (((H5.Int.div(byteCount, 2)) | 0) + 2) | 0;
50059
50060                if (charCount > 2147483647) {
50061                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
50062                }
50063
50064                return charCount;
50065            }
50066        }
50067    });
50068
50069    // @source UTF7Encoding.js
50070
50071    H5.define("System.Text.UTF7Encoding", {
50072        inherits: [System.Text.Encoding],
50073        statics: {
50074            methods: {
50075                Escape: function (chars) {
50076                    return chars.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
50077                }
50078            }
50079        },
50080        fields: {
50081            allowOptionals: false
50082        },
50083        props: {
50084            CodePage: {
50085                get: function () {
50086                    return 65000;
50087                }
50088            },
50089            EncodingName: {
50090                get: function () {
50091                    return "Unicode (UTF-7)";
50092                }
50093            }
50094        },
50095        ctors: {
50096            ctor: function () {
50097                System.Text.UTF7Encoding.$ctor1.call(this, false);
50098            },
50099            $ctor1: function (allowOptionals) {
50100                this.$initialize();
50101                System.Text.Encoding.ctor.call(this);
50102                this.allowOptionals = allowOptionals;
50103                this.fallbackCharacter = 65533;
50104            }
50105        },
50106        methods: {
50107            Encode$3: function (s, outputBytes, outputIndex, writtenBytes) {
50108                var setD = "A-Za-z0-9" + (System.Text.UTF7Encoding.Escape("'(),-./:?") || "");
50109
50110                var encode = $asm.$.System.Text.UTF7Encoding.f1;
50111
50112                var setO = System.Text.UTF7Encoding.Escape("!\"#$%&*;<=>@[]^_`{|}");
50113                var setW = System.Text.UTF7Encoding.Escape(" \r\n\t");
50114
50115                s = s.replace(new RegExp("[^" + setW + setD + (this.allowOptionals ? setO : "") + "]+", "g"), function (chunk) { return "+" + (chunk === "+" ? "" : encode(chunk)) + "-"; });
50116
50117                var arr = System.String.toCharArray(s, 0, s.length);
50118
50119                if (outputBytes != null) {
50120                    var recorded = 0;
50121
50122                    if (arr.length > (((outputBytes.length - outputIndex) | 0))) {
50123                        throw new System.ArgumentException.$ctor1("bytes");
50124                    }
50125
50126                    for (var j = 0; j < arr.length; j = (j + 1) | 0) {
50127                        outputBytes[System.Array.index(((j + outputIndex) | 0), outputBytes)] = arr[System.Array.index(j, arr)];
50128                        recorded = (recorded + 1) | 0;
50129                    }
50130
50131                    writtenBytes.v = recorded;
50132                    return null;
50133                }
50134
50135                writtenBytes.v = arr.length;
50136
50137                return arr;
50138            },
50139            Decode$2: function (bytes, index, count, chars, charIndex) {
50140                var _base64ToArrayBuffer = $asm.$.System.Text.UTF7Encoding.f2;
50141
50142                var decode = function (s) {
50143                    var b = _base64ToArrayBuffer(s);
50144                    var r = System.Array.init(0, 0, System.Char);
50145                    for (var i = 0; i < b.length; ) {
50146                        r.push(((b[System.Array.index(H5.identity(i, ((i = (i + 1) | 0))), b)] << 8 | b[System.Array.index(H5.identity(i, ((i = (i + 1) | 0))), b)]) & 65535));
50147                    }
50148                    return System.String.fromCharArray(r);
50149                };
50150
50151                var str = System.String.fromCharArray(bytes, index, count);
50152                return str.replace(/\+([A-Za-z0-9\/]*)-?/gi, function (_, chunk) { if (chunk === "") { return _ == "+-" ? "+" : ""; } return decode(chunk); });
50153            },
50154            GetMaxByteCount: function (charCount) {
50155                if (charCount < 0) {
50156                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50157                }
50158
50159                var byteCount = System.Int64(charCount).mul(System.Int64(3)).add(System.Int64(2));
50160
50161                if (byteCount.gt(System.Int64(2147483647))) {
50162                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50163                }
50164
50165                return System.Int64.clip32(byteCount);
50166            },
50167            GetMaxCharCount: function (byteCount) {
50168                if (byteCount < 0) {
50169                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
50170                }
50171
50172                var charCount = byteCount;
50173                if (charCount === 0) {
50174                    charCount = 1;
50175                }
50176
50177                return charCount | 0;
50178            }
50179        }
50180    });
50181
50182    H5.ns("System.Text.UTF7Encoding", $asm.$);
50183
50184    H5.apply($asm.$.System.Text.UTF7Encoding, {
50185        f1: function (str) {
50186            var b = System.Array.init(H5.Int.mul(str.length, 2), 0, System.Byte);
50187            var bi = 0;
50188            for (var i = 0; i < str.length; i = (i + 1) | 0) {
50189                var c = str.charCodeAt(i);
50190                b[System.Array.index(H5.identity(bi, ((bi = (bi + 1) | 0))), b)] = (c >> 8);
50191                b[System.Array.index(H5.identity(bi, ((bi = (bi + 1) | 0))), b)] = (c & 255);
50192            }
50193            var base64Str = System.Convert.toBase64String(b, null, null, null);
50194            return base64Str.replace(/=+$/, "");
50195        },
50196        f2: function (base64) {
50197            try {
50198                if (typeof window === "undefined") { throw new System.Exception(); };
50199                var binary_string = window.atob(base64);
50200                var len = binary_string.length;
50201                var arr = System.Array.init(len, 0, System.Char);
50202
50203                if (len === 1 && binary_string.charCodeAt(0) === 0) {
50204                    return System.Array.init(0, 0, System.Char);
50205                }
50206
50207                for (var i = 0; i < len; i = (i + 1) | 0) {
50208                    arr[System.Array.index(i, arr)] = binary_string.charCodeAt(i);
50209                }
50210
50211                return arr;
50212            } catch ($e1) {
50213                $e1 = System.Exception.create($e1);
50214                return System.Array.init(0, 0, System.Char);
50215            }
50216        }
50217    });
50218
50219    // @source UTF8Encoding.js
50220
50221    H5.define("System.Text.UTF8Encoding", {
50222        inherits: [System.Text.Encoding],
50223        fields: {
50224            encoderShouldEmitUTF8Identifier: false,
50225            throwOnInvalid: false
50226        },
50227        props: {
50228            CodePage: {
50229                get: function () {
50230                    return 65001;
50231                }
50232            },
50233            EncodingName: {
50234                get: function () {
50235                    return "Unicode (UTF-8)";
50236                }
50237            }
50238        },
50239        ctors: {
50240            ctor: function () {
50241                System.Text.UTF8Encoding.$ctor1.call(this, false);
50242            },
50243            $ctor1: function (encoderShouldEmitUTF8Identifier) {
50244                System.Text.UTF8Encoding.$ctor2.call(this, encoderShouldEmitUTF8Identifier, false);
50245            },
50246            $ctor2: function (encoderShouldEmitUTF8Identifier, throwOnInvalidBytes) {
50247                this.$initialize();
50248                System.Text.Encoding.ctor.call(this);
50249                this.encoderShouldEmitUTF8Identifier = encoderShouldEmitUTF8Identifier;
50250                this.throwOnInvalid = throwOnInvalidBytes;
50251                this.fallbackCharacter = 65533;
50252            }
50253        },
50254        methods: {
50255            Encode$3: function (s, outputBytes, outputIndex, writtenBytes) {
50256                var hasBuffer = outputBytes != null;
50257                var record = 0;
50258
50259                var write = function (args) {
50260                    var len = args.length;
50261                    for (var j = 0; j < len; j = (j + 1) | 0) {
50262                        var code = args[System.Array.index(j, args)];
50263                        if (hasBuffer) {
50264                            if (outputIndex >= outputBytes.length) {
50265                                throw new System.ArgumentException.$ctor1("bytes");
50266                            }
50267
50268                            outputBytes[System.Array.index(H5.identity(outputIndex, ((outputIndex = (outputIndex + 1) | 0))), outputBytes)] = code;
50269                        } else {
50270                            outputBytes.push(code);
50271                        }
50272                        record = (record + 1) | 0;
50273                    }
50274                };
50275
50276                var fallback = H5.fn.bind(this, $asm.$.System.Text.UTF8Encoding.f1);
50277
50278                if (!hasBuffer) {
50279                    outputBytes = System.Array.init(0, 0, System.Byte);
50280                }
50281
50282                for (var i = 0; i < s.length; i = (i + 1) | 0) {
50283                    var charcode = s.charCodeAt(i);
50284
50285                    if ((charcode >= 55296) && (charcode <= 56319)) {
50286                        var next = s.charCodeAt(((i + 1) | 0));
50287                        if (!((next >= 56320) && (next <= 57343))) {
50288                            charcode = fallback();
50289                        }
50290                    } else if ((charcode >= 56320) && (charcode <= 57343)) {
50291                        charcode = fallback();
50292                    }
50293
50294                    if (charcode < 128) {
50295                        write(System.Array.init([charcode], System.Byte));
50296                    } else if (charcode < 2048) {
50297                        write(System.Array.init([(192 | (charcode >> 6)), (128 | (charcode & 63))], System.Byte));
50298                    } else if (charcode < 55296 || charcode >= 57344) {
50299                        write(System.Array.init([(224 | (charcode >> 12)), (128 | ((charcode >> 6) & 63)), (128 | (charcode & 63))], System.Byte));
50300                    } else {
50301                        i = (i + 1) | 0;
50302                        var code = (65536 + (((charcode & 1023) << 10) | (s.charCodeAt(i) & 1023))) | 0;
50303                        write(System.Array.init([(240 | (code >> 18)), (128 | ((code >> 12) & 63)), (128 | ((code >> 6) & 63)), (128 | (code & 63))], System.Byte));
50304                    }
50305                }
50306
50307                writtenBytes.v = record;
50308
50309                if (hasBuffer) {
50310                    return null;
50311                }
50312
50313                return outputBytes;
50314            },
50315            Decode$2: function (bytes, index, count, chars, charIndex) {
50316                this._hasError = false;
50317                var position = index;
50318                var result = "";
50319                var surrogate1 = 0;
50320                var addFallback = false;
50321                var endpoint = (position + count) | 0;
50322
50323                for (; position < endpoint; position = (position + 1) | 0) {
50324                    var accumulator = 0;
50325                    var extraBytes = 0;
50326                    var hasError = false;
50327                    var firstByte = bytes[System.Array.index(position, bytes)];
50328
50329                    if (firstByte <= 127) {
50330                        accumulator = firstByte;
50331                    } else if ((firstByte & 64) === 0) {
50332                        hasError = true;
50333                    } else if ((firstByte & 224) === 192) {
50334                        accumulator = firstByte & 31;
50335                        extraBytes = 1;
50336                    } else if ((firstByte & 240) === 224) {
50337                        accumulator = firstByte & 15;
50338                        extraBytes = 2;
50339                    } else if ((firstByte & 248) === 240) {
50340                        accumulator = firstByte & 7;
50341                        extraBytes = 3;
50342                    } else if ((firstByte & 252) === 248) {
50343                        accumulator = firstByte & 3;
50344                        extraBytes = 4;
50345                        hasError = true;
50346                    } else if ((firstByte & 254) === 252) {
50347                        accumulator = firstByte & 3;
50348                        extraBytes = 5;
50349                        hasError = true;
50350                    } else {
50351                        accumulator = firstByte;
50352                        hasError = false;
50353                    }
50354
50355                    while (extraBytes > 0) {
50356                        position = (position + 1) | 0;
50357
50358                        if (position >= endpoint) {
50359                            hasError = true;
50360                            break;
50361                        }
50362
50363                        var extraByte = bytes[System.Array.index(position, bytes)];
50364                        extraBytes = (extraBytes - 1) | 0;
50365
50366                        if ((extraByte & 192) !== 128) {
50367                            position = (position - 1) | 0;
50368                            hasError = true;
50369                            break;
50370                        }
50371
50372                        accumulator = (accumulator << 6) | (extraByte & 63);
50373                    }
50374
50375                    /* if ((accumulator == 0xFFFE) || (accumulator == 0xFFFF)) {
50376                       hasError = true;
50377                    }*/
50378
50379                    var characters = null;
50380                    addFallback = false;
50381                    if (!hasError) {
50382                        if (surrogate1 > 0 && !((accumulator >= 56320) && (accumulator <= 57343))) {
50383                            hasError = true;
50384                            surrogate1 = 0;
50385                        } else if ((accumulator >= 55296) && (accumulator <= 56319)) {
50386                            surrogate1 = accumulator & 65535;
50387                        } else if ((accumulator >= 56320) && (accumulator <= 57343)) {
50388                            hasError = true;
50389                            addFallback = true;
50390                            surrogate1 = 0;
50391                        } else {
50392                            characters = System.String.fromCharCode(accumulator);
50393                            surrogate1 = 0;
50394                        }
50395                    }
50396
50397                    if (hasError) {
50398                        if (this.throwOnInvalid) {
50399                            throw new System.Exception("Invalid character in UTF8 text");
50400                        }
50401
50402                        result = (result || "") + String.fromCharCode(this.fallbackCharacter);
50403                        this._hasError = true;
50404                    } else if (surrogate1 === 0) {
50405                        result = (result || "") + (characters || "");
50406                    }
50407                }
50408
50409                if (surrogate1 > 0 || addFallback) {
50410                    if (this.throwOnInvalid) {
50411                        throw new System.Exception("Invalid character in UTF8 text");
50412                    }
50413
50414                    if (result.length > 0 && result.charCodeAt(((result.length - 1) | 0)) === this.fallbackCharacter) {
50415                        result = (result || "") + String.fromCharCode(this.fallbackCharacter);
50416                    } else {
50417                        result = (result || "") + (((this.fallbackCharacter + this.fallbackCharacter) | 0));
50418                    }
50419
50420                    this._hasError = true;
50421                }
50422
50423                return result;
50424            },
50425            GetMaxByteCount: function (charCount) {
50426                if (charCount < 0) {
50427                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50428                }
50429
50430
50431                var byteCount = System.Int64(charCount).add(System.Int64(1));
50432                byteCount = byteCount.mul(System.Int64(3));
50433
50434                if (byteCount.gt(System.Int64(2147483647))) {
50435                    throw new System.ArgumentOutOfRangeException.$ctor1("charCount");
50436                }
50437
50438                return System.Int64.clip32(byteCount);
50439            },
50440            GetMaxCharCount: function (byteCount) {
50441                if (byteCount < 0) {
50442                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
50443                }
50444
50445                var charCount = System.Int64(byteCount).add(System.Int64(1));
50446
50447                if (charCount.gt(System.Int64(2147483647))) {
50448                    throw new System.ArgumentOutOfRangeException.$ctor1("byteCount");
50449                }
50450
50451                return System.Int64.clip32(charCount);
50452            }
50453        }
50454    });
50455
50456    H5.ns("System.Text.UTF8Encoding", $asm.$);
50457
50458    H5.apply($asm.$.System.Text.UTF8Encoding, {
50459        f1: function () {
50460            if (this.throwOnInvalid) {
50461                throw new System.Exception("Invalid character in UTF8 text");
50462            }
50463
50464            return this.fallbackCharacter;
50465        }
50466    });
50467
50468    // @source Timer.js
50469
50470    H5.define("System.Threading.Timer", {
50471        inherits: [System.IDisposable],
50472        statics: {
50473            fields: {
50474                MAX_SUPPORTED_TIMEOUT: 0,
50475                EXC_LESS: null,
50476                EXC_MORE: null,
50477                EXC_DISPOSED: null
50478            },
50479            ctors: {
50480                init: function () {
50481                    this.MAX_SUPPORTED_TIMEOUT = 4294967294;
50482                    this.EXC_LESS = "Number must be either non-negative and less than or equal to Int32.MaxValue or -1.";
50483                    this.EXC_MORE = "Time-out interval must be less than 2^32-2.";
50484                    this.EXC_DISPOSED = "The timer has been already disposed.";
50485                }
50486            }
50487        },
50488        fields: {
50489            dueTime: System.Int64(0),
50490            period: System.Int64(0),
50491            timerCallback: null,
50492            state: null,
50493            id: null,
50494            disposed: false
50495        },
50496        alias: ["Dispose", "System$IDisposable$Dispose"],
50497        ctors: {
50498            $ctor1: function (callback, state, dueTime, period) {
50499                this.$initialize();
50500                this.TimerSetup(callback, state, System.Int64(dueTime), System.Int64(period));
50501            },
50502            $ctor3: function (callback, state, dueTime, period) {
50503                this.$initialize();
50504                var dueTm = H5.Int.clip64(dueTime.getTotalMilliseconds());
50505                var periodTm = H5.Int.clip64(period.getTotalMilliseconds());
50506
50507                this.TimerSetup(callback, state, dueTm, periodTm);
50508            },
50509            $ctor4: function (callback, state, dueTime, period) {
50510                this.$initialize();
50511                this.TimerSetup(callback, state, System.Int64(dueTime), System.Int64(period));
50512            },
50513            $ctor2: function (callback, state, dueTime, period) {
50514                this.$initialize();
50515                this.TimerSetup(callback, state, dueTime, period);
50516            },
50517            ctor: function (callback) {
50518                this.$initialize();
50519                var dueTime = -1;
50520                var period = -1;
50521
50522                this.TimerSetup(callback, this, System.Int64(dueTime), System.Int64(period));
50523            }
50524        },
50525        methods: {
50526            TimerSetup: function (callback, state, dueTime, period) {
50527                if (this.disposed) {
50528                    throw new System.InvalidOperationException.$ctor1(System.Threading.Timer.EXC_DISPOSED);
50529                }
50530
50531                if (H5.staticEquals(callback, null)) {
50532                    throw new System.ArgumentNullException.$ctor1("TimerCallback");
50533                }
50534
50535                if (dueTime.lt(System.Int64(-1))) {
50536                    throw new System.ArgumentOutOfRangeException.$ctor4("dueTime", System.Threading.Timer.EXC_LESS);
50537                }
50538                if (period.lt(System.Int64(-1))) {
50539                    throw new System.ArgumentOutOfRangeException.$ctor4("period", System.Threading.Timer.EXC_LESS);
50540                }
50541                if (dueTime.gt(System.Int64(System.Threading.Timer.MAX_SUPPORTED_TIMEOUT))) {
50542                    throw new System.ArgumentOutOfRangeException.$ctor4("dueTime", System.Threading.Timer.EXC_MORE);
50543                }
50544                if (period.gt(System.Int64(System.Threading.Timer.MAX_SUPPORTED_TIMEOUT))) {
50545                    throw new System.ArgumentOutOfRangeException.$ctor4("period", System.Threading.Timer.EXC_MORE);
50546                }
50547
50548                this.dueTime = dueTime;
50549                this.period = period;
50550
50551                this.state = state;
50552                this.timerCallback = callback;
50553
50554                return this.RunTimer(this.dueTime);
50555            },
50556            HandleCallback: function () {
50557                if (this.disposed) {
50558                    return;
50559                }
50560
50561                if (!H5.staticEquals(this.timerCallback, null)) {
50562                    var myId = this.id;
50563                    this.timerCallback(this.state);
50564
50565                    if (System.Nullable.eq(this.id, myId)) {
50566                        this.RunTimer(this.period, false);
50567                    }
50568                }
50569            },
50570            RunTimer: function (period, checkDispose) {
50571                if (checkDispose === void 0) { checkDispose = true; }
50572                if (checkDispose && this.disposed) {
50573                    throw new System.InvalidOperationException.$ctor1(System.Threading.Timer.EXC_DISPOSED);
50574                }
50575
50576                if (period.ne(System.Int64(-1)) && !this.disposed) {
50577                    var p = period.toNumber();
50578                    this.id = H5.global.setTimeout(H5.fn.cacheBind(this, this.HandleCallback), p);
50579                    return true;
50580                }
50581
50582                return false;
50583            },
50584            Change: function (dueTime, period) {
50585                return this.ChangeTimer(System.Int64(dueTime), System.Int64(period));
50586            },
50587            Change$2: function (dueTime, period) {
50588                return this.ChangeTimer(H5.Int.clip64(dueTime.getTotalMilliseconds()), H5.Int.clip64(period.getTotalMilliseconds()));
50589            },
50590            Change$3: function (dueTime, period) {
50591                return this.ChangeTimer(System.Int64(dueTime), System.Int64(period));
50592            },
50593            Change$1: function (dueTime, period) {
50594                return this.ChangeTimer(dueTime, period);
50595            },
50596            ChangeTimer: function (dueTime, period) {
50597                this.ClearTimeout();
50598                return this.TimerSetup(this.timerCallback, this.state, dueTime, period);
50599            },
50600            ClearTimeout: function () {
50601                if (System.Nullable.hasValue(this.id)) {
50602                    H5.global.clearTimeout(System.Nullable.getValue(this.id));
50603                    this.id = null;
50604                }
50605            },
50606            Dispose: function () {
50607                this.ClearTimeout();
50608                this.disposed = true;
50609            }
50610        }
50611    });
50612
50613    // @source TaskCanceledException.js
50614
50615    H5.define("System.Threading.Tasks.TaskCanceledException", {
50616        inherits: [System.OperationCanceledException],
50617        fields: {
50618            _canceledTask: null
50619        },
50620        props: {
50621            Task: {
50622                get: function () {
50623                    return this._canceledTask;
50624                }
50625            }
50626        },
50627        ctors: {
50628            ctor: function () {
50629                this.$initialize();
50630                System.OperationCanceledException.$ctor1.call(this, "A task was canceled.");
50631            },
50632            $ctor1: function (message) {
50633                this.$initialize();
50634                System.OperationCanceledException.$ctor1.call(this, message);
50635            },
50636            $ctor2: function (message, innerException) {
50637                this.$initialize();
50638                System.OperationCanceledException.$ctor2.call(this, message, innerException);
50639            },
50640            $ctor3: function (task) {
50641                this.$initialize();
50642                System.OperationCanceledException.$ctor4.call(this, "A task was canceled.", task != null ? new System.Threading.CancellationToken() : new System.Threading.CancellationToken());
50643                this._canceledTask = task;
50644            }
50645        }
50646    });
50647
50648    // @source TaskSchedulerException.js
50649
50650    H5.define("System.Threading.Tasks.TaskSchedulerException", {
50651        inherits: [System.Exception],
50652        ctors: {
50653            ctor: function () {
50654                this.$initialize();
50655                System.Exception.ctor.call(this, "An exception was thrown by a TaskScheduler.");
50656            },
50657            $ctor2: function (message) {
50658                this.$initialize();
50659                System.Exception.ctor.call(this, message);
50660            },
50661            $ctor1: function (innerException) {
50662                this.$initialize();
50663                System.Exception.ctor.call(this, "An exception was thrown by a TaskScheduler.", innerException);
50664            },
50665            $ctor3: function (message, innerException) {
50666                this.$initialize();
50667                System.Exception.ctor.call(this, message, innerException);
50668            }
50669        }
50670    });
50671
50672    // @source Version.js
50673
50674    H5.define("System.Version", {
50675        inherits: function () { return [System.ICloneable,System.IComparable$1(System.Version),System.IEquatable$1(System.Version)]; },
50676        statics: {
50677            fields: {
50678                ZERO_CHAR_VALUE: 0,
50679                separatorsArray: 0
50680            },
50681            ctors: {
50682                init: function () {
50683                    this.ZERO_CHAR_VALUE = 48;
50684                    this.separatorsArray = 46;
50685                }
50686            },
50687            methods: {
50688                appendPositiveNumber: function (num, sb) {
50689                    var index = sb.getLength();
50690                    var reminder;
50691
50692                    do {
50693                        reminder = num % 10;
50694                        num = (H5.Int.div(num, 10)) | 0;
50695                        sb.insert(index, String.fromCharCode(((((System.Version.ZERO_CHAR_VALUE + reminder) | 0)) & 65535)));
50696                    } while (num > 0);
50697                },
50698                parse: function (input) {
50699                    if (input == null) {
50700                        throw new System.ArgumentNullException.$ctor1("input");
50701                    }
50702
50703                    var r = { v : new System.Version.VersionResult() };
50704                    r.v.init("input", true);
50705                    if (!System.Version.tryParseVersion(input, r)) {
50706                        throw r.v.getVersionParseException();
50707                    }
50708                    return r.v.m_parsedVersion;
50709                },
50710                tryParse: function (input, result) {
50711                    var r = { v : new System.Version.VersionResult() };
50712                    r.v.init("input", false);
50713                    var b = System.Version.tryParseVersion(input, r);
50714                    result.v = r.v.m_parsedVersion;
50715                    return b;
50716                },
50717                tryParseVersion: function (version, result) {
50718                    var major = { }, minor = { }, build = { }, revision = { };
50719
50720                    if (version == null) {
50721                        result.v.setFailure(System.Version.ParseFailureKind.ArgumentNullException);
50722
50723                        return false;
50724                    }
50725
50726                    var parsedComponents = System.String.split(version, [System.Version.separatorsArray].map(function (i) {{ return String.fromCharCode(i); }}));
50727                    var parsedComponentsLength = parsedComponents.length;
50728
50729                    if ((parsedComponentsLength < 2) || (parsedComponentsLength > 4)) {
50730                        result.v.setFailure(System.Version.ParseFailureKind.ArgumentException);
50731                        return false;
50732                    }
50733
50734                    if (!System.Version.tryParseComponent(parsedComponents[System.Array.index(0, parsedComponents)], "version", result, major)) {
50735                        return false;
50736                    }
50737
50738                    if (!System.Version.tryParseComponent(parsedComponents[System.Array.index(1, parsedComponents)], "version", result, minor)) {
50739                        return false;
50740                    }
50741
50742                    parsedComponentsLength = (parsedComponentsLength - 2) | 0;
50743
50744                    if (parsedComponentsLength > 0) {
50745                        if (!System.Version.tryParseComponent(parsedComponents[System.Array.index(2, parsedComponents)], "build", result, build)) {
50746                            return false;
50747                        }
50748
50749                        parsedComponentsLength = (parsedComponentsLength - 1) | 0;
50750
50751                        if (parsedComponentsLength > 0) {
50752                            if (!System.Version.tryParseComponent(parsedComponents[System.Array.index(3, parsedComponents)], "revision", result, revision)) {
50753                                return false;
50754                            } else {
50755                                result.v.m_parsedVersion = new System.Version.$ctor3(major.v, minor.v, build.v, revision.v);
50756                            }
50757                        } else {
50758                            result.v.m_parsedVersion = new System.Version.$ctor2(major.v, minor.v, build.v);
50759                        }
50760                    } else {
50761                        result.v.m_parsedVersion = new System.Version.$ctor1(major.v, minor.v);
50762                    }
50763
50764                    return true;
50765                },
50766                tryParseComponent: function (component, componentName, result, parsedComponent) {
50767                    if (!System.Int32.tryParse(component, parsedComponent)) {
50768                        result.v.setFailure$1(System.Version.ParseFailureKind.FormatException, component);
50769                        return false;
50770                    }
50771
50772                    if (parsedComponent.v < 0) {
50773                        result.v.setFailure$1(System.Version.ParseFailureKind.ArgumentOutOfRangeException, componentName);
50774                        return false;
50775                    }
50776
50777                    return true;
50778                },
50779                op_Equality: function (v1, v2) {
50780                    if (H5.referenceEquals(v1, null)) {
50781                        return H5.referenceEquals(v2, null);
50782                    }
50783
50784                    return v1.equalsT(v2);
50785                },
50786                op_Inequality: function (v1, v2) {
50787                    return !(System.Version.op_Equality(v1, v2));
50788                },
50789                op_LessThan: function (v1, v2) {
50790                    if (v1 == null) {
50791                        throw new System.ArgumentNullException.$ctor1("v1");
50792                    }
50793
50794                    return (v1.compareTo(v2) < 0);
50795                },
50796                op_LessThanOrEqual: function (v1, v2) {
50797                    if (v1 == null) {
50798                        throw new System.ArgumentNullException.$ctor1("v1");
50799                    }
50800
50801                    return (v1.compareTo(v2) <= 0);
50802                },
50803                op_GreaterThan: function (v1, v2) {
50804                    return (System.Version.op_LessThan(v2, v1));
50805                },
50806                op_GreaterThanOrEqual: function (v1, v2) {
50807                    return (System.Version.op_LessThanOrEqual(v2, v1));
50808                }
50809            }
50810        },
50811        fields: {
50812            _Major: 0,
50813            _Minor: 0,
50814            _Build: 0,
50815            _Revision: 0
50816        },
50817        props: {
50818            Major: {
50819                get: function () {
50820                    return this._Major;
50821                }
50822            },
50823            Minor: {
50824                get: function () {
50825                    return this._Minor;
50826                }
50827            },
50828            Build: {
50829                get: function () {
50830                    return this._Build;
50831                }
50832            },
50833            Revision: {
50834                get: function () {
50835                    return this._Revision;
50836                }
50837            },
50838            MajorRevision: {
50839                get: function () {
50840                    return H5.Int.sxs((this._Revision >> 16) & 65535);
50841                }
50842            },
50843            MinorRevision: {
50844                get: function () {
50845                    return H5.Int.sxs((this._Revision & 65535) & 65535);
50846                }
50847            }
50848        },
50849        alias: [
50850            "clone", "System$ICloneable$clone",
50851            "compareTo", ["System$IComparable$1$System$Version$compareTo", "System$IComparable$1$compareTo"],
50852            "equalsT", "System$IEquatable$1$System$Version$equalsT"
50853        ],
50854        ctors: {
50855            init: function () {
50856                this._Build = -1;
50857                this._Revision = -1;
50858            },
50859            $ctor3: function (major, minor, build, revision) {
50860                this.$initialize();
50861                if (major < 0) {
50862                    throw new System.ArgumentOutOfRangeException.$ctor4("major", "Cannot be < 0");
50863                }
50864
50865                if (minor < 0) {
50866                    throw new System.ArgumentOutOfRangeException.$ctor4("minor", "Cannot be < 0");
50867                }
50868
50869                if (build < 0) {
50870                    throw new System.ArgumentOutOfRangeException.$ctor4("build", "Cannot be < 0");
50871                }
50872
50873                if (revision < 0) {
50874                    throw new System.ArgumentOutOfRangeException.$ctor4("revision", "Cannot be < 0");
50875                }
50876
50877                this._Major = major;
50878                this._Minor = minor;
50879                this._Build = build;
50880                this._Revision = revision;
50881            },
50882            $ctor2: function (major, minor, build) {
50883                this.$initialize();
50884                if (major < 0) {
50885                    throw new System.ArgumentOutOfRangeException.$ctor4("major", "Cannot be < 0");
50886                }
50887
50888                if (minor < 0) {
50889                    throw new System.ArgumentOutOfRangeException.$ctor4("minor", "Cannot be < 0");
50890                }
50891
50892                if (build < 0) {
50893                    throw new System.ArgumentOutOfRangeException.$ctor4("build", "Cannot be < 0");
50894                }
50895
50896                this._Major = major;
50897                this._Minor = minor;
50898                this._Build = build;
50899            },
50900            $ctor1: function (major, minor) {
50901                this.$initialize();
50902                if (major < 0) {
50903                    throw new System.ArgumentOutOfRangeException.$ctor4("major", "Cannot be < 0");
50904                }
50905
50906                if (minor < 0) {
50907                    throw new System.ArgumentOutOfRangeException.$ctor4("minor", "Cannot be < 0");
50908                }
50909
50910                this._Major = major;
50911                this._Minor = minor;
50912            },
50913            $ctor4: function (version) {
50914                this.$initialize();
50915                var v = System.Version.parse(version);
50916                this._Major = v.Major;
50917                this._Minor = v.Minor;
50918                this._Build = v.Build;
50919                this._Revision = v.Revision;
50920            },
50921            ctor: function () {
50922                this.$initialize();
50923                this._Major = 0;
50924                this._Minor = 0;
50925            }
50926        },
50927        methods: {
50928            clone: function () {
50929                var v = new System.Version.ctor();
50930                v._Major = this._Major;
50931                v._Minor = this._Minor;
50932                v._Build = this._Build;
50933                v._Revision = this._Revision;
50934                return (v);
50935            },
50936            compareTo$1: function (version) {
50937                if (version == null) {
50938                    return 1;
50939                }
50940
50941                var v = H5.as(version, System.Version);
50942                if (System.Version.op_Equality(v, null)) {
50943                    throw new System.ArgumentException.$ctor1("version should be of System.Version type");
50944                }
50945
50946                if (this._Major !== v._Major) {
50947                    if (this._Major > v._Major) {
50948                        return 1;
50949                    } else {
50950                        return -1;
50951                    }
50952                }
50953
50954                if (this._Minor !== v._Minor) {
50955                    if (this._Minor > v._Minor) {
50956                        return 1;
50957                    } else {
50958                        return -1;
50959                    }
50960                }
50961
50962                if (this._Build !== v._Build) {
50963                    if (this._Build > v._Build) {
50964                        return 1;
50965                    } else {
50966                        return -1;
50967                    }
50968                }
50969
50970                if (this._Revision !== v._Revision) {
50971                    if (this._Revision > v._Revision) {
50972                        return 1;
50973                    } else {
50974                        return -1;
50975                    }
50976                }
50977
50978                return 0;
50979            },
50980            compareTo: function (value) {
50981                if (System.Version.op_Equality(value, null)) {
50982                    return 1;
50983                }
50984
50985                if (this._Major !== value._Major) {
50986                    if (this._Major > value._Major) {
50987                        return 1;
50988                    } else {
50989                        return -1;
50990                    }
50991                }
50992
50993                if (this._Minor !== value._Minor) {
50994                    if (this._Minor > value._Minor) {
50995                        return 1;
50996                    } else {
50997                        return -1;
50998                    }
50999                }
51000
51001                if (this._Build !== value._Build) {
51002                    if (this._Build > value._Build) {
51003                        return 1;
51004                    } else {
51005                        return -1;
51006                    }
51007                }
51008
51009                if (this._Revision !== value._Revision) {
51010                    if (this._Revision > value._Revision) {
51011                        return 1;
51012                    } else {
51013                        return -1;
51014                    }
51015                }
51016
51017                return 0;
51018            },
51019            equals: function (obj) {
51020                return this.equalsT(H5.as(obj, System.Version));
51021            },
51022            equalsT: function (obj) {
51023                if (System.Version.op_Equality(obj, null)) {
51024                    return false;
51025                }
51026
51027                if ((this._Major !== obj._Major) || (this._Minor !== obj._Minor) || (this._Build !== obj._Build) || (this._Revision !== obj._Revision)) {
51028                    return false;
51029                }
51030
51031                return true;
51032            },
51033            getHashCode: function () {
51034
51035                var accumulator = 0;
51036
51037                accumulator = accumulator | ((this._Major & 15) << 28);
51038                accumulator = accumulator | ((this._Minor & 255) << 20);
51039                accumulator = accumulator | ((this._Build & 255) << 12);
51040                accumulator = accumulator | (this._Revision & 4095);
51041
51042                return accumulator;
51043            },
51044            toString: function () {
51045                if (this._Build === -1) {
51046                    return (this.toString$1(2));
51047                }
51048                if (this._Revision === -1) {
51049                    return (this.toString$1(3));
51050                }
51051                return (this.toString$1(4));
51052            },
51053            toString$1: function (fieldCount) {
51054                var sb;
51055                switch (fieldCount) {
51056                    case 0: 
51057                        return ("");
51058                    case 1: 
51059                        return (H5.toString(this._Major));
51060                    case 2: 
51061                        sb = new System.Text.StringBuilder();
51062                        System.Version.appendPositiveNumber(this._Major, sb);
51063                        sb.append(String.fromCharCode(46));
51064                        System.Version.appendPositiveNumber(this._Minor, sb);
51065                        return sb.toString();
51066                    default: 
51067                        if (this._Build === -1) {
51068                            throw new System.ArgumentException.$ctor3("Build should be > 0 if fieldCount > 2", "fieldCount");
51069                        }
51070                        if (fieldCount === 3) {
51071                            sb = new System.Text.StringBuilder();
51072                            System.Version.appendPositiveNumber(this._Major, sb);
51073                            sb.append(String.fromCharCode(46));
51074                            System.Version.appendPositiveNumber(this._Minor, sb);
51075                            sb.append(String.fromCharCode(46));
51076                            System.Version.appendPositiveNumber(this._Build, sb);
51077                            return sb.toString();
51078                        }
51079                        if (this._Revision === -1) {
51080                            throw new System.ArgumentException.$ctor3("Revision should be > 0 if fieldCount > 3", "fieldCount");
51081                        }
51082                        if (fieldCount === 4) {
51083                            sb = new System.Text.StringBuilder();
51084                            System.Version.appendPositiveNumber(this._Major, sb);
51085                            sb.append(String.fromCharCode(46));
51086                            System.Version.appendPositiveNumber(this._Minor, sb);
51087                            sb.append(String.fromCharCode(46));
51088                            System.Version.appendPositiveNumber(this._Build, sb);
51089                            sb.append(String.fromCharCode(46));
51090                            System.Version.appendPositiveNumber(this._Revision, sb);
51091                            return sb.toString();
51092                        }
51093                        throw new System.ArgumentException.$ctor3("Should be < 5", "fieldCount");
51094                }
51095            }
51096        }
51097    });
51098
51099    // @source ParseFailureKind.js
51100
51101    H5.define("System.Version.ParseFailureKind", {
51102        $kind: "nested enum",
51103        statics: {
51104            fields: {
51105                ArgumentNullException: 0,
51106                ArgumentException: 1,
51107                ArgumentOutOfRangeException: 2,
51108                FormatException: 3
51109            }
51110        }
51111    });
51112
51113    // @source VersionResult.js
51114
51115    H5.define("System.Version.VersionResult", {
51116        $kind: "nested struct",
51117        statics: {
51118            methods: {
51119                getDefaultValue: function () { return new System.Version.VersionResult(); }
51120            }
51121        },
51122        fields: {
51123            m_parsedVersion: null,
51124            m_failure: 0,
51125            m_exceptionArgument: null,
51126            m_argumentName: null,
51127            m_canThrow: false
51128        },
51129        ctors: {
51130            ctor: function () {
51131                this.$initialize();
51132            }
51133        },
51134        methods: {
51135            init: function (argumentName, canThrow) {
51136                this.m_canThrow = canThrow;
51137                this.m_argumentName = argumentName;
51138            },
51139            setFailure: function (failure) {
51140                this.setFailure$1(failure, "");
51141            },
51142            setFailure$1: function (failure, argument) {
51143                this.m_failure = failure;
51144                this.m_exceptionArgument = argument;
51145                if (this.m_canThrow) {
51146                    throw this.getVersionParseException();
51147                }
51148            },
51149            getVersionParseException: function () {
51150                switch (this.m_failure) {
51151                    case System.Version.ParseFailureKind.ArgumentNullException: 
51152                        return new System.ArgumentNullException.$ctor1(this.m_argumentName);
51153                    case System.Version.ParseFailureKind.ArgumentException: 
51154                        return new System.ArgumentException.$ctor1("VersionString");
51155                    case System.Version.ParseFailureKind.ArgumentOutOfRangeException: 
51156                        return new System.ArgumentOutOfRangeException.$ctor4(this.m_exceptionArgument, "Cannot be < 0");
51157                    case System.Version.ParseFailureKind.FormatException: 
51158                        try {
51159                            System.Int32.parse(this.m_exceptionArgument);
51160                        } catch ($e1) {
51161                            $e1 = System.Exception.create($e1);
51162                            var e;
51163                            if (H5.is($e1, System.FormatException)) {
51164                                e = $e1;
51165                                return e;
51166                            } else if (H5.is($e1, System.OverflowException)) {
51167                                e = $e1;
51168                                return e;
51169                            } else {
51170                                throw $e1;
51171                            }
51172                        }
51173                        return new System.FormatException.$ctor1("InvalidString");
51174                    default: 
51175                        return new System.ArgumentException.$ctor1("VersionString");
51176                }
51177            },
51178            getHashCode: function () {
51179                var h = H5.addHash([5139482776, this.m_parsedVersion, this.m_failure, this.m_exceptionArgument, this.m_argumentName, this.m_canThrow]);
51180                return h;
51181            },
51182            equals: function (o) {
51183                if (!H5.is(o, System.Version.VersionResult)) {
51184                    return false;
51185                }
51186                return H5.equals(this.m_parsedVersion, o.m_parsedVersion) && H5.equals(this.m_failure, o.m_failure) && H5.equals(this.m_exceptionArgument, o.m_exceptionArgument) && H5.equals(this.m_argumentName, o.m_argumentName) && H5.equals(this.m_canThrow, o.m_canThrow);
51187            },
51188            $clone: function (to) {
51189                var s = to || new System.Version.VersionResult();
51190                s.m_parsedVersion = this.m_parsedVersion;
51191                s.m_failure = this.m_failure;
51192                s.m_exceptionArgument = this.m_exceptionArgument;
51193                s.m_argumentName = this.m_argumentName;
51194                s.m_canThrow = this.m_canThrow;
51195                return s;
51196            }
51197        }
51198    });
51199
51200    // @source End.js
51201
51202    // module export
51203    if (typeof define === "function" && define.amd) {
51204        // AMD
51205        define("h5", [], function () { return H5; });
51206    } else if (typeof module !== "undefined" && module.exports) {
51207        // Node
51208        module.exports = H5;
51209    }
51210
51211    // @source Finally.js
51212
51213})(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.