internal static GrainServiceConfigurations Load(XmlElement child)
        {
            var container = new GrainServiceConfigurations();

            var nsManager = new XmlNamespaceManager(new NameTable());

            nsManager.AddNamespace("orleans", "urn:orleans");

            GrainServiceConfiguration.LoadProviderConfigurations(
                child, nsManager, container.GrainServices,
                c => container.GrainServices.Add(c.Name, c));

            return(container);
        }
        internal static void RegisterGrainService(GrainServiceConfigurations grainServicesConfig, string serviceName, string clientType, string serviceType, IDictionary <string, string> properties = null)
        {
            if (grainServicesConfig.GrainServices.ContainsKey(serviceName))
            {
                throw new InvalidOperationException(
                          string.Format("Grain service of with name '{0}' has been already registered", serviceName));
            }

            var config = new GrainServiceConfiguration(
                properties ?? new Dictionary <string, string>(),
                serviceName, clientType, serviceType);

            grainServicesConfig.GrainServices.Add(config.Name, config);
        }
        internal static void LoadProviderConfigurations(XmlElement root, XmlNamespaceManager nsManager,
                                                        IDictionary <string, IGrainServiceConfiguration> alreadyLoaded, Action <IGrainServiceConfiguration> add)
        {
            var nodes = root.SelectNodes("orleans:GrainService", nsManager);

            foreach (var node in nodes)
            {
                var subElement = node as XmlElement;
                if (subElement == null)
                {
                    continue;
                }

                var config = new GrainServiceConfiguration();
                config.Load(subElement, alreadyLoaded, nsManager);
                add(config);
            }
        }