Exemplo n.º 1
0
        /// <inheritdoc />
        public void AddProperty <T>(
            string name,
            T value)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("When adding a property, invalid input was specified!");
            }

            if (!typeof(T).IsSerializable)
            {
                throw new Exception($"The specified property does not support serialization ({typeof(T)}).");
            }

            foreach (var p in Properties)
            {
                if (p.Name == name)
                {
                    throw new Exception($"A property with the same name already exists ({name}).");
                }
            }

            var property = new WavesProperty <T>(
                name,
                value);

            Properties.Add(property);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Compares two properties.
 /// </summary>
 /// <param name="other">Other property.</param>
 /// <returns>Property.</returns>
 protected bool Equals(
     WavesProperty <T> other)
 {
     return(EqualityComparer <T> .Default.Equals(
                Value,
                other.Value) &&
            Name == other.Name &&
            Id.Equals(other.Id));
 }