mirror of
				https://github.com/esiur/esiur-dart.git
				synced 2025-11-04 09:11:35 +00:00 
			
		
		
		
	Guid
This commit is contained in:
		@@ -70,10 +70,18 @@ class DC with IterableMixin<int> {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  DC.fromHex(String hex, [String separator = ' ']) {
 | 
			
		||||
    var list =
 | 
			
		||||
        hex.split(separator).map((e) => int.parse(e, radix: 16)).toList();
 | 
			
		||||
    _data = Uint8List.fromList(list);
 | 
			
		||||
    _dv = ByteData.view(_data.buffer);
 | 
			
		||||
    if (separator == '') {
 | 
			
		||||
      var list = <int>[];
 | 
			
		||||
      for (var i = 0; i < hex.length; i += 2)
 | 
			
		||||
        list.add(int.parse(hex.substring(i, i + 2), radix: 16));
 | 
			
		||||
      _data = Uint8List.fromList(list);
 | 
			
		||||
      _dv = ByteData.view(_data.buffer);
 | 
			
		||||
    } else {
 | 
			
		||||
      var list =
 | 
			
		||||
          hex.split(separator).map((e) => int.parse(e, radix: 16)).toList();
 | 
			
		||||
      _data = Uint8List.fromList(list);
 | 
			
		||||
      _dv = ByteData.view(_data.buffer);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int operator [](int index) => _data[index];
 | 
			
		||||
@@ -83,11 +91,7 @@ class DC with IterableMixin<int> {
 | 
			
		||||
  Iterator<int> get iterator => _data.iterator;
 | 
			
		||||
 | 
			
		||||
  static DC hexToBytes(String value) {
 | 
			
		||||
    // convert hex to Uint8Array
 | 
			
		||||
    var rt = new DC(value.length ~/ 2);
 | 
			
		||||
    for (var i = 0; i < rt.length; i++)
 | 
			
		||||
      rt[i] = int.parse(value.substring(i * 2, 2), radix: 16);
 | 
			
		||||
    return rt;
 | 
			
		||||
    return DC.fromHex(value, '');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static DC boolToBytes(bool value) {
 | 
			
		||||
@@ -234,9 +238,11 @@ class DC with IterableMixin<int> {
 | 
			
		||||
    return rt;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static DC dateTimeArrayToBytes(List<DateTime> value, [Endian endian = Endian.little]) {
 | 
			
		||||
  static DC dateTimeArrayToBytes(List<DateTime> value,
 | 
			
		||||
      [Endian endian = Endian.little]) {
 | 
			
		||||
    var rt = new DC(value.length * 8);
 | 
			
		||||
    for (var i = 0; i < value.length; i++) rt.setDateTime(i * 8, value[i], endian);
 | 
			
		||||
    for (var i = 0; i < value.length; i++)
 | 
			
		||||
      rt.setDateTime(i * 8, value[i], endian);
 | 
			
		||||
    return rt;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -484,7 +490,7 @@ class DC with IterableMixin<int> {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getUint64(int offset, [Endian endian = Endian.little]) {
 | 
			
		||||
     if (kIsWeb) {
 | 
			
		||||
    if (kIsWeb) {
 | 
			
		||||
      if (endian == Endian.big) {
 | 
			
		||||
        var bi = BigInt.from(0);
 | 
			
		||||
 | 
			
		||||
@@ -596,7 +602,8 @@ class DC with IterableMixin<int> {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void setDateTime(int offset, DateTime value, [Endian endian = Endian.little]) {
 | 
			
		||||
  void setDateTime(int offset, DateTime value,
 | 
			
		||||
      [Endian endian = Endian.little]) {
 | 
			
		||||
    // Unix Epoch
 | 
			
		||||
    var ticks = UNIX_EPOCH + (value.millisecondsSinceEpoch * 10000);
 | 
			
		||||
    this.setUint64(offset, ticks, endian);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ class Guid {
 | 
			
		||||
 | 
			
		||||
  Guid(this._data) {}
 | 
			
		||||
 | 
			
		||||
  Guid.fromString(String data) {
 | 
			
		||||
  Guid.parse(String data) {
 | 
			
		||||
    _data = DC.fromHex(data, '');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -348,11 +348,11 @@ class TemplateGenerator {
 | 
			
		||||
        var className = _translateClassName(tmp.className);
 | 
			
		||||
        if (tmp.type == TemplateType.Resource ||
 | 
			
		||||
            tmp.type == TemplateType.Wrapper) {
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedResource, false, Guid.fromString('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedResource, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
        } else if (tmp.type == TemplateType.Record) {
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedRecord, false, Guid.fromString('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedRecord, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
        } else if (tmp.type == TemplateType.Enum) {
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.Enum, false, Guid.fromString('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
          return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.Enum, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
 | 
			
		||||
        }
 | 
			
		||||
      }).join("\r\n");
 | 
			
		||||
 | 
			
		||||
@@ -470,7 +470,7 @@ class TemplateGenerator {
 | 
			
		||||
 | 
			
		||||
      if (f.isStatic) {
 | 
			
		||||
        rt.write(
 | 
			
		||||
            "AsyncReply<$rtTypeName> ${f.name}(DistributedConnection connection");
 | 
			
		||||
            "static AsyncReply<$rtTypeName> ${f.name}(DistributedConnection connection");
 | 
			
		||||
 | 
			
		||||
        if (positionalArgs.length > 0)
 | 
			
		||||
          rt.write(
 | 
			
		||||
@@ -515,7 +515,6 @@ class TemplateGenerator {
 | 
			
		||||
      rt.writeln("..error((x) => rt.triggerError(x))");
 | 
			
		||||
      rt.writeln("..chunk((x) => rt.triggerChunk(x));");
 | 
			
		||||
      rt.writeln("return rt; }");
 | 
			
		||||
      
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    template.properties.where((p) => !p.inherited).forEach((p) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user