protected override void ExecuteCmdlet() { ContentType ct = null; List list = SelectedWeb.GetList(List); if (ContentType.ContentType == null) { if (ContentType.Id != null) { ct = SelectedWeb.GetContentTypeById(ContentType.Id); } else if (ContentType.Name != null) { ct = SelectedWeb.GetContentTypeByName(ContentType.Name); } } else { ct = ContentType.ContentType; } if (ct != null) { SelectedWeb.AddContentTypeToList(list.Title, ct, DefaultContentType); } }
protected override void ExecuteCmdlet() { ContentType ct = null; List list = List.GetList(SelectedWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } if (ContentType.ContentType == null) { if (ContentType.Id != null) { ct = SelectedWeb.GetContentTypeById(ContentType.Id, true); } else if (ContentType.Name != null) { ct = SelectedWeb.GetContentTypeByName(ContentType.Name, true); } } else { ct = ContentType.ContentType; } if (ct != null) { SelectedWeb.AddContentTypeToList(list.Title, ct, DefaultContentType); } }