Skip to content

Commit 579fe57

Browse files
committed
update to support event for F# layer using .NET 2.0 EventHandler type
1 parent 16e7485 commit 579fe57

File tree

5 files changed

+88
-59
lines changed

5 files changed

+88
-59
lines changed

AzureFluentManagement.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Elastacloud.AzureManagement
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastacloud.AzureManagement.Fluent.Types", "Elastacloud.AzureManagement.Fluent.Types\Elastacloud.AzureManagement.Fluent.Types.csproj", "{07344DF3-FB3E-46FD-ABF4-19D0EAF31C72}"
3030
EndProject
31+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F178076F-431B-4C34-B399-F207553B22E7}"
32+
ProjectSection(SolutionItems) = preProject
33+
package.fsx = package.fsx
34+
EndProjectSection
35+
EndProject
3136
Global
3237
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3338
Debug|Any CPU = Debug|Any CPU

Elastacloud.AzureManagement.Fluent/Fluent API/Watchers/DeploymentStatusWatcher.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
using System.Security.Cryptography.X509Certificates;
1+
using System;
2+
using System.Security.Cryptography.X509Certificates;
23
using Elastacloud.AzureManagement.Fluent.Commands.Services;
34
using Elastacloud.AzureManagement.Fluent.Types;
45

56
namespace Elastacloud.AzureManagement.Fluent.Watchers
67
{
7-
/// <summary>
8-
/// Used to connect a status change event for user consumption
9-
/// </summary>
10-
/// <param name="newStatus">The DeploymentStatus depicting the change</param>
11-
/// <param name="oldStatus">The deployment status it has transitioned from</param>
12-
public delegate void StatusChange(DeploymentStatus newStatus, DeploymentStatus oldStatus);
13-
148
/// <summary>
159
/// The watcher class used to monitor whether a role has had a status change
1610
/// </summary>
@@ -56,7 +50,7 @@ protected override void Pingback(object state)
5650
command.Execute();
5751
DeploymentStatus status = command.DeploymentStatus;
5852
if (status != CurrentState && RoleStatusChangeHandler != null)
59-
RoleStatusChangeHandler(status, CurrentState);
53+
RoleStatusChangeHandler(this, new CloudServiceState(CurrentState, status));
6054
CurrentState = status;
6155
}
6256

@@ -74,6 +68,19 @@ protected override object GetState()
7468
/// <summary>
7569
/// The event that should be subscribed to get role status change information back
7670
/// </summary>
77-
public event StatusChange RoleStatusChangeHandler;
71+
public event EventHandler<CloudServiceState> RoleStatusChangeHandler;
72+
73+
}
74+
75+
public class CloudServiceState
76+
{
77+
public CloudServiceState(DeploymentStatus oldState, DeploymentStatus newState)
78+
{
79+
OldState = oldState;
80+
NewState = newState;
81+
}
82+
83+
public DeploymentStatus OldState { get; private set; }
84+
public DeploymentStatus NewState { get; private set; }
7885
}
7986
}
Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,21 @@
1-
/************************************************************************************************************
2-
* This software is distributed under a GNU Lesser License by Elastacloud Limited and it is free to *
3-
* modify and distribute providing the terms of the license are followed. From the root of the source the *
4-
* license can be found in /Resources/license.txt *
5-
* *
6-
* Web at: www.elastacloud.com *
7-
* Email: [email protected] *
8-
************************************************************************************************************/
9-
1+
// <auto-generated/>
102
using System.Reflection;
113
using System.Runtime.CompilerServices;
124
using System.Runtime.InteropServices;
135

14-
// General Information about an assembly is controlled through the following
15-
// set of attributes. Change these attribute values to modify the information
16-
// associated with an assembly.
17-
18-
[assembly: AssemblyTitle("Elastacloud.AzureManagement.Fluent")]
19-
[assembly:
20-
AssemblyDescription(
21-
"Library used for management of Windows Azure services, SQL, storage, networking, WASD, WAMS and VM's")]
22-
[assembly: AssemblyConfiguration("")]
23-
[assembly: AssemblyCompany("Elastacloud Limited")]
24-
[assembly: AssemblyProduct("Elastacloud.AzureManagement.Fluent")]
25-
[assembly: AssemblyCopyright("Copyright © 2015")]
26-
[assembly: AssemblyTrademark("")]
27-
[assembly: AssemblyCulture("")]
28-
29-
// Setting ComVisible to false makes the types in this assembly not visible
30-
// to COM components. If you need to access a type in this assembly from
31-
// COM, set the ComVisible attribute to true on that type.
32-
33-
[assembly: ComVisible(false)]
34-
35-
// The following GUID is for the ID of the typelib if this project is exposed to COM
36-
37-
[assembly: Guid("909b2b8c-10bf-4f0d-a94e-208ef3bdca52")]
38-
39-
// Version information for an assembly consists of the following four values:
40-
//
41-
// Major Version
42-
// Minor Version
43-
// Build Number
44-
// Revision
45-
//
46-
// You can specify all the values or you can default the Build and Revision Numbers
47-
// by using the '*' as shown below:
48-
// [assembly: AssemblyVersion("1.0.*")]
49-
50-
// Make internal interfaces visible to Moq and the testing library
51-
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2"), InternalsVisibleTo("Elastacloud.AzureManagement.Fluent.Tests")]
52-
[assembly: AssemblyVersion("0.5.1.6")]
53-
[assembly: AssemblyFileVersion("0.5.1.6")]
6+
[assembly: AssemblyTitleAttribute("Elastacloud.AzureManagement.Fluent")]
7+
[assembly: AssemblyDescriptionAttribute("Library used for management of Windows Azure services, SQL, storage, networking, WASD, WAMS and VM's")]
8+
[assembly: AssemblyCompanyAttribute("Elastacloud Limited")]
9+
[assembly: AssemblyProductAttribute("Azure Fluent Management")]
10+
[assembly: AssemblyCopyrightAttribute("Copyright Elastacloud Limited © 2015")]
11+
[assembly: ComVisibleAttribute(false)]
12+
[assembly: GuidAttribute("909b2b8c-10bf-4f0d-a94e-208ef3bdca52")]
13+
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
14+
[assembly: InternalsVisibleToAttribute("Elastacloud.AzureManagement.Fluent.Tests")]
15+
[assembly: AssemblyVersionAttribute("0.5.1.7")]
16+
[assembly: AssemblyFileVersionAttribute("0.5.1.7")]
17+
namespace System {
18+
internal static class AssemblyVersionInformation {
19+
internal const string Version = "0.5.1.7";
20+
}
21+
}

