| | 1 | | using Microsoft.Xrm.Sdk; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.IO; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Runtime.Serialization; |
| | 7 | | using System.Runtime.Serialization.Json; |
| | 8 | | using System.Text; |
| | 9 | | using System.Threading.Tasks; |
| | 10 | | using Xrm.Oss.XTL.Interpreter; |
| | 11 | |
|
| | 12 | | namespace Xrm.Oss.XTL.Templating |
| | 13 | | { |
| | 14 | | [DataContract] |
| | 15 | | public class ProcessorConfig : IConfig |
| | 16 | | { |
| 26 | 17 | | public string Raw { get; set; } |
| | 18 | |
|
| | 19 | | [DataMember(Name = "targetField")] |
| 56 | 20 | | public string TargetField { get; set; } |
| | 21 | |
|
| | 22 | | [DataMember(Name = "templateField")] |
| 39 | 23 | | public string TemplateField { get; set; } |
| | 24 | |
|
| | 25 | | [DataMember(Name = "template")] |
| 35 | 26 | | public string Template { get; set; } |
| | 27 | |
|
| | 28 | | [DataMember(Name = "executionCriteria")] |
| 31 | 29 | | public string ExecutionCriteria { get; set; } |
| | 30 | |
|
| | 31 | | [DataMember(Name = "target")] |
| 37 | 32 | | public EntityReference Target { get; set; } |
| | 33 | |
|
| | 34 | | [DataMember(Name = "targetEntity")] |
| 10 | 35 | | public Entity TargetEntity { get; set; } |
| | 36 | |
|
| | 37 | | [DataMember(Name = "targetColumns")] |
| 11 | 38 | | public string[] TargetColumns { get; set; } |
| | 39 | |
|
| | 40 | | [DataMember(Name = "triggerUpdate")] |
| 32 | 41 | | public bool TriggerUpdate { get; set; } |
| | 42 | |
|
| | 43 | | [DataMember(Name = "forceUpdate")] |
| 9 | 44 | | public bool ForceUpdate { get; set; } |
| | 45 | |
|
| | 46 | | [DataMember(Name = "throwOnCustomActionError")] |
| 5 | 47 | | public bool ThrowOnCustomActionError { get; set; } |
| | 48 | |
|
| | 49 | | [DataMember(Name = "organizationUrl")] |
| 9 | 50 | | public string OrganizationUrl { get; set; } |
| | 51 | |
|
| | 52 | | public static ProcessorConfig Parse (string json) |
| 36 | 53 | | { |
| 36 | 54 | | if (string.IsNullOrEmpty(json)) |
| 10 | 55 | | { |
| 10 | 56 | | return null; |
| | 57 | | } |
| | 58 | |
|
| 26 | 59 | | using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(json))) |
| 26 | 60 | | { |
| 26 | 61 | | var serializer = new DataContractJsonSerializer(typeof(ProcessorConfig)); |
| | 62 | |
|
| 26 | 63 | | var config = serializer.ReadObject(memoryStream) as ProcessorConfig; |
| 26 | 64 | | config.Raw = json; |
| | 65 | |
|
| 26 | 66 | | return config; |
| | 67 | | } |
| 36 | 68 | | } |
| | 69 | | } |
| | 70 | | } |