private string _GetRuntimeName(SchemaType type, _RuntimeField extra) { if (type is ObjectType anyType) { return(typeof(Object).Name); } if (type is StringType strType) { return(typeof(String).Name); } if (type is BlittableType blitType) { var tname = blitType.DataType.Name; return(blitType.IsNullable ? $"{tname}?" : tname); } if (type is ArrayType arrayType) { var container = extra?.CollectionContainer; if (string.IsNullOrWhiteSpace(container)) { container = _DefaultCollectionContainer; } return(container.Replace("TItem", _GetRuntimeName(arrayType.ItemType))); } if (type is DictionaryType dictType) { var key = this._GetRuntimeName(dictType.KeyType); var val = this._GetRuntimeName(dictType.ValueType); return($"Dictionary<{key},{val}>"); } if (type is EnumType enumType) { return(_UseType(enumType).RuntimeName); } if (type is ClassType classType) { return(_UseType(classType).RuntimeName); } throw new NotImplementedException(); }
public _RuntimeField UseField(FieldInfo finfo) { var key = $"{finfo.PersistentName}"; if (_Fields.TryGetValue(key, out _RuntimeField rfield)) { return(rfield); } rfield = new _RuntimeField(finfo); _Fields[key] = rfield; return(rfield); }