Exemple #1
0
        public T Get <T>(IConceptInfo conceptInfo, ConceptMetadataType <T> metadataType)
        {
            Func <string> missingMetadataMessage = () => "There is no metadata of requested type for concept " + conceptInfo.GetUserDescription() + ". Metadata type is " + metadataType + ".";
            var           conceptMetadataByType  = _metadata.GetValue(conceptInfo.GetKey(), missingMetadataMessage);
            var           metadataValue          = conceptMetadataByType.GetValue(metadataType.Id, missingMetadataMessage);

            return((T)metadataValue);
        }
Exemple #2
0
        public bool Contains <T>(IConceptInfo conceptInfo, ConceptMetadataType <T> metadataType)
        {
            Dictionary <Guid, object> conceptMetadataByType;

            if (!_metadata.TryGetValue(conceptInfo.GetKey(), out conceptMetadataByType))
            {
                return(false);
            }
            return(conceptMetadataByType.ContainsKey(metadataType.Id));
        }
Exemple #3
0
        public void Set <T>(IConceptInfo conceptInfo, ConceptMetadataType <T> metadataType, T value)
        {
            Dictionary <Guid, object> conceptMetadataByType;
            string conceptKey = conceptInfo.GetKey();

            if (!_metadata.TryGetValue(conceptKey, out conceptMetadataByType))
            {
                conceptMetadataByType = new Dictionary <Guid, object>();
                _metadata.Add(conceptKey, conceptMetadataByType);
            }

            if (conceptMetadataByType.ContainsKey(metadataType.Id))
            {
                throw new FrameworkException(string.Format(
                                                 "The metadata is already set for concept {0}. Metadata type {1}.",
                                                 conceptInfo.GetUserDescription(),
                                                 metadataType));
            }

            conceptMetadataByType.Add(metadataType.Id, value);
        }
Exemple #4
0
 public T GetOrDefault <T>(IConceptInfo conceptInfo, ConceptMetadataType <T> metadataType, T defaultValue)
 {
     return(Contains(conceptInfo, metadataType)
         ? Get(conceptInfo, metadataType)
         : defaultValue);
 }
Exemple #5
0
 public bool Contains <T>(IConceptInfo conceptInfo, ConceptMetadataType <T> metadataType)
 {
     return(_metadata.ContainsKey(conceptInfo.GetKey()));
 }