/// <summary> /// Constructor /// </summary> /// <param name="client">The instance that implements IDocumentClient</param> public DatabaseInitialiser( IDocumentClient client) { client.NotNull(nameof(client)); _client = client; }
public IOrderedQueryable <T> CreateQuery <T>(IDocumentClient client, StorageConfig cfg) { var collectionLink = $"/dbs/{cfg.DocumentDbDatabase}/colls/{cfg.DocumentDbCollection}"; return(client.CreateDocumentQuery <T>(collectionLink)); }
private void OnSerializingMethod(StreamingContext context) { this.documentClient = GlobalConfiguration.Configuration.DependencyResolver.GetService <IDocumentClient>(); this.strategies = GlobalConfiguration.Configuration.DependencyResolver.GetService <IEnumerable <ISubscriptionStrategy> >(); }
public StopsController(ITransitFeedCosmosDatabase transitFeedDatabase, IDocumentClient client) { this.transitFeedDatabase = transitFeedDatabase; }
public DocumentRepository(IDocumentClient documentClient) { _documentClient = documentClient; _collectionUri = UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId); }
public void CosmosDbClient_WithNullArgument_ShouldThrowArgumentNullException(string databaseName, string collectionName, IDocumentClient documentClient, string paramName) { var ex = Assert.Throws <ArgumentNullException>(() => new CosmosDbClient(databaseName, collectionName, documentClient)); Assert.Equal(paramName, ex.ParamName); }
public FileCommandTag(Command command, IDocumentClient client) { Command = command; Editor = client; }
public DocumentDbRepository(string cosmosDatabase, IDocumentClient @object) { this.cosmosDatabase = cosmosDatabase; this.@object = @object; }
private string PromptUserForNewFilePath(IDocumentClient client, string fileName, IDocument existingDocument) { string filePath = Path.GetFileName(fileName); FileFilterBuilder fb = new FileFilterBuilder(); string[] extensions = client.Info.Extensions; foreach (string extension in extensions) fb.AddFileType(client.Info.FileType, extension); if (extensions.Length > 1) fb.AddAllFilesWithExtensions(); string filter = fb.ToString(); FileDialogService.InitialDirectory = client.Info.InitialDirectory; if (FileDialogService.SaveFileName(ref filePath, filter) != FileDialogResult.OK) return null; if (!client.Info.IsCompatiblePath(filePath)) { Outputs.WriteLine(OutputMessageType.Error, "File extension not supported".Localize()); return null; } // Check that the document isn't already open Uri uri = new Uri(filePath); IDocument openDocument = FindOpenDocument(uri); if (openDocument != null && openDocument != existingDocument) { Outputs.WriteLine(OutputMessageType.Error, "A file with that name is already open".Localize()); return null; } return filePath; }
// 'Safe' in the sense that all exceptions are caught (and reported via OnOpenException). private IDocument SafeOpen(IDocumentClient client, Uri uri) { IDocument document = null; try { if (client.CanOpen(uri)) { if (OnDocumentOpening(uri)) { document = client.Open(uri); if (document != null) { OnDocumentOpened(document); DocumentOpened.Raise(this, new DocumentEventArgs(document, DocumentEventType.Opened)); DocumentRegistry.ActiveDocument = document; } } } } catch (Exception ex) { // DAN: Added this - if an exception occurs during line: // DocumentRegistry.ActiveDocument = document; // then we need to remove it if (DocumentRegistry.ActiveDocument == document) DocumentRegistry.Remove(document); document = null; // Let's share the exception directly. We used to wrap it in another Exception // object but this hides the actual exception in the error dialog. OnOpenException(ex); } return document; }
/// <summary> /// Gets the path name for a new document</summary> /// <param name="client">Document client</param> /// <returns>URI representing the new path, or null if the user cancelled</returns> protected virtual Uri GetNewDocumentUri(IDocumentClient client) { Uri uri = null; string fileName = client.Info.NewDocumentName; string extension = null; string directoryName = null; if (client.Info.Extensions.Length > 1) { if (string.IsNullOrEmpty(client.Info.DefaultExtension)) { // Since there are multiple possible extensions, ask the user to pick a filename. string path = PromptUserForNewFilePath(client, fileName, null); if (path != null) { try { if (File.Exists(path)) File.Delete(path); } catch (Exception e) { string message = string.Format( "Failed to delete: {0}. Exception: {1}", path, e); Outputs.WriteLine(OutputMessageType.Warning, message); } m_newDocumentPaths.Add(path); uri = new Uri(path, UriKind.RelativeOrAbsolute); return uri; } } else { directoryName = client.Info.InitialDirectory; if (directoryName == null) directoryName = FileDialogService.InitialDirectory; extension = client.Info.DefaultExtension; } } if (client.Info.Extensions.Length >= 1) { // Since there is only one possible extension, we can choose the new name (e.g., "Untitled.xml"). directoryName = client.Info.InitialDirectory; if (directoryName == null) directoryName = FileDialogService.InitialDirectory; extension = client.Info.Extensions[0]; if (directoryName != null && extension != null) { int suffix; m_extensionSuffixes.TryGetValue(extension, out suffix); // check the name to make sure there is no existing file with the same name while (true) { string fullFileName = fileName; if (suffix > 0) fullFileName += "(" + (suffix + 1) + ")"; suffix++; fullFileName += extension; string fullPath = Path.Combine(directoryName, fullFileName); if (!FileDialogService.PathExists(fullPath)) { uri = new Uri(fullPath, UriKind.RelativeOrAbsolute); break; } } m_extensionSuffixes[extension] = suffix; } } return uri; }
/// <summary> /// Opens one or more existing documents for the given client</summary> /// <param name="client">Document client</param> /// <param name="uri">Document URI, or null to present file dialog to user</param> /// <returns>Last document opened by the given client, or null</returns> /// <remarks>Exceptions during opening are caught and reported via OnOpenException.</remarks> public virtual IDocument OpenExistingDocument(IDocumentClient client, Uri uri) { if (client == null) throw new ArgumentNullException("client"); string filter = client.Info.GetFilterString(); string[] pathNames = null; if (uri != null) { pathNames = new[] { uri.ToString() }; } else { FileDialogService.InitialDirectory = client.Info.InitialDirectory; FileDialogService.OpenFileNames(ref pathNames, filter); } IDocument document = null; if (pathNames != null) { foreach (string pathName in pathNames) { Uri docUri = new Uri(pathName, UriKind.RelativeOrAbsolute); IDocument openDocument = FindOpenDocument(docUri); if (openDocument != null) { // Simply show the document. http://tracker.ship.scea.com/jira/browse/CORETEXTEDITOR-403 document = openDocument; client.Show(openDocument); } else document = SafeOpen(client, docUri); } } return document; }
/// <summary> /// Opens a new document for the given client</summary> /// <param name="client">Document client</param> /// <returns>Document, opened by the given client, or null if the user cancelled or /// there was a problem</returns> /// <remarks>Exceptions during opening are caught and reported via OnOpenException.</remarks> public virtual IDocument OpenNewDocument(IDocumentClient client) { if (client == null) throw new ArgumentNullException("client"); IDocument result = null; Uri uri = GetNewDocumentUri(client); if (uri != null) { result = SafeOpen(client, uri); // Consider the document untitled unless its file has been created by the client or // unless the user has already chosen a filename. if (result != null) { if (!m_newDocumentPaths.Contains(result.Uri.LocalPath) && !FileDialogService.PathExists(result.Uri.LocalPath)) { m_untitledDocuments.Add(result); } } } return result; }
public ProjectRepository(IOptions <DbSettings> dbSettings, ILogger <ProjectRepository> logger, IDocumentClient client) : base(dbSettings, logger, client) { }
internal async Task <IReadOnlyCollection <PartitionKeyRange> > GetPartitionKeyRanges(IDocumentClient client) { string responseContinuation = null; var partitionKeyRanges = new List <PartitionKeyRange>(); var documentCollectionUri = UriFactory.CreateDocumentCollectionUri(this.Database, this.Collection); do { var response = await client.ReadPartitionKeyRangeFeedAsync(documentCollectionUri, new FeedOptions { RequestContinuation = responseContinuation }); partitionKeyRanges.AddRange(response); responseContinuation = response.ResponseContinuation; }while (responseContinuation != null); return(partitionKeyRanges); }
public CosmosOffers(IDocumentClient documentClient) { this.documentClient = documentClient; }
public CategoryMappingsService(IDocumentClient client) { _databaseId = "CQCData"; _collectionId = "CategoryMappings"; _client = client; }
public CosmosDbClient(string databaseName, string collectionName, IDocumentClient documentClient) { _databaseName = databaseName ?? throw new ArgumentNullException(nameof(databaseName)); _collectionName = collectionName ?? throw new ArgumentNullException(nameof(collectionName)); _documentClient = documentClient ?? throw new ArgumentNullException(nameof(documentClient)); }
public GenericRepository(IAppConfiguration <T> appConfig, IDocumentClient client) { _databaseId = appConfig?.DatabaseId; _collectionId = appConfig?.CollectionId; _client = client; }
public CosmosDbClient CreateCosmosDbClientForTesting(IDocumentClient documentClient) { return(new CosmosDbClient(DatabaseName, CollectionName, documentClient)); }
public SimpleScaler(IDocumentClient client, string databaseId, string collectionId) { _client = client; _databaseId = databaseId; _collectionId = collectionId; }
public CosmosCollectionCreator(IDocumentClient documentClient) { _documentClient = documentClient; }
public UserSessionRepository(IDocumentClient client, CosmosDbConnection cosmosDbConnection) { this.cosmosDbConnection = cosmosDbConnection; this.client = client; }
public MyFunction(IDocumentClient client) { _client = client; }
public CosmosDbClientFactory(string databaseName, List <string> collectionNames, IDocumentClient documentClient) { _databaseName = databaseName ?? throw new ArgumentNullException(nameof(databaseName)); _collectionNames = collectionNames ?? throw new ArgumentNullException(nameof(collectionNames)); _documentClient = documentClient ?? throw new ArgumentNullException(nameof(documentClient)); }
public SearchService(IDocumentClient documentClient, IApplicationConfig applicationConfig, IUserDigestService userDigestService) { _documentClient = documentClient; _applicationConfig = applicationConfig; _userDigestService = userDigestService; }
public StateChangeProcessor(IDocumentClient client, IOptions <StateChangeProcessorOptions> options) { this.client = client; this.cosmosDBDatabase = options.Value.COSMOSDB_DATABASE_NAME; this.cosmosDBCollection = options.Value.COSMOSDB_DATABASE_COL; }
public async Task DeleteAsync(IDocumentClient client, StorageConfig cfg, string docId) { var collectionLink = $"/dbs/{cfg.DocumentDbDatabase}/colls/{cfg.DocumentDbCollection}"; await client.DeleteDocumentAsync($"{collectionLink}/docs/{docId}"); }
public CosmosClientBase(IDocumentClient client, string databaseName, string collectionName) { _client = client; CollectionUri = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName); }
public UserStore(IDocumentClient documentClient, DocumentCollection users) // DocumentCollection of TUser { _Client = documentClient; _Users = users; UsesPartitioning = _Users.PartitionKey?.Paths.Any() ?? false; }
public ProductRepository(IDocumentClient client) : base(client) { }
public SpikeRepo(IDocumentClient documentClient, IOptions <DatabaseSettings> dbOptions) : base(documentClient, dbOptions) { }
public UserSessionRepo(IDocumentClient documentClient, IOptions <DatabaseSettings> dbOptions) : base(documentClient, dbOptions) { }
private DocumentDbRepository(IDocumentClient client, DocumentCollection collection) { Client = client; DocumentCollection = collection; }
public CommandRepository(IDocumentClient documentClient, IOptions <DomainDbOptions> settings) : base(settings.Value.CommandCollectionId, documentClient, settings) { }
public ReadOnlyDocumentRepository(IDocumentClient documentClient, string databaseName, string collectionName) { DocumentClient = documentClient; DatabaseName = databaseName; CollectionName = collectionName; }
public DocumentRepository(IDocumentClient documentClient, string databaseName, string collectionName) : base(documentClient, databaseName, collectionName) { }
private static void InsertSession(IDocumentClient client) { //Create some data to store var session = CreateSession(); client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(DatabaseName, CollectionName), session).GetAwaiter().GetResult(); }
/// <summary> /// Gets the path name for a new document</summary> /// <param name="client">Document client</param> /// <returns>URI representing the new path, or null if the user cancelled</returns> protected virtual Uri GetNewDocumentUri(IDocumentClient client) { Uri uri = null; string fileName = client.Info.NewDocumentName; if (client.Info.Extensions.Length > 1 && string.IsNullOrEmpty(client.Info.DefaultExtension)) { // Since there are multiple possible extensions and no default, ask the user. string path = PromptUserForNewFilePath(client, fileName, null); if (path != null) { try { if (File.Exists(path)) File.Delete(path); } catch (Exception e) { string message = string.Format( "Failed to delete: {0}. Exception: {1}", path, e); Outputs.WriteLine(OutputMessageType.Warning, message); } m_newDocumentPaths.Add(path); uri = new Uri(path, UriKind.RelativeOrAbsolute); return uri; } } if (client.Info.Extensions.Length >= 1) { // There is either only one possible extension or there is a default, so we choose. string directoryName = client.Info.InitialDirectory; if (directoryName == null) directoryName = FileDialogService.InitialDirectory; string extension = client.Info.DefaultExtension; if (string.IsNullOrEmpty(extension)) extension = client.Info.Extensions[0]; if (directoryName != null && extension != null) uri = GenerateUniqueUri(directoryName, fileName, extension); } return uri; }