Пример #1
0
        protected static Entity create(EntityClass parent, entitySpec entitySpec, Type type, Action <string> log, bool throwOnCircularReference)
        {
            log?.Invoke($"create: {type.Name} - {entitySpec.name}");

            if (!string.IsNullOrEmpty(entitySpec.aggregation))
            {
                return(new EntityAggregation(entitySpec, log));
            }
            if (!string.IsNullOrEmpty(entitySpec.formula))
            {
                return(new EntityFormula(entitySpec, log));
            }

            var fieldInfo = new LinkedFieldInfo(type, entitySpec.name);

            if (fieldInfo.IEnumerable != null)
            {
                return(new EntityClass(parent, entitySpec, fieldInfo.IEnumerable.GetGenericArguments()[0], fieldInfo, log, throwOnCircularReference));
            }
            if (!entitySpec.AnyNotStar())
            {
                return(new EntityPlainField(entitySpec, fieldInfo, log));
            }

            throw new Exception("Unknown error");
        }