public CacheBuilder(IProxyFactory proxyFactory) { _configuredTypes = new Dictionary <Type, ConfigurationForType>(); _details = new List <ConfigurationForType>(); _proxyFactory = proxyFactory; _proxyValidator = new ProxyValidator(_proxyFactory); _eventListeners = new List <IEventListener>(); if (LogEventListener.IsLoggingEnabled()) { _eventListeners.Add(new LogEventListener()); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; if (appListener == null) { appListener = new LogEventListener(); appListener.EnableEvents(LogEventSource.Log, EventLevel.Verbose); errorListener = new LogEventListener("Errors"); errorListener.EnableEvents(LogEventSource.Log, EventLevel.Error); LogEventSource.Log.Info("App initialized."); // winRT approach channel = new LoggingChannel("WinRTChannel"); channel.LoggingEnabled += (o, args) => { this.winRtLoggingEnabled = o.Enabled; this.winRtLogLevel = o.Level; }; session = new LoggingSession("WinRTSession"); session.AddLoggingChannel(channel); } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); //Associate the frame with a SuspensionManager key SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { const string Message = "Restoring saved session state."; LogEventSource.Log.Info(Message); channel.LogMessage(Message, LoggingLevel.Information); await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException ex) { var message = string.Format("Error restoring saved session state: {0}", ex.Message); LogEventSource.Log.Error(message); channel.LogMessage(message, LoggingLevel.Error); //Something went wrong restoring state. //Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(HubPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); const string Msg = "Window activated."; LogEventSource.Log.Info(Msg); channel.LogMessage(Msg, LoggingLevel.Information); }
static async Task Main(string[] args) { var connectionString = Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING"); if (string.IsNullOrEmpty(connectionString)) { throw new InvalidOperationException("Environment variable STORAGE_CONNECTION_STRING is not set"); } Log($"ITERATIONS: {_iterations}"); Log($"UPLOAD_SIZE: {_uploadSize}"); Log($"BUFFER_SIZE: {_bufferSize}"); Log($"MAX_CONCURRENCY: {_maxConcurrency}"); // Enable SDK logging (with timestamps) using var azureListener = new AzureEventSourceListener( (eventData, text) => Log(String.Format("[{1}] {0}: {2}", eventData.EventSource.Name, eventData.Level, text)), EventLevel.Verbose); // Enable System.Net logging using var httpListener = new LogEventListener("Microsoft-System-Net-Http"); using var socketsListener = new LogEventListener("Microsoft-System-Net-Sockets"); var containerName = $"container{DateTime.Now.Ticks}"; // Test custom transport with shorter timeout var containerClient = new BlobContainerClient(connectionString, containerName, new BlobClientOptions() { Transport = new HttpClientTransport(new HttpClient() { Timeout = _httpClientTimeout }) }); Log($"Creating container {containerName}"); await containerClient.CreateAsync(); Log($"Created container {containerName}"); var randomBuffer = new byte[_uploadSize]; new Random(0).NextBytes(randomBuffer); var randomStream = new NonSeekableMemoryStream(randomBuffer); for (var i = 0; i < _iterations; i++) { try { Log($"Iteration {i}"); var blobName = $"blob{DateTime.Now.Ticks}"; var blobClient = containerClient.GetBlobClient(blobName); randomStream.Seek(0, SeekOrigin.Begin); Log($"Uploading blob {blobName}"); await blobClient.UploadAsync(randomStream, transferOptions : new StorageTransferOptions() { MaximumConcurrency = _maxConcurrency, MaximumTransferLength = _bufferSize }); Log($"Uploaded blob {blobName}"); Log($"Deleting blob {blobName}"); await blobClient.DeleteAsync(); Log($"Deleted blob {blobName}"); } catch (Exception e) { Log(e); } } Log($"Deleting container {containerName}"); await containerClient.DeleteAsync(); Log($"Deleted container {containerName}"); }