Example #1
0
        /// <summary>
        /// Adds the behaviour, provided that such a behaviour does not already exist.
        /// </summary>
        /// <param name="behaviour">The behaviour.</param>
        /// <returns><c>true</c> if the behaviour was added; else <c>false</c>.</returns>
        public bool AddBehaviour(BehaviourData behaviour)
        {
            Assert.ArgumentNotNull("behaviour.Type", behaviour.Type);

            if (behaviours.Contains(behaviour))
            {
                return(false);
            }

            behaviours.Add(behaviour);
            IncrementVersion();

            return(true);
        }
Example #2
0
        private Behaviour CreateBehaviourInstance(IKernel kernel, BehaviourData behaviour)
        {
            Behaviour instance;

            if (behaviour.Factory != null)
            {
                instance = behaviour.Factory(behaviour.Name);
            }
            else
            {
                instance = kernel.Get(behaviour.Type, new ConstructorArgument("name", behaviour.Name)) as Behaviour;
            }

            instance.Name = behaviour.Name;
            return(instance);
        }
Example #3
0
 public bool Equals(BehaviourData data)
 {
     return(this.Name == data.Name &&
            this.Type == data.Type);
 }