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


C# DataServiceContext.AddRelatedObject方法代码示例

本文整理汇总了C#中DataServiceContext.AddRelatedObject方法的典型用法代码示例。如果您正苦于以下问题:C# DataServiceContext.AddRelatedObject方法的具体用法?C# DataServiceContext.AddRelatedObject怎么用?C# DataServiceContext.AddRelatedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataServiceContext的用法示例。


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

示例1: InnerSubmit

        private void InnerSubmit(DataServiceContext dataContext)
        {
            if (!string.IsNullOrWhiteSpace(this.TemplateId))
            {
                dataContext.AddObject(JobBaseCollection.JobSet, this);

                foreach (IAsset asset in this.InputMediaAssets)
                {
                    AssetData target = asset as AssetData;
                    if (target == null)
                    {
                        throw new ArgumentException(StringTable.ErrorInputTypeNotSupported);
                    }

                    dataContext.AttachTo(AssetCollection.AssetSet, asset);
                    dataContext.AddLink(this, InputMediaAssetsPropertyName, target);
                }
            }
            else
            {
                X509Certificate2 certToUse = null;
                Verify(this);

                dataContext.AddObject(JobBaseCollection.JobSet, this);

                List<AssetData> inputAssets = new List<AssetData>();
                AssetNamingSchemeResolver<AssetData, OutputAsset> assetNamingSchemeResolver = new AssetNamingSchemeResolver<AssetData, OutputAsset>(inputAssets);

                foreach (ITask task in ((IJob)this).Tasks)
                {
                    Verify(task);
                    TaskData taskData = (TaskData)task;

                    if (task.Options.HasFlag(TaskOptions.ProtectedConfiguration))
                    {
                        ProtectTaskConfiguration(taskData, ref certToUse, dataContext);
                    }

                    taskData.TaskBody = CreateTaskBody(assetNamingSchemeResolver, task.InputAssets.ToArray(), task.OutputAssets.ToArray());
                    taskData.InputMediaAssets.AddRange(task.InputAssets.OfType<AssetData>().ToArray());
                    taskData.OutputMediaAssets.AddRange(
                        task.OutputAssets
                            .OfType<OutputAsset>()
                            .Select(
                                c =>
                                {
                                    AssetData assetData = new AssetData { Name = c.Name, Options = (int)c.Options, AlternateId = c.AlternateId };
                                    assetData.InitCloudMediaContext(this._cloudMediaContext);

                                    return assetData;
                                })
                            .ToArray());
                    dataContext.AddRelatedObject(this, TasksPropertyName, taskData);
                }

                foreach (IAsset asset in inputAssets)
                {
                    dataContext.AttachTo(AssetCollection.AssetSet, asset);
                    dataContext.AddLink(this, InputMediaAssetsPropertyName, asset);
                }
            }
        }
开发者ID:gittehub,项目名称:azure-sdk-for-media-services,代码行数:62,代码来源:JobData.cs

示例2: InnerSave

        private void InnerSave(DataServiceContext dataContext)
        {
            X509Certificate2 certToUse = null;

            dataContext.AddObject(JobTemplateBaseCollection.JobTemplateSet, this);

            foreach (TaskTemplateData taskTemplate in this.TaskTemplates)
            {
                dataContext.AddRelatedObject(this, TaskTemplatesPropertyName, taskTemplate);

                if (((ITaskTemplate)taskTemplate).Options.HasFlag(TaskOptions.ProtectedConfiguration) && (taskTemplate.Configuration != taskTemplate.ConfigurationCopied))
                {
                    ProtectTaskConfiguration((TaskTemplateData)taskTemplate, ref certToUse, dataContext);
                }
            }

            MatchCollection matches = Regex.Matches(this.JobTemplateBodyCopied, @"taskTemplateId=""nb:ttid:UUID:([a-zA-Z0-9\-]+)""");
            this.JobTemplateBody = this.JobTemplateBodyCopied;
            for (int i = 0; i < matches.Count; i++)
            {
                string taskTemplateId = Guid.NewGuid().ToString();

                this.TaskTemplates[i].Id = string.Concat("nb:ttid:UUID:", taskTemplateId);
                this.JobTemplateBody = this.JobTemplateBody.Replace(matches[i].Groups[1].Value, taskTemplateId);
            }
        }
开发者ID:gittehub,项目名称:azure-sdk-for-media-services,代码行数:26,代码来源:JobTemplateData.cs


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