/// <summary> /// Adds a new Collection. /// </summary> /// <param name="type">The type must be of type ADatabaseCollection</param> /// <returns>The created Collection</returns> /// <exception cref="Exception"></exception> public ADatabaseCollection Add(Type type) { if (Collections.ContainsKey(type)) { throw new Exception($"Database already contains a collection for type [{type}]"); } if (!type.IsSubclassOf(typeof(ADatabaseCollection))) { throw new Exception($"[{type}] must be of type DatabaseCollection"); } var newCollection = (ADatabaseCollection)Activator.CreateInstance(type); if (newCollection.DefaultValues != null) { foreach (var i in newCollection.DefaultValues) { newCollection.Add(i.Value); } } Collections.Add(type, newCollection); return(newCollection); }
internal Collection AddCollection(string name) { if (name == null || name == "") { throw new AegisException(RoseResult.InvalidCollectionName, "Invalid collection name."); } using (WriterLock) { Collection collection; Collections.TryGetValue(name, out collection); if (collection != null) { throw new AegisException(RoseResult.DuplicateName, "The same collection name exists."); } // Collection 추가 collection = new Collection(this, name, false); Collections.Add(name, collection); return(collection); } }
public void SeedData() { Collections.Add(new Collection { Name = "My collection", Description = "Default collection" }); SaveChanges(); }
static Collections GenByYear(Beatmaps maps) { var year = 2007; Collections collections = new Collections(); Dictionary <int, Collection> CollYears = new Dictionary <int, Collection>(); for (int i = year; i < 2050; i++) { var collection = new Collection(OsuFileIo.LoadedMaps) { Name = i.ToString() }; collections.Add(collection); CollYears.Add(i, collection); } foreach (BeatmapExtensionEx map in maps) { CollYears[map.ApprovedDate.Year].AddBeatmap(map); } RemoveEmptyCollections(collections); return(collections); }
public void ReloadCollections() { try { var sw = new Stopwatch(); sw.Start(); List <Collection> collections = ImoutoCollectionService.Use(imoutoService => { var res = imoutoService.GetCollections(); return(res); }); sw.Stop(); Debug.WriteLine($"Collections reloaded in {sw.ElapsedMilliseconds}ms."); Collections.Clear(); collections.ForEach(x => Collections.Add(new CollectionVM(x.Id, x.Name))); Collections.ForEach(x => x.LoadFolders()); SelectedCollection = Collections.FirstOrDefault(); } catch (Exception ex) { App.MainWindowVM?.SetStatusError("Can't reload collections", ex.Message); Debug.WriteLine("Collections reload error: " + ex.Message); } }
public async Task ReloadCollectionsAsync() { try { var sw = new Stopwatch(); sw.Start(); var collections = await _collectionService.GetAllCollectionsAsync(); sw.Stop(); Debug.WriteLine($"Collections reloaded in {sw.ElapsedMilliseconds}ms."); Collections.Clear(); foreach (var collection in collections) { Collections.Add(new CollectionVM(collection.Id, collection.Name)); } foreach (var collectionVm in Collections) { await collectionVm.LoadFolders(); } SelectedCollection = Collections.FirstOrDefault(); } catch (Exception ex) { App.MainWindowVM?.SetStatusError("Can't reload collections", ex.Message); Debug.WriteLine("Collections reload error: " + ex.Message); } }
///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // send update for any updated children foreach (CollectionViewModel item in Collections) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (CollectionViewModel item in ItemsToAdd.OfType <CollectionViewModel>()) { item.Update(); Collections.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (CollectionViewModel item in ItemsToDelete.OfType <CollectionViewModel>()) { item.Delete(); Collections.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (CollectionViewModel item in Collections) { item.ResetModified(false); } }
private void ShowCollections() { if (Database == string.Empty) { _userMessageService.ShowMessage("You must specify a non-empty database name"); return; } IMongoQuery query = _mongoQueryFactory.BuildQuery(); try { IList <string> collections = query.GetCollections(Server, Database, Port); Collections.Clear(); foreach (string collection in collections) { Collections.Add(collection); } } catch (UnknownServerException ex) { _userMessageService.ShowMessage(ex.Message); } }
private void LoadProjectCollections() { try { foreach (var pc in TfsServiceWrapper.GetProjectCollections()) { Collections.Add(pc); } var settings = TeamRoomWindowCommand.Instance.LoadUserSettings(); if (settings.ProjectCollectionUri != null && Collections.Select(x => x.Uri).Contains(settings.ProjectCollectionUri)) { projectCollectionUri = settings.ProjectCollectionUri; savedteamRoomId = settings.TeamRoomId; if (projectCollectionUri != null && Collections.Select(x => x.Uri).Contains(projectCollectionUri)) { foreach (RegisteredProjectCollection item in cmbCollectionList.Items) { if (item.Uri == projectCollectionUri) { cmbCollectionList.SelectedIndex = cmbCollectionList.Items.IndexOf(item); break; } } } } } catch (Exception ex) { throw ex; } }
public void AddTag(IDmKeyword tagReference) { switch (tagReference.Type) { case TagType.Autor: Autors.Add((DmAutor)tagReference); break; case TagType.Category: Categories.Add((DmCategory)tagReference); break; case TagType.Genre: Genres.Add((DmGenre)tagReference); break; case TagType.People: Peoples.Add((DmPeople)tagReference); break; case TagType.Tag: Keywords.Add((DmKeyword)tagReference); break; case TagType.Collection: Collections.Add((DmCollection)tagReference); break; } }
public Collection CreateCollection(string name, bool justInCache) { if (name == null || name == "") { throw new AegisException(RoseResult.InvalidCollectionName, "Invalid collection name."); } using (WriterLock) { Collection collection; Collections.TryGetValue(name, out collection); if (collection != null) { throw new AegisException(RoseResult.DuplicateName, "The same collection name exists."); } // Collection 생성 collection = new Collection(this, name, justInCache); Collections.Add(name, collection); if (justInCache == false) { Storage.StorageEngine.Engine.CreateCollection(collection); } return(collection); } }
public override bool Load() { Log.WriteLine($"Loading database..."); if (Directory.Exists(Path)) { Mut.WaitOne(); Collections.Clear(); string[] files = Directory.GetFiles(Path); foreach (string file in files) { // file = Full Path string name = System.IO.Path.GetFileNameWithoutExtension(file); Collection c = JsonConvert.DeserializeObject <Collection>( Encoding.UTF8.GetString(File.Sync.ReadFile(file)), SerializerSettings); Collections.Add(name, c); } Mut.ReleaseMutex(); Log.WriteLine($"Loaded {files.Length} collections."); return(true); } else { Mut.WaitOne(); Directory.Create(Path); Collections.Clear(); Mut.ReleaseMutex(); Log.WriteLine("No database found. Created directory."); return(false); } }
/// <summary> /// Adds a collection to the database. /// </summary> public void AddCollection(string collectionName) { if (Collections.Any(collection => collection.Name == collectionName)) { throw new ArgumentException("Duplicate collection name."); } Collections.Add(new CollectionModel(Parent, this, collectionName)); }
public TagSearchVM(ObservableCollection <CollectionVM> collections) { Collections.Add(new KeyValuePair <string, int?>("All", null)); collections.ForEach(x => Collections.Add(new KeyValuePair <string, int?>(x.Name, x.Id))); SelectedColleciton = Collections.FirstOrDefault(); ResetValueEnter(); }
private async Task LoadCollections() { var r = await DataService.GetCollections(); foreach (var col in r.collections) { Collections.Add(col); } }
void BuildModel() { int idx = 0; foreach (var collection in Theme.Collections) { Collections.Add(new WordCollectionViewModel(collection, idx++, this)); } }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public void SetSplitQueryCollectionContext(int collectionId, SplitQueryCollectionContext splitQueryCollectionContext) { while (Collections.Count <= collectionId) { Collections.Add(null); } Collections[collectionId] = splitQueryCollectionContext; }
private IMongoCollection <T> GetCollection(IDatabaseSettings dbSettings = null) { if (dbSettings == null) { dbSettings = new DatabaseSettings() { CollectionName = typeof(T).Name, ConnectionString = Environment.GetEnvironmentVariable("MONGO_URI"), DatabaseName = Environment.GetEnvironmentVariable("MONGO_DB"), }; } string key = string.Format("{0}/{1}.{2}", dbSettings.ConnectionString.TrimEnd('/'), dbSettings.DatabaseName, dbSettings.CollectionName); object collection = null; _collecionLocker.EnterReadLock(); try { if (Collections.ContainsKey(key)) { collection = Collections[key]; } else { _collecionLocker.ExitReadLock(); _collecionLocker.EnterWriteLock(); try { if (!Collections.ContainsKey(key)) { IMongoDatabase database = GetDatabase(dbSettings); if (database.GetCollection <T>(typeof(T).Name) == null) { database.CreateCollection(typeof(T).Name); } collection = database.GetCollection <T>(typeof(T).Name); Collections.Add(key, collection); } collection = Collections[key]; } finally { _collecionLocker.ExitWriteLock(); } } } finally { if (_collecionLocker.IsReadLockHeld) { _collecionLocker.ExitReadLock(); } } return(collection as IMongoCollection <T>); }
public TextureSetFile WithTextureCollection([NotNull] TileTextureCollection c) { if (c == null) { throw new ArgumentNullException(nameof(c)); } Collections.Add(c); return(this); }
public void RenameCollection(VltCollection collection, string newName) { Collections.Remove(collection.ShortPath); collection.SetName(newName); if (collection.Class.HasField("CollectionName")) { collection.SetDataValue("CollectionName", newName); } Collections.Add(collection.ShortPath, collection); }
private void ViewOnSelectedCollectionsChanged(object sender, EventArgs eventArgs) { Collections selectedCollections = new Collections(); foreach (var collection in _view.SelectedCollections) { selectedCollections.Add((Collection)collection); } _model.SelectedCollections = selectedCollections; }
public MongoCollectionInfo AddCollection(string name) { var dbInfo = new MongoCollectionInfo { Name = name, Database = this }; Collections.Add(dbInfo); return(dbInfo); }
public Workspace(TextSyndicationContent title, IEnumerable <ResourceCollectionInfo> collections) : this() { Title = title; if (collections != null) { foreach (var i in collections) { Collections.Add(i); } } }
/// <summary> /// Generates a new collection scanning recursively the specified dir /// for music files. /// </summary> /// <param name="musicScanDir">A dir containing music files.</param> public void ScanDirectory(string musicScanDir) { if (musicScanDir == null) { throw new ArgumentNullException("musicScanDir", "The collection data load path cant be null"); } Collection data = CollectionFactory.ScanDirectory(musicScanDir); data.Reconnect(); Collections.Add(data); RefreshBands(); }
public void AddCollection(PTFlatGroupElement element) { if (Contains(element)) { return; } else { PTFlatGroupCollection newCollection = new PTFlatGroupCollection(false); newCollection.Add(element); Collections.Add(newCollection); } }
public MongoCollectionModelInfo SetCollectionModel(string collectionName, string modelCode, string rootClassName, bool isAutoGenerated, int sampleSize, decimal samplePercent) { if (Collections != null && Collections.Count > 0) { var collection = Collections.Find(col => col.Name.Equals(collectionName)); if (collection != null) { collection.Models.Clear(); collection.Models.Add(new MongoCollectionModelInfo { Collection = collection, ModelCode = modelCode, RootClassName = rootClassName, IsAutoGenerated = isAutoGenerated, SampleSize = sampleSize, SamplePercent = samplePercent }); return(collection.Models[0]); } } if (Collections == null) { Collections = new List <MongoCollectionInfo>(); } var newCollection = new MongoCollectionInfo { Name = collectionName, Database = this, Models = new List <MongoCollectionModelInfo> { new MongoCollectionModelInfo { Collection = null, ModelCode = modelCode, RootClassName = rootClassName, IsAutoGenerated = isAutoGenerated, SampleSize = sampleSize, SamplePercent = samplePercent } } }; newCollection.Models[0].Collection = newCollection; Collections.Add(newCollection); return(newCollection.Models[0]); }
public Gedcomx AddCollection(Collection collection) { if (collection != null) { if (Collections == null) { Collections = new List <Collection>(); } Collections.Add(collection); } return(this); }
static Collections GenBulkCollection(Beatmaps maps) { var collections = new Collections(); var collection = new Collection(OsuFileIo.LoadedMaps) { Name = "Bulk" }; foreach (var map in maps) { collection.AddBeatmap(map); } collections.Add(collection); return(collections); }
public TagSearchVM(ObservableCollection <CollectionVM> collections) { _fileTagService = ServiceLocator.GetService <IFileTagService>(); _tagService = ServiceLocator.GetService <ITagService>(); Collections.Add(new KeyValuePair <string, Guid?>("All", null)); foreach (var collectionVm in collections) { Collections.Add(new KeyValuePair <string, Guid?>(collectionVm.Name, collectionVm.Id)); } SelectedCollection = Collections.FirstOrDefault(); ResetValueEnter(); }
private void AddCollections(object sender, object data = null) { var webCollections = (IList <WebCollection>)data; var collections = new Collections(); foreach (var webCollection in webCollections) { if (!Initalizer.CollectionsManager.LoadedCollections.Contains(webCollection)) { collections.Add(webCollection); } } Initalizer.CollectionsManager.EditCollection(CollectionEditArgs.AddCollections(collections)); }
//-------------------------------------------------------------- /// <inheritdoc/> internal override void Flatten(Collections.ArrayList<Vector3F> vertices, Collections.ArrayList<int> strokeIndices, Collections.ArrayList<int> fillIndices) { _arcSegment.IsLargeArc = true; _arcSegment.Point1 = new Vector2F(RadiusX, 0); _arcSegment.Point2 = _arcSegment.Point1; _arcSegment.Radius = new Vector2F(RadiusX, RadiusY); _arcSegment.RotationAngle = 0; _arcSegment.SweepClockwise = false; var tempVertices = ResourcePools<Vector2F>.Lists.Obtain(); _arcSegment.Flatten(tempVertices, MaxNumberOfIterations, Tolerance); int numberOfVertices = tempVertices.Count; if (numberOfVertices < 2) return; int startIndex = vertices.Count; // Add 3D vertices. We skip the duplicated vertices. for (int i = 0; i < numberOfVertices; i += 2) vertices.Add(new Vector3F(tempVertices[i].X, tempVertices[i].Y, 0)); // Add stroke indices. for (int i = 0; i < numberOfVertices - 1; i++) strokeIndices.Add(startIndex + (i + 1) / 2); // Closing stroke: strokeIndices.Add(startIndex); if (IsFilled) { // Add a center vertex. var centerIndex = vertices.Count; vertices.Add(new Vector3F(0, 0, 0)); // Add one triangle per circle segment. for (int i = 0; i < numberOfVertices / 2 - 1; i++) { fillIndices.Add(centerIndex); fillIndices.Add(startIndex + i + 1); fillIndices.Add(startIndex + i); } // Last triangle: fillIndices.Add(centerIndex); fillIndices.Add(startIndex); fillIndices.Add(centerIndex - 1); } ResourcePools<Vector2F>.Lists.Recycle(tempVertices); }
protected virtual void UpdateDetailCollections(Collections.IContentList<DetailCollection> target, Collections.IContentList<DetailCollection> source, ContentItem targetItem) { ReplaceDetailCollectionsEnclosingItem(targetItem, source); List<string> keys = new List<string>(target.Keys); foreach (string key in keys) { DetailCollection detailCollection = target[key]; if (detailCollection.Name == "TrackedLinks") continue; if (source.Keys.Contains(key)) { UpdateDetails(detailCollection.Details as Collections.IContentList<ContentDetail>, source[key].Details as Collections.IContentList<ContentDetail>, targetItem); } else target.Remove(detailCollection); } keys = new List<string>(source.Keys); foreach (string key in keys) { DetailCollection detailCollection = source[key]; if (detailCollection.Name == "TrackedLinks") continue; if (target.Keys.Contains(key) == false) { detailCollection.ID = 0; target.Add(detailCollection); } } }
protected virtual void UpdateDetails(Collections.IContentList<ContentDetail> target, Collections.IContentList<ContentDetail> source, ContentItem targetItem) { ReplaceDetailsEnclosingItem(targetItem, source); List<string> keys = new List<string>(target.Keys); foreach (string key in keys) { ContentDetail detail = target[key]; //Don't update Parent and Versionkey if (target[key].Name == "ParentID" || target[key].Name == "VersionKey") continue; //Update Values if (source.Keys.Contains(key)) { //Check Ignore Attribute var prop = targetItem.GetType().GetProperty(key); //Details left in db not used as property anymore check if (prop != null) { if (Attribute.IsDefined(prop, typeof(N2.Details.XMLUpdaterIgnoreAttribute))) continue; } target[key].ObjectValue = source[key].BoolValue; target[key].DateTimeValue = source[key].DateTimeValue; target[key].DoubleValue = source[key].DoubleValue; target[key].IntValue = source[key].IntValue; target[key].Meta = source[key].Meta; target[key].ObjectValue = source[key].ObjectValue; target[key].StringValue = source[key].StringValue; target[key].Value = source[key].Value; } else { target.Remove(detail); } } //Add none existing Details from source keys = new List<string>(source.Keys); foreach (string key in keys) { ContentDetail detail = source[key]; //Ignore Parent and Versionkey if (detail.Name == "ParentID" && detail.Name == "VersionKey") continue; if (target.Keys.Contains(key) == false) { detail.ID = 0; target.Add(detail); } } }