PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/SolutionFramework/Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.10.0/Microsoft/VisualStudio/ServiceModel/DomainServices/Tools/BusinessLogicEntity.cs

#
C# | 131 lines | 118 code | 13 blank | 0 comment | 7 complexity | e56ebc9e6d87827d2ae7664aa97c0a21 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
  1. namespace Microsoft.VisualStudio.ServiceModel.DomainServices.Tools
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.Linq;
  7. internal class BusinessLogicEntity
  8. {
  9. private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext _businessLogicContext;
  10. private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData _entityData;
  11. private string _name;
  12. private Type _type;
  13. public BusinessLogicEntity(Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext businessLogicContext, string name, Type type)
  14. {
  15. this._businessLogicContext = businessLogicContext;
  16. this._name = name;
  17. this._type = type;
  18. }
  19. private IEnumerable<Attribute> GetTypeCustomAttributes()
  20. {
  21. List<Attribute> list = this.ClrType.GetCustomAttributes(true).OfType<Attribute>().ToList<Attribute>();
  22. Type associatedMetadataType = TypeUtilities.GetAssociatedMetadataType(this.ClrType);
  23. if (associatedMetadataType != null)
  24. {
  25. list.AddRange(associatedMetadataType.GetCustomAttributes(true).OfType<Attribute>());
  26. }
  27. return list;
  28. }
  29. public string AssemblyName
  30. {
  31. get
  32. {
  33. return this.ClrType.Assembly.GetName().Name;
  34. }
  35. }
  36. public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext BusinessLogicContext
  37. {
  38. get
  39. {
  40. return this._businessLogicContext;
  41. }
  42. }
  43. public virtual bool CanBeEdited
  44. {
  45. get
  46. {
  47. EditableAttribute attribute = this.GetTypeCustomAttributes().OfType<EditableAttribute>().FirstOrDefault<EditableAttribute>();
  48. return (((attribute == null) || attribute.AllowEdit) && this.CanBeIncluded);
  49. }
  50. }
  51. public virtual bool CanBeIncluded
  52. {
  53. get
  54. {
  55. return CodeGenUtilities.IsValidGenericTypeParam(this.ClrType);
  56. }
  57. }
  58. public Type ClrType
  59. {
  60. get
  61. {
  62. return this._type;
  63. }
  64. }
  65. public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData EntityData
  66. {
  67. get
  68. {
  69. if (this._entityData == null)
  70. {
  71. Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData data = new Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData {
  72. Name = this._name,
  73. IsIncluded = false,
  74. IsEditable = false,
  75. CanBeIncluded = this.CanBeIncluded,
  76. CanBeEdited = this.CanBeEdited,
  77. AssemblyName = this.AssemblyName
  78. };
  79. this._entityData = data;
  80. }
  81. return this._entityData;
  82. }
  83. set
  84. {
  85. this._entityData = value;
  86. }
  87. }
  88. public bool IsEditable
  89. {
  90. get
  91. {
  92. return this.EntityData.IsEditable;
  93. }
  94. set
  95. {
  96. this.EntityData.IsEditable = value;
  97. }
  98. }
  99. public bool IsIncluded
  100. {
  101. get
  102. {
  103. return this.EntityData.IsIncluded;
  104. }
  105. set
  106. {
  107. this.EntityData.IsIncluded = value;
  108. }
  109. }
  110. public string Name
  111. {
  112. get
  113. {
  114. return this._name;
  115. }
  116. }
  117. }
  118. }