コード例 #1
0
        /// <summary>
        /// Loads a behaviour from a ConfigNode.
        /// </summary>
        /// <param name="configNode"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public static ContractBehaviour LoadBehaviour(ConfigNode configNode, ConfiguredContract contract)
        {
            // Determine the type
            string typeName = configNode.GetValue("type");
            Type   type     = ContractConfigurator.GetAllTypes <ContractBehaviour>().Where(t => t.FullName == typeName).FirstOrDefault();

            if (type == null)
            {
                throw new Exception("No ContractBehaviour with type = '" + typeName + "'.");
            }

            // Instantiate and load
            ContractBehaviour behaviour = (ContractBehaviour)Activator.CreateInstance(type);

            behaviour.contract = contract;
            behaviour.Load(configNode);
            return(behaviour);
        }
コード例 #2
0
        /// <summary>
        /// Loads a behaviour from a ConfigNode.
        /// </summary>
        /// <param name="configNode"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public static ContractBehaviour LoadBehaviour(ConfigNode configNode, ConfiguredContract contract)
        {
            // Determine the type
            string typeName = configNode.GetValue("type");
            Type   type     = null;

            typeMap.TryGetValue(typeName, out type);
            if (type == null)
            {
                throw new Exception("No ContractBehaviour with type = '" + typeName + "'.");
            }

            // Instantiate and load
            ContractBehaviour behaviour = (ContractBehaviour)Activator.CreateInstance(type);

            behaviour.contract = contract;
            behaviour.Load(configNode);
            return(behaviour);
        }
コード例 #3
0
        /*
         * Loads a behaviour from a ConfigNode.
         */
        public static ContractBehaviour LoadBehaviour(ConfigNode configNode, ConfiguredContract contract)
        {
            // Determine the type
            string typeName = configNode.GetValue("type");
            Type   type     = Type.GetType(typeName);

            if (type == null)
            {
                LoggingUtil.LogError(typeof(ContractBehaviour), "No ContractBehaviour with type = '" + typeName + "'.");
                return(null);
            }

            // Instantiate and load
            ContractBehaviour behaviour = (ContractBehaviour)Activator.CreateInstance(type);

            behaviour.contract = contract;
            behaviour.Load(configNode);
            return(behaviour);
        }