protected RegistrationInfo CreateInfo() { var info = new RegistrationInfo { ClassName = "Apply" + GetType().Name }; return(info); }
static void GenerateRegisterCommand(RegistrationInfo registrationInfo) { var typeVarMap = new Dictionary <Type, string>(); var parameterBuilder = new List <string>(); var declarationBuilder = new List <string>(); var registrationBuilder = new List <string>(); var handlerBuilder = new List <string>(); var assignmentBuilder = new List <string>(); var cleanupBuilder = new List <string>(); var postInjectionBuilder = new List <string>(); foreach (var registrationData in registrationInfo.Registrations) { var flags = registrationData.Flags; if (flags.Has(RegisterFlags.NoCache)) { RegisterTypeByHandler(registrationData, typeVarMap, handlerBuilder); } else if (flags.Has(RegisterFlags.Parameter)) { var index = parameterBuilder.Count; var parameter = "var {0} = ({1}) args[" + index + "];"; RegisterMultipleTypes(registrationData, typeVarMap, parameterBuilder, registrationBuilder, parameter, false); } else { const string DECLARATION = "var {0} = new {1}();"; RegisterMultipleTypes(registrationData, typeVarMap, declarationBuilder, registrationBuilder, DECLARATION, true); } } AssignInjections(registrationInfo.Registrations, typeVarMap, assignmentBuilder, cleanupBuilder, postInjectionBuilder); var parameters = string.Join(Environment.NewLine, parameterBuilder); UpdateRegistrationCommand( registrationInfo, parameters, string.Join(Environment.NewLine, declarationBuilder), string.Join(Environment.NewLine, registrationBuilder), string.Join(Environment.NewLine, handlerBuilder), string.Join(Environment.NewLine, assignmentBuilder), string.Join(Environment.NewLine, cleanupBuilder), string.Join(Environment.NewLine, postInjectionBuilder)); }