本文整理汇总了C#中IConfiguration.AddProfile方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.AddProfile方法的具体用法?C# IConfiguration.AddProfile怎么用?C# IConfiguration.AddProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfiguration
的用法示例。
在下文中一共展示了IConfiguration.AddProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureAutoMapper
private void ConfigureAutoMapper(IConfiguration cfg)
{
//AutoMapper Help
//https://github.com/AutoMapper/AutoMapper/wiki
//http://www.rqna.net/qna/yxzrz-automapper-bidirectional-mapping-with-reversemap-and-formember.html
//基类执行程序集搜索、Mappter 初始化。
//scan all assemblies finding Automapper Profile
var profiles = DotEnvironment.GetAppPlugins()
.SelectMany(p => p.Assembly.GetTypes())
.Where(t => t.BaseType == typeof(AutoMapper.Profile))
.Distinct().ToList();
foreach (var item in profiles)
{
cfg.AddProfile(Activator.CreateInstance(item) as AutoMapper.Profile);
}
var maps = Mapper.GetAllTypeMaps();
foreach (var map in maps)
{
}
Dot.Utility.Log.LogFactory.PlatformLog.Debug("Domain Dto 映射完成");
}
示例2: BuildAutoMapperConfiguration
private static void BuildAutoMapperConfiguration(IConfiguration configuration, IEnumerable<Profile> profiles)
{
foreach (var profile in profiles)
{
configuration.AddProfile(profile);
}
}
示例3: GetConfiguration
private static void GetConfiguration(IConfiguration configuration)
{
var profiles = typeof(AutomapperConfiguration).Assembly.GetTypes().Where(x => typeof(AutoMapper.Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as AutoMapper.Profile);
}
}
示例4: GetConfiguration
private static void GetConfiguration(IConfiguration configuration)
{
var profiles = typeof(IApplicationService).Assembly.GetTypes().Where(x => typeof(Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
}
}
示例5: GetConfiguration
private void GetConfiguration(IConfiguration configuration)
{
var profiles = typeof(DefaultProfileMapper).Assembly.GetTypes().Where(x => typeof(Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
}
}
示例6: GetConfiguration
private static void GetConfiguration(IConfiguration configuration)
{
var assembly = typeof(AutoMapperWebConfiguration).GetTypeInfo().Assembly;
var exportedTypes = assembly.GetExportedTypes();
foreach (var type in exportedTypes.Where(a => typeof(Profile).IsAssignableFrom(a)))
{
configuration.AddProfile(Activator.CreateInstance(type) as Profile);
}
}
示例7: GetConfigurationFromAssembly
private static void GetConfigurationFromAssembly(IConfiguration cfg)
{
var profiles = typeof(PersonProfile).Assembly
.GetTypes()
.Where(t => t != typeof(Profile) && typeof(Profile).IsAssignableFrom(t));
foreach (var profile in profiles)
{
cfg.AddProfile((Profile)Activator.CreateInstance(profile));
}
}
示例8: GetConfiguration
private static void GetConfiguration(IConfiguration configuration, IEnumerable<Assembly> assemblies)
{
foreach (var assembly in assemblies)
{
var profiles = assembly.GetTypes().Where(x => typeof(Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
}
}
}
示例9: GetConfiguration
// Using Reflection load all the profiles which contain the AutoMapper configuration
// from entities to view models visa versa
// to be used if applying ViewModels in a mature application so that entity models are not
// tighly coupled to the UI layer
private static void GetConfiguration(IConfiguration configuration)
{
configuration.AllowNullDestinationValues = true;
configuration.AllowNullCollections = true;
IEnumerable<Type> profiles = Assembly.GetExecutingAssembly().GetTypes().Where(type => typeof(Profile).IsAssignableFrom(type));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
}
}
示例10: GetConfiguration
private static void GetConfiguration(IConfiguration configuration)
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in assemblies)
{
var profiles = assembly.GetTypes().Where(x => x != typeof(Profile) && typeof(Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile((Profile)Activator.CreateInstance(profile));
}
}
}
示例11: GetConfiguration
private static void GetConfiguration(IConfiguration configuration, ContainerBuilder builder)
{
var profileTypes = typeof(AutoMapperConfiguration).Assembly.GetTypes().Where(type =>
type.ContainsGenericParameters == false &&
typeof(Profile).IsAssignableFrom(type));
foreach (var profileType in profileTypes)
{
var profile = Activator.CreateInstance(profileType) as Profile;
configuration.AddProfile(profile);
builder.RegisterInstance(profile).AsImplementedInterfaces().SingleInstance();
}
}
示例12: AddProfile
/// <summary>
///
/// </summary>
/// <param name="config"></param>
/// <param name="assembly"></param>
private static void AddProfile(IConfiguration config, Assembly assembly)
{
foreach (var type in assembly.GetTypes())
{
if (type.IsAbstract || type.IsInterface)
{
continue;
}
if (typeof(Profile).IsAssignableFrom(type))
{
config.AddProfile(Activator.CreateInstance(type) as Profile);
}
}
}
示例13: GetAutoMapperConfiguration
private void GetAutoMapperConfiguration(IConfiguration configuration, IWindsorContainer container)
{
var registrar = container.Resolve<AssemblyRegistrar>();
using (var childContainer = new WindsorContainer())
{
Action<Assembly> action =
asm =>
childContainer.Register(Types.FromAssembly(asm)
.BasedOn<Profile>()
.WithServices(typeof(Profile)));
action.VisitAssemblies(registrar);
foreach (var profile in childContainer.ResolveAll<Profile>())
configuration.AddProfile(profile);
}
}
示例14: GetConfiguration
private static void GetConfiguration(IConfiguration configuration, IEnumerable<Assembly> assemblies)
{
assemblies = assemblies
//?? AppDomain.CurrentDomain.GetAssemblies()
?? new[] { Assembly.GetExecutingAssembly() }
;
foreach (var assembly in assemblies)
{
var profileClasses = assembly.GetTypes()
.Where(t => t != typeof(Profile) && typeof(Profile).IsAssignableFrom(t))
.ToArray()
;
foreach (var profileClass in profileClasses)
{
configuration.AddProfile((Profile)Activator.CreateInstance(profileClass));
}
}
}
示例15: GetConfiguration
private static void GetConfiguration(IEnumerable<Assembly> assemblies, IConfiguration configuration)
{
var types = new List<Type>();
foreach (var thisAssembly in assemblies)
{
types.AddRange(thisAssembly.GetTypes());
}
var profiles = types.Where(x => typeof(Profile).IsAssignableFrom(x));
foreach (var profile in profiles)
{
configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
}
Mapper.AssertConfigurationIsValid();
}