protected override IPromise<object, Exception> LoadChildrenAsync() { var promise = Utility.ExecuteAsync(_web.IncludeContentTypes().LoadAsync()); promise.Done(() => { var contentTypes = _web.GetContentTypes(); Name = $"Content Types ({contentTypes.Length})"; foreach (var contentType in contentTypes.OrderBy(ct => ct.ContentType.Name)) { var ct = contentType; Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(() => { var viewModel = new SPContentTypeViewModel(ct, this); Children.Add(viewModel); })); } }); return promise; }
/// <summary> /// Initializes a new instance of the SiteItemViewModel class. /// </summary> protected SPContentTypeFieldCollectionViewModel(SPContentTypeViewModel parent, bool lazyLoadChildren) : base(parent, lazyLoadChildren) { }
public SPContentTypeFieldCollectionViewModel(SPClientContentType contentType, SPContentTypeViewModel parent) : this(parent, true) { if (contentType == null) throw new ArgumentNullException(nameof(contentType)); _contentType = contentType; }