/// <summary> /// Creates a connection to view storage /// </summary> /// <param name="storageConfiguration">Storage configuration (either local file path /// or <see cref="AzureStoreConfiguration"/>)</param> /// <param name="containerName">container name (directory) where to put views</param> /// <returns>new instance of the client that can read and write events</returns> public static ViewClient ConnectToViewStorage(string storageConfiguration, string containerName) { AzureStoreConfiguration configuration; if (!AzureStoreConfiguration.TryParse(storageConfiguration, out configuration)) { var root = new FileViewRoot(new DirectoryInfo(storageConfiguration)); var viewClient = new ViewClient(root.GetContainer(containerName), FileActionPolicy); viewClient.CreateContainerIfNeeded(); return viewClient; } else { var account = CloudStorageAccount.Parse(configuration.ConnectionString); var client = account.CreateCloudBlobClient(); var viewContainer = new AzureViewRoot(client).GetContainer(configuration.RootBlobContainerName); var viewClient = new ViewClient(viewContainer.GetContainer(containerName), AzureActionPolicy); viewClient.CreateContainerIfNeeded(); return viewClient; } }
/// <summary> /// Creates a connection to view storage /// </summary> /// <param name="storageConfiguration">Storage configuration (either local file path /// or <see cref="AzureStoreConfiguration"/>)</param> /// <param name="containerName">container name (directory) where to put views</param> /// <returns>new instance of the client that can read and write events</returns> public static ViewClient ConnectToViewStorage(string storageConfiguration, string containerName) { AzureStoreConfiguration configuration; if (!AzureStoreConfiguration.TryParse(storageConfiguration, out configuration)) { var root = new FileViewRoot(new DirectoryInfo(storageConfiguration)); var viewClient = new ViewClient(root.GetContainer(containerName), FileActionPolicy); viewClient.CreateContainerIfNeeded(); return(viewClient); } else { var account = CloudStorageAccount.Parse(configuration.ConnectionString); var client = account.CreateCloudBlobClient(); var viewContainer = new AzureViewRoot(client).GetContainer(configuration.RootBlobContainerName); var viewClient = new ViewClient(viewContainer.GetContainer(containerName), AzureActionPolicy); viewClient.CreateContainerIfNeeded(); return(viewClient); } }