/// <summary> /// LoadBitmapResource /// </summary> /// <param name="type"></param> /// <param name="resourceID"></param> /// <returns></returns> /// <exception cref="MobileException"></exception> public static SKBitmap LoadBitmapResource(Type type, string resourceID) { Assembly assembly = type.GetTypeInfo().Assembly; using Stream stream = assembly.GetManifestResourceStream(resourceID) ?? throw MobileExceptions.ResourceNotFound(resourceId: resourceID); return(SKBitmap.Decode(stream)); }
private static async Task <string> SaveFileAsync(Stream stream, string fullPath) { if (await FileUtil.TrySaveFileAsync(stream, fullPath).ConfigureAwait(false)) { return(fullPath); } else { throw MobileExceptions.LocalFileSaveError(fullPath: fullPath); } }
/// <exception cref="MobileException"></exception> /// <exception cref="DatabaseException"></exception> private async Task ChangeIdAsync(object?obj, string requestId, ChangeDirection direction, ApiRequestType requestType) { if (obj == null) { return; } //替换ID foreach (PropertyInfo propertyInfo in obj.GetType().GetProperties().Where(p => Attribute.IsDefined(p, typeof(IdBarrierAttribute)))) { object?propertyValue = propertyInfo.GetValue(obj); if (propertyValue == null) { continue; } if (propertyValue is long id) { await ConvertLongIdAsync(obj, id, propertyInfo, requestType, direction, requestId).ConfigureAwait(false); } else if (propertyValue is IEnumerable <long> longIds) { foreach (long iditem in longIds) { await ConvertLongIdAsync(obj, iditem, propertyInfo, requestType, direction, requestId).ConfigureAwait(false); } } else if (propertyValue is IEnumerable enumerable) { foreach (object subObj in enumerable) { await ChangeIdAsync(subObj, requestId, direction, requestType).ConfigureAwait(false); } } else { throw MobileExceptions.IdBarrierError(cause: "Id Barrier碰到无法解析的类型"); } } }