本文整理汇总了C#中IStorage.Save方法的典型用法代码示例。如果您正苦于以下问题:C# IStorage.Save方法的具体用法?C# IStorage.Save怎么用?C# IStorage.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorage
的用法示例。
在下文中一共展示了IStorage.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSmallRegistration
static async Task SaveSmallRegistration(IStorage storage, Uri registrationBaseAddress, IDictionary<string, IGraph> items, int partitionSize, Uri contentBaseAddress, CancellationToken cancellationToken)
{
Trace.TraceInformation("RegistrationPersistence.SaveSmallRegistration");
SingleGraphPersistence graphPersistence = new SingleGraphPersistence(storage);
//await graphPersistence.Initialize();
await SaveRegistration(storage, registrationBaseAddress, items, null, graphPersistence, partitionSize, contentBaseAddress, cancellationToken);
// now the commit has happened the graphPersistence.Graph should contain all the data
JObject frame = (new CatalogContext()).GetJsonLdContext("context.Registration.json", graphPersistence.TypeUri);
StorageContent content = new StringStorageContent(Utils.CreateJson(graphPersistence.Graph, frame), "application/json", "no-store");
await storage.Save(graphPersistence.ResourceUri, content, cancellationToken);
}
示例2: CreateSaveOperationForItem
protected override ResourceSaveOperation CreateSaveOperationForItem(IStorage storage, CatalogContext context, CatalogItem item, CancellationToken cancellationToken)
{
// This method decides what to do with the item.
// If it's a RegistrationMakerCatalogItem and it already exists, then don't write content.
var registrationMakerCatalogItem = item as RegistrationMakerCatalogItem;
if (registrationMakerCatalogItem != null)
{
var content = item.CreateContent(Context); // note: always do this first
var resourceUri = item.GetItemAddress();
var saveOperation = new ResourceSaveOperation();
saveOperation.ResourceUri = resourceUri;
if (!registrationMakerCatalogItem.IsExistingItem && content != null)
{
saveOperation.SaveTask = storage.Save(resourceUri, content, cancellationToken);
}
else
{
Trace.WriteLine(string.Format("Resource {0} already exists. Skipping.", resourceUri), "Debug");
}
return saveOperation;
}
return base.CreateSaveOperationForItem(storage, context, item, cancellationToken);
}
示例3: CreateSaveOperationForItem
protected virtual ResourceSaveOperation CreateSaveOperationForItem(IStorage storage, CatalogContext context, CatalogItem item, CancellationToken cancellationToken)
{
// This method decides what to do with the item.
// Standard method of operation: if content == null, don't do a thing. Else, write content.
var content = item.CreateContent(Context); // note: always do this first
var resourceUri = item.GetItemAddress();
var operation = new ResourceSaveOperation();
operation.ResourceUri = resourceUri;
if (content != null)
{
operation.SaveTask = storage.Save(resourceUri, content, cancellationToken);
}
return operation;
}