当前位置: 首页>>代码示例>>C#>>正文


C# Repository类代码示例

本文整理汇总了C#中Repository的典型用法代码示例。如果您正苦于以下问题:C# Repository类的具体用法?C# Repository怎么用?C# Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Repository类属于命名空间,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAllLocation

 private static List<LocationDO> GetAllLocation()
 {
     Repository<vStore_Location> rep = new Repository<vStore_Location>(CheckoutDataContextProvider.Instance);
     List<vStore_Location> list = rep.GetAll().ToList();
     list.ForEach(x => x.Code = x.Code.Trim());
     return Mapper.Map<List<vStore_Location>, List<LocationDO>>(list);
 }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:7,代码来源:LocationBL.cs

示例2: CanStageANewFileInAPersistentManner

        public void CanStageANewFileInAPersistentManner()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
            using (var repo = new Repository(path.RepositoryPath))
            {
                const string filename = "unit_test.txt";
                Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename));
                Assert.Null(repo.Index[filename]);

                File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, filename), "some contents");
                Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(filename));
                Assert.Null(repo.Index[filename]);

                repo.Index.Stage(filename);
                Assert.NotNull(repo.Index[filename]);
                Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
            }

            using (var repo = new Repository(path.RepositoryPath))
            {
                const string filename = "unit_test.txt";
                Assert.NotNull(repo.Index[filename]);
                Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
            }
        }
开发者ID:KindDragon,项目名称:libgit2sharp,代码行数:25,代码来源:StageFixture.cs