Elastacloud.FluentManagement.FSTest/VirtualMachines.fsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open Elastacloud.AzureManagement.Fluent.Types.VirtualMachines
2020
open System.Collections.Generic
2121
open System.Security.Cryptography.X509Certificates
2222
open Elastacloud.AzureManagement.Fluent.Types.VirtualNetworks
23+
open Elastacloud.AzureManagement.Fluent.Watchers
2324

2425
let subscriptionId = "84bf11d2-7751-4ce7-b22d-ac44bf33cbe9"
2526
/// Start Fuctions
@@ -87,3 +88,11 @@ let clouddelete = sbClient.DeleteNamespace("elastatools3")
8788
let sblist = sbClient.GetServiceBusNamspaceList("West US")
8889
let sbpolicy = sbClient.GetServiceBusConnectionString("briskuidev", "RootManageSharedAccessKey")
8990

91+
92+
let manager = new SubscriptionManager(subscriptionId)
93+
let watcher = manager.GetRoleStatusChangedWatcher("isaacfoobar",
94+
"isaacfoobar",
95+
DeploymentSlot.Production,
96+
(getFromBizsparkPlus subscriptionId).Thumbprint)
97+
watcher.RoleStatusChangeHandler.Add(fun status -> printfn "from %s to %s" (status.OldState.ToString()) (status.NewState.ToString()))
98+

package.fsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#r @"packages\FAKE.3.17.0\tools\FakeLib.dll" // include Fake lib
2+
open Fake
3+
open Fake.AssemblyInfoFile
4+
open Fake.NuGetHelper
5+
open System
6+
7+
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
8+
[<Literal>]
9+
let version = "0.5.1.7"
10+
// 1. Increment the minor number assemblyinfo version
11+
CreateCSharpAssemblyInfo (sprintf @"%s\Elastacloud.AzureManagement.Fluent\Properties\AssemblyInfo.cs" Environment.CurrentDirectory) [Attribute.Title("Elastacloud.AzureManagement.Fluent")
12+
Attribute.Description("Library used for management of Windows Azure services, SQL, storage, networking, WASD, WAMS and VM's")
13+
Attribute.Company("Elastacloud Limited")
14+
Attribute.Product("Azure Fluent Management")
15+
Attribute.Copyright("Copyright Elastacloud Limited © 2015")
16+
Attribute.ComVisible(false)
17+
Attribute.Guid("909b2b8c-10bf-4f0d-a94e-208ef3bdca52")
18+
Attribute.InternalsVisibleTo("DynamicProxyGenAssembly2")
19+
Attribute.InternalsVisibleTo("Elastacloud.AzureManagement.Fluent.Tests")
20+
Attribute.Version(version)
21+
Attribute.FileVersion(version)]
22+
// 1.5. Clean the bin folder
23+
CleanDirs [ @"Elastacloud.AzureManagement.Fluent\bin" ] |> ignore
24+
// 2. Build of fluent in release mode
25+
MSBuildRelease "" "Rebuild" [(sprintf @"%s\AzureFluentManagement.sln" Environment.CurrentDirectory)]
26+
// 3. Create the nuget package
27+
let nupack = { Authors = ["@azurecoder";"@andybareweb";"@isaac_abraham"]
28+
Id = "Elastacloud.AzureManagement.Fluent"
29+
Version = version
30+
Owners = ["@azurecoder";"@andybareweb";"@isaac_abraham"]
31+
Url = "http://www.elastacloud.com"
32+
IsLatestVersion = true
33+
Created = DateTime.UtcNow.ToString()
34+
Published = DateTime.UtcNow.ToString()
35+
36+
}
37+
38+
let p = NuGetDefaults()
39+
NuGetPack "Elastacloud.AzureManagement.Fluent.nuspec"
40+
// 4. Push a label to github

0 commit comments

Comments
 (0)