public static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions) { message = ""; bool result; if (!Provider.enabled) { result = true; } else if (string.IsNullOrEmpty(assetPath)) { result = true; } else { Asset asset; if (statusOptions == StatusQueryOptions.UseCachedIfPossible || statusOptions == StatusQueryOptions.UseCachedAsync) { AssetModificationHook.CachedStatusMode mode = (statusOptions != StatusQueryOptions.UseCachedAsync) ? AssetModificationHook.CachedStatusMode.Sync : AssetModificationHook.CachedStatusMode.Async; asset = AssetModificationHook.GetStatusCachedIfPossible(assetPath, mode); } else { asset = AssetModificationHook.GetStatusForceUpdate(assetPath); } if (asset == null) { if (Provider.onlineState == OnlineState.Offline && Provider.offlineReason != string.Empty) { message = Provider.offlineReason; } result = false; } else { result = Provider.IsOpenForEdit(asset); } } return(result); }
private static Asset GetStatusCachedIfPossible(string from, AssetModificationHook.CachedStatusMode mode) { Asset asset = Provider.CacheStatus(from); if (asset == null || asset.IsState(Asset.States.Updating)) { if (mode == AssetModificationHook.CachedStatusMode.Sync) { Task task = Provider.Status(from, false); task.Wait(); if (task.success) { asset = Provider.CacheStatus(from); } else { asset = null; } } } return(asset); }