Ouya.Console.Api.GamerUuidListener.FromCache C# (CSharp) Метод

FromCache() статический приватный Метод

static private FromCache ( ) : string
Результат string
        internal static string FromCache()
        {
            OuyaFacade.Log("Returning cached gamerUuid");
            string gamerUuid = null;
            try
            {
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (store.FileExists(gamerUuidFileName))
                    {
                        using (var reader = new StreamReader(store.OpenFile(gamerUuidFileName, FileMode.Open)))
                        {
                            gamerUuid = reader.ReadToEnd();
                            try
                            {
                                Guid.Parse(gamerUuid);
                            }
                            catch (Exception e2)
                            {
                                OuyaFacade.Log("Incorrectly formatted gamerUuid: " + e2.Message);
                                gamerUuid = null;
                            }
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                OuyaFacade.Log("Error decaching gamerUuid: " + e1.Message);
            }
            return gamerUuid;
        }

Usage Example

Пример #1
0
        public async Task <string> RequestGamerUuidAsync()
        {
            if (!String.IsNullOrEmpty(_gamerUuid))
            {
                return(_gamerUuid);
            }
            var tcs      = new TaskCompletionSource <string>();
            var listener = new GamerUuidListener(tcs);

            try
            {
                RequestGamerUuid(listener);
                _gamerUuid = await tcs.Task.TimeoutAfter(timeout);
            }
            catch (Exception e)
            {
                Log(e.GetType().Name + ": " + e.Message);
                _gamerUuid = GamerUuidListener.FromCache();
            }
            return(_gamerUuid);
        }