src/Misc/EFTools/XmlCore/Core/Context/EditingContext.cs
/// <summary>
///     If you already have an instance to a service, you can publish it here.
/// </summary>
/// <param name="serviceType"></param>
/// <param name="serviceInstance"></param>
If you already have an instance to a service, you can publish it here.
If you already have an instance to a service you can publish it here .
public override void Publish(Type serviceType, object serviceInstance)
            {
                if (serviceType == null)
                {
                    throw new ArgumentNullException("serviceType");
                }
                if (serviceInstance == null)
                {
                    throw new ArgumentNullException("serviceInstance");
                }
                if (!(serviceInstance is PublishServiceCallback)
                    && !serviceType.IsInstanceOfType(serviceInstance))
                {
                    throw new ArgumentException(
                        "Incorrect Service Type" +
                        typeof(ServiceCollection).Name + " " +
                        serviceType.FullName + " " +
                        serviceInstance.GetType().FullName);
                }
                if (_services == null)
                {
                    _services = new Dictionary<Type, object>();
                }
                try
                {
                    _services.Add(serviceType, serviceInstance);
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException("Duplicate Service: " + serviceType.FullName, e);
                }
                SubscribeServiceCallback subscribeCallback;
                if (_subscriptions != null
                    && _subscriptions.TryGetValue(serviceType, out subscribeCallback))
                {
                    subscribeCallback(serviceType, GetService(serviceType));
                    _subscriptions.Remove(serviceType);
                }
            }
public override void Publish ( Type serviceType , object serviceInstance ) { if ( serviceType == null ) { throw new ArgumentNullException ( " " ) ; } if ( serviceInstance == null ) { throw new ArgumentNullException ( " " ) ; } if ( ! ( serviceInstance is PublishServiceCallback ) && ! serviceType . IsInstanceOfType ( serviceInstance ) ) { throw new ArgumentException ( " " + typeof ( ServiceCollection ) . Name + " " + serviceType . FullName + " " + serviceInstance . GetType ( ) . FullName ) ; } if ( _services == null ) { _services = new Dictionary < Type , object > ( ) ; } try { _services . Add ( serviceType , serviceInstance ) ; } catch ( ArgumentException e ) { throw new ArgumentException ( " " + serviceType . FullName , e ) ; } SubscribeServiceCallback subscribeCallback ; if ( _subscriptions != null && _subscriptions . TryGetValue ( serviceType , out subscribeCallback ) ) { subscribeCallback ( serviceType , GetService ( serviceType ) ) ; _subscriptions . Remove ( serviceType ) ; } }
If you already have an instance to a service, you can publish it here.
If you already have an instance to a service you can publish it here .
/*
                    throw new ArgumentException(
                        string.Format(CultureInfo.CurrentCulture,
                        Resources.Error_IncorrectServiceType,
                        typeof(ServiceCollection).Name,
                        serviceType.FullName,
                        serviceInstance.GetType().FullName));
                    */ //throw new ArgumentException(string.Format( //CultureInfo.CurrentCulture,  //Resources.Error_DuplicateService, serviceType.FullName), e); // Now see if there were any subscriptions that required this service
serviceType
Type
None
serviceInstance
object
None