public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var definition = model.WithAssertAndCast <EventReceiverDefinition>("model", value => value.RequireNotNull());

            Microsoft.SharePoint.Client.EventReceiverDefinition spObject = null;

            if (modelHost is ListModelHost)
            {
                spObject = FindEventReceiverDefinition((modelHost as ListModelHost).HostList.EventReceivers, definition);
            }
            else if (modelHost is WebModelHost)
            {
                spObject = FindEventReceiverDefinition((modelHost as WebModelHost).HostWeb.EventReceivers, definition);
            }
            else if (modelHost is SiteModelHost)
            {
                spObject = FindEventReceiverDefinition((modelHost as SiteModelHost).HostSite.EventReceivers, definition);
            }
            else
            {
                throw new SPMeta2UnsupportedModelHostException("model host should be ListModelHost or WebModelHost");
            }

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Name, o => o.ReceiverName)
                         .ShouldBeEqual(m => m.Class, o => o.ReceiverClass)
                         .ShouldBeEqual(m => m.Assembly, o => o.ReceiverAssembly)
                         .SkipProperty(m => m.Data, "Data property is not supported by CSOM. SKipping.")
                         .ShouldBeEqual(m => m.SequenceNumber, o => o.SequenceNumber)
                         .ShouldBeEqual(m => m.Synchronization, o => o.GetSynchronization())
                         .ShouldBeEqual(m => m.Type, o => o.GetEventReceiverType());
        }
예제 #2
0
 private static void MapEventReceiverProperties(EventReceiverDefinition definition,
                                                Microsoft.SharePoint.Client.EventReceiverDefinition existingReceiver,
                                                bool isNew)
 {
     // nothing can be updated, shame :(
 }
 public static string GetEventReceiverType(this Microsoft.SharePoint.Client.EventReceiverDefinition def)
 {
     return(def.EventType.ToString());
 }
 public static string GetSynchronization(this Microsoft.SharePoint.Client.EventReceiverDefinition def)
 {
     return(def.Synchronization.ToString());
 }