本文整理汇总了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);
}
示例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));
}
}
示例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);
}
}
}
示例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;
}
示例5: CannotReadReflogOnUnknownReference
public void CannotReadReflogOnUnknownReference()
{
using (var repo = new Repository(StandardTestRepoWorkingDirPath))
{
Assert.Throws<InvalidSpecificationException>(() => repo.Refs.Log("toto").Count());
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例12: RendezVousController
public RendezVousController()
{
SlotRepository = new TimeSlotRepository();
ContactRepository = new Repository<Contact>();
DateRepository = new DateRepository();
HolidayRepository = new HolidayRepository();
}
示例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);
}
示例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();
}
示例15: TransportadorasController
public TransportadorasController()
{
context = new Context();
var dataBaseInitializer = new DataBaseInitializer();
dataBaseInitializer.InitializeDatabase(context);
repositorioTransportadora = new Repository<Transportadora>(context);
}