Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ProcessBuilderRemote.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.ServiceModel;
6 using System.Threading.Tasks;
7 
8 using SiliconStudio.Core.Diagnostics;
9 using SiliconStudio.Core.Serialization.Assets;
10 using SiliconStudio.Core.Storage;
11 
12 namespace SiliconStudio.BuildEngine
13 {
14  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext = false)]
16  {
17  private readonly LocalCommandContext commandContext;
18  private readonly Command remoteCommand;
19  private readonly BuildParameterCollection buildParameters;
20 
21  public CommandResultEntry Result { get; protected set; }
22 
23  public ProcessBuilderRemote(LocalCommandContext commandContext, Command remoteCommand, BuildParameterCollection buildParameters)
24  {
25  this.commandContext = commandContext;
26  this.remoteCommand = remoteCommand;
27  this.buildParameters = buildParameters;
28  }
29 
31  {
32  return remoteCommand;
33  }
34 
36  {
37  return buildParameters;
38  }
39 
40  public void RegisterResult(CommandResultEntry commandResult)
41  {
42  Result = commandResult;
43  }
44 
45  public void ForwardLog(SerializableLogMessage message)
46  {
47  commandContext.Logger.Log(new LogMessage(message.Module, message.Type, message.Text));
48  if (message.ExceptionInfo != null)
49  commandContext.Logger.Log(new LogMessage(message.Module, message.Type, message.ExceptionInfo.ToString()));
50  }
51 
52  public async Task<ResultStatus> SpawnCommand(Command command)
53  {
54  Task<ResultStatus> task = commandContext.ScheduleAndExecuteCommand(command);
55  commandContext.Step.AwaitSpawnedCommand(task);
56  return await task;
57  }
58 
59  public ObjectId ComputeInputHash(UrlType type, string filePath)
60  {
61  return commandContext.ComputeInputHash(type, filePath);
62  }
63 
64  public Dictionary<ObjectUrl, ObjectId> GetOutputObjects()
65  {
66  var result = new Dictionary<ObjectUrl, ObjectId>();
67  foreach (var outputObjects in commandContext.GetOutputObjectsGroups())
68  {
69  foreach (var outputObject in outputObjects)
70  {
71  if (!result.ContainsKey(outputObject.Key))
72  {
73  result.Add(outputObject.Key, outputObject.Value.ObjectId);
74  }
75  }
76  }
77  return result;
78  }
79  }
80 }
void RegisterResult(CommandResultEntry commandResult)
async Task< ResultStatus > SpawnCommand(Command command)
ExceptionInfo ExceptionInfo
Gets or sets the ExceptionInfo of this message.
ObjectId ComputeInputHash(UrlType type, string filePath)
A class that represents a copy of a LogMessage that can be serialized.
void ForwardLog(SerializableLogMessage message)
LogMessageType Type
Gets or sets the type of this message.
A hash to uniquely identify data.
Definition: ObjectId.cs:13
A base log message used by the logging infrastructure.
Definition: LogMessage.cs:13
ProcessBuilderRemote(LocalCommandContext commandContext, Command remoteCommand, BuildParameterCollection buildParameters)
Dictionary< ObjectUrl, ObjectId > GetOutputObjects()