/// <summary> /// 检查是否具有扩展数据字段 /// </summary> /// <param name="cache"></param> /// <returns></returns> public bool DetermineExtensionDataProperty(Dictionary <string, BinaryPropertyInfo> cache) { // 一个类型中只能由一个扩展字段(由BinaryExtensionDataAttribute标注) BinaryPropertyInfo binaryPropertyInfo = GetPropertyWithUniqueAttribute(Type, typeof(BinaryExtensionDataAttribute), cache); if (binaryPropertyInfo != null) { Type declaredPropertyType = binaryPropertyInfo.DeclaredPropertyType; if (typeof(IDictionary <string, object>).IsAssignableFrom(declaredPropertyType)) { BinaryConverter converter = Options.GetConverter(declaredPropertyType); Debug.Assert(converter != null); } else { ThrowHelper.ThrowInvalidOperationException_SerializationDataExtensionPropertyInvalid(Type, binaryPropertyInfo); } DataExtensionProperty = binaryPropertyInfo; return(true); } return(false); }