Пример #1
0
        /// <summary>
        /// Removes a mock service info from our collections.
        /// </summary>
        /// <param name="serviceInfo">Mock service info to remove</param>
        internal void RemoveService(ServiceInfo serviceInfo)
        {
            // If we delete a service : Unbind linked plugins and services.

            // Unbind generalized services
            foreach (ServiceInfo s in ServiceInfos.Where(si => si.Generalization == serviceInfo).ToList())
            {
                s.Generalization = null;
            }

            // Unbind implementations
            foreach (PluginInfo p in PluginInfos.Where(pi => pi.Service == serviceInfo).ToList())
            {
                p.Service = null;
            }

            // Delete all existing service references

            foreach (PluginInfo p in PluginInfos)
            {
                foreach (MockServiceReferenceInfo reference in p.InternalServiceReferences.Where(r => r.Reference == serviceInfo).ToList())
                {
                    p.InternalServiceReferences.Remove(reference);
                }
            }

            _labServiceInfos.Remove(serviceInfo);
            _serviceInfos.Remove(serviceInfo);
        }
Пример #2
0
 /// <summary>
 /// Get all Service Infos of type
 /// </summary>
 /// <param name="type">Service Info Type to retrieve</param>
 /// <returns>List of matching Service Infos</returns>
 public List <IServiceInfo> GetServiceInfos(Type type)
 {
     return(ServiceInfos.Where((info) => info.GetType() == type).ToList());
 }