Пример #1
0
        private async Task <Tuple <TelemetryManifest, long> > ReadAndParseManifest(BehaviorOnStale staleBehavior)
        {
            //IL_000a: Unknown result type (might be due to invalid IL or missing references)
            //IL_000b: Unknown result type (might be due to invalid IL or missing references)
            Stream stream = await remoteControlClient.ReadFileAsync(staleBehavior).ConfigureAwait(false);

            if (stream == null)
            {
                return(new Tuple <TelemetryManifest, long>(null, 0L));
            }
            using (StreamReader streamReader = new StreamReader(stream))
            {
                _ = 1;
                try
                {
                    return(new Tuple <TelemetryManifest, long>((TelemetryManifest)(await manifestParser.ParseAsync(streamReader).ConfigureAwait(false)), stream.Length));
                }
                catch (Exception ex)
                {
                    if (ex is IOException || ex is ThreadAbortException)
                    {
                        return(new Tuple <TelemetryManifest, long>(null, 0L));
                    }
                    throw;
                }
            }
        }
Пример #2
0
 private async Task Check(BehaviorOnStale staleBehavior, CancellationToken token = default(CancellationToken))
 {
     //IL_000a: Unknown result type (might be due to invalid IL or missing references)
     //IL_000b: Unknown result type (might be due to invalid IL or missing references)
     try
     {
         await LoadManifest(staleBehavior, token).ConfigureAwait(false);
     }
     catch (TelemetryManifestParserException ex)
     {
         if (!token.IsCancellationRequested)
         {
             List <string> list = new List <string>();
             for (Exception innerException = ex.InnerException; innerException != null; innerException = innerException.InnerException)
             {
                 list.Add(innerException.Message);
             }
             OnUpdateTelemetryManifestStatusEvent(new TelemetryManifestEventArgs(null));
             InstrumentLoad(null, 0L, ex.Message, (list.Count > 0) ? StringExtensions.Join((IEnumerable <string>)list, ";") : null, 0.0);
         }
     }
     catch (Exception exceptionObject)
     {
         FaultEvent faultEvent = new FaultEvent("VS/Telemetry/InternalFault", $"LoadManifest ManifestManager.Check", exceptionObject)
         {
             PostThisEventToTelemetry = false
         };
         faultEvent.AddProcessDump(Process.GetCurrentProcess().Id);
         mainSession.PostEvent(faultEvent);
     }
 }
Пример #3
0
 /// <summary>
 /// Reads the settings file based on the <paramref name="staleBehavior" /> specified.
 /// </summary>
 /// <param name="staleBehavior">See <see cref="T:Coding4Fun.VisualStudio.RemoteControl.BehaviorOnStale" /> for details about each possible setting.
 /// In most cases use the BehaviorOnStale.ReturnStale setting.</param>
 /// <returns>A Stream that can be used to read the setting file. !Callers must call Dispose on this stream
 /// object returned. Or Null is returned in case of failure to get the file (or if server returned
 /// NotFound).</returns>
 public Stream ReadFile(BehaviorOnStale staleBehavior)
 {
     if (isDisabled)
     {
         return(null);
     }
     if (isDisposed)
     {
         throw new ObjectDisposedException("RemoteControlClient");
     }
     return(ReadFileAsync(staleBehavior).Result);
 }
Пример #4
0
        private async Task LoadManifest(BehaviorOnStale staleBehavior, CancellationToken token = default(CancellationToken))
        {
            //IL_000a: Unknown result type (might be due to invalid IL or missing references)
            //IL_000b: Unknown result type (might be due to invalid IL or missing references)
            Stopwatch watch = Stopwatch.StartNew();
            Tuple <TelemetryManifest, long> tuple = await ReadAndParseManifest(staleBehavior).ConfigureAwait(false);

            watch.Stop();
            if (!token.IsCancellationRequested && (CurrentManifest == null || (tuple.Item1 != null && !(CurrentManifest.Version == tuple.Item1.Version))))
            {
                string message = "Manifest is null";
                if (tuple.Item1 != null)
                {
                    CurrentManifest = tuple.Item1;
                    message         = null;
                }
                OnUpdateTelemetryManifestStatusEvent(new TelemetryManifestEventArgs(tuple.Item1));
                InstrumentLoad(tuple.Item1, tuple.Item2, message, null, watch.ElapsedMilliseconds);
            }
        }
Пример #5
0
        /// <summary>
        /// Reads the settings file based on the <paramref name="staleBehavior" /> specified. This is the Async version
        /// of ReadFile method.
        /// </summary>
        /// <param name="staleBehavior">See <see cref="T:Coding4Fun.VisualStudio.RemoteControl.BehaviorOnStale" /> for details about each possible setting.
        /// In most cases use the BehaviorOnStale.ReturnStale setting.</param>
        /// <returns>A Stream that can be used to read the setting file. !Callers must call Dispose on this stream
        /// object returned. Or Null is returned in case of failure to get the file (or if server returned
        /// NotFound).</returns>
        public async Task <Stream> ReadFileAsync(BehaviorOnStale staleBehavior)
        {
            if (isDisabled)
            {
                return(null);
            }
            if (isDisposed)
            {
                throw new ObjectDisposedException("RemoteControlClient");
            }
            if (Uri.IsLocalFile)
            {
                return((await ReadFileFromLocalAsync().ConfigureAwait(false)).RespStream);
            }
            switch (staleBehavior)
            {
            case BehaviorOnStale.ReturnStale:
                return((await GetFileAndInstrumentAsync().ConfigureAwait(false)).RespStream);

            case BehaviorOnStale.ReturnNull:
            {
                GetFileResult getFileResult = await GetFileAndInstrumentAsync().ConfigureAwait(false);

                if (IsStale(getFileResult))
                {
                    return(getFileResult.RespStream);
                }
                getFileResult.Dispose();
                return(null);
            }

            case BehaviorOnStale.ForceDownload:
                return((await GetFileAndInstrumentAsync(true).ConfigureAwait(false)).RespStream);

            default:
                return(null);
            }
        }