From 64ecf56dbadb5baf0d9e1b3a8d87d22c134caef9 Mon Sep 17 00:00:00 2001 From: Michael Grafnetter Date: Wed, 2 Jan 2019 19:38:40 +0100 Subject: [PATCH] Switched to AutoMapper instance-based API --- .../Datastore/GetADDBDomainControllerCommand.cs | 7 +++---- .../Datastore/GetADDBSchemaAttributeCommand.cs | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBDomainControllerCommand.cs b/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBDomainControllerCommand.cs index 100349c..1a66245 100644 --- a/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBDomainControllerCommand.cs +++ b/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBDomainControllerCommand.cs @@ -1,6 +1,5 @@ namespace DSInternals.PowerShell.Commands { - using System; using System.Management.Automation; using AutoMapper; @@ -11,10 +10,10 @@ protected override void BeginProcessing() { base.BeginProcessing(); - Mapper.Initialize(cfg => cfg.CreateMap()); var dc = this.DirectoryContext.DomainController; - var dcTransfer = Mapper.Map(dc); + var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); + var dcTransfer = mapper.Map(dc); this.WriteObject(dcTransfer); } } -} \ No newline at end of file +} diff --git a/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBSchemaAttributeCommand.cs b/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBSchemaAttributeCommand.cs index b124c8b..807c531 100644 --- a/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBSchemaAttributeCommand.cs +++ b/Src/DSInternals.PowerShell/Commands/Datastore/GetADDBSchemaAttributeCommand.cs @@ -7,6 +7,8 @@ [OutputType(typeof(DSInternals.PowerShell.SchemaAttribute))] public class GetADDBSchemaAttributeCommand : ADDBCommandBase { + private IMapper mapper; + [Parameter(Position = 0, ValueFromPipeline = true)] [Alias("LdapDisplayName,AttributeName,AttrName,Attr")] [ValidateNotNullOrEmpty] @@ -19,7 +21,7 @@ protected override void BeginProcessing() { base.BeginProcessing(); - Mapper.Initialize(cfg => cfg.CreateMap()); + this.mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); } protected override void ProcessRecord() { @@ -29,7 +31,7 @@ var attributes = this.DirectoryContext.Schema.FindAllAttributes(); foreach (var attribute in attributes) { - var attributeTransfer = Mapper.Map(attribute); + var attributeTransfer = this.mapper.Map(attribute); this.WriteObject(attributeTransfer); } } @@ -39,10 +41,10 @@ foreach(string attributeName in this.Name) { var attribute = this.DirectoryContext.Schema.FindAttribute(attributeName); - var attributeTransfer = Mapper.Map(attribute); + var attributeTransfer = this.mapper.Map(attribute); this.WriteObject(attributeTransfer); } } } } -} \ No newline at end of file +}