Skip to content
Snippets Groups Projects
Commit 3d70d63e authored by Recolic Keghart's avatar Recolic Keghart
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 892 additions and 0 deletions
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/projectSettingsUpdater.xml
/.idea.ConsoleApp1.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{8881DAED-081E-4CB1-A800-6C9DB011CCDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8881DAED-081E-4CB1-A800-6C9DB011CCDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8881DAED-081E-4CB1-A800-6C9DB011CCDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8881DAED-081E-4CB1-A800-6C9DB011CCDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8881DAED-081E-4CB1-A800-6C9DB011CCDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Mail;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Azure.Cis.Activities.Contracts;
using Microsoft.Azure.Cis.Activities.Contracts.Events;
using Microsoft.Azure.Cis.Activities.Contracts.Planner;
/*
* This class could be used when you want to
*/
namespace FleetAGC.Activities.Util
{
public class ContextConversion
{
static public IActivityContext plan2activity<T>(T obj) where T : IPlanContext
{
return new PlanContext2ActivityContext<T>(ref obj);
}
}
internal class __dict_isettings : Dictionary<string, string>, ISettings
{
public IDictionary<string, string> GetAllSettings()
{
return this;
}
public bool IsTrue(string settingName)
{
return ContainsKey(settingName);
}
public ICollection<string> Keys => base.Keys;
public ICollection<string> Values => base.Values;
}
/*
* This is std::forward<T> in C++, to make silly csc happy about missing existing members in PlanContext2ActivityContext.
* I'm very unhappy that C# has NO meta-programming at all.
*
* This forwarder class has included all stateful data, because this IS NOT an actual type function, this IS a data function.
*/
internal class __fake_cxx_std_forward<T> : IPlanContext where T : IPlanContext
{
public T realbase;
public __fake_cxx_std_forward(ref T _realbase)
{
realbase = _realbase;
GlobalSettings = realbase.GlobalSettings;
SystemSettings = realbase.SystemSettings;
Tenant = realbase.Tenant;
}
public ISettings GlobalSettings { get; }
public IReadOnlySettings SystemSettings { get; }
public void TraceStart(string format, params object[] args)
{
realbase.TraceStart(format, args);
}
public void TraceStart(string message)
{
realbase.TraceStart(message);
}
public void TraceStop(string format, params object[] args)
{
realbase.TraceStop(format, args);
}
public void TraceStop(string message)
{
realbase.TraceStop(message);
}
public void TraceVerbose(string format, params object[] args)
{
realbase.TraceVerbose(format, args);
}
public void TraceVerbose(string message)
{
realbase.TraceVerbose(message);
}
public void TraceInfo(string format, params object[] args)
{
realbase.TraceInfo(format, args);
}
public void TraceInfo(string message)
{
realbase.TraceInfo(message);
}
public void TraceWarning(string format, params object[] args)
{
realbase.TraceWarning(format, args);
}
public void TraceWarning(string message)
{
realbase.TraceWarning(message);
}
public void TraceError(string format, params object[] args)
{
realbase.TraceError(format, args);
}
public void TraceError(string message)
{
realbase.TraceError(message);
}
public TraceSource GetActiveTraceSource()
{
return realbase.GetActiveTraceSource();
}
public TraceListener GetActivityContextTraceListener()
{
return realbase.GetActivityContextTraceListener();
}
public string GetCredentialSetting(CredentialSettingType credentialSettingType, string securityId)
{
return realbase.GetCredentialSetting(credentialSettingType, securityId);
}
public X509Certificate2 GetManagedTenantCert()
{
return GetManagedTenantCert();
}
public X509Certificate2 GetProtectedSciTenantCert()
{
return GetProtectedSciTenantCert();
}
public string Tenant { get; }
}
/*
* This class is completely auto-generated by Jetbrains Rider.
* DO NOT modify by hand.
*/
internal class PlanContext2ActivityContext<T> : __fake_cxx_std_forward<T>, IActivityContext where T : IPlanContext
{
public PlanContext2ActivityContext(ref T realbase) : base(ref realbase)
{
// Manual patch: simulate some useful elements to empty, instead of null.
InputSettings = ActivityPersistedSettings = new __dict_isettings();
}
public bool IsSingleStep()
{
throw new NotImplementedException();
}
public string TaskDisplayName { get; }
public string TaskId { get; }
public string TaskLink { get; }
public string TaskNotes { get; }
public Guid RunId { get; }
public string JobDisplayName { get; }
public string JobId { get; }
public string JobType { get; }
public string Workflow { get; }
public string ProjectRoot { get; }
public string ScratchRoot { get; }
public string ComponentName { get; }
public void SignalActivityEvent(string eventName, string rootJobId)
{
throw new NotImplementedException();
}
public void SignalActivityEvent(string eventName, string rootJobId, Dictionary<string, string> eventArgs)
{
throw new NotImplementedException();
}
public void SignalActivityEvent(string eventName, string rootJobId, string eventArgs)
{
throw new NotImplementedException();
}
public void SignalActivityEvent(string eventName, string rootJobId, string senderId, Dictionary<string, string> eventArgs,
Dictionary<string, string> eventScopes)
{
throw new NotImplementedException();
}
public void UpdateActivityEventArgs(string eventName, string rootJobId, string argName, string argValue, bool append)
{
throw new NotImplementedException();
}
public IActivityEventData GetActivityEvent(string eventName, string rootJobId)
{
throw new NotImplementedException();
}
public IEnumerable<IActivityEventData> GetActivityEvents(string eventName)
{
throw new NotImplementedException();
}
public void RegisterActivityEvent(string eventName, string rootJobId)
{
throw new NotImplementedException();
}
public IEventData GetEventWithPrimaryScope(string eventName, KeyValuePair<string, string> scope)
{
throw new NotImplementedException();
}
public IEnumerable<IEventData> GetEventsWithSecondaryScope(string eventName, IDictionary<string, string> scopes)
{
throw new NotImplementedException();
}
public void SignalEvent(IEventData eventData)
{
throw new NotImplementedException();
}
public void SignalEventForAllClouds(IEventData eventData)
{
throw new NotImplementedException();
}
public void RegisterEvent(IEventData eventData)
{
throw new NotImplementedException();
}
public void UpdateEvent(IEventData eventData)
{
throw new NotImplementedException();
}
public void ResetEvent(string eventName)
{
throw new NotImplementedException();
}
public void ResetEvent(string eventName, KeyValuePair<string, string> primaryScope)
{
throw new NotImplementedException();
}
public void CancelEvent(string eventName)
{
throw new NotImplementedException();
}
public void CancelEvent(string eventName, KeyValuePair<string, string> primaryScope)
{
throw new NotImplementedException();
}
public void ReplanWorkflow()
{
throw new NotImplementedException();
}
public void RescheduleActivity(TimeSpan delayDuration)
{
throw new NotImplementedException();
}
public void ScheduleChildActivity(Type childActivity, string displayName, Dictionary<string, string> inputSettings)
{
throw new NotImplementedException();
}
public void ScheduleChildActivity(Type childActivity, string displayName, Dictionary<string, string> inputSettings,
RescheduleCallback callback)
{
throw new NotImplementedException();
}
public long FileIncident(string exceptionSourceName, string exceptionComponent, Exception unhandledException,
string incidentFilingPolicy = "", string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(string exceptionSourceName, string exceptionComponent, Exception unhandledException, string routingId,
string correlationId, string incidentFilingPolicy = "", string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(string activityName, string componentName, string providedIncidentTitle,
string providedIncidentDetails, long incidentIdToReuse, bool incidentIsException = false,
bool needToRestartWacb = false, string incidentFilingPolicy = "", string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(string activityName, string componentName, string providedIncidentTitle,
string providedIncidentDetails, string routingId, string correlationId, long incidentIdToReuse,
bool incidentIsException = false, bool needToRestartWacb = false, string incidentFilingPolicy = "",
string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(string activityName, string componentName, string taskUniqueName, string providedIncidentTitle,
string providedIncidentDetails, string routingId, string correlationId, long incidentIdToReuse,
bool incidentIsException = false, bool needToRestartWacb = false, string incidentFilingPolicy = "",
string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(string activityName, string componentName, string taskUniqueName, string providedIncidentTitle,
string providedIncidentDetails, string routingId, string correlationId, long incidentIdToReuse,
bool formatTitleAndDescription, bool incidentIsException = false, bool needToRestartWacb = false,
string incidentFilingPolicy = "", string externalSystemType = "Tfs")
{
throw new NotImplementedException();
}
public long FileIncident(IDictionary<IncidentParameters, string> incidentParams = null, bool ignoreIncidentTitlePrefix = false,
bool createWorkflowIncident = true, bool createOperationHistory = true)
{
throw new NotImplementedException();
}
public bool LinkIncident(string incidentId, bool createOperationHistory = true)
{
throw new NotImplementedException();
}
public IEnumerable<string> GetIncidentIds()
{
throw new NotImplementedException();
}
public IEnumerable<string> GetAllIncidentIdsForActivity()
{
throw new NotImplementedException();
}
public IEnumerable<string> GetAllIncidentIdsForActivity(string externSystemTypes)
{
throw new NotImplementedException();
}
public string ScheduleRemoteJob(bool rescheduleActivity, RunRemoteJobParameters parameters)
{
throw new NotImplementedException();
}
public Dictionary<string, string> ReadRemoteJobSettings()
{
throw new NotImplementedException();
}
public RemoteJobStatus GetRemoteJobStatus()
{
throw new NotImplementedException();
}
public string GetRemoteJobId()
{
throw new NotImplementedException();
}
public string GetRootJobId()
{
throw new NotImplementedException();
}
public string GetJobSeverity()
{
throw new NotImplementedException();
}
public string CreateJob(CreateJobParameters job)
{
throw new NotImplementedException();
}
public JobInfo GetJob(string jobType, string jobId, string cloud = "")
{
throw new NotImplementedException();
}
public Dictionary<string, string> GetJobSettings(string jobType, string jobId, string cloud = "")
{
throw new NotImplementedException();
}
public void AbortJob(string jobType, string jobId, string cloud = "")
{
throw new NotImplementedException();
}
public void StartJob(string jobType, string jobId, string cloud = "")
{
throw new NotImplementedException();
}
public void RestartJob(string jobType, string jobId, string cloud = "")
{
throw new NotImplementedException();
}
public void UpdateJobSeverity(string jobType, string jobId, string jobSeverity)
{
throw new NotImplementedException();
}
public IEnumerable<string> GetSubJobIds(string jobType, string jobId)
{
throw new NotImplementedException();
}
public IEnumerable<TaskInfo> GetTasks(string jobType, string jobId)
{
throw new NotImplementedException();
}
public ISettings LoadNamespaceSettings(string namespaceName)
{
throw new NotImplementedException();
}
public void LogSettingSource(string name, string method)
{
throw new NotImplementedException();
}
public IReadOnlySettings InputSettings { get; }
public ISettings ActivityPersistedSettings { get; }
public IComponentSettings ComponentSettings { get; }
public void UpdateProgress(string progressUpdate)
{
throw new NotImplementedException();
}
public void UpdateProgressLink(string progressReportLink)
{
throw new NotImplementedException();
}
public void UpdateProgressLink(Uri progressReportLink, string progressUpdate)
{
throw new NotImplementedException();
}
public void UpdateProgressLink(string progressReportLink, string progressUpdate)
{
throw new NotImplementedException();
}
public void UpdateProgressLinks(IEnumerable<Tuple<Uri, string>> links)
{
throw new NotImplementedException();
}
public void UpdateCustomState(string customState, string customStateReportLink = "")
{
throw new NotImplementedException();
}
public void UpdateWorkflowCustomState(string customState)
{
throw new NotImplementedException();
}
public void ReportOperation(string operation, string note, bool taskLevelOperation = false)
{
throw new NotImplementedException();
}
public void UpdateLastProgressReportTime(DateTime lastProgressReportTime)
{
throw new NotImplementedException();
}
public void UpdateBlockedReason(string message)
{
throw new NotImplementedException();
}
public string ProgressReportLink { get; }
public IEnumerable<IActivityTicket> GetActivityTickets()
{
throw new NotImplementedException();
}
public void AddOrUpdateTicket(long ticketId, string ticketingSystem, ActivityTicketState ticketState)
{
throw new NotImplementedException();
}
public bool AcquireResources(IDictionary<string, int> resourcesNeeded, int waitingTimeoutInMinute)
{
throw new NotImplementedException();
}
public void ReleaseResources()
{
throw new NotImplementedException();
}
public void AddMetric(string name, int value)
{
throw new NotImplementedException();
}
public void SendEmail(string to, string subject, string body, bool isHtml = false, string ccRecipients = null,
IEnumerable<string> attachmentFilePaths = null, MailPriority priority = MailPriority.Normal)
{
throw new NotImplementedException();
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cis.SdkV2" Version="21.10.15008" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Azure.Cis.Activities.Contracts;
using Microsoft.Azure.Cis.Activities.Contracts.Planner;
namespace ConsoleApp1
{
public class MyPlanCtx : IPlanContext
{
public ISettings GlobalSettings { get; set; }
public IReadOnlySettings SystemSettings { get; set; }
public void TraceStart(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceStart(string message)
{
Console.WriteLine(message);
}
public void TraceStop(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceStop(string message)
{
Console.WriteLine(message);
}
public void TraceVerbose(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceVerbose(string message)
{
Console.WriteLine(message);
}
public void TraceInfo(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceInfo(string message)
{
Console.WriteLine(message);
}
public void TraceWarning(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceWarning(string message)
{
Console.WriteLine(message);
}
public void TraceError(string format, params object[] args)
{
Console.WriteLine(format);
}
public void TraceError(string message)
{
Console.WriteLine(message);
}
public TraceSource GetActiveTraceSource()
{
Console.WriteLine("GA");
return null;
}
public TraceListener GetActivityContextTraceListener()
{
Console.WriteLine("GATL");
return null;
}
public string GetCredentialSetting(CredentialSettingType credentialSettingType, string securityId)
{
Console.WriteLine("GCR");
return null;
}
public X509Certificate2 GetManagedTenantCert()
{
Console.WriteLine("GMTC");
return null;
}
public X509Certificate2 GetProtectedSciTenantCert()
{
Console.WriteLine("GPST");
return null;
}
public string Tenant { get; set; }
}
}
\ No newline at end of file
using System;
using FleetAGC.Activities.Util;
using Microsoft.Azure.Cis.Activities.Contracts;
namespace ConsoleApp1
{
class Program
{
/// <summary>
/// try to get value from CIS context, get global setting fristly, then input setting
/// </summary>
/// <param name="context">CIS context </param>
/// <param name="settingName">setting name</param>
/// <param name="settingValue">setting value</param>
/// <returns></returns>
public static bool TryGetSetting(IActivityContext context, string settingName, out string settingValue)
{
return context.GlobalSettings.TryGetValue(settingName, out settingValue)
|| context.InputSettings.TryGetValue(settingName, out settingValue);
}
static void Main(string[] args)
{
var ctx = new MyPlanCtx();
ctx.GlobalSettings = new __dict_isettings();
ctx.SystemSettings = new __dict_isettings();
ctx.Tenant = "Tenant";
ctx.GlobalSettings.Add("k", "v");
Console.WriteLine("Hello World!");
var ctx2 = ContextConversion.plan2activity(ctx);
TryGetSetting(ctx2, "k", out string v);
Console.WriteLine("RES::" + v);
}
}
}
\ No newline at end of file
File added
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"ConsoleApp1/1.0.0": {
"dependencies": {
"Cis.SdkV2": "21.10.15008"
},
"runtime": {
"ConsoleApp1.dll": {}
}
},
"Cis.SdkV2/21.10.15008": {
"runtime": {
"lib/net45/Microsoft.Azure.Cis.Activities.Contracts.dll": {
"assemblyVersion": "10.8.0.0",
"fileVersion": "21.10.15008.0"
},
"lib/net45/Microsoft.Azure.Cis.Activities.Stub.dll": {
"assemblyVersion": "10.8.0.0",
"fileVersion": "21.10.15008.0"
}
}
}
}
},
"libraries": {
"ConsoleApp1/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Cis.SdkV2/21.10.15008": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ic3BbbJNtfSKh8UDSkpJTJT8Wa84A0r6/R/RZnklIa482KIJ5Nb/C01hPPL/6duaLmU7odH7yWz4Eel3l2m96g==",
"path": "cis.sdkv2/21.10.15008",
"hashPath": "cis.sdkv2.21.10.15008.nupkg.sha512"
}
}
}
\ No newline at end of file
File added
File added
{
"runtimeOptions": {
"additionalProbingPaths": [
"/home/recolic/.dotnet/store/|arch|/|tfm|",
"/home/recolic/.nuget/packages"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}
\ No newline at end of file
File added
File added
File added
{
"format": 1,
"restore": {
"/home/recolic/RiderProjects/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj": {}
},
"projects": {
"/home/recolic/RiderProjects/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/recolic/RiderProjects/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj",
"projectName": "ConsoleApp1",
"projectPath": "/home/recolic/RiderProjects/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj",
"packagesPath": "/home/recolic/.nuget/packages/",
"outputPath": "/home/recolic/RiderProjects/ConsoleApp1/ConsoleApp1/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/recolic/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net5.0"
],
"sources": {
"https://msazure.pkgs.visualstudio.com/One/_packaging/Azure-Compute-Consumption/nuget/v3/index.json": {},
"https://msazure.visualstudio.com/LSG-linux?Feed=LSG-linux-yocto-release": {},
"https://msazure.visualstudio.com/One?feed=ManualMirror": {}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"dependencies": {
"Cis.SdkV2": {
"target": "Package",
"version": "[21.10.15008, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[5.0.0, 5.0.0]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/5.0.205/RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/recolic/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/recolic/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.10.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/recolic/.nuget/packages/" />
</ItemGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment