/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
- namespace Microsoft.VisualStudio.ServiceModel.DomainServices.Tools
- {
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
-
- internal class BusinessLogicEntity
- {
- private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext _businessLogicContext;
- private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData _entityData;
- private string _name;
- private Type _type;
-
- public BusinessLogicEntity(Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext businessLogicContext, string name, Type type)
- {
- this._businessLogicContext = businessLogicContext;
- this._name = name;
- this._type = type;
- }
-
- private IEnumerable<Attribute> GetTypeCustomAttributes()
- {
- List<Attribute> list = this.ClrType.GetCustomAttributes(true).OfType<Attribute>().ToList<Attribute>();
- Type associatedMetadataType = TypeUtilities.GetAssociatedMetadataType(this.ClrType);
- if (associatedMetadataType != null)
- {
- list.AddRange(associatedMetadataType.GetCustomAttributes(true).OfType<Attribute>());
- }
- return list;
- }
-
- public string AssemblyName
- {
- get
- {
- return this.ClrType.Assembly.GetName().Name;
- }
- }
-
- public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.BusinessLogicContext BusinessLogicContext
- {
- get
- {
- return this._businessLogicContext;
- }
- }
-
- public virtual bool CanBeEdited
- {
- get
- {
- EditableAttribute attribute = this.GetTypeCustomAttributes().OfType<EditableAttribute>().FirstOrDefault<EditableAttribute>();
- return (((attribute == null) || attribute.AllowEdit) && this.CanBeIncluded);
- }
- }
-
- public virtual bool CanBeIncluded
- {
- get
- {
- return CodeGenUtilities.IsValidGenericTypeParam(this.ClrType);
- }
- }
-
- public Type ClrType
- {
- get
- {
- return this._type;
- }
- }
-
- public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData EntityData
- {
- get
- {
- if (this._entityData == null)
- {
- Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData data = new Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData {
- Name = this._name,
- IsIncluded = false,
- IsEditable = false,
- CanBeIncluded = this.CanBeIncluded,
- CanBeEdited = this.CanBeEdited,
- AssemblyName = this.AssemblyName
- };
- this._entityData = data;
- }
- return this._entityData;
- }
- set
- {
- this._entityData = value;
- }
- }
-
- public bool IsEditable
- {
- get
- {
- return this.EntityData.IsEditable;
- }
- set
- {
- this.EntityData.IsEditable = value;
- }
- }
-
- public bool IsIncluded
- {
- get
- {
- return this.EntityData.IsIncluded;
- }
- set
- {
- this.EntityData.IsIncluded = value;
- }
- }
-
- public string Name
- {
- get
- {
- return this._name;
- }
- }
- }
- }
-