コード例 #1
0
        /// <summary>
        /// Loads a set of laws obtained from the given JusticeDepartment.
        /// </summary>
        /// <param name="justiceDepartment">The JusticeDepartment containing
        /// the laws to embark in Dredd's AI.</param>
        public virtual void Load(JusticeDepartment justiceDepartment)
        {
            if (justiceDepartment == null)
            {
                throw new ArgumentNullException("justiceDepartment");
            }

            this.Load(justiceDepartment.GetLaws());
        }
コード例 #2
0
        /// <summary>
        /// Seeks all JusticeDeparment from the library and loads the Laws
        /// they contains in Dredd's AI.
        /// </summary>
        /// <param name="library">The library to search for JusticeDepartment
        /// </param>
        public virtual void Load(Assembly library)
        {
            if (library == null)
            {
                throw new ArgumentNullException("library");
            }

            Type justiceDeptType = typeof(JusticeDepartment);

            foreach (var type in library.ExportedTypes)
            {
                if (justiceDeptType.IsAssignableFrom(type))
                {
                    JusticeDepartment dept = (JusticeDepartment)Activator.CreateInstance(type);
                    this.Load(dept.GetLaws());
                }
            }
        }