/// <summary>
        /// Registers an individual type name with the underlying codegen infrastructure.
        /// </summary>
        /// <param name="type">The type to register.</param>
        /// <param name="containingNamespace">The containing namespace.</param>
        private void RegisterTypeName(Type type, string containingNamespace)
        {
            if (string.IsNullOrEmpty(type.Namespace))
            {
                this.LogError(string.Format(CultureInfo.CurrentCulture, Resource.ClientCodeGen_Namespace_Required, type));
                return;
            }

            // Check if we're in conflict
            if (!CodeGenUtilities.RegisterTypeName(type, containingNamespace))
            {
                // Aggressively check for potential conflicts across other entity types.
                IEnumerable <Type> potentialConflicts =
                    // Entity types with namespace matches
                    EntityDescriptions
                    .SelectMany(d => d.EntityTypes)
                    .Where(entity => entity.Namespace == type.Namespace).Distinct();

                foreach (var potentialConflict in potentialConflicts)
                {
                    // Register potential conflicts so we qualify type names correctly
                    // later during codegen.
                    CodeGenUtilities.RegisterTypeName(potentialConflict, containingNamespace);
                }
            }
        }
Ejemplo n.º 2
0
 public virtual GeneratorSetup RegisterEntities(IEnumerable <IEntityDescription> entityDescriptions)
 {
     foreach (IEntityDescription item in entityDescriptions)
     {
         EntityDescriptions.Add(item.Type, item);
     }
     return(this);
 }
Ejemplo n.º 3
0
        //Register entitities
        public virtual EntityDescription <TEntity> RegisterEntity <TEntity>()
            where TEntity : class
        {
            var entityDescription = new EntityDescription <TEntity>();

            EntityDescriptions.Add(entityDescription.Type, entityDescription);
            return(entityDescription);
        }
Ejemplo n.º 4
0
        public virtual IEntityDescription GetEntityDescription(Type entityType)
        {
            bool isEntityRegistered = EntityDescriptions.ContainsKey(entityType);

            if (!isEntityRegistered || EntityDescriptions[entityType] == null)
            {
                throw new KeyNotFoundException($"Entity type [{entityType.FullName}] is not registered. Use {nameof(RegisterEntity)} method first.");
            }

            IEntityDescription entityDescription = EntityDescriptions[entityType];

            return(entityDescription);
        }
Ejemplo n.º 5
0
 public virtual GeneratorSetup RegisterEntity(IEntityDescription entityDescription)
 {
     EntityDescriptions.Add(entityDescription.Type, entityDescription);
     return(this);
 }