string Function(IGivenClassProperty excelGivenProperty)
        {
            var functionName = excelGivenProperty.Name;

            return
                ($@"        // No sensible implementation can be generated for functions, so please 
        // add the function below in a (partial) custom class.
        // public void {functionName}() {{ .. }} ");
        }
Пример #2
0
        void AddProperty(IGivenClassProperty property)
        {
            if (properties.Any(p => p.Name == property.Name))
            {
                var allProperties = properties.ToList();
                allProperties.Add(property);
                var multipleTypes = string.Join(", ", allProperties.Where(p => p.Name == property.Name).Select(s => s.ToString()));

                throw new ExcelToCodeException($"Multiple different property types found for {property.Name}: {multipleTypes}");
            }

            properties.Add(property);
        }
        string Function(IGivenClassProperty excelGivenProperty)
        {
            var functionName = excelGivenProperty.Name;

            return
                ($@"        // No sensible implementation can be generated for functions, so please 
        // add the function below in a custom class.
        // Custom classes should go in the 'Setup' folder.
        // If the custom class filename is '{SpecificationSpecificClassName}Override.cs',
        // then it will be used instead of this file. If it is called something else,
        // say {SpecificationSpecificClassName}Partial.cs, then this class will remain, and
        // the custom class can add to it.
        // public void {functionName}() {{ .. }} 
");
        }
 bool MatchesAnyCsharpPropertyOrFunction(
     IGivenClassProperty excelProperty,
     IEnumerable <PropertyInfo> properties,
     IEnumerable <MethodInfo> methods
     )
 {
     return
         (properties.Any(
              cSharpProperty =>
              excelCsharpPropertyMatcher.PropertiesMatch(cSharpProperty, excelProperty)
              ) ||
          methods.Any(
              cSharpMethod =>
              excelCsharpPropertyMatcher.MethodsMatch(cSharpMethod, excelProperty)
              ));
 }
Пример #5
0
        public bool MethodsMatch(
            MethodInfo cSharpMethod,
            IGivenClassProperty excelProperty)
        {
            return(false);

            //if (!NamesMatch(cSharpMethod.Name, excelProperty.Name))
            //    return false;

            //if (cSharpMethod.ReturnType != typeof(void))
            //    return false;

            //if (cSharpMethod.GetParameters().Length == 0)
            //    return excelProperty.Type == ExcelPropertyType.Null;
            //else if (cSharpMethod.GetParameters().Length == 1)
            //    return excelProperty.TypesMatch(cSharpMethod.GetParameters()[0].ParameterType);

            //return false;
        }
 protected string ListPropertyName(IGivenClassProperty excelProperty) =>
 CamelCase(excelProperty.Name) + "s";
Пример #7
0
 public bool PropertiesMatch(
     PropertyInfo cSharpProperty,
     IGivenClassProperty excelProperty) =>
 NamesMatch(cSharpProperty.Name, excelProperty.Name) &&
 excelProperty.TypesMatch(cSharpProperty.PropertyType);