CreateInstance() public static méthode

public static CreateInstance ( IServiceProvider provider, int id, string name, string comment, FavoritesFolder parent ) : FavoritesFolder
provider IServiceProvider
id int
name string
comment string
parent FavoritesFolder
Résultat FavoritesFolder
        public void AddFolder(string name, string comment, FavoritesFolder parentFolder)
        {
            if (parentFolder.SubFolders.Any(f => f.Name == name))
            {
                return;
            }

            var newFolder =
                FavoritesFolder.CreateInstance(_provider, -1, name, comment, parentFolder);

            using (var db = _provider.CreateDBContext())
                using (var tx = db.BeginTransaction())
                {
                    db
                    .IntoFavoriteFolders()
                    .Value(_ => _.Name, name)
                    .Value(_ => _.ParentID, parentFolder.Id)
                    .Value(_ => _.Comment, comment)
                    .Insert();

                    newFolder.Id = db.FavoriteFolders().Max(ff => ff.ID);
                    tx.Commit();
                }
            parentFolder.SubFolders.Add(newFolder);
            SetFavoriteLinksSetDirty();
        }
        private Dictionary <int, FavoritesFolder> GetFavorites()
        {
            using (var db = _provider.CreateDBContext())
            {
                var folders =
                    db
                    .FavoriteFolders()
                    .Select(
                        ff =>
                        new FavoritesFolder(_provider)
                {
                    Id       = ff.ID,
                    Name     = ff.Name,
                    ParentId = ff.ParentID,
                    Comment  = ff.Comment
                })
                    .ToDictionary(ff => ff.Id);

                var links =
                    db
                    .FavoriteItems()
                    .Select(
                        i =>
                        new FavoritesLink(_provider)
                {
                    Id        = i.ID,
                    FolderId  = i.FolderID,
                    Comment   = i.Comment,
                    Url       = i.Url,
                    MessageId = i.MessageID,
                })
                    .ToList();

                var rootFolder =
                    FavoritesFolder.CreateInstance(
                        _provider,
                        0,
                        string.Empty,
                        string.Empty,
                        null);

                folders.Add(0, rootFolder);

                foreach (var link in links)
                {
                    var folder = folders[link.FolderId];

                    folder.Links.Add(link);
                    link.Parent = folder;
                }

                return(folders);
            }
        }