Ejemplo n.º 1
0
 /*==========================================================================================================================
 | METHOD: GET TOPIC
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Retrieves a <typeparamref name="T"/> by key.
 /// </summary>
 public T? GetTopic(string key) {
   TopicFactory.ValidateKey(key);
   if (_innerCollection.Contains(key)) {
     return _innerCollection[key];
   }
   return null;
 }
Ejemplo n.º 2
0
 /*==========================================================================================================================
 | METHOD: GET TOPIC
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Retrieves a <typeparamref name="T"/> by key.
 /// </summary>
 public T? GetTopic(string key) {
   TopicFactory.ValidateKey(key);
   if (Contains(key)) {
     return this[key];
   }
   return null;
 }
Ejemplo n.º 3
0
        /*==========================================================================================================================
        | CONSTRUCTOR
        \-------------------------------------------------------------------------------------------------------------------------*/
        /// <summary>
        ///   Initializes a new instance of the <see cref="AttributeValue"/> class, using the specified key/value pair.
        /// </summary>
        /// <param name="key">
        ///   The string identifier for the <see cref="AttributeValue"/> collection item key/value pair.
        /// </param>
        /// <param name="value">
        ///   The string value text for the <see cref="AttributeValue"/> collection item key/value pair.
        /// </param>
        /// <param name="isDirty">
        ///   An optional boolean indicator noting whether the <see cref="AttributeValue"/> collection item is a new value, and
        ///   should thus be saved to the database when <see cref="ITopicRepository.Save(Topic, Boolean, Boolean)"/> is next called.
        /// </param>
        /// <requires
        ///   description="The key must be specified for the key/value pair." exception="T:System.ArgumentNullException">
        ///   !String.IsNullOrWhiteSpace(key)
        /// </requires>
        public AttributeValue(string key, string?value, bool isDirty = true)
        {
            /*------------------------------------------------------------------------------------------------------------------------
            | Validate input
            \-----------------------------------------------------------------------------------------------------------------------*/
            TopicFactory.ValidateKey(key, false);

            /*------------------------------------------------------------------------------------------------------------------------
            | Set local values
            \-----------------------------------------------------------------------------------------------------------------------*/
            Key     = key;
            Value   = value;
            IsDirty = isDirty;
            EnforceBusinessLogic = true;
        }
Ejemplo n.º 4
0
        /*==========================================================================================================================
        | METHOD: FIND ALL BY ATTRIBUTE
        \-------------------------------------------------------------------------------------------------------------------------*/
        /// <summary>
        ///   Retrieves a collection of topics based on an attribute name and value.
        /// </summary>
        /// <param name="topic">The instance of the <see cref="Topic"/> to operate against; populated automatically by .NET.</param>
        /// <param name="name">The string identifier for the <see cref="AttributeValue"/> against which to be searched.</param>
        /// <param name="value">The text value for the <see cref="AttributeValue"/> against which to be searched.</param>
        /// <returns>A collection of topics matching the input parameters.</returns>
        /// <requires description="The attribute name must be specified." exception="T:System.ArgumentNullException">
        ///   !String.IsNullOrWhiteSpace(name)
        /// </requires>
        /// <requires
        ///   decription="The name should be an alphanumeric sequence; it should not contain spaces or symbols."
        ///   exception="T:System.ArgumentException">
        ///   !name.Contains(" ")
        /// </requires>
        public static ReadOnlyTopicCollection <Topic> FindAllByAttribute(this Topic topic, string name, string value)
        {
            /*------------------------------------------------------------------------------------------------------------------------
            | Validate contracts
            \-----------------------------------------------------------------------------------------------------------------------*/
            Contract.Requires(topic, "The topic parameter must be specified.");
            Contract.Requires <ArgumentNullException>(!String.IsNullOrWhiteSpace(name), "The attribute name must be specified.");
            Contract.Requires <ArgumentNullException>(!String.IsNullOrWhiteSpace(value), "The attribute value must be specified.");
            TopicFactory.ValidateKey(name);

            /*------------------------------------------------------------------------------------------------------------------------
            | Return results
            \-----------------------------------------------------------------------------------------------------------------------*/
            return(topic.FindAll(t =>
                                 !String.IsNullOrEmpty(t.Attributes.GetValue(name)) &&
                                 t.Attributes.GetValue(name).IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0
                                 ));
        }
Ejemplo n.º 5
0
 /*==========================================================================================================================
 | CONSTRUCTOR
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Annotates a property with the <see cref="FilterByAttributeAttribute"/> class by providing a (required) attribute key
 ///   and value.
 /// </summary>
 /// <param name="attributeKey">The key of the attribute to filter by.</param>
 /// <param name="attributeValue">The value of the attribute to filter by.</param>
 public FilterByAttributeAttribute(string attributeKey, string attributeValue) {
   TopicFactory.ValidateKey(attributeKey, false);
   Key = attributeKey;
   Value = attributeValue;
 }
Ejemplo n.º 6
0
 /*==========================================================================================================================
 | CONSTRUCTOR
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Annotates a property with the <see cref="MetadataAttribute"/> class by providing a (required) key.
 /// </summary>
 /// <param name="key">The key represents the name of the Metadata topic that should be mapped to.</param>
 public MetadataAttribute(string key) {
   TopicFactory.ValidateKey(key, false);
   Key = key;
 }
 /*==========================================================================================================================
 | CONSTRUCTOR
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Annotates a property with the <see cref="RelationshipAttribute"/> by providing an <paramref name="key"/>.
 /// </summary>
 /// <param name="key">The key value of the relationships associated with the current property.</param>
 public RelationshipAttribute(string key) {
   TopicFactory.ValidateKey(key, false);
   Key = key;
 }
 /*==========================================================================================================================
 | CONSTRUCTOR
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Annotates a property with the <see cref="AttributeKeyAttribute"/> class by providing a (required) attribute key.
 /// </summary>
 /// <param name="attributeKey">The key value of the attribute associated with the current property.</param>
 public AttributeKeyAttribute(string attributeKey) {
   TopicFactory.ValidateKey(attributeKey, false);
   Value = attributeKey;
 }