-
Notifications
You must be signed in to change notification settings - Fork 6
/
FMEDotNetHelloWorldFactory.cs
66 lines (59 loc) · 3.17 KB
/
FMEDotNetHelloWorldFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Text;
namespace Safe.DotNet.Samples
{
/// <summary>
/// Implements a HelloWorld sample of a DotNet custom Transformer.
/// </summary>
public class FMEDotNetHelloWorldFactory : Safe.DotNet.FMEDotNetFactory
{
/// <summary> Reference to the plugin SDK bridge. </summary>
private IFMEOFactoryBridge _bridge;
/// <summary> Initialize the object in the current task. </summary>
public override void Initialize(IFMEOFactoryBridge bridge)
{
_bridge = bridge;
_bridge.LogFile.LogMessageString("## HelloWord - Initialize(), Message='" + bridge.Keywords["MESSAGE_TO_SAY_ATTR"] + "'", FMEOMessageLevel.Inform);
}
/// <summary> Process the specified Feature. </summary>
public override IEnumerable<KeyValuePair<string,IFMEOFeature>> ProcessFeature(string inputTag, IFMEOFeature feature)
{
// Depending on how we have chosen to process features in this factory we could:
// a) Process and output each feature immediately or
// b) Process and store features into a list, then when all features have been collected, process and output them.
// Under a) the bulk of the work occurs in this function since features are output immediately as soon as they are done processing.
// Under b) the bulk of the work occurs in the close() function.
if (feature!=null)
{
StringBuilder sb = new StringBuilder();
sb.Append("## HelloWord - Processing Feature, Attributes=[");
foreach (string attrib in feature.GetAllAttributeNames()) sb.Append(attrib).Append("='").Append(feature.GetAttributeAsString(attrib)).Append("', ");
sb.Length-=2; sb.Append("]");
_bridge.LogFile.LogMessageString(sb.ToString(), FMEOMessageLevel.Inform);
// For this sample we output the feature with a specific OutputTag.
// For this module the related fmx file defines one unique output tag called "OUTPUT"...
yield return new KeyValuePair<string,IFMEOFeature>("OUTPUT", feature);
// But we can use the '_bridge.OutputTags' member to query the available collection of output tags...
// foreach (string outputTag in _bridge.OutputTags) yield return new KeyValuePair<string,IFMEOFeature>(outputTag, feature);
}
yield break;
}
/// <summary> Abort the current task. </summary>
public override void Abort()
{
_bridge.LogFile.LogMessageString("## HelloWord - Abort()", FMEOMessageLevel.Warn);
}
/// <summary> Close the current task. </summary>
public override void Close()
{
_bridge.LogFile.LogMessageString("## HelloWord - Close()", FMEOMessageLevel.Inform);
}
/// <summary> Releases the resources of the object. </summary>
public override void DisposeObject()
{
_bridge.LogFile.LogMessageString("## HelloWord - Dispose()", FMEOMessageLevel.Inform);
_bridge = null;
}
}
}