public StorageService(CloudAuthenticator authenticator) : base(authenticator) { if (authenticator == null) throw new ArgumentNullException(nameof(authenticator)); _config = new StorageConfiguration(); }
public Bucket(string bucketId, CloudAuthenticator authenticator, StorageConfiguration configuration) { this._bucketId = bucketId; this._authenticator = authenticator; this._config = configuration; _authenticator.GetInitializer().GZipEnabled = _config.EnableGzip; _googleStorageService = new Google.Apis.Storage.v1.StorageService(_authenticator.GetInitializer()); }
public StorageService(CloudAuthenticator authenticator) : base(authenticator) { if (authenticator == null) { throw new ArgumentNullException(nameof(authenticator)); } _config = new StorageConfiguration(); }
public DatastoreService(CloudAuthenticator authenticator, DatastoreConfiguration configuration) : this(authenticator) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } Configuration = configuration; }
public DatastoreService(CloudAuthenticator authenticator) : base(authenticator) { if (authenticator == null) { throw new ArgumentNullException(nameof(authenticator)); } if (IndexContainer == null) { IndexContainer = new InMemoryIndexContainer(); } Configuration = new DatastoreConfiguration(); // default config }
protected DatastoreProvider(CloudAuthenticator authenticator, DatastoreConfiguration configuration, IIndexContainer indexContainer) { if (authenticator == null) { throw new NullReferenceException(nameof(authenticator)); } if (configuration == null) { throw new NullReferenceException(nameof(configuration)); } if (indexContainer == null) { throw new NullReferenceException(nameof(indexContainer)); } Authenticator = authenticator; Configuration = configuration; IndexContainer = indexContainer; }
private bool IsKeyUsed(CloudAuthenticator authenticator, string key) { // TODO consider using AllocateIds() var result = new Google.Apis.Datastore.v1beta3.DatastoreService(authenticator.GetInitializer()).Projects.Lookup(new LookupRequest { Keys = new List <Key> { new Key { Path = new List <PathElement> { new PathElement { Name = key, Kind = typeof(T).Name } } } } }, authenticator.GetProjectId()).Execute(); return(result.Found.Any()); }
public StorageService(CloudAuthenticator authenticator, StorageConfiguration config) : this(authenticator) { _config = config; }
public DatastoreTranslatorProvider(CloudAuthenticator authenticator, DatastoreConfiguration configuration, IIndexContainer indexes) : base(authenticator, configuration, indexes) { }
public List <Entity> SerializeAndAutoKey(IEnumerable <T> entities, CloudAuthenticator authenticator, bool verifyThatIdIsUnused) { var datastoreEntities = new List <Entity>(); foreach (var entity in entities) { var idPropInfo = QueryHelper.GetIdProperty <T>(); string key = null; if (idPropInfo != null) { var typeCode = idPropInfo.PropertyType.GetTypeCode(); switch (typeCode) { case TypeCode.String: { var idField = idPropInfo.GetValue(entity); if (string.IsNullOrWhiteSpace((string)idField)) { string autoId; do { autoId = Guid.NewGuid().ToString(); } while (verifyThatIdIsUnused && IsKeyUsed(authenticator, autoId)); idPropInfo.SetValue(entity, autoId); key = autoId; } else { key = (string)idField; } break; } default: throw new NotSupportedException($"Id type `{typeCode}` is not supported. Id type must be a string."); } } else { // Require that an id or key field exists. throw new MissingMemberException($"`{typeof(T).Name}` does not contain an Id property nor any other property with the DatastoreKey attribute."); } // TODO(neil-119) Right now the id duplicates the key column, need to change behavior, must account for Select(x => x.key) projection // Serialize it. var datastoreEntity = SerializeEntity(entity); // Setup its key. if (datastoreEntity == null) { throw new NullReferenceException("Serialized entity is null"); } if (datastoreEntity?.Key?.Path == null) { datastoreEntity.Key = new Key { Path = new List <PathElement>() } } ; datastoreEntity.Key.Path.Add(new PathElement { Kind = typeof(T).GetTypeInfo().Name, Name = key }); datastoreEntities.Add(datastoreEntity); } return(datastoreEntities); }
protected GAEService(CloudAuthenticator authenticator) { Authenticator = authenticator; }