コード例 #1
0
        public void AddTagInteraction(string imageHash, string interactionTagPath, string affectedTagPath)
        {
            // Make sure image and tags are in database
            AssertContainsImage(imageHash, $"Unable to add tag interaction, image {imageHash} not found in database!");
            AssertContainsTag(interactionTagPath, $"Unable to add tag interaction, tag {interactionTagPath} not found in database!");
            AssertContainsTag(affectedTagPath, $"Unable to add tag interaction, tag {affectedTagPath} not found in database!");

            // Retrieve image and tag from database
            Image    image          = ImageTable[imageHash];
            ImageTag interactionTag = TagTable[interactionTagPath];
            ImageTag affectedTag    = TagTable[affectedTagPath];

            // TODO: Rework interaction tags then modify + reenable this part
            // Make sure interaction tag is of correct type
            //if (interactionTag.Type != ImageTagTypes.Interaction)
            //{
            //Log.WriteLine($"Unable to add non-interaction tag {interactionTagPath} to {affectedTagPath}", MessageType.Warning);
            //return;
            //}

            // Create tag interaction if does not exist
            if (!image.TagInteractions.ContainsKey(interactionTagPath))
            {
                image.TagInteractions.Add(interactionTagPath, new ImageTagInteractions(interactionTag));
            }

            // Add tag interaction
            ImageTagInteractions interactions = image.TagInteractions[interactionTagPath];

            interactions.AffectedTags.Add(affectedTag);
            Log.WriteLine($"Added interaction {interactionTagPath} to {affectedTagPath}");
        }
コード例 #2
0
        public HashSet <ImageTag> GetTagInteractions(string imageHash, string interactionTag)
        {
            // Make sure image and tag is in database
            AssertContainsImage(imageHash, $"Unable to add tag interaction, image {imageHash} not found in database!");
            AssertContainsTag(interactionTag, $"Unable to add tag interaction, tag {interactionTag} not found in database!");

            // Check if there are any interactions
            Image image = ImageTable[imageHash];

            if (!image.TagInteractions.ContainsKey(interactionTag))
            {
                return(null);
            }

            // Return list of tag interactions
            ImageTagInteractions interactions = image.TagInteractions[interactionTag];

            return(interactions.AffectedTags);
        }