private SPModelMonitor(SPSite site) { this.siteId = site.ID; this.descriptor = SPModelDescriptor.Resolve(typeof(T)); foreach (SPModelUsage usage in descriptor.GetUsages(site.RootWeb)) { monitoredLists.Add(usage.ListId); } Initialize(site.ID, new SPChangeMonitorFilter(SPChangeObjectType.List, SPChangeFlags.ListContentTypeAdd | SPChangeFlags.ListContentTypeDelete), new SPChangeMonitorFilter(SPChangeObjectType.Item, SPChangeFlags.Add | SPChangeFlags.Update | SPChangeFlags.Delete | SPChangeFlags.SystemUpdate)); }
/// <summary> /// Gets all lists under the specified site and all its descendant sites which contains the content type associated with the model type. /// </summary> /// <param name="type">Model type.</param> /// <param name="contextWeb">A site object.</param> /// <exception cref="ArgumentException">The type <paramref name="type"/> does not associate with any content type.</exception> /// <returns>An enumerable of list objects.</returns> public static IEnumerable <SPList> EnumerateLists(Type type, SPWeb contextWeb) { SPModelDescriptor descriptor = SPModelDescriptor.Resolve(type); return(descriptor.GetUsages(contextWeb).GetListCollection()); }