Esempio n. 1
0
        /// <summary>
        /// Adds a <see cref="StatePropertyDefinition"/> to the <see cref="StateProperties"/> list.
        /// </summary>
        /// <param name="stateProperty">The <see cref="StatePropertyDefinition"/> to be added. Must not be <see langword="null" />.</param>
        /// <exception cref="ArgumentException">
        /// The <paramref name="stateProperty"/> already exists on the <see cref="SecurableClassDefinition"/>.
        /// </exception>
        public void AddStateProperty(StatePropertyDefinition stateProperty)
        {
            ArgumentUtility.CheckNotNull("stateProperty", stateProperty);

            if (StatePropertyReferences.Where(r => r.StateProperty == stateProperty).Any())
            {
                throw CreateArgumentException(
                          "stateProperty", "The property '{0}' has already been added to the securable class definition.", stateProperty.Name);
            }

            var reference = StatePropertyReference.NewObject();

            reference.StateProperty = stateProperty;

            StatePropertyReferences.Add(reference);

            RegisterForCommit();
        }