Skip to content

Commit 8f34a91

Browse files
committed
Queue Storage IntegrationCommands working
1 parent 14465c1 commit 8f34a91

File tree

15 files changed

+528
-16
lines changed

15 files changed

+528
-16
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Intent.Metadata.Models;
5+
using Intent.Modelers.Eventing.Api;
6+
using Intent.Modules.Common;
7+
using Intent.RoslynWeaver.Attributes;
8+
9+
[assembly: DefaultIntentManaged(Mode.Fully)]
10+
[assembly: IntentTemplate("Intent.ModuleBuilder.Templates.Api.ApiElementModelExtensions", Version = "1.0")]
11+
12+
namespace Intent.Eventing.AzureQueueStorage.Api
13+
{
14+
public static class IntegrationCommandModelStereotypeExtensions
15+
{
16+
public static AzureQueueStorage GetAzureQueueStorage(this IntegrationCommandModel model)
17+
{
18+
var stereotype = model.GetStereotype(AzureQueueStorage.DefinitionId);
19+
return stereotype != null ? new AzureQueueStorage(stereotype) : null;
20+
}
21+
22+
23+
public static bool HasAzureQueueStorage(this IntegrationCommandModel model)
24+
{
25+
return model.HasStereotype(AzureQueueStorage.DefinitionId);
26+
}
27+
28+
public static bool TryGetAzureQueueStorage(this IntegrationCommandModel model, out AzureQueueStorage stereotype)
29+
{
30+
if (!HasAzureQueueStorage(model))
31+
{
32+
stereotype = null;
33+
return false;
34+
}
35+
36+
stereotype = new AzureQueueStorage(model.GetStereotype(AzureQueueStorage.DefinitionId));
37+
return true;
38+
}
39+
40+
public class AzureQueueStorage
41+
{
42+
private IStereotype _stereotype;
43+
public const string DefinitionId = "7b57f640-600d-4b91-98a7-2a304c715f27";
44+
45+
public AzureQueueStorage(IStereotype stereotype)
46+
{
47+
_stereotype = stereotype;
48+
}
49+
50+
public string Name => _stereotype.Name;
51+
52+
public string QueueName()
53+
{
54+
return _stereotype.GetProperty<string>("Queue Name");
55+
}
56+
57+
}
58+
59+
}
60+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Intent.Engine;
2+
using Intent.Modules.Common;
3+
using Intent.Modules.Common.CSharp.Templates;
4+
using Intent.Modules.Common.Plugins;
5+
using Intent.Modules.Common.Templates;
6+
using Intent.Plugins.FactoryExtensions;
7+
using Intent.RoslynWeaver.Attributes;
8+
using System.Linq;
9+
10+
[assembly: DefaultIntentManaged(Mode.Fully)]
11+
[assembly: IntentTemplate("Intent.ModuleBuilder.Templates.FactoryExtension", Version = "1.0")]
12+
13+
namespace Intent.Modules.Eventing.AzureQueueStorage.FactoryExtensions
14+
{
15+
[IntentManaged(Mode.Fully, Body = Mode.Merge)]
16+
public class EventBusInterfaceExtension : FactoryExtensionBase
17+
{
18+
public override string Id => "Intent.Eventing.AzureQueueStorage.EventBusInterfaceExtension";
19+
20+
[IntentManaged(Mode.Ignore)]
21+
public override int Order => 0;
22+
23+
protected override void OnAfterTemplateRegistrations(IApplication application)
24+
{
25+
var templates = application.FindTemplateInstances<ICSharpFileBuilderTemplate>(TemplateDependency.OnTemplate("Application.Eventing.EventBusInterface"));
26+
foreach (var template in templates)
27+
{
28+
template.CSharpFile.OnBuild(file =>
29+
{
30+
file.AddUsing("System");
31+
var @interface = file.Interfaces.First();
32+
if (@interface.Methods.Any(x => x.Name == "Send"))
33+
{
34+
return;
35+
}
36+
37+
@interface.AddMethod("void", "Send", m => m
38+
.AddGenericParameter("T")
39+
.AddParameter("T", "message")
40+
.AddGenericTypeConstraint("T", c => c.AddType("class")));
41+
});
42+
}
43+
}
44+
}
45+
}

Modules/Intent.Modules.Eventing.AzureQueueStorage/Intent.Eventing.AzureQueueStorage.imodspec

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,23 @@
8282
</template>
8383
</templates>
8484
<decorators></decorators>
85-
<factoryExtensions></factoryExtensions>
86-
<moduleSettings></moduleSettings>
85+
<factoryExtensions>
86+
<factoryExtension id="Intent.Eventing.AzureQueueStorage.EventBusInterfaceExtension" externalReference="ba04a154-bf68-41ff-b199-2609ca419a72" />
87+
</factoryExtensions>
88+
<moduleSettings>
89+
<group id="e71edb78-27b4-4326-9def-796a18064e8b" title="Azure Queue Storage Settings" type="application-settings" externalReference="e71edb78-27b4-4326-9def-796a18064e8b">
90+
<settings>
91+
<setting id="32d8dbd8-c478-48ef-8e1a-cdbed0e9da98" title="Message Encoding" type="select">
92+
<hint>The encoding mechanism to use when publishing/consuming messages.</hint>
93+
<defaultValue>none</defaultValue>
94+
<options>
95+
<option value="none" description="None" />
96+
<option value="base-64" description="Base64" />
97+
</options>
98+
</setting>
99+
</settings>
100+
</group>
101+
</moduleSettings>
87102
<dependencies>
88103
<dependency id="Intent.Common" version="3.8.0" />
89104
<dependency id="Intent.Common.CSharp" version="3.8.0" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<class id="ba04a154-bf68-41ff-b199-2609ca419a72" type="Factory Extension" typeId="7d008e84-bb28-4b10-ba28-7439202fca76">
3+
<name>EventBusInterfaceExtension</name>
4+
<display>EventBusInterfaceExtension</display>
5+
<isAbstract>false</isAbstract>
6+
<genericTypes />
7+
<isMapped>false</isMapped>
8+
<parentFolderId>f924ae65-9274-415c-a1c4-9682f8b463d1</parentFolderId>
9+
<packageId>f924ae65-9274-415c-a1c4-9682f8b463d1</packageId>
10+
<packageName>Intent.Eventing.AzureQueueStorage</packageName>
11+
<stereotypes />
12+
<metadata />
13+
<childElements />
14+
</class>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<class id="e71edb78-27b4-4326-9def-796a18064e8b" type="Module Settings Configuration" typeId="37e678f8-370a-4b05-ae44-69bb3d2b39b6">
3+
<name>Azure Queue Storage Settings</name>
4+
<display>Azure Queue Storage Settings</display>
5+
<isAbstract>false</isAbstract>
6+
<sort-children>manually</sort-children>
7+
<genericTypes />
8+
<isMapped>false</isMapped>
9+
<parentFolderId>f924ae65-9274-415c-a1c4-9682f8b463d1</parentFolderId>
10+
<packageId>f924ae65-9274-415c-a1c4-9682f8b463d1</packageId>
11+
<packageName>Intent.Eventing.AzureQueueStorage</packageName>
12+
<stereotypes>
13+
<stereotype stereotypeDefinitionId="15b3e709-aeb8-410a-9172-1273eb7b0864" name="Configuration">
14+
<addedByDefault>true</addedByDefault>
15+
<definitionPackageName>Intent.ModuleBuilder</definitionPackageName>
16+
<definitionPackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</definitionPackageId>
17+
<properties>
18+
<property name="ce4eefa2-657c-42b0-a8cf-bbe35ef1d8a9" display="Settings Type" value="Application Settings" isActive="true" />
19+
</properties>
20+
</stereotype>
21+
</stereotypes>
22+
<metadata />
23+
<childElements>
24+
<childElement id="32d8dbd8-c478-48ef-8e1a-cdbed0e9da98" type="Module Settings Field Configuration" typeId="88e29cab-1342-40c7-b052-5fcd68ffafec">
25+
<name>Message Encoding</name>
26+
<display>Message Encoding</display>
27+
<isAbstract>false</isAbstract>
28+
<sort-children>manually</sort-children>
29+
<genericTypes />
30+
<isMapped>false</isMapped>
31+
<parentFolderId>e71edb78-27b4-4326-9def-796a18064e8b</parentFolderId>
32+
<packageId>f924ae65-9274-415c-a1c4-9682f8b463d1</packageId>
33+
<packageName>Intent.Eventing.AzureQueueStorage</packageName>
34+
<stereotypes>
35+
<stereotype stereotypeDefinitionId="4805c791-5be3-4049-b929-6046d7be9944" name="Field Configuration">
36+
<addedByDefault>true</addedByDefault>
37+
<definitionPackageName>Intent.ModuleBuilder</definitionPackageName>
38+
<definitionPackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</definitionPackageId>
39+
<properties>
40+
<property name="e33ce4e3-a3c5-4a3c-a6b8-96418be03de0" display="Control Type" value="Select" isActive="true" />
41+
<property name="7070a9ce-ff31-422e-9cff-d82876c5efdf" display="Is Required" value="false" isActive="false" />
42+
<property name="01489021-8311-43d5-b41b-e7628a512c1d" display="Hint" value="The encoding mechanism to use when publishing/consuming messages." isActive="true" />
43+
<property name="653d889c-626f-45c5-a6e6-72b74a2f805c" display="Default Value" value="none" isActive="true" />
44+
<property name="c3456e79-0607-41a5-9b85-e0712f4f4834" display="Is Active Function" isActive="true" />
45+
<property name="fa54329f-d4e5-48bc-8027-e17206e9fc89" display="Is Required Function" isActive="true" />
46+
<property name="29696a13-bf1d-4fbd-bdf3-adb802430cb4" display="Order Priority" isActive="true" />
47+
</properties>
48+
</stereotype>
49+
</stereotypes>
50+
<metadata />
51+
<childElements>
52+
<childElement id="d3b2d375-e8bf-47e6-9d37-6bf31b28f03f" type="Module Settings Field Option" typeId="1592709a-89b1-4cb0-9801-ce9d3b94545a">
53+
<name>None</name>
54+
<display>None = none</display>
55+
<isAbstract>false</isAbstract>
56+
<value>none</value>
57+
<genericTypes />
58+
<isMapped>false</isMapped>
59+
<parentFolderId>32d8dbd8-c478-48ef-8e1a-cdbed0e9da98</parentFolderId>
60+
<packageId>f924ae65-9274-415c-a1c4-9682f8b463d1</packageId>
61+
<packageName>Intent.Eventing.AzureQueueStorage</packageName>
62+
<stereotypes />
63+
<metadata />
64+
<childElements />
65+
</childElement>
66+
<childElement id="deb29ed3-7e57-4b36-b7fe-683c6873581c" type="Module Settings Field Option" typeId="1592709a-89b1-4cb0-9801-ce9d3b94545a">
67+
<name>Base64</name>
68+
<display>Base64 = base-64</display>
69+
<isAbstract>false</isAbstract>
70+
<value>base-64</value>
71+
<genericTypes />
72+
<isMapped>false</isMapped>
73+
<parentFolderId>32d8dbd8-c478-48ef-8e1a-cdbed0e9da98</parentFolderId>
74+
<packageId>f924ae65-9274-415c-a1c4-9682f8b463d1</packageId>
75+
<packageName>Intent.Eventing.AzureQueueStorage</packageName>
76+
<stereotypes />
77+
<metadata />
78+
<childElements />
79+
</childElement>
80+
</childElements>
81+
</childElement>
82+
</childElements>
83+
</class>

Modules/Intent.Modules.Eventing.AzureQueueStorage/Intent.Metadata/Module Builder/Intent.Eventing.AzureQueueStorage/Stereotypes/Azure Queue Storage__4h5lyyw6.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<targetMode>of-type</targetMode>
66
<targetTypes>
77
<type id="cbe970af-5bad-4d92-a3ed-a24b9fdaa23e">Message</type>
8+
<type id="7f01ca8e-0e3c-4735-ae23-a45169f71625">Integration Command</type>
89
</targetTypes>
910
<targetReferenceTypes />
1011
<applyMode>manually</applyMode>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<deviationsLog>
3-
<files />
3+
<files>
4+
<file>
5+
<correlationId>Intent.ModuleBuilder.CSharp.Templates.CSharpTemplatePartial#9c36bf3d-d160-43fa-a0f6-f643552aea59</correlationId>
6+
<path>Intent.Modules.Eventing.AzureQueueStorage/Templates/IntegrationEventHandler/IntegrationEventHandlerTemplatePartial.cs</path>
7+
<count>2</count>
8+
<updatedByAccountName>[email protected]</updatedByAccountName>
9+
<updatedByDisplayName>JP Seini</updatedByDisplayName>
10+
<updatedAt>2025-10-23T17:15:08.7268152Z</updatedAt>
11+
<deviationsHash>BE502B15295EDE70065F734F6DC13376DE021AF5C048271D0EDC922B96F9A00B</deviationsHash>
12+
<fileHash>E47E54EFD6AFE4D8B4EB850C548B025C0761F4A6B32407F6954FBCAB3AF7FA71</fileHash>
13+
</file>
14+
</files>
415
</deviationsLog>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using Intent.Configuration;
3+
using Intent.Engine;
4+
using Intent.Modules.Common.Templates;
5+
using Intent.RoslynWeaver.Attributes;
6+
7+
[assembly: DefaultIntentManaged(Mode.Fully)]
8+
[assembly: IntentTemplate("Intent.ModuleBuilder.Templates.Settings.ModuleSettingsExtensions", Version = "1.0")]
9+
10+
namespace Intent.Modules.Eventing.AzureQueueStorage.Settings
11+
{
12+
public static class ModuleSettingsExtensions
13+
{
14+
public static AzureQueueStorageSettings GetAzureQueueStorageSettings(this IApplicationSettingsProvider settings)
15+
{
16+
return new AzureQueueStorageSettings(settings.GetGroup("e71edb78-27b4-4326-9def-796a18064e8b"));
17+
}
18+
}
19+
20+
public class AzureQueueStorageSettings : IGroupSettings
21+
{
22+
private readonly IGroupSettings _groupSettings;
23+
24+
public AzureQueueStorageSettings(IGroupSettings groupSettings)
25+
{
26+
_groupSettings = groupSettings;
27+
}
28+
29+
public string Id => _groupSettings.Id;
30+
31+
public string Title
32+
{
33+
get => _groupSettings.Title;
34+
set => _groupSettings.Title = value;
35+
}
36+
37+
public ISetting GetSetting(string settingId)
38+
{
39+
return _groupSettings.GetSetting(settingId);
40+
}
41+
public MessageEncodingOptions MessageEncoding() => new MessageEncodingOptions(_groupSettings.GetSetting("32d8dbd8-c478-48ef-8e1a-cdbed0e9da98")?.Value);
42+
43+
public class MessageEncodingOptions
44+
{
45+
public readonly string Value;
46+
47+
public MessageEncodingOptions(string value)
48+
{
49+
Value = value;
50+
}
51+
52+
public MessageEncodingOptionsEnum AsEnum()
53+
{
54+
return Value switch
55+
{
56+
"none" => MessageEncodingOptionsEnum.None,
57+
"base-64" => MessageEncodingOptionsEnum.Base64,
58+
_ => throw new ArgumentOutOfRangeException(nameof(Value), $"{Value} is out of range")
59+
};
60+
}
61+
62+
public bool IsNone()
63+
{
64+
return Value == "none";
65+
}
66+
67+
public bool IsBase64()
68+
{
69+
return Value == "base-64";
70+
}
71+
}
72+
73+
public enum MessageEncodingOptionsEnum
74+
{
75+
None,
76+
Base64,
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)