コード例 #1
0
 public CSharpMemberNameFinder(AtomMemberInfo member)
     : this(AliasedAtomMemberInfo.FromAtomMemberInfo(member))
 {
 }
コード例 #2
0
        public IEnumerable <GeneratorOutput> Generate(IEnumerable <ProjectedAtomRoot> atoms)
        {
            atoms = atoms.Where(a => a.BasedOn.AdditionalInfo.ShouldGenerateCode()).ToList();

            var classes = atoms.Select(GenerateClass)
                          .ToList();

            var strongTypesLookup = atoms.SelectMany(atom => atom.Members.Where(i => CanBeStronger(i.Member)).Select(j => AliasedAtomMemberInfo.FromAtomMemberInfo(GetStrongTypeMember(j.Member))))
                                    .ToLookup(t => new CSharpStrongTypeNameFinder(t.Member).TypeName());

            var strongTypes = strongTypesLookup.Select(c => StrongTypeDefinition(c.First()));


            string strongTypesCode = Config.Entities.StrongTypes ? string.Join(Environment.NewLine, strongTypes.IndentAllLines(1)) : string.Empty;

            yield return(new GeneratorOutput(
                             Path.ChangeExtension("Records.cs", Config.FileExtension),
                             $@"
{new NamespaceGenerator().ByConfig(Config)}

namespace {Config.Entities.Namespace}
{{
    {string.Join(Environment.NewLine, classes.IndentAllLines(1)).Trim()}

    {strongTypesCode}
}}
".Trim()));
        }