private LimitedCrashExtraDataList GetExtra(IDictionary<string, string> extra)
        {
            var data = new BugSense.Core.Model.LimitedCrashExtraDataList();

            foreach (var pair in extra)
            {
                try
                {
                    data.Add(new CrashExtraData(pair.Key, pair.Value));
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("Could not add value to Bugsense additional data");
                }
            }

            return data;
        }
Esempio n. 2
0
        private async Task <LiveConnectSessionStatus> Connect(bool includeEmailAddress = false)
        {
            if (client != null)
            {
                return(LiveConnectSessionStatus.Connected);
            }

            LiveAuthException liveConnectException = null;

            try
            {
                var liveAuth       = new LiveAuthClient(Constants.MICROSOFT_LIVE_CLIENTID);
                var liveAuthResult = includeEmailAddress
                                        ? await liveAuth.InitializeAsync(new[]
                {
                    Constants.MICROSOFT_LIVE_SCOPE_BASIC,
                    Constants.MICROSOFT_LIVE_SCOPE_EMAILS,
                    Constants.MICROSOFT_LIVE_SCOPE_SIGNIN,
                    Constants.MICROSOFT_LIVE_SCOPE_OFFLINEACCESS,
                    Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVE,
                    Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVEUPDATE
                })
                                        : await liveAuth.InitializeAsync(new[]
                {
                    Constants.MICROSOFT_LIVE_SCOPE_BASIC,
                    Constants.MICROSOFT_LIVE_SCOPE_SIGNIN,
                    Constants.MICROSOFT_LIVE_SCOPE_OFFLINEACCESS,
                    Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVE,
                    Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVEUPDATE
                });

                if (liveAuthResult.Status == LiveConnectSessionStatus.Connected)
                {
                    client = CreateClientForSession(liveAuth.Session);
                }
                else
                {
                    liveAuthResult = includeEmailAddress
                                        ? await liveAuth.LoginAsync(new[]
                    {
                        Constants.MICROSOFT_LIVE_SCOPE_BASIC,
                        Constants.MICROSOFT_LIVE_SCOPE_EMAILS,
                        Constants.MICROSOFT_LIVE_SCOPE_SIGNIN,
                        Constants.MICROSOFT_LIVE_SCOPE_OFFLINEACCESS,
                        Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVE,
                        Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVEUPDATE
                    })
                                        : await liveAuth.LoginAsync(new[]
                    {
                        Constants.MICROSOFT_LIVE_SCOPE_BASIC,
                        Constants.MICROSOFT_LIVE_SCOPE_SIGNIN,
                        Constants.MICROSOFT_LIVE_SCOPE_OFFLINEACCESS,
                        Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVE,
                        Constants.MICROSOFT_LIVE_SCOPE_SKYDRIVEUPDATE
                    });

                    client   = liveAuthResult.Status == LiveConnectSessionStatus.Connected ? CreateClientForSession(liveAuth.Session) : null;
                    meResult = null;
                }
                return(liveAuthResult.Status);
            }
            catch (TaskCanceledException)
            {
                client = null;
                return(LiveConnectSessionStatus.NotConnected);
            }
            catch (LiveAuthException ex)
            {
                if (ex.ErrorCode.Equals("access_denied", StringComparison.OrdinalIgnoreCase))
                {
                    client = null;
                    return(LiveConnectSessionStatus.NotConnected);
                }
                liveConnectException = ex;
            }
            if (liveConnectException != null)
            {
                var extraCrashData = new BugSense.Core.Model.LimitedCrashExtraDataList();
                extraCrashData.Add("ErrorCode", liveConnectException.ErrorCode);
                extraCrashData.Add("Message", liveConnectException.Message);
                await BugSenseHandler.Instance.LogExceptionAsync(liveConnectException, extraCrashData);
            }
            return(LiveConnectSessionStatus.Unknown);
        }