Example #1
0
        /// <summary>
        /// Добавление нового св-ва.
        /// </summary>
        /// <param name="prop"></param>
        public void AddNewProperty(MessageProperty prop)
        {
            #region Validate parameters
            if (prop == null)
            {
                throw new ArgumentNullException("prop");
            }

            if (String.IsNullOrEmpty(prop.Name))
            {
                throw new ArgumentException("Отсутствует имя свойства.", "prop");
            }

            if (prop.LINK != 0)
            {
                throw new ArgumentException("Свойство не должно иметь LINK.", "prop");
            }
            #endregion

            lock (this.properties)
            {
                if (this.properties.Any(p => p.Name == prop.Name))
                {
                    throw new InvalidOperationException(String.Format("Сообщение уже содержит свойство {0}.", prop.Name));
                }

                prop.MessageLINK = this.LINK;
                this.properties.Add(prop);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="propName"></param>
        /// <exception cref="MessagePropertyNotFoundException"></exception>
        /// <returns></returns>
        public MessageProperty GetProperty(string propName)
        {
            MessageProperty prop = FindProperty(propName);

            if (prop == null)
            {
                throw new MessagePropertyNotFoundException(propName, this.LINK);
            }

            return(prop);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="propLink"></param>
        /// <exception cref="MessagePropertyNotFoundException"></exception>
        /// <returns></returns>
        public MessageProperty GetProperty(int propLink)
        {
            MessageProperty prop = FindProperty(propLink);

            if (prop == null)
            {
                throw new MessagePropertyNotFoundException(propLink, this.LINK);
            }

            return(prop);
        }
        /// <summary>
        /// Сравнение объектов по "Name".
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            MessageProperty prop = obj as MessageProperty;

            if (prop == null)
            {
                return(false);
            }

            return(this.Name == prop.Name);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="propName"></param>
        public void RemoveProperty(string propName)
        {
            #region Validate parameters
            if (String.IsNullOrEmpty(propName))
            {
                throw new ArgumentException("propName");
            }
            #endregion

            MessageProperty prop = FindProperty(propName);
            if (prop != null)
            {
                lock (this.properties)
                {
                    this.properties.Remove(prop);
                }
            }
        }