本文整理汇总了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);
}
}
}
示例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);
}
}