int ITypeSerialize.CalculateSize(object value) { if (value == null) { return(0); } int total = 0; for (int i = 0; i < fieldInfos.Count; ++i) { var fieldInfo = fieldInfos[i]; var cv = fieldInfo.GetValue(value); if (cv == null) { continue; } var fieldType = fieldInfo.FieldType; total += WRStream.ComputeStringSize(fieldInfo.Name); int size = MonoSerialize.GetByType(fieldInfo).CalculateSize(cv); total += WRStream.ComputeLengthSize(size); total += size; } return(total); }
int ITypeSerialize.CalculateSize(object value) { var array = value as IList; if (array != null) { int total = WRStream.ComputeLengthSize(array.Count); // 长度 // 长度+各个元素内容 for (int i = 0; i < array.Count; ++i) { total += WRStream.ComputeStringSize((string)array[i]); } return(total); } return(0); }
protected override int CalculateSize(string value) { return(WRStream.ComputeStringSize(value)); }