/// <summary> /// Retrieves the set of <see cref="EntityData"/> data objects for all the entities /// belonging to the specified context. /// </summary> /// <remarks> /// The primary purpose of this method is lazy loading. The view model will ask for /// these only when it needs them. It allows us to defer examining metadata until /// we absolutely need it, which could be a large performance win when multiple /// contexts are available. /// </remarks> /// <param name="contextData">The <see cref="ContextData"/> to use to locate /// the respective <see cref="BusinessLogicContext"/>.</param> /// <returns>The set of <see cref="EntityData"/> objects for the given context.</returns> public IEntityData[] GetEntityDataItemsForContext(IContextData contextData) { IBusinessLogicContext context = this._contexts[contextData.ID]; List <IBusinessLogicEntity> entities = (context == null) ? new List <IBusinessLogicEntity>() : context.Entities.ToList(); return(entities.Select <IBusinessLogicEntity, IEntityData>(ble => ble.EntityData).ToArray()); }
public bool IsMetadataGenerationRequired(IContextData contextData) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return((context) != null ? context.NeedToGenerateMetadataClasses : false); }
/// <summary> /// Generates the source code for the metadata class for the given context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <param name="optionalSuffix">If nonblank, the suffix to append to namespace and class names for testing</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateMetadataClasses(IContextData contextData, string rootNamespace, string optionalSuffix) { IBusinessLogicContext context = this._contexts.Single(c => c.ContextData.ID == contextData.ID); return((context) != null ? context.GenerateMetadataClasses(this.Language, rootNamespace, optionalSuffix) : new GeneratedCode(string.Empty, new string[0])); }
/// <summary> /// Generates source code for the specified context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="className">The name of the class.</param> /// <param name="namespaceName">The namespace to use for the class.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateBusinessLogicClass(IContextData contextData, string className, string namespaceName, string rootNamespace) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return(context != null ? context.GenerateBusinessLogicClass(this.Language, className, namespaceName, rootNamespace) : new GeneratedCode()); }
/// <summary> /// Initializes a new instance of the <see cref="BusinessLogicEntity"/> class. /// </summary> /// <param name="businessLogicContext">The context that owns this entity. It cannot be null.</param> /// <param name="name">The name of the entity as it will appear in the UI</param> /// <param name="type">The CLR type of the entity as it will be used in code gen</param> public BusinessLogicEntity(IBusinessLogicContext businessLogicContext, string name, Type type) { this._businessLogicContext = businessLogicContext; this._name = name; this._type = type; }
/// <summary> /// Initializes a new instance of the <see cref="BusinessLogicEntity"/> class. /// </summary> /// <param name="businessLogicContext">The context that owns this entity. It cannot be null.</param> /// <param name="name">The name of the entity as it will appear in the UI</param> /// <param name="type">The CLR type of the entity as it will be used in code gen</param> public BusinessLogicEntity(IBusinessLogicContext businessLogicContext, string name, Type type) { this._businessLogicContext = businessLogicContext; this._name = name; this._type = type; }