public ComponentsBuilder(TextWriter textWriter, TLanguages languages, TSetupTypes setupTypes, TCustomMessages customMessages, TMessages messages, HashSet <InstallationMethod> methods) { _textWriter = textWriter; _languages = languages; _setupTypes = setupTypes; _customMessages = customMessages; _messages = messages; _methods = methods; }
private IList <TEntry> AddEntries <TEntry, TBuilder>( string sectionName, Func <TBuilder> builderFactory, Func <Func <TBuilder>, TLanguages, TSetupTypes, TCustomMessages, TMessages, TComponents, TTasks, IEnumerable <TEntry> > builder, TLanguages languages, TSetupTypes setupTypes, TCustomMessages customMessages, TMessages messages, TComponents components, TTasks tasks, Action <TEntry> newEntryHandler = null) where TEntry : ICustomizable, IPredicated { var entries = builder(builderFactory, languages, setupTypes, customMessages, messages, components, tasks).ToList(); if (entries.Count > 0) { var typeConverterFactory = new Func <System.ComponentModel.TypeConverterAttribute, System.ComponentModel.TypeConverter>(attr => { var type = typeof(DelegateExpressionToStringConverter <Func <string, bool> >); var converterType = Type.GetType(attr.ConverterTypeName); if (converterType == type) { return(new DelegateExpressionToStringConverter <Func <string, bool> >(methodInfo => { if (!_methods.Any(im => im.MetadataToken == methodInfo.MetadataToken)) { _methods.Add(new InstallationMethod(methodInfo)); } })); } return((System.ComponentModel.TypeConverter)Activator.CreateInstance(converterType)); }); using (new Section(_textWriter, sectionName)) { foreach (var entry in entries) { newEntryHandler?.Invoke(entry); var converter = new PropertiesToNameValuePairsConverter(_propertyFormatter, typeConverterFactory); var pairs = converter.ConvertTo(entry, typeof(NameValueCollection)) as NameValueCollection; _textWriter.WriteLine(pairs.Format()); } } } return(entries); }