private void SetArtifactLink(UnfoldScope scope) { var container = scope.Automation.Owner; // Determine created item IItemContainer createdItem = null; createdItem = this.Solution.Find <IProject>(p => p.PhysicalPath == this.projectCreated).SingleOrDefault(); if (createdItem == null) { createdItem = this.Solution.Find <IItem>(pi => pi.PhysicalPath == this.projectItemCreated).SingleOrDefault(); } if (createdItem != null) { if (this.UriService.CanCreateUri <IItemContainer>(createdItem)) { // Set the artifact link SolutionArtifactLinkReference .SetReference(container, this.UriService.CreateUri <IItemContainer>(createdItem)) .Tag = BindingSerializer.Serialize(scope.ReferenceTag); } else { tracer.Warn(Properties.Resources.InstantiationTemplateWizard_CantCreateUri, createdItem.GetLogicalPath()); } } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.templateScope != null) { this.templateScope.Dispose(); this.templateScope = null; } if (this.eventBufferingScope != null) { this.eventBufferingScope.Dispose(); this.eventBufferingScope = null; } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.templateScope != null) { this.templateScope.Dispose(); this.templateScope = null; } if (this.eventBufferingScope != null) { this.eventBufferingScope.Dispose(); this.eventBufferingScope = null; } }
public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { base.RunStarted(automationObject, replacementsDictionary, runKind, customParams); if (this.PatternManager == null) { NuPatternCompositionService.Instance.SatisfyImportsOnce(this); } Guard.NotNull(() => this.PatternManager, this.PatternManager); Guard.NotNull(() => this.UriService, this.UriService); var safeProductName = GetSafeTemplateName(replacementsDictionary); this.templateFile = (string)customParams[0]; this.templateUri = this.UriService.CreateUri(this.TemplateSchema); if (!UnfoldScope.IsActive || !UnfoldScope.Current.HasUnfolded(templateUri.AbsoluteUri)) { var toolkit = FindToolkitOrThrow(this.PatternManager, templateFile); var settings = FindTemplateSettingsOrThrow(toolkit, templateUri); using (tracer.StartActivity(Resources.InstantiationTemplateWizard_StartingTemplateOriginated, this.TemplateSchema.PhysicalPath)) { if (settings.CreateElementOnUnfold) { if (!this.Solution.IsOpen && !this.PatternManager.IsOpen) { this.tempStoreFile = Path.GetTempFileName(); this.PatternManager.Open(this.tempStoreFile, true); } // We always create the new scope. If there's a wrapping EventBufferingTemplateWizard, we'll just // hook on top of that. Events that we buffer will not be raised until the outer buffering completes. eventBufferingScope = new StoreEventBufferingScope(); this.element = this.PatternManager.CreateProduct(toolkit, safeProductName); var templateAutomation = FindTemplateAutomationOrThrow(this.element, this.templateUri.AbsoluteUri); if (settings.SyncName && settings.TargetFileName.ValueProvider != null) { throw new NotSupportedException(Resources.TemplateAutomation_ValueProviderUnsupportedForSyncNames); } this.templateScope = new UnfoldScope( templateAutomation, new ReferenceTag { SyncNames = settings.SyncName, TargetFileName = settings.TargetFileName.Value }, this.templateUri.AbsoluteUri); if (!templateAutomation.ExecuteWizard()) { if (this.templateScope != null) { this.PatternManager.Close(); File.Delete(this.tempStoreFile); throw new WizardCancelledException(); } else { wizardCancelled = true; } } } } } }
private void SetArtifactLink(UnfoldScope scope) { var container = scope.Automation.Owner; // Determine created item IItemContainer createdItem = null; createdItem = this.Solution.Find<IProject>(p => p.PhysicalPath == this.projectCreated).SingleOrDefault(); if (createdItem == null) { createdItem = this.Solution.Find<IItem>(pi => pi.PhysicalPath == this.projectItemCreated).SingleOrDefault(); } if (createdItem != null) { if (this.UriService.CanCreateUri<IItemContainer>(createdItem)) { // Set the artifact link SolutionArtifactLinkReference .SetReference(container, this.UriService.CreateUri<IItemContainer>(createdItem)) .Tag = BindingSerializer.Serialize(scope.ReferenceTag); } else { tracer.Warn(Properties.Resources.InstantiationTemplateWizard_CantCreateUri, createdItem.GetLogicalPath()); } } }
public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { base.RunStarted(automationObject, replacementsDictionary, runKind, customParams); if (this.PatternManager == null) { NuPatternCompositionService.Instance.SatisfyImportsOnce(this); } Guard.NotNull(() => this.PatternManager, this.PatternManager); Guard.NotNull(() => this.UriService, this.UriService); var safeProductName = GetSafeTemplateName(replacementsDictionary); this.templateFile = (string)customParams[0]; this.templateUri = this.UriService.CreateUri(this.TemplateSchema); if (!UnfoldScope.IsActive || !UnfoldScope.Current.HasUnfolded(templateUri.AbsoluteUri)) { var toolkit = FindToolkitOrThrow(this.PatternManager, templateFile); var settings = FindTemplateSettingsOrThrow(toolkit, templateUri); using (tracer.StartActivity(Resources.InstantiationTemplateWizard_StartingTemplateOriginated, this.TemplateSchema.PhysicalPath)) { if (settings.CreateElementOnUnfold) { if (!this.Solution.IsOpen && !this.PatternManager.IsOpen) { this.tempStoreFile = Path.GetTempFileName(); this.PatternManager.Open(this.tempStoreFile, true); } // We always create the new scope. If there's a wrapping EventBufferingTemplateWizard, we'll just // hook on top of that. Events that we buffer will not be raised until the outer buffering completes. eventBufferingScope = new StoreEventBufferingScope(); this.element = this.PatternManager.CreateProduct(toolkit, safeProductName); var templateAutomation = FindTemplateAutomationOrThrow(this.element, this.templateUri.AbsoluteUri); if (settings.SyncName && settings.TargetFileName.ValueProvider != null) throw new NotSupportedException(Resources.TemplateAutomation_ValueProviderUnsupportedForSyncNames); this.templateScope = new UnfoldScope( templateAutomation, new ReferenceTag { SyncNames = settings.SyncName, TargetFileName = settings.TargetFileName.Value }, this.templateUri.AbsoluteUri); if (!templateAutomation.ExecuteWizard()) { if (this.templateScope != null) { this.PatternManager.Close(); File.Delete(this.tempStoreFile); throw new WizardCancelledException(); } else { wizardCancelled = true; } } } } } }