public static void DependencyRegister(dynamic container, dynamic Config, IConfigOptions options) { var typeFinder = new WebAppTypeFinder(); var drTypes = typeFinder.FindClassesOfType <IDependencyRegistrar>().AsEnumerable(); var drInstances = new List <IDependencyRegistrar>(); foreach (var drType in drTypes) { var dependency = (IDependencyRegistrar)Activator.CreateInstance(drType); dependency.IsAssemblyValid(Config); drInstances.Add(dependency); } //sort foreach (var regtype in Enum.GetValues(typeof(RegType))) { var byRegTypeInstances = drInstances .Where(w => w.RegisterType.ToString() == regtype.ToString()) .OrderBy(o => o.Order); foreach (var dr in byRegTypeInstances) { var builder = new ContainerBuilder(); if (options.Contains(enumConfigOpts.RegAll)) { dr.ResolveDependencyName = true; } dr.Register(builder, container, typeFinder, Config, options); builder.Update(container); dr.ApplyAdditionRuleToParent(byRegTypeInstances, Config, options); } } }
public string SetResolveName(Type t , string Name = "" , string postFix = "" , IConfigOptions Opts = default(IConfigOptions)) { string TypeName = t.Name; if (!ResolveDependencyName && (Opts != null && !Opts.Contains(enumConfigOpts.ForceNameResolve)) ) { return(TypeName); } if (!string.IsNullOrEmpty(Name)) { TypeName = Name; } string name; var temp = t.FullName.Split('.'); if (!string.IsNullOrEmpty(postFix)) { name = temp.First(); } else { name = string.Join(".", temp.Take(temp.Length - 1)); } var sreturn = name + "." + (string.IsNullOrEmpty(postFix) ? "" : postFix + ".") + TypeName; return(sreturn); }