示例3: CanListRemoteReferencesFromUrl

        public void CanListRemoteReferencesFromUrl(string url)
        {
            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                IList<DirectReference> references = repo.Network.ListReferences(url).ToList();

                foreach (var directReference in references)
                {
                    // None of those references point to an existing
                    // object in this brand new repository
                    Assert.Null(directReference.Target);
                }

                List<Tuple<string, string>> actualRefs = references.
                    Select(directRef => new Tuple<string, string>(directRef.CanonicalName, directRef.TargetIdentifier)).ToList();

                Assert.Equal(ExpectedRemoteRefs.Count, actualRefs.Count);
                for (int i = 0; i < ExpectedRemoteRefs.Count; i++)
                {
                    Assert.Equal(ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
                    Assert.Equal(ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
                }
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:26,代码来源:NetworkFixture.cs

示例4: PackageManager

        public PackageManager(Repository repo, IAbsoluteDirectoryPath workDir, bool createWhenNotExisting = false,
            string remote = null) {
            Contract.Requires<ArgumentNullException>(repo != null);
            Contract.Requires<ArgumentNullException>(workDir != null);
            WorkDir = workDir;
            Repo = repo;
            StatusRepo = new StatusRepo();
            Settings = new PackageManagerSettings();

            Repository.Factory.HandlePathRequirements(WorkDir, Repo);

            if (!WorkDir.Exists) {
                if (!createWhenNotExisting)
                    throw new Exception("Workdir doesnt exist");
                WorkDir.MakeSurePathExists();
            }

            if (!string.IsNullOrWhiteSpace(remote)) {
                var config =
                    Repository.DeserializeJson<RepositoryConfigDto>(
                        FetchString(Tools.Transfer.JoinUri(new Uri(remote), "config.json")));
                if (config.Uuid == Guid.Empty)
                    throw new Exception("Invalid remote, does not contain an UUID");
                Repo.AddRemote(config.Uuid, remote);
                Repo.Save();
            }

            Repository.Log("Opening repository at: {0}. Working directory at: {1}", Repo.RootPath, WorkDir);
            _remote = remote;
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:30,代码来源:PackageManager.cs

示例5: CannotReadReflogOnUnknownReference

 public void CannotReadReflogOnUnknownReference()
 {
     using (var repo = new Repository(StandardTestRepoWorkingDirPath))
     {
         Assert.Throws<InvalidSpecificationException>(() => repo.Refs.Log("toto").Count());
     }
 }
开发者ID:kckrinke,项目名称:libgit2sharp,代码行数:7,代码来源:ReflogFixture.cs

示例6: CanListRemoteReferences

        public void CanListRemoteReferences(string url)
        {
            string remoteName = "testRemote";

            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                Remote remote = repo.Network.Remotes.Add(remoteName, url);
                IList<Reference> references = repo.Network.ListReferences(remote).ToList();

                foreach (var reference in references)
                {
                    // None of those references point to an existing
                    // object in this brand new repository
                    Assert.Null(reference.ResolveToDirectReference().Target);
                }

                List<Tuple<string, string>> actualRefs = references.
                    Select(directRef => new Tuple<string, string>(directRef.CanonicalName, directRef.ResolveToDirectReference()
                        .TargetIdentifier)).ToList();

                Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs.Count, actualRefs.Count);
                Assert.True(references.Single(reference => reference.CanonicalName == "HEAD") is SymbolicReference);
                for (int i = 0; i < TestRemoteRefs.ExpectedRemoteRefs.Count; i++)
                {
                    Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
                    Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
                }
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:31,代码来源:NetworkFixture.cs

示例7: CanCompareACommitTreeAgainstItsParent

        public void CanCompareACommitTreeAgainstItsParent()
        {
            var path = SandboxStandardTestRepoGitDir();
            using (var repo = new Repository(path))
            {
                Tree commitTree = repo.Head.Tip.Tree;
                Tree parentCommitTree = repo.Head.Tip.Parents.Single().Tree;

                using (var changes = repo.Diff.Compare<TreeChanges>(parentCommitTree, commitTree))
                {
                    Assert.Equal(1, changes.Count());
                    Assert.Equal(1, changes.Added.Count());

                    TreeEntryChanges treeEntryChanges = changes.Single(c => c.Path == "1.txt");

                    Assert.Equal("1.txt", treeEntryChanges.Path);
                    Assert.Equal(ChangeKind.Added, treeEntryChanges.Status);

                    Assert.Equal(treeEntryChanges.Path, changes.Added.Single().Path);

                    Assert.Equal(Mode.Nonexistent, treeEntryChanges.OldMode);
                }

                using (var patch = repo.Diff.Compare<Patch>(parentCommitTree, commitTree))
                {
                    Assert.False(patch["1.txt"].IsBinaryComparison);
                }
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:29,代码来源:DiffTreeToTreeFixture.cs

示例8: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            var bus = new FakeBus();

            var storage = new EventStore(bus);
            var rep = new Repository<InventoryItem>(storage);
            var commands = new InventoryCommandHandlers(rep);
            bus.RegisterHandler<CheckInItemsToInventory>(commands.Handle);
            bus.RegisterHandler<CreateInventoryItem>(commands.Handle);
            bus.RegisterHandler<DeactivateInventoryItem>(commands.Handle);
            bus.RegisterHandler<RemoveItemsFromInventory>(commands.Handle);
            bus.RegisterHandler<RenameInventoryItem>(commands.Handle);
            var detail = new InvenotryItemDetailView();
            bus.RegisterHandler<InventoryItemCreated>(detail.Handle);
            bus.RegisterHandler<InventoryItemDeactivated>(detail.Handle);
            bus.RegisterHandler<InventoryItemRenamed>(detail.Handle);
            bus.RegisterHandler<ItemsCheckedInToInventory>(detail.Handle);
            bus.RegisterHandler<ItemsRemovedFromInventory>(detail.Handle);
            var list = new InventoryListView();
            bus.RegisterHandler<InventoryItemCreated>(list.Handle);
            bus.RegisterHandler<InventoryItemRenamed>(list.Handle);
            bus.RegisterHandler<InventoryItemDeactivated>(list.Handle);
            ServiceLocator.Bus = bus;
        }
开发者ID:jeremiahredekop,项目名称:m-r,代码行数:28,代码来源:Global.asax.cs

示例9: Main

        static void Main()
        {
            //Create all the repos I need
            var repo = new Repository();

            //Get some entities
            var person = repo.GetById<Person>(1);
            var company = repo.GetById<Company>(2);
            var order = repo.GetById<Order>(3);

            //Chagne and save entities
            person.FirstName = "Bob";
            company.CompanyName = "Bob's House of Propane and Day Old Sushi";
            order.OrderTotal = 1000000;

            var personId = repo.Save(person);
            var companyId = repo.Save(company);
            var orderId = repo.Save(order);

            Console.WriteLine("Saved person, Id is {0}", personId);
            Console.WriteLine("Saved company, Id is {0}", companyId);
            Console.WriteLine("Saved order, Id is {0}", orderId);

            Console.ReadKey();
        }
开发者ID:4ngardner,项目名称:GCGenericsDone,代码行数:25,代码来源:Program.cs

示例10: Init

        public void Init()
        {
            _users = new List<UserEntity>();
            for (var ndx = 0; ndx < 10; ++ndx)
            {
                var postfix = ndx.ToString();
                var user = new UserEntity
                {
                    UserEntityId = ndx + 1,
                    DateRegistered = ServerTime.Now,
                    UserName = "User" + postfix,
                    Email = String.Format("user.{0}@test.com", ndx)
                };

                _users.Add(user);
            }

            Mapper.CreateMap<UserEntity, User>()
                .ForMember(p => p.Id, opt => opt.MapFrom(src => src.UserEntityId))
                .IgnoreAllNonExisting();

            var builder = new ContainerBuilder();

            builder.RegisterType<QueryBuilder>().As<IQueryBuilder>();
            var entitiesRepo = new Repository<UserEntity>(_users);
            var usersRepo = new Repository<User>(_users.Select(p
                => p.MapTo<User>()));

            builder.RegisterInstance(entitiesRepo).As<IRepository<UserEntity>>().SingleInstance();
            builder.RegisterInstance(usersRepo).As<IRepository<User>>().SingleInstance();

            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);
            DependencyResolver.SetResolver(resolver);
        }
开发者ID:kamaelyoung,项目名称:Carcass,代码行数:35,代码来源:AccountControllerTest.cs

示例11: PerformSearch

        public override List<EpisodeParseResult> PerformSearch(Repository.Series series, dynamic options, Model.Notification.ProgressNotification notification)
        {
            if (options.Episode == null)
                throw new ArgumentException("Episode is invalid");

            notification.CurrentMessage = "Looking for " + options.Episode;

            var reports = new List<EpisodeParseResult>();
            var title = GetSearchTitle(series);

            var seasonNumber = options.Episode.SeasonNumber;
            var episodeNumber = options.Episode.EpisodeNumber;

            Parallel.ForEach(_indexerProvider.GetEnabledIndexers(), indexer =>
            {
                try
                {
                    reports.AddRange(indexer.FetchEpisode(title, seasonNumber, episodeNumber));
                }

                catch (Exception e)
                {
                    logger.ErrorException(String.Format("An error has occurred while searching for {0}-S{1:00}E{2:00} from: {3}",
                                                         series.Title, options.SeasonNumber, options.EpisodeNumber, indexer.Name), e);
                }
            });

            return reports;
        }
开发者ID:realpatriot,项目名称:NzbDrone,代码行数:29,代码来源:TestSearch.cs

示例12: RendezVousController

 public RendezVousController()
 {
     SlotRepository = new TimeSlotRepository();
     ContactRepository = new Repository<Contact>();
     DateRepository = new DateRepository();
     HolidayRepository = new HolidayRepository();
 }
开发者ID:QTruffart,项目名称:OsteoYoga,代码行数:7,代码来源:RendezVousController.cs

示例13: ArticleRevisionDiffApiModel

        public ArticleRevisionDiffApiModel(
            ArticleSlug articleSlug,
            ArticleRevisionDate oldRevisionDate,
            ArticleRevisionDate newRevisionDate,
            Repository repository)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            var oldRevision = repository.GetArticleRevision(articleSlug, oldRevisionDate);
            if (oldRevision == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var newRevision = repository.GetArticleRevision(articleSlug, newRevisionDate);
            if (newRevision == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var oldRevisionContent = MarkdownTextService.MakeText(oldRevision.MarkdownContent).ToHtmlLinebreaks();

            var newRevisionContent = MarkdownTextService.MakeText(newRevision.MarkdownContent).ToHtmlLinebreaks();

            var diff = new Helpers.HtmlDiff(oldRevisionContent ?? string.Empty, newRevisionContent ?? string.Empty);

            this.HtmlDiff = diff.Build();

            this.OldCreatedAt = oldRevision.CreatedAt.ToString(ArticleRevisionDate.FormattedDateTimeFormat);
            this.NewCreatedAt = newRevision.CreatedAt.ToString(ArticleRevisionDate.FormattedDateTimeFormat);
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:34,代码来源:ArticleRevisionDiffApiModel.cs

示例14: CleanDialog

        /// <summary>Create <see cref="CleanDialog"/>.</summary>
        /// <param name="repository">Related <see cref="Repository"/>.</param>
        public CleanDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();

            Localize();

            for(int i = 0; i < _lstFilesToClear.Columns.Count; ++i)
            {
                var col = _lstFilesToClear.Columns[i];
                col.IsVisible = col.Id == (int)ColumnId.Name;
            }

            _lstFilesToClear.Style = GitterApplication.DefaultStyle;
            _lstFilesToClear.Columns[0].SizeMode = Framework.Controls.ColumnSizeMode.Auto;
            _lstFilesToClear.ShowTreeLines = false;

            if(!GitFeatures.CleanExcludeOption.IsAvailableFor(repository))
            {
                _lblExcludePattern.Enabled = false;
                _txtExclude.Enabled = false;
                _txtExclude.Text = Resources.StrlRequiredVersionIs.UseAsFormat(
                    GitFeatures.CleanExcludeOption.RequiredVersion);
            }

            GitterApplication.FontManager.InputFont.Apply(_txtPattern, _txtExclude);

            LoadConfig();
        }
开发者ID:Kuzq,项目名称:gitter,代码行数:34,代码来源:CleanDialog.cs

示例15: TransportadorasController

 public TransportadorasController()
 {
     context = new Context();
     var dataBaseInitializer = new DataBaseInitializer();
     dataBaseInitializer.InitializeDatabase(context);
     repositorioTransportadora = new Repository<Transportadora>(context);
 }
开发者ID:maricrmacedo,项目名称:testeAxado,代码行数:7,代码来源:TransportadorasController.cs


注:本文中的Repository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。