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


C# IStorage.Save方法代码示例

本文整理汇总了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);
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:16,代码来源:RegistrationPersistence.cs

示例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);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:27,代码来源:RegistrationMakerCatalogWriter.cs

示例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;
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:18,代码来源:CatalogWriterBase.cs


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