PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Condor.Core/PropertyObjects/BusinessObjectsPropertiesRenderForeignKeyForDbContext.cs

http://github.com/kahanu/CondorXE
C# | 47 lines | 40 code | 3 blank | 4 comment | 6 complexity | ba8365ca63b02f9f338e8063436e5e14 MD5 | raw file
  1. using System;
  2. using System.Linq;
  3. using Condor.Core.Interfaces;
  4. using MyMeta;
  5. using Zeus;
  6. namespace Condor.Core.PropertyObjects
  7. {
  8. /// <summary>
  9. /// This class doesn't need to inherit from Property since it has a different signature.
  10. /// This class renders properties that are related entities to this entity.
  11. /// </summary>
  12. public class BusinessObjectsPropertiesRenderForeignKeyForDbContext
  13. {
  14. private readonly ITable _table;
  15. private readonly RequestContext _context;
  16. private readonly ScriptSettings _script;
  17. private readonly IZeusOutput _output;
  18. public BusinessObjectsPropertiesRenderForeignKeyForDbContext(MyMeta.ITable table, RequestContext context)
  19. {
  20. this._context = context;
  21. this._table = table;
  22. this._script = context.ScriptSettings;
  23. this._output = context.Zeus.Output;
  24. }
  25. public void Render()
  26. {
  27. string tableName = _table.Name;
  28. foreach (IForeignKey key in _table.ForeignKeys)
  29. {
  30. if (_script.Tables.Contains(key.ForeignTable.Name))
  31. {
  32. if (key.PrimaryTable.Name == tableName)
  33. _output.autoTabLn("public virtual ICollection<" + StringFormatter.CleanUpClassName(key.ForeignTable.Name) + "> " + StringFormatter.CleanUpClassName(key.ForeignTable.Name) + "List { get; set; }");
  34. }
  35. if (_script.Tables.Contains(key.PrimaryTable.Name))
  36. {
  37. if (key.PrimaryTable.Name != tableName)
  38. _output.autoTabLn("public virtual " + StringFormatter.CleanUpClassName(key.PrimaryTable.Name) + " " + StringFormatter.CleanUpClassName(key.PrimaryTable.Name) + " { get; set; }");
  39. }
  40. }
  41. _output.writeln("");
  42. }
  43. }
  44. }