Exemplo n.º 1
0
        /// <summary>
        /// Load this configuratin from xml element.
        /// </summary>
        /// <param name="xmlElement"></param>
        /// <param name="logger"></param>
        public void Load(XmlElement xmlElement, TraceLogger logger)
        {
            bool found = false;
            foreach (XmlNode node in xmlElement.ChildNodes)
            {
                found = true;
                var config = GrainTypeConfiguration.Load((XmlElement)node, logger);
                if (null == config) continue;

                if (config.AreDefaults)
                {
                    defaults = config;
                }
                else
                {
                    if (classSpecific.ContainsKey(config.FullTypeName))
                    {
                        throw new InvalidOperationException(string.Format("duplicate type {0} in configuration", config.FullTypeName));
                    }
                    classSpecific.Add(config.FullTypeName, config);
                }
            }

            if (!found)
            {
                throw new InvalidOperationException("empty GrainTypeConfiguration element");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load this configuratin from xml element.
        /// </summary>
        /// <param name="xmlElement"></param>
        /// <param name="logger"></param>
        public void Load(XmlElement xmlElement, TraceLogger logger)
        {
            bool found = false;

            foreach (XmlNode node in xmlElement.ChildNodes)
            {
                found = true;
                var config = GrainTypeConfiguration.Load((XmlElement)node, logger);
                if (null == config)
                {
                    continue;
                }

                if (config.AreDefaults)
                {
                    defaults = config;
                }
                else
                {
                    if (classSpecific.ContainsKey(config.Type.FullName))
                    {
                        throw new InvalidOperationException(string.Format("duplicate type {0} in configuration", config.Type.FullName));
                    }
                    classSpecific.Add(config.Type.FullName, config);
                }
            }

            if (!found)
            {
                throw new InvalidOperationException("empty GrainTypeConfiguration element");
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="defaultCollectionAgeLimit">The default time period used to collect in-active activations.</param>
 public ApplicationConfiguration(TimeSpan?defaultCollectionAgeLimit = null)
 {
     classSpecific = new Dictionary <string, GrainTypeConfiguration>();
     defaults      = new GrainTypeConfiguration(null)
     {
         CollectionAgeLimit = defaultCollectionAgeLimit
     };
 }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the time period  to collect in-active activations for a given type.
        /// </summary>
        /// <param name="type">Grain type full name.</param>
        /// <param name="ageLimit">The age limit to use.</param>
        public void SetCollectionAgeLimit(Type type, TimeSpan ageLimit)
        {
            ThrowIfLessThanZero(ageLimit, "ageLimit");

            GrainTypeConfiguration config;

            if (!classSpecific.TryGetValue(type.FullName, out config))
            {
                config = new GrainTypeConfiguration(type);
                classSpecific[type.FullName] = config;
            }

            config.CollectionAgeLimit = ageLimit;
        }
        /// <summary>
        /// Sets the time period  to collect in-active activations for a given type.
        /// </summary>
        /// <param name="grainTypeFullName">Grain type full name string.</param>
        /// <param name="ageLimit">The age limit to use.</param>
        public void SetCollectionAgeLimit(string grainTypeFullName, TimeSpan ageLimit)
        {
            if (string.IsNullOrEmpty(grainTypeFullName))
            {
                throw new ArgumentNullException("grainTypeFullName");
            }
            ThrowIfLessThanZero(ageLimit, "ageLimit");

            GrainTypeConfiguration config;
            if (!this.classSpecific.TryGetValue(grainTypeFullName, out config))
            {
                config = new GrainTypeConfiguration(grainTypeFullName);
                this.classSpecific[grainTypeFullName] = config;
            }

            config.SetCollectionAgeLimit(ageLimit);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="defaultCollectionAgeLimit">The default time period used to collect in-active activations.</param>
 public ApplicationConfiguration(TimeSpan? defaultCollectionAgeLimit = null)
 {
     classSpecific = new Dictionary<string, GrainTypeConfiguration>();
     defaults = new GrainTypeConfiguration(null, defaultCollectionAgeLimit);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Sets the time period  to collect in-active activations for a given type.
        /// </summary>
        /// <param name="grainTypeFullName">Grain type full name string.</param>
        /// <param name="ageLimit">The age limit to use.</param>
        public void SetCollectionAgeLimit(string grainTypeFullName, TimeSpan ageLimit)
        {
            if (String.IsNullOrEmpty(grainTypeFullName))
            {
                throw new ArgumentNullException("grainTypeFullName");
            }
            ThrowIfLessThanZero(ageLimit, "ageLimit");

            GrainTypeConfiguration config;
            if (!classSpecific.TryGetValue(grainTypeFullName, out config))
            {
                config = new GrainTypeConfiguration(grainTypeFullName);
                classSpecific[grainTypeFullName] = config;
            }

            config.SetCollectionAgeLimit(ageLimit);
        }