/// <summary>
        /// Register all actions of a TagHandler. Overwrites duplicates in favor of new actions. The actions can have side-effects.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public IReadOnlyList <string> ForceRegisterHandler(ITagHandler th)
        {
            th = th ?? throw new ArgumentNullException(nameof(th));

            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            var report = new List <string>();

            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_tagFuncs.ContainsKey(x.Key))
                {
                    report.Add(TagName(x.Key));
                }

                _tagFuncs[x.Key] = x.Value;
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_regexFuncs.FirstOrDefault(pair => pair.Key.ToString().Equals(x.Key.ToString(), StringComparison.Ordinal)).Key != null)
                {
                    report.Add(x.Key.ToString());
                }

                _regexFuncs[x.Key] = x.Value;
            });
            return(report);
        }
示例#2
0
        /// <summary>
        /// Register all actions of a TagHandler. Overwrites duplicates in favor of new actions. The actions can have side-effects.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public List <string> ForceRegisterHandler(ITagHandler th)
        {
            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            var report = new List <string>();

            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_tagFuncs.ContainsKey(x.Key))
                {
                    report.Add(TagName(x.Key));
                }

                _tagFuncs[x.Key] = x.Value;
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_regexFuncs.FirstOrDefault(pair => pair.Key.ToString().Equals(x.Key.ToString())).Key != null)
                {
                    report.Add(x.Key.ToString());
                }

                _regexFuncs[x.Key] = x.Value;
            });
            return(report);
        }
示例#3
0
        /// <summary>
        /// Register all actions of a TagHandler. If a tag is already handled, we throw an error.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public void RegisterHandler(ITagHandler th)
        {
            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            // TODO: check that handlers respect VR
            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);
                _tagFuncs.Add(x.Key, x.Value);
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);
                _regexFuncs.Add(x.Key, x.Value);
            });
        }