/// <exception cref="System.MissingMethodException"/> /// <exception cref="java.lang.IllegalAccessException"/> /// <exception cref="java.lang.reflect.InvocationTargetException"/> /// <exception cref="java.lang.InstantiationException"/> /// <exception cref="VPackException"/> private void DeserializeFields(object entity, VPackSlice vpack) { IDictionary <string, VPackCache.FieldInfo> fields = this.cache.getFields(entity.GetType()); for (IEnumerator <IEntry <string, VPackSlice> > iterator = vpack.ObjectIterator(); iterator.MoveNext();) { IEntry <string, VPackSlice> next = iterator.Current; VPackCache.FieldInfo fieldInfo = fields[next.Key]; if (fieldInfo != null && fieldInfo.IsDeserialize) { this.DeserializeField(vpack, next.Value, entity, fieldInfo); } } }
/// <exception cref="java.lang.InstantiationException"/> /// <exception cref="java.lang.IllegalAccessException"/> /// <exception cref="System.MissingMethodException"/> /// <exception cref="java.lang.reflect.InvocationTargetException"/> /// <exception cref="VPackException"/> private IDictionary DeserializeMap(VPackSlice parent, VPackSlice vpack, Type type, Type keyType, Type valueType) { var info = type.GetTypeInfo(); int length = vpack.GetLength(); IDictionary value; if (typeof(IDictionary).GetTypeInfo().IsAssignableFrom(info) && info.IsClass) { value = (IDictionary)CreateInstance(type); } else { value = new Dictionary <object, object>(length); } if (length > 0) { IVPackKeyMapAdapter keyMapAdapter = this.GetKeyMapAdapter(keyType); if (keyMapAdapter != null) { for (IEnumerator <IEntry <string, VPackSlice> > iterator = vpack.ObjectIterator(); iterator.MoveNext();) { IEntry <string, VPackSlice> next = iterator.Current; object name = keyMapAdapter.Deserialize(next.Key); value[name] = GetValue(vpack, next.Value, valueType, name.ToString()); } } else { for (int i = 0; i < vpack.GetLength(); i++) { VPackSlice entry = vpack.Get(i); object mapKey = GetValue(parent, entry.Get(ATTR_KEY), keyType, null); object mapValue = GetValue(parent, entry.Get(ATTR_VALUE), valueType, null); value[mapKey] = mapValue; } } } return(value); }
/// <exception cref="VPackException"/> private void ParseObject(VPackSlice value, StringBuilder json, bool includeNullValues) { json.Append(OBJECT_OPEN); int added = 0; for (IEnumerator <IEntry <string, VPackSlice> > iterator = value.ObjectIterator(); iterator.MoveNext();) { IEntry <string, VPackSlice> next = iterator.Current; VPackSlice nextValue = next.Value; if (!nextValue.IsNull || includeNullValues) { if (added++ > 0) { json.Append(SEPARATOR); } this.Parse(value, next.Key, nextValue, json, includeNullValues); } } json.Append(OBJECT_CLOSE); }