Пример #1
0
        /// <summary>
        /// Displays a list of content types from Kentico Kontent and allows the user to select one
        /// </summary>
        /// <param name="types"></param>
        /// <returns></returns>
        public static ContentType VerifyContentType(DeliveryTypeListingResponse types)
        {
            Console.WriteLine();
            Program.WriteColoredText("Which content type would you like to create? [Enter a number]", ConsoleColor.Green);

            for (int i = 0; i < types.Types.Count; i++)
            {
                Console.WriteLine($"{i+1}. {types.Types[i].System.Name}");
            }

            int index = 0;
            var num   = Console.ReadLine();

            if (int.TryParse(num, out index) && index >= 1 && index <= types.Types.Count)
            {
                index--; // Subtract one since index is zero-based

                // Validate that the type has supported elements
                var elements = KontentHelper.FilterElements(types.Types[index].Elements);
                if (elements.Count == 0)
                {
                    Program.WriteColoredText("Chosen content type has no Text or Rich Text elements, please choose another.", ConsoleColor.Green);
                    Console.ReadKey();
                    return(VerifyContentType(types));
                }

                return(types.Types[index]);
            }
            else
            {
                Program.ShowError("Unrecognized or out-of-bounds number. Please press any key to try again.");
                Console.ReadKey();
                return(VerifyContentType(types));
            }
        }
Пример #2
0
        protected async Task <List <ContentType> > getCloudContentTypes()
        {
            string KenticoCloudProjectID = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".KenticoCloudProjectId");

            DeliveryClient client = new DeliveryClient(KenticoCloudProjectID);

            DeliveryTypeListingResponse response = await client.GetTypesAsync();

            var types = response.Types;

            return(types.ToList());
        }
Пример #3
0
 /// <summary>
 /// Extracts identifier sets from a content type listing response.
 /// </summary>
 /// <param name="response">The <see cref="DeliveryTypeListingResponse"/> response.</param>
 /// <returns>Identifiers of all formats of all the content types and their elements.</returns>
 public IEnumerable <CacheTokenPair> GetTypeListingDependencies(DeliveryTypeListingResponse response)
 {
     return(response?.Types?.SelectMany(t => GetTypeSingleDependencies(t)).Distinct());
 }
 /// <summary>
 /// Extracts identifier sets from a content type listing response.
 /// </summary>
 /// <param name="response">The <see cref="DeliveryTypeListingResponse"/> response.</param>
 /// <returns>Identifiers of all formats of all the content types and their elements.</returns>
 public IEnumerable <IdentifierSet> GetTypeListingDependencies(DeliveryTypeListingResponse response)
 {
     return(response?.Types?.SelectMany(t => GetTypeSingleDependencies(t)).Distinct());
 }
Пример #5
0
 /// <summary>
 /// Gets Types dependency keys from response
 /// </summary>
 /// <param name="response">Response</param>
 /// <returns>Dependency keys</returns>
 public static IEnumerable <string> GetTypesDependencies(DeliveryTypeListingResponse response)
 {
     return(response?.Types != null
         ? new[] { GetTypesDependencyKey() }
         : Enumerable.Empty <string>());
 }