Example #1
0
 /// <summary/>
 internal override object DeserializeCore(BplBinaryReader stream) {
    var count = stream.ReadInt();
    var array = new object[count];
    if (count > 0) {
       var converter = BplLanguage.BinaryConverters[PrimitiveItemType];
       for (var i = 0; i < count; i++) {
          array[i] = converter.Deserialize(stream);
       }
    }
    return CreateInstance(null, array);
 }
Example #2
0
      /// <summary>Parses an input XML document into an output BPL object.</summary>
      public override bool Parse(String input) {
         Clear();
         Input = input;
         if (input.IsEmpty()) {
            Errors.AddError("Input HEX string is empty");
            return false;
         }

         try {
            var buffer = _fromHexString(Input);
            var reader = new BplBinaryReader(buffer);
            Output = reader.Deserialize();
            return true;
         } catch (Exception e) {
            Errors.AddException(e);
            return false;
         }
      }
Example #3
0
 /// <summary/>
 internal override object DeserializeCore(BplBinaryReader stream) {
    throw new NotSupportedException("Deserialization of delegate primitives is not supported");
 }
Example #4
0
 // Connects with the implementations of the deserialize method on derived classes
 internal abstract object DeserializeCore(BplBinaryReader stream);
Example #5
0
 /// <summary>Implements <see cref="M:IBplBinaryConverter.Deserialize(BplBinaryReader, object)"/>.</summary>
 public object Deserialize(BplBinaryReader stream) {
    try {
       return DeserializeCore(stream);
    } catch (Exception e) {
       throw new BplConversionException(TEXT.BplConverter_DeserializeFailure.Substitute(this, e.Message), e);
    }
 }
Example #6
0
 /// <summary/>
 internal override object DeserializeCore(BplBinaryReader stream) {
    return stream.ReadNullable(PrimitiveItemType.UnderlyingType);
 }
Example #7
0
 private void _openFile(string path) {
    if (path.IsEmpty()) {
       _input.Text = null;
       _output.Text = null;
       InputFile = null;
    } else {
       try {
          _input.Text = File.ReadAllText(path);
          InputFormat = _detectFormat(_input.Text);
          if (InputFormat == BplFormat.Unknown) {
             var buffer = File.ReadAllBytes(path);
             var reader = new BplBinaryReader(buffer);
             var formatter = new BplHexFormatter();
             formatter.Format(reader.Deserialize());
             _input.Text = formatter.Output;
             InputFormat = BplFormat.Binary;
          }
          _reformat();
          InputFile = path;
       } catch (Exception e2) {
          MessageBox.Show("Failed to read '{0}' file. {1}".Substitute(path, e2.Message));
       }
    }
    IsDirty = false;
 }