protected override void DoWrite(object obj, Hessian2Writer writer) { var type = obj.GetType(); if (!writer.WriteObjectHeader(type.AssemblyQualifiedName)) { writer.WriteInt(1); writer.WriteString("value"); writer.WriteObjectHeader(type.AssemblyQualifiedName); } writer.WriteString(obj.ToString()); }
protected override void DoWrite(object obj, Hessian2Writer writer) { var type = obj.GetType(); var name = Enum.GetName(type, obj); var nameAttr = type.GetCustomAttribute <NameAttribute>(); if (!writer.WriteObjectHeader(nameAttr == null ? type.AssemblyQualifiedName : nameAttr.TargetName)) { writer.WriteInt(1); writer.WriteString("name"); writer.WriteObjectHeader(type.AssemblyQualifiedName); } writer.WriteString(name); }
protected override void DoWrite(object obj, Hessian2Writer writer) { if (!writer.WriteObjectHeader(_typeName)) { writer.WriteInt(_propertyInfos.Count); foreach (var key in _propertyInfos.Keys) { writer.WriteString(key); } writer.WriteObjectHeader(_typeName); } foreach (var fieldInfo in _propertyInfos.Values) { writer.WriteObject(fieldInfo.GetValue(obj)); } }
protected override void DoWrite(object obj, Hessian2Writer writer) { if (!writer.WriteObjectHeader(_typeName)) { writer.WriteInt(_fieldInfos.Length); foreach (var field in _fieldInfos) { writer.WriteString(field.Name); } writer.WriteObjectHeader(_typeName); } foreach (var fieldInfo in _fieldInfos) { writer.WriteObject(fieldInfo.GetValue(obj)); } }