Beispiel #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            hash ^= label_.GetHashCode();
            hash ^= labelId_.GetHashCode();
            hash ^= score_.GetHashCode();
            if (locationData_ != null)
            {
                hash ^= LocationData.GetHashCode();
            }
            if (HasFeatureTag)
            {
                hash ^= FeatureTag.GetHashCode();
            }
            if (HasTrackId)
            {
                hash ^= TrackId.GetHashCode();
            }
            if (HasDetectionId)
            {
                hash ^= DetectionId.GetHashCode();
            }
            hash ^= associatedDetections_.GetHashCode();
            hash ^= displayName_.GetHashCode();
            if (HasTimestampUsec)
            {
                hash ^= TimestampUsec.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        private void ChangeTagList(Feature feature, List <Tag> tags, FeatureChangeSet changeSet, List <string> targetTagList, TagCategory category)
        {
            var activeTagList = feature.FeatureTags.Where(x => x.Tag.Category == category).ToList();
            var orphanedList  = activeTagList.ToList();

            var categoryTags = tags.Where(x => x.Category == category).ToList();

            foreach (var targetTagName in targetTagList)
            {
                var availableTag = activeTagList.FirstOrDefault(x => targetTagName.Equals(x.Tag.Name, StringComparison.InvariantCultureIgnoreCase));

                if (availableTag != null)
                {
                    orphanedList.Remove(availableTag);
                    continue;
                }

                var dbTag = categoryTags.FirstOrDefault(x => x.Name.Equals(targetTagName, StringComparison.CurrentCultureIgnoreCase));

                if (dbTag == null)
                {
                    dbTag = new Tag
                    {
                        Id       = Guid.NewGuid(),
                        Category = category,
                        Name     = targetTagName,
                    };
                    tags.Add(dbTag);
                }

                var featureTag = new FeatureTag
                {
                    Feature = feature,
                    Tag     = dbTag
                };
                feature.FeatureTags.Add(featureTag);
                activeTagList.Add(featureTag);


                changeSet.Changes.Add(new FeatureChange
                {
                    Id = Guid.NewGuid(),
                    FeatureChangeSet = changeSet,
                    Property         = $"Tag-{category}",
                    OldValue         = "add",
                    NewValue         = targetTagName
                });
            }

            foreach (var featureTag in orphanedList)
            {
                feature.FeatureTags.Remove(featureTag);

                changeSet.Changes.Add(new FeatureChange
                {
                    Id = Guid.NewGuid(),
                    FeatureChangeSet = changeSet,
                    Property         = $"Tag-{category}",
                    OldValue         = "remove",
                    NewValue         = featureTag.Tag.Name
                });
            }
        }