Пример #1
0
            public SPContentType CreateAsPartOfGroup(string groupName)
            {
                if (Web.ContentTypes[Name] != null)
                {
                    return(Web.ContentTypes[Name]);
                }

                var contentType = new SPContentType(Web.AvailableContentTypes[ParentContentType], Web.ContentTypes, Name)
                {
                    Group = groupName
                };

                foreach (var fieldInfo in FieldDefinitions.Select(fieldDef => new { fieldDef.IsHidden, Field = fieldDef.CreateIn(Web.Fields, groupName) }))
                {
                    contentType.FieldLinks.Add(new SPFieldLink(fieldInfo.Field)
                    {
                        Hidden = fieldInfo.IsHidden
                    });
                }

                if (!string.IsNullOrEmpty(NewFormUrl))
                {
                    contentType.NewFormUrl = NewFormUrl;
                }

                Web.ContentTypes.Add(contentType);
                Web.Update();

                contentType.Update();
                return(contentType);
            }
Пример #2
0
 private void BindItemsSource()
 {
     ItemsSource = FieldDefinitions
                   .Select(f => Model.GetValueOrDefault(f.Identifier, (object)null))
                   .Where(v => v != null);
 }