Acceleratio.SPDG.Generator.Server.GenerationTasks.CreateContentTypesGenerationTask.createContentTypesOnRootWeb C# (CSharp) Метод

createContentTypesOnRootWeb() приватный Метод

private createContentTypesOnRootWeb ( SPWeb web ) : List
web SPWeb
Результат List
        private List<SPContentType> createContentTypesOnRootWeb(SPWeb web)
        {
            List<SPContentType> newContentTypes = new List<SPContentType>();
            generateCustomContentTypeGroupNames();
            for (int c = 0; c < WorkingDefinition.MaxNumberOfContentTypesPerSiteCollection; c++)
            {
                try
                {
                    string contentTypeName = findAvailableContentTypeName(web);
                    Owner.IncrementCurrentTaskProgress("Creating Content Type '" + contentTypeName + "'");
                    SPContentType contentType = new SPContentType(web.ContentTypes["Document"], web.ContentTypes,
                        contentTypeName + " Document");
                    web.ContentTypes.Add(contentType);
                    contentType.Group = getCustomContentTypeName();
                    contentType.Description = contentTypeName + " content type";
                    List<string> randomSiteColumns = GetRandomSiteColumns();
                    foreach (string siteColumn in randomSiteColumns)
                    {
                        contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(siteColumn)));
                    }

                    contentType.Update();
                    newContentTypes.Add(contentType);

                    if (WorkingDefinition.ContentTypesCanInheritFromOtherContentType)
                    {
                        c++;
                        if (c < WorkingDefinition.MaxNumberOfContentTypesPerSiteCollection)
                        {
                            contentTypeName = findAvailableContentTypeName(web);
                            Owner.IncrementCurrentTaskProgress("Creating Content Type '" + contentTypeName + "'");
                            SPContentType childContentType = new SPContentType(contentType, web.ContentTypes,
                                contentTypeName + " Document");
                            web.ContentTypes.Add(childContentType);
                            childContentType.Group = getCustomContentTypeName();
                            childContentType.Description = contentTypeName + " content type";
                            randomSiteColumns = GetRandomSiteColumns();
                            foreach (string siteColumn in randomSiteColumns)
                            {
                                contentType.FieldLinks.Add(new SPFieldLink(web.Fields.GetField(siteColumn)));
                            }
                            childContentType.Update();
                            newContentTypes.Add(childContentType);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Errors.Log(ex);
                }
            }

            return newContentTypes;
        }