コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public void SeedData()
 {
     Collections.Add(new Collection {
         Name = "My collection", Description = "Default collection"
     });
     SaveChanges();
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
    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);
        }
    }
コード例 #7
0
        ///--------------------------------------------------------------------------------
        /// <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);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
        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;
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
ファイル: Database.cs プロジェクト: envis10n/XeonProject
 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);
     }
 }
コード例 #13
0
 /// <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));
 }
コード例 #14
0
        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();
        }
コード例 #15
0
ファイル: MainViewModel.cs プロジェクト: showbiznine/Dojo
        private async Task LoadCollections()
        {
            var r = await DataService.GetCollections();

            foreach (var col in r.collections)
            {
                Collections.Add(col);
            }
        }
コード例 #16
0
ファイル: ThemeViewModel.cs プロジェクト: ygrenier/Phraseur
        void BuildModel()
        {
            int idx = 0;

            foreach (var collection in Theme.Collections)
            {
                Collections.Add(new WordCollectionViewModel(collection, idx++, this));
            }
        }
コード例 #17
0
        /// <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;
        }
コード例 #18
0
        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>);
        }
コード例 #19
0
        public TextureSetFile WithTextureCollection([NotNull] TileTextureCollection c)
        {
            if (c == null)
            {
                throw new ArgumentNullException(nameof(c));
            }

            Collections.Add(c);
            return(this);
        }
コード例 #20
0
 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);
 }
コード例 #21
0
        private void ViewOnSelectedCollectionsChanged(object sender, EventArgs eventArgs)
        {
            Collections selectedCollections = new Collections();

            foreach (var collection in _view.SelectedCollections)
            {
                selectedCollections.Add((Collection)collection);
            }
            _model.SelectedCollections = selectedCollections;
        }
コード例 #22
0
        public MongoCollectionInfo AddCollection(string name)
        {
            var dbInfo = new MongoCollectionInfo
            {
                Name     = name,
                Database = this
            };

            Collections.Add(dbInfo);
            return(dbInfo);
        }
コード例 #23
0
ファイル: Workspace.cs プロジェクト: pmq20/mono_forked
 public Workspace(TextSyndicationContent title, IEnumerable <ResourceCollectionInfo> collections)
     : this()
 {
     Title = title;
     if (collections != null)
     {
         foreach (var i in collections)
         {
             Collections.Add(i);
         }
     }
 }
コード例 #24
0
ファイル: MainViewModel.cs プロジェクト: Wscar/NMusicPlayer
        /// <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();
        }
コード例 #25
0
 public void AddCollection(PTFlatGroupElement element)
 {
     if (Contains(element))
     {
         return;
     }
     else
     {
         PTFlatGroupCollection newCollection = new PTFlatGroupCollection(false);
         newCollection.Add(element);
         Collections.Add(newCollection);
     }
 }
コード例 #26
0
        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]);
        }
コード例 #27
0
ファイル: Gedcomx.cs プロジェクト: xocrus/gedcomx-csharp
        public Gedcomx AddCollection(Collection collection)
        {
            if (collection != null)
            {
                if (Collections == null)
                {
                    Collections = new List <Collection>();
                }

                Collections.Add(collection);
            }

            return(this);
        }
コード例 #28
0
        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);
        }
コード例 #29
0
    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();
    }
コード例 #30
0
        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));
        }
コード例 #31
0
ファイル: EllipseFigure.cs プロジェクト: Zolniu/DigitalRune
        //--------------------------------------------------------------
        /// <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);
        }
コード例 #32
0
ファイル: Updater.cs プロジェクト: andy4711/n2cms
		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);
				}
			}

		}
コード例 #33
0
ファイル: Updater.cs プロジェクト: andy4711/n2cms
		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);
				}
			}
		}