public override int GetHashCode() { unchecked { return(ValueTypes.Aggregate(0, (t, v) => (t * 397) ^ v.GetHashCode()) ^ (IndexMap?.Aggregate(0, (t, v) => (t * 397) ^ v.GetHashCode()) ?? 0)); } }
internal static void Write() { List <string> mappingsList = ValueTypes.Aggregate(new List <string>(), (list, next) => { list.Add(File.ReadAllText(string.Format(CultureInfo.InvariantCulture, "{0}\\InputMapperProfilesTemplate.txt", Directory.GetCurrentDirectory())) .Replace("#TYPE#", next)); return(list); }); mappingsList = ValueTypes.Aggregate(mappingsList, (list, next) => { list.Add(File.ReadAllText(string.Format(CultureInfo.InvariantCulture, "{0}\\InputMapperProfilesTemplate.txt", Directory.GetCurrentDirectory())) .Replace("#TYPE#", string.Concat(next, "?"))); return(list); }); mappingsList = OtherTypes.Aggregate(mappingsList, (list, next) => { list.Add(File.ReadAllText(string.Format(CultureInfo.InvariantCulture, "{0}\\InputMapperProfilesTemplate.txt", Directory.GetCurrentDirectory())) .Replace("#TYPE#", next)); return(list); }); string mappings = string.Join(string.Concat(Environment.NewLine, Environment.NewLine), mappingsList); string text = File.ReadAllText(string.Format(CultureInfo.InvariantCulture, "{0}\\InputVariablesMappingProfileFileTemplate.txt", Directory.GetCurrentDirectory())) .Replace("#Mappings#", mappings); List <string> includesViewToParametersList = ValueTypes.Aggregate(new List <string>(), (list, next) => { list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<{0}>, InputQuestionParameters<{0}>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<{0}?>, InputQuestionParameters<{0}?>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IEnumerable<{0}>>, InputQuestionParameters<IEnumerable<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IEnumerable<{0}?>>, InputQuestionParameters<IEnumerable<{0}?>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<ICollection<{0}>>, InputQuestionParameters<ICollection<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<ICollection<{0}?>>, InputQuestionParameters<ICollection<{0}?>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IList<{0}>>, InputQuestionParameters<IList<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IList<{0}?>>, InputQuestionParameters<IList<{0}?>>>()", next)); return(list); }); includesViewToParametersList = OtherTypes.Aggregate(includesViewToParametersList, (list, next) => { list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<{0}>, InputQuestionParameters<{0}>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IEnumerable<{0}>>, InputQuestionParameters<IEnumerable<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<ICollection<{0}>>, InputQuestionParameters<ICollection<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputView<IList<{0}>>, InputQuestionParameters<IList<{0}>>>()", next)); return(list); }); List <string> includesParametersToViewList = ValueTypes.Aggregate(new List <string>(), (list, next) => { list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<{0}>, InputView<{0}>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<{0}?>, InputView<{0}?>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IEnumerable<{0}>>, InputView<IEnumerable<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IEnumerable<{0}?>>, InputView<IEnumerable<{0}?>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<ICollection<{0}>>, InputView<ICollection<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<ICollection<{0}?>>, InputView<ICollection<{0}?>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IList<{0}>>, InputView<IList<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IList<{0}?>>, InputView<IList<{0}?>>>()", next)); return(list); }); includesParametersToViewList = OtherTypes.Aggregate(includesParametersToViewList, (list, next) => { list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<{0}>, InputView<{0}>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IEnumerable<{0}>>, InputView<IEnumerable<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<ICollection<{0}>>, InputView<ICollection<{0}>>>()", next)); list.Add(string.Format(CultureInfo.CurrentCulture, "\t\t\t\t.Include<InputQuestionParameters<IList<{0}>>, InputView<IList<{0}>>>()", next)); return(list); }); text = text.Replace("#ViewToParameterIncludes#", string.Join(Environment.NewLine, includesViewToParametersList)); text = text.Replace("#ParameterToViewIncludes#", string.Join(Environment.NewLine, includesParametersToViewList)); using (StreamWriter sr = new StreamWriter($@"{Constants.BASEPATH}\CheckMySymptoms.AutoMapperProfiles\InputVariablesMappingProfile.cs", false, Encoding.UTF8)) { sr.Write(text); } }