//public static Type[] DecodeTypes<TD>(WhatItShouldBe whatItShouldBe) where TD : class
        //{
        //    return GetTypesFromInitialType<TD>(whatItShouldBe, new SyncAsyncDefiner(whatItShouldBe));
        //}

        private static dynamic CreateService <TD>(WhatItShouldBe whatItShouldBe, params object[] ctorParams) where TD : class
        {
            var syncAsync = new SyncAsyncDefiner(whatItShouldBe);

            var dataTypes = GetTypesFromInitialType <TD>(whatItShouldBe, syncAsync);

            var genericServiceString = syncAsync.BuildTypeString(dataTypes.Length);
            var serviceGenericType   = Type.GetType(genericServiceString);

            if (serviceGenericType == null)
            {
                throw new InvalidOperationException("Failed to create the type. Is the DTO of the correct type?");
            }
            var serviceType = serviceGenericType.MakeGenericType(dataTypes);

            return(Activator.CreateInstance(serviceType, ctorParams));
        }
        /// <summary>
        /// This decodes the type and returns an array of types. If the type is based on a GenericDto
        /// then it returns the Data type and the
        /// </summary>
        /// <typeparam name="TD"></typeparam>
        /// <param name="whatItShouldBe"></param>
        /// <param name="syncAsync"></param>
        /// <returns></returns>
        private static Type[] GetTypesFromInitialType <TD>(WhatItShouldBe whatItShouldBe, SyncAsyncDefiner syncAsync)
            where TD : class
        {
            var classType = typeof(TD);

            Type[] dataTypes;
            if (classType.IsSubclassOf(typeof(EfGenericDtoBase)))
            {
                dataTypes = GetGenericTypesIfCorrectGeneric(classType, syncAsync.BaseGenericDtoType);
                if (dataTypes == null)
                {
                    throw new InvalidOperationException(string.Format("This service needs a class which inherited from {0}.",
                                                                      syncAsync.BaseGenericDtoType.Name));
                }
            }
            else if (!whatItShouldBe.HasFlag(WhatItShouldBe.DataClass))
            {
                throw new InvalidOperationException("This type of service only works with some form of EfGenericDto.");
            }
            else
            {
                //Its a data class
                dataTypes = new[] { typeof(TD) };
            }
            return(dataTypes);
        }