src/Misc/EFTools/XmlCore/Core/Context/EditingContext.cs
/// <summary>
///     Retrieves the requested service.  This method returns null if the service could not be located.
/// </summary>
/// <param name="serviceType"></param>
/// <returns></returns>
Retrieves the requested service.  This method returns null if the service could not be located.
Retrieves the requested service . This method returns null if the service could not be located .
public override object GetService(Type serviceType)
            {
                object service = null;
                if (serviceType == null)
                {
                    throw new ArgumentNullException("serviceType");
                }
                if (_services != null
                    && _services.TryGetValue(serviceType, out service))
                {
                    if (service == _recursionSentinel)
                    {
                        throw new InvalidOperationException("Recursion Error" + serviceType.FullName);
                    }
                    var callback = service as PublishServiceCallback;
                    if (callback != null)
                    {
                        _services[serviceType] = _recursionSentinel;
                        try
                        {
                            service = callback(serviceType);
                            if (service == null)
                            {
                                throw new InvalidOperationException(
                                    "Null Service: " +
                                    callback.Method.DeclaringType.FullName + " " +
                                    serviceType.FullName);
                            }
                            if (!serviceType.IsInstanceOfType(service))
                            {
                                throw new InvalidOperationException(
                                    "Incorrect Service Type: " +
                                    callback.Method.DeclaringType.FullName + " " +
                                    serviceType.FullName + " " +
                                    service.GetType().FullName);
                            }
                        }
                        finally
                        {
                            _services[serviceType] = service;
                        }
                    }
                }
                return service;
            }
public override object GetService ( Type serviceType ) { object service = null ; if ( serviceType == null ) { throw new ArgumentNullException ( " " ) ; } if ( _services != null && _services . TryGetValue ( serviceType , out service ) ) { if ( service == _recursionSentinel ) { throw new InvalidOperationException ( " " + serviceType . FullName ) ; } var callback = service as PublishServiceCallback ; if ( callback != null ) { _services [ serviceType ] = _recursionSentinel ; try { service = callback ( serviceType ) ; if ( service == null ) { throw new InvalidOperationException ( " " + callback . Method . DeclaringType . FullName + " " + serviceType . FullName ) ; } if ( ! serviceType . IsInstanceOfType ( service ) ) { throw new InvalidOperationException ( " " + callback . Method . DeclaringType . FullName + " " + serviceType . FullName + " " + service . GetType ( ) . FullName ) ; } } finally { _services [ serviceType ] = service ; } } } return service ; }
Retrieves the requested service.
Retrieves the requested service .
// If this service is our recursion sentinel, it means that someone is recursing // while resolving a service callback.  Throw to break out of the recursion // cycle. // throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.Error_RecursionResolvingService, serviceType.FullName)); // See if this service is a callback.  If it is, invoke it and store // the resulting service back in the dictionary. // Store a recursion sentinel in the dictionary so we can easily // tell if someone is recursing /*                                    
                                throw new InvalidOperationException(
                                    string.Format(CultureInfo.CurrentCulture, 
                                    Resources.Error_NullService,
                                    callback.Method.DeclaringType.FullName,
                                    serviceType.FullName));
                                */ /*
                                throw new InvalidOperationException(
                                    string.Format(CultureInfo.CurrentCulture, 
                                    Resources.Error_IncorrectServiceType,
                                    callback.Method.DeclaringType.FullName,
                                    serviceType.FullName,
                                    service.GetType().FullName));
                                */ // Note, this puts the callback back in place if it threw. // If the service is not found locally, do not walk up the parent chain.   // This was a major source of unreliability with the component model // design.  For a service to be accessible from the editing context, it // must be added.
None
serviceType
Type
None