public IJavaData Convert(JavaObject @object) { JavaObject transformed = new JavaObject(@object.Type); transformed.Fields.AddRange(@object.Fields); for (int i = 1; i < @object.Custom.Count; i += 2) { JavaValue value = @object.Custom[i] as JavaValue; if (value == null) { continue; } JavaField field = new JavaField(value.Get <string>(), @object.Custom[i + 1]); transformed.Fields.Add(field); } return(transformed); }
/// <summary> /// reads an object /// </summary> /// <returns></returns> public T Read() { IJavaData data = stream.ReadObject(); if (reducer != null && data is JavaObject) { data = reducer.Reduce((JavaObject)data); } JavaValue value = data as JavaValue; if (value == null) { throw new InvalidOperationException("Stream contains no object of the specified type"); } return(value.Get <T>()); }