Beispiel #1
0
        /// <summary>
        /// Static invoke method implementation
        /// </summary>
        internal static void Invoke(SPServiceContext serviceContext, CodeToRunOnApplicationProxy codeBlock)
        {
            if (null == serviceContext)
            {
                throw new ArgumentNullException("serviceContext");
            }
            ServiceApplicationProxy proxy = (ServiceApplicationProxy)serviceContext.GetDefaultProxy(typeof(ServiceApplicationProxy));

            if (null == proxy)
            {
                throw new InvalidOperationException("SharePoint Identity Proxy not found.");
            }
            using (new SPServiceContextScope(serviceContext))
            {
                codeBlock(proxy);
            }
        }
        internal static void Invoke(SPServiceContext serviceContext, CodeToRunOnApplicationProxy codeBlock)
        {
            if (serviceContext == null)
            {
                throw new ArgumentNullException("serviceContext");
            }

            // get service app proxy from the context
            DayNamerServiceApplicationProxy proxy = (DayNamerServiceApplicationProxy)serviceContext.GetDefaultProxy(typeof(DayNamerServiceApplicationProxy));

            if (proxy == null)
            {
                throw new InvalidOperationException("Unable to obtain object reference to the day namer service application proxy.");
            }

            // run the code block on the proxy
            using (new SPServiceContextScope(serviceContext))
            {
                codeBlock(proxy);
            }
        }