public void CreateSimpleStorage(Type ofType) { var defaultFieldName = DefaultFieldName; var fieldBuilder = ImplType.DefineField(defaultFieldName, ofType, FieldAttributes.Public); ObjectStorage[defaultFieldName] = fieldBuilder; }
/// <summary> /// 将 [序列化程式实现种类] 转换为 [JSON 序列化程式实现种类] /// </summary> /// <param name="enum"></param> /// <param name="value"></param> /// <returns></returns> public static bool TryConvert(this ImplType @enum, out JsonImplType value) { switch (@enum) { case ImplType.NewtonsoftJson: value = JsonImplType.NewtonsoftJson; return(true); case ImplType.SystemTextJson: value = JsonImplType.SystemTextJson; return(true); default: value = default; return(false); } }
/// <summary> /// Construct: using the implementtation type /// </summary> /// <param name="type"></param> public DeviceInfoAdaptor(ImplType type) { switch (type) { case ImplType.GUID: _target = new DeviceInfoGuidHelperImpl(); break; case ImplType.NETWORKADAPTOR: _target = new DeviceInfoNetworkHelperImpl(); break; case ImplType.KERNELIOCONTROL: _target = new DeviceInfoKernalIoControlHelperImpl(); break; default: throw new ArgumentException("Implementation type error!"); } }
public DType GetField(string fieldName) { if (ImplType.TryGetField(fieldName, out var _, out var findex)) { return(Fields[findex]); }