// Generates code for custom authentication and shows the file on IDE editor public static void ApplyCustomAuthentication(IAbstractEndpoint endpoint, IApplication application, IServiceProvider sp) { var solution = sp.TryGetService<ISolution>(); // If the custom file doesn't exist... we will generate it if (!solution.Find(endpoint.Project.Name + @"\Infrastructure\Authentication.cs").Any()) { application.Design.Infrastructure.Security.Authentication.LocalNamespace = endpoint.Project.Data.RootNamespace + ".Infrastructure"; application.Design.Infrastructure.Security.Authentication.As<IProductElement>() // We are using Temp as we don't want the generation run on each build .CreateTempGenerateCodeCommand(sp, "Authentication.cs" , endpoint.Project.Name + @"\Infrastructure" , @"t4://extension/a5e9f15b-ad7f-4201-851e-186dd8db3bc9/T/T4/Security/EndpointCustomAuthentication.tt") .Execute(); } var item = solution.Find(endpoint.Project.Name + @"\Infrastructure\Authentication.cs").FirstOrDefault(); if (item != null) { // Open the file on the IDE Editor item.As<EnvDTE.ProjectItem>() .Open(EnvDTE.Constants.vsViewKindCode) .Visible = true; } }
private void StartUseCase(IAbstractEndpoint e, IApplication a, IServiceProvider sp) { var vm = a.Design.UseCases as IProductElementViewModel; if (vm != null) throw new ArgumentNullException(); var instanceName = vm.AddNewElement(a.Design.UseCases.AsCollection().Info); if (!String.IsNullOrEmpty(instanceName)) { using (new MouseCursor(System.Windows.Input.Cursors.Wait)) { var useCase = a.Design.UseCases.CreateUseCase(instanceName); useCase.AddEndpointStartingUseCase(e); //useCase.AddRelatedElement(e.As<IProductElement>()); } } }
// Generates code for custom authentication and shows the file on IDE editor public static void ApplyCustomAuthentication(IAbstractEndpoint endpoint, IApplication application, IServiceProvider sp) { var solution = sp.TryGetService<ISolution>(); // If the custom file doesn't exist... we will generate it if (!solution.Find(endpoint.Project.Name + @"\Infrastructure\Authentication.cs").Any()) { application.Design.Infrastructure.Security.Authentication.LocalNamespace = endpoint.Project.Data.RootNamespace + ".Infrastructure"; application.Design.Infrastructure.Security.Authentication.As<IProductElement>() // We are using Temp as we don't want the generation run on each build .CreateTempGenerateCodeCommand(sp, "Authentication.cs" , endpoint.Project.Name + @"\Infrastructure" , @"t4://extension/23795EC3-3DEA-4F04-9044-4056CF91A2ED/T/T4/Security/EndpointCustomAuthentication.tt") .Execute(); } var item = solution.Find(endpoint.Project.Name + @"\Infrastructure\Authentication.cs").FirstOrDefault(); if (item != null) { // Open the file on the IDE Editor item.As<EnvDTE.ProjectItem>() .Open(EnvDTE.Constants.vsViewKindCode) .Visible = true; } // If the custom file doesn't exist... we will generate it if (!solution.Find(endpoint.Project.Name + @"\Infrastructure\AuthenticationEndpointCode.cs").Any()) { application.Design.Infrastructure.Security.Authentication.LocalNamespace = endpoint.Project.Data.RootNamespace + ".Infrastructure"; application.Design.Infrastructure.Security.Authentication.As<IProductElement>() // We are using Temp as we don't want the generation run on each build .CreateTempGenerateCodeCommand(sp, "AuthorizeOutgoingMessages.cs" , endpoint.Project.Name + @"\Infrastructure" , (application.TargetNsbVersion == TargetNsbVersion.Version4) ? @"t4://extension/23795EC3-3DEA-4F04-9044-4056CF91A2ED/T/T4/Security/EndpointCustomAutorizeOutgoingMessages.v4.0.tt" : @"t4://extension/23795EC3-3DEA-4F04-9044-4056CF91A2ED/T/T4/Security/EndpointCustomAutorizeOutgoingMessages.v5.0.tt") .Execute(); } }
public void RemoveLinks(IAbstractEndpoint endpoint) { var project = endpoint.Project; if (project == null) return; if (this.IsProcessor) { // 1. Remove Links for Custom Code var customCodePath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, null, false); RemoveLinkFromProject(project, this.OriginalInstanceName + ".cs", customCodePath); //2. Remove Links for Infrastructure Code var infraCodePath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, "Infrastructure", false); RemoveLinkFromProject(project, this.OriginalInstanceName + ".cs", infraCodePath); } // 3. Remove Links for References foreach (var libraryLink in this.LibraryReferences.LibraryReference) { IProductElement element = null; if (libraryLink.Library != null) { if (libraryLink.Library.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.Library.As<IProductElement>(); } } else { if (libraryLink.ServiceLibrary.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.ServiceLibrary.As<IProductElement>(); } } var suggestedPath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, null, false); RemoveLinkFromProject(project, element.InstanceName + ".cs", suggestedPath); } }
public void EndpointDefined(IAbstractEndpoint newEndpoint) { if (newEndpoint != null && !this.deployedTo.Contains(newEndpoint)) { this.deployedTo.Add(newEndpoint); } foreach (var endpoint in this.DeployedTo) { var service = this.Parent.Parent; if (!endpoint.Project.Folders.Any(f => f.Name == service.CodeIdentifier)) { endpoint.Project.CreateFolder(service.CodeIdentifier); } foreach (var i in this.Subscribes.SubscribedEventLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in this.Subscribes.ProcessedCommandLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in this.Publishes.CommandLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in this.Publishes.EventLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } // Generate Code for Component Handlers this.AsElement().AutomationExtensions.First(x => x.Name == "GenerateCodeConditionalHandlers").Execute(); this.AsElement().AutomationExtensions.First(x => x.Name == "UnfoldConditionalCustomHandlers").Execute(); if (this.IsSaga) { this.AsElement().AutomationExtensions.First(x => x.Name == "UnfoldConditionalSagaDataCode").Execute(); } // Add Links for Referenced Libraries this.AddLinks(endpoint); } }
public void AddLinks(IAbstractEndpoint endpoint) { var project = endpoint.Project; // 1. Add Links for References foreach (var libraryLink in this.LibraryReferences.LibraryReference) { IProductElement element = null; if (libraryLink.Library != null) { if (libraryLink.Library.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.Library.As<IProductElement>(); } } else { if (libraryLink.ServiceLibrary.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.ServiceLibrary.As<IProductElement>(); } } var suggestedPath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, null, true); AddLinkToProject(project, element, suggestedPath, i => i.First()); } }
public void RaiseOnInitializingEndpoint(IAbstractEndpoint endpoint) { if (OnInitializingEndpoint != null) { OnInitializingEndpoint(endpoint, EventArgs.Empty); } }
private static string DefaultBuildPathForComponentCode(IAbstractEndpoint endpoint, IService service, string subPath, bool useNewServiceName) { var result = string.Format(@"{0}\{1}", endpoint.Project.Name, (useNewServiceName) ? service.InstanceName : service.OriginalInstanceName); if (subPath != string.Empty && subPath != null) { result = string.Format(@"{0}\Infrastructure\{1}\{2}", endpoint.Project.Name, subPath, (useNewServiceName) ? service.InstanceName : service.OriginalInstanceName); } return result; }
private static string DefaultBuildNamespaceForComponentCode(IAbstractEndpoint endpoint, IService service) { return(endpoint == null ? string.Empty : string.Format(@"{0}.{1}", endpoint.Project.Data.RootNamespace, service.CodeIdentifier)); }
public static void RaiseOnInstantiated(this IAbstractEndpoint endpoint) { endpoint.As <IProductElement>().Root.As <IApplication>().RaiseOnInstantiatedEndpoint(endpoint); }
public static void RaiseOnInitializing(this IAbstractEndpoint endpoint) { endpoint.As <IProductElement>().Root.As <IApplication>().RaiseOnInitializingEndpoint(endpoint); }
private void DeleteComponentLink(IAbstractEndpoint endpoint) { var componentLink = endpoint.EndpointComponents.AbstractComponentLinks.FirstOrDefault(cl => cl.ComponentReference.Value == this); componentLink.As <IProductElement>().Delete(); }
public void RemoveSagaLinks(IAbstractEndpoint endpoint) { throw new NotImplementedException(); }
public void DeployTo(IAbstractEndpoint endpoint) { }
public void EndpointDefined(IAbstractEndpoint endpoint) { }
private void DeleteComponentLink(IAbstractEndpoint endpoint) { var componentLink = endpoint.EndpointComponents.AbstractComponentLinks.FirstOrDefault(cl => cl.ComponentReference.Value == this); componentLink.As<IProductElement>().Delete(); }
public void AddEndpointToUseCase(IAbstractEndpoint endpoint, IApplication application, IServiceProvider sp) { var command = new Commands.AddReferenceToUseCaseCommand { CurrentElement = endpoint.As<IProductElement>()}; command.Execute(); }
public void EndpointDefined(IAbstractEndpoint newEndpoint) { if (newEndpoint != null && !DeployedTo.Contains(newEndpoint)) { DeployedTo.Add(newEndpoint); } foreach (var endpoint in DeployedTo) { var service = Parent.Parent; var endpointProject = endpoint.Project; if (endpointProject == null) { continue; } if (!endpoint.Project.Folders.Any(f => f.Name == service.CodeIdentifier)) { endpoint.Project.CreateFolder(service.CodeIdentifier); } foreach (var i in Subscribes.SubscribedEventLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in Subscribes.ProcessedCommandLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in Publishes.CommandLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } foreach (var i in Publishes.EventLinks) { i.AsElement().AutomationExtensions.First(x => x.Name == "OnInstantiateCommand").Execute(); } if (IsSaga) { AsElement().AutomationExtensions.First(x => x.Name == "UnfoldSagaConfigureHowToFindCode").Execute(); AsElement().AutomationExtensions.First(x => x.Name == "UnfoldSagaDataCode").Execute(); } // Add Links for Referenced Libraries AddLinks(endpoint); } }
public void BuildDetailsForEndpoint(IAbstractEndpoint endpoint, ISolutionBuilderViewModel solutionBuilderModel) { var application = endpoint.As<IProductElement>().Root.As<IApplication>(); var allcomponents = application.Design.Services.Service.SelectMany(s => s.Components.Component); var components = allcomponents.Where(c => endpoint.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference != null && cl.ComponentReference.Value == c)); this.CleanDetails(); // Components this.CreateComponentsPanelForEndpoint(solutionBuilderModel, components, endpoint.EndpointComponents.AbstractComponentLinks, 0); // Commands this.CreateCommandsPanel(solutionBuilderModel, components, 1); // Events this.CreateEventsPanel(solutionBuilderModel, components, 2); // UseCases //this.CreateUseCasesPanel(solutionBuilderModel, endpoint.As<IProductElement>(), application, 3); }
public void RemoveLinks(IAbstractEndpoint endpoint) { var project = endpoint.Project; if (project == null) return; // TODO: Evaluate where this is being called. Removed the steps related to libraries. }
private static string DefaultBuildNamespaceForComponentCode(IAbstractEndpoint endpoint, IService service) { return endpoint == null ? string.Empty : string.Format(@"{0}.{1}", endpoint.Project.Data.RootNamespace, service.CodeIdentifier); }
public void AddLinks(IAbstractEndpoint endpoint) { var project = endpoint.Project; if (this.IsProcessor) { // 1. Add Links for Custom Code var customCodePath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, null, true); AddLinkToProject(project, this.As<IProductElement>(), customCodePath, items => items.First(i => Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(i.PhysicalPath))) != "Infrastructure" )); //2. Add Links for Infrastructure Code var infraCodePath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, "Infrastructure", true); AddLinkToProject(project, this.As<IProductElement>(), infraCodePath, items => items.First(i => Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(i.PhysicalPath))) == "Infrastructure" )); } // 3. Add Links for References foreach (var libraryLink in this.LibraryReferences.LibraryReference) { IProductElement element = null; if (libraryLink.Library != null) { if (libraryLink.Library.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.Library.As<IProductElement>(); } } else { if (libraryLink.ServiceLibrary.As<IProductElement>().References.Any(r => r.Kind == ReferenceKindConstants.ArtifactLink)) { element = libraryLink.ServiceLibrary.As<IProductElement>(); } } var suggestedPath = endpoint.CustomizationFuncs().BuildPathForComponentCode(endpoint, this.Parent.Parent, null, true); AddLinkToProject(project, element, suggestedPath, i => i.First()); } }
public void AddEndpointStartingUseCase(IAbstractEndpoint endpoint) { var element = endpoint.As<IProductElement>(); this.EnsureRelatedElementListsExist(); if (!this.UseCaseLinks.Any(l => l.LinkedElementId == element.Id)) { this.InternalAddRelatedElement(element, true, true); } }
public void DeployTo(IAbstractEndpoint endpoint) { if (!endpoint.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference.Value == this)) { var linkSource = endpoint.EndpointComponents.CreateComponentLink(String.Format("{0}.{1}", this.Parent.Parent.InstanceName, this.InstanceName), e => e.ComponentReference.Value = this); linkSource.ComponentReference.Value.EndpointDefined(endpoint); } }
public void RaiseOnInstantiatedEndpoint(IAbstractEndpoint endpoint) { if (OnInstantiatedEndpoint != null) { OnInstantiatedEndpoint(endpoint, EventArgs.Empty); } }
public void AddLinks(IAbstractEndpoint endpoint) { var project = endpoint.Project; // TODO: Evaluate where this is being called. Removed the steps related to libraries. }