本文整理汇总了C#中IBrightstarService.GetCommitPoints方法的典型用法代码示例。如果您正苦于以下问题:C# IBrightstarService.GetCommitPoints方法的具体用法?C# IBrightstarService.GetCommitPoints怎么用?C# IBrightstarService.GetCommitPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBrightstarService
的用法示例。
在下文中一共展示了IBrightstarService.GetCommitPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommitPointsModule
public CommitPointsModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider permissionsProvider)
{
this.RequiresBrightstarStorePermission(permissionsProvider, get:StorePermissions.ViewHistory, post:StorePermissions.Admin);
Get["/{storeName}/commits"] = parameters =>
{
int skip = Request.Query["skip"].TryParse<int>(0);
int take = Request.Query["take"].TryParse<int>(DefaultPageSize);
DateTime timestamp = Request.Query["timestamp"].TryParse<DateTime>();
DateTime earliest = Request.Query["earliest"].TryParse<DateTime>();
DateTime latest = Request.Query["latest"].TryParse<DateTime>();
var request = this.Bind<CommitPointsRequestModel>();
ViewBag.Title = request.StoreName + " - Commit History";
if (timestamp != default(DateTime))
{
// Request for a single commit point
var commitPoint = brightstarService.GetCommitPoint(parameters["storeName"], timestamp);
return commitPoint == null ? HttpStatusCode.NotFound : MakeResponseObject(commitPoint);
}
if (earliest != default(DateTime) && latest != default(DateTime))
{
IEnumerable<ICommitPointInfo> results =
brightstarService.GetCommitPoints(parameters["storeName"], latest, earliest, skip, take + 1);
var resourceUri = String.Format("commits?latest={0}&earliest={1}", latest.ToString("s"), earliest.ToString("s"));
return Negotiate.WithPagedList(request, results.Select(MakeResponseObject), skip, take, DefaultPageSize, resourceUri);
}
IEnumerable<ICommitPointInfo> commitPointInfos = brightstarService.GetCommitPoints(parameters["storeName"], skip, take + 1);
return Negotiate.WithPagedList(request, commitPointInfos.Select(MakeResponseObject), skip, take, DefaultPageSize, "commits");
};
Post["/{storeName}/commits"] = parameters =>
{
var commitPoint = this.Bind<CommitPointResponseModel>();
if (commitPoint == null ||
String.IsNullOrEmpty(commitPoint.StoreName) ||
!commitPoint.StoreName.Equals(parameters["storeName"]))
{
return HttpStatusCode.BadRequest;
}
var commitPointInfo = brightstarService.GetCommitPoint(parameters["storeName"], commitPoint.Id);
if (commitPointInfo == null) return HttpStatusCode.BadRequest;
brightstarService.RevertToCommitPoint(parameters["storeName"], commitPointInfo);
return HttpStatusCode.OK;
};
}
示例2: StoreModule
public StoreModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
{
this.RequiresBrightstarStorePermission(storePermissionsProvider, get:StorePermissions.Read, delete:StorePermissions.Admin);
Get["/{storeName}"] = parameters =>
{
var storeName = parameters["storeName"];
ViewBag.Title = storeName;
if (!brightstarService.DoesStoreExist(storeName)) return HttpStatusCode.NotFound;
if (Request.Method.ToUpperInvariant() == "HEAD")
{
IEnumerable < ICommitPointInfo > commitPoints = brightstarService.GetCommitPoints(storeName, 0, 1);
var commit = commitPoints.First();
return
Negotiate.WithHeader("Last-Modified", commit.CommitTime.ToUniversalTime().ToString("r"))
.WithStatusCode(HttpStatusCode.OK)
.WithModel(new StoreResponseModel(parameters["storeName"]));
}
return new StoreResponseModel(parameters["storeName"]);
};
Delete["/{storeName}"] = parameters =>
{
var storeName = parameters["storeName"];
ViewBag.Title = "Deleted - " + storeName;
if (brightstarService.DoesStoreExist(storeName))
{
brightstarService.DeleteStore(storeName);
}
return Negotiate.WithMediaRangeModel(new MediaRange("text/html"),
new StoreDeletedModel {StoreName = storeName});
};
}
示例3: ListCommitPoints
private static List<ICommitPointInfo> ListCommitPoints(IBrightstarService client, string storeName)
{
var ret = new List<ICommitPointInfo>();
int commitPointNumber = 0;
// Retrieve 10 most recent commit point info from the store
foreach(var commitPointInfo in client.GetCommitPoints(storeName, 0, 10))
{
ret.Add(commitPointInfo);
Console.WriteLine("#{0}: ID: {1} Commited at: {2}", commitPointNumber++, commitPointInfo.Id, commitPointInfo.CommitTime);
// Query this commit point
QueryCommitPoint(client, commitPointInfo);
}
return ret;
}