Пример #1
0
        protected Web GetCurrentObject(object modelHost, RootWebDefinition definition)
        {
            if (modelHost is SiteModelHost)
            {
                var siteModelHost = modelHost as SiteModelHost;

                var site = siteModelHost.HostSite;
                var context = site.Context;

                context.Load(site, s => s.RootWeb);
                context.ExecuteQuery();

                return site.RootWeb;
            }
            else if (modelHost is WebModelHost)
            {
                var webModelHost = modelHost as WebModelHost;

                var site = webModelHost.HostSite;
                var context = site.Context;

                context.Load(site, s => s.RootWeb);
                context.ExecuteQuery();

                return site.RootWeb;
            }

            throw new SPMeta2UnsupportedModelHostException("ModelHost should be SiteModelHost/WebModelHost");
        }
Пример #2
0
        protected SPWeb GetCurrentObject(object modelHost, RootWebDefinition definition)
        {
            if (modelHost is SiteModelHost)
                return (modelHost as SiteModelHost).HostSite.RootWeb;
            else if (modelHost is WebModelHost)
                return (modelHost as WebModelHost).HostWeb.Site.RootWeb;

            throw new SPMeta2UnsupportedModelHostException("ModelHost should be SiteModelHost/WebModelHost");
        }