protected string ListPropertyDeclarationOnSelf(GivenClassComplexListProperty excelGivenProperty)
        {
            var listClassName    = $"SpecificationSpecific{excelGivenProperty.ClassName}";
            var listPropertyName = ListPropertyName(excelGivenProperty);

            return($"        readonly List<{listClassName}> {listPropertyName};");
        }
        protected string ListPropertyInitialisationOnSelf(GivenClassComplexListProperty excelGivenProperty)
        {
            var listClassName    = $"SpecificationSpecific{excelGivenProperty.ClassName}";
            var listPropertyName = ListPropertyName(excelGivenProperty);

            return($"            {listPropertyName} = new List<{listClassName}>();");
        }
        protected string ListPropertySetterOnSelf(GivenClassComplexListProperty excelGivenProperty)
        {
            var parameterName     = CamelCase(excelGivenProperty.Name);
            var listParameterName = ListPropertyName(excelGivenProperty);
            var listPropertyName  = ListPropertyName(excelGivenProperty);
            var listClassName     = $"SpecificationSpecific{excelGivenProperty.ClassName}";

            return
                ($@"        internal {SpecificationSpecificClassName} {excelGivenProperty.Name}_of({listClassName} {parameterName})
        {{
            AddClassProperty(new ReportSpecificationSetupClass(GetCurrentMethod(), {parameterName}));

            this.{listPropertyName}.Add({parameterName});

            return this;
        }}

        internal {SpecificationSpecificClassName} {excelGivenProperty.Name}_list_of(string listType, List<{listClassName}> {listParameterName})
        {{
            AddListProperty(new ReportSpecificationSetupList(GetCurrentMethod().Name, listType, {listParameterName}));

            this.{listPropertyName}.AddRange({listParameterName});

            return this;
        }}

        internal {SpecificationSpecificClassName} {excelGivenProperty.Name}_table_of(ReportSpecificationSetupClassUsingTable<{listClassName}> {listParameterName})
        {{
            {listParameterName}.PropertyName = GetCurrentMethod().Name;

            AddClassTableProperty({listParameterName});

            foreach (var row in {listParameterName}.Rows)
                this.{listPropertyName}.Add(row.Properties);

            return this;
        }}");
        }
コード例 #4
0
        IReadOnlyList <IGivenClassProperty> RationaliseProperties(
            IReadOnlyList <IVisitedGivenSimpleProperty> rationalisedGivenSimpleProperties,
            IReadOnlyList <IVisitedGivenComplexProperty> rationalisedGivenComplexProperties,
            IReadOnlyList <IVisitedGivenFunction> rationalisedGivenFunctions,
            IReadOnlyList <IVisitedGivenListProperty> rationalisedGivenListProperties,
            IReadOnlyList <IVisitedGivenTableProperty> rationalisedGivenTableProperties
            )
        {
            properties.Clear();
            givenSimpleProperties.Clear();

            foreach (var givenComplexProperty in rationalisedGivenComplexProperties)
            {
                var complexProperty =
                    new GivenClassComplexProperty(
                        givenComplexProperty.PropertyName,
                        givenComplexProperty.ClassName);

                givenComplexProperties.Add(complexProperty);
                AddProperty(complexProperty);
            }

            foreach (var givenSimpleProperty in rationalisedGivenSimpleProperties)
            {
                var simpleProperty =
                    new GivenClassSimpleProperty(
                        givenSimpleProperty.PropertyOrFunctionName,
                        givenSimpleProperty.ExcelPropertyType,
                        givenSimpleProperty.CsharpCodeRepresentation,
                        givenSimpleProperty.Nullable
                        );

                givenSimpleProperties.Add(simpleProperty);
                AddProperty(simpleProperty);
            }

            foreach (var givenFunction in rationalisedGivenFunctions)
            {
                var function = new GivenClassFunction(givenFunction.PropertyOrFunctionName);

                givenFunctions.Add(function);
                AddProperty(function);
            }

            foreach (var givenListProperty in rationalisedGivenListProperties)
            {
                var complexListProperty =
                    new GivenClassComplexListProperty(
                        givenListProperty.PropertyName,
                        givenListProperty.ClassName);

                givenComplexListProperties.Add(complexListProperty);
                AddProperty(complexListProperty);
            }

            foreach (var givenTableProperty in rationalisedGivenTableProperties)
            {
                var complexListProperty =
                    new GivenClassComplexListProperty(
                        givenTableProperty.PropertyName,
                        givenTableProperty.ClassName);

                givenComplexListProperties.Add(complexListProperty);
                AddProperty(complexListProperty);
            }

            return(properties);
        }
 string NonMatchingListProperty(GivenClassComplexListProperty givenClassProperty)
 {
     return($"// Could not match {givenClassProperty.Name}, please add this in a custom partial class, or override this file entirely, by creating a file in  a Setup subfolder called {givenClassProperty.ClassName}Override.cs");
 }