mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-01-09 15:49:53 +00:00
Switched to AutoMapper instance-based API
This commit is contained in:
parent
7747f96e45
commit
64ecf56dba
@ -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<DSInternals.DataStore.DomainController, DSInternals.PowerShell.DomainController>());
|
||||
var dc = this.DirectoryContext.DomainController;
|
||||
var dcTransfer = Mapper.Map<DSInternals.PowerShell.DomainController>(dc);
|
||||
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<DSInternals.DataStore.DomainController, DSInternals.PowerShell.DomainController>()).CreateMapper();
|
||||
var dcTransfer = mapper.Map<DSInternals.PowerShell.DomainController>(dc);
|
||||
this.WriteObject(dcTransfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<DSInternals.DataStore.SchemaAttribute, DSInternals.PowerShell.SchemaAttribute>());
|
||||
this.mapper = new MapperConfiguration(cfg => cfg.CreateMap<DSInternals.DataStore.SchemaAttribute, DSInternals.PowerShell.SchemaAttribute>()).CreateMapper();
|
||||
}
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
@ -29,7 +31,7 @@
|
||||
var attributes = this.DirectoryContext.Schema.FindAllAttributes();
|
||||
foreach (var attribute in attributes)
|
||||
{
|
||||
var attributeTransfer = Mapper.Map<DSInternals.PowerShell.SchemaAttribute>(attribute);
|
||||
var attributeTransfer = this.mapper.Map<DSInternals.PowerShell.SchemaAttribute>(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<DSInternals.PowerShell.SchemaAttribute>(attribute);
|
||||
var attributeTransfer = this.mapper.Map<DSInternals.PowerShell.SchemaAttribute>(attribute);
|
||||
this.WriteObject(attributeTransfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user