예제 #1
0
        protected Dictionary <string, FileType> _getAttached(SourceType ext)
        {
            if (!this.IsSet())
            {
                return(new Dictionary <string, FileType>());
            }
            Dictionary <string, FileType> first = new Dictionary <string, FileType>();
            List <string> stringList            = new List <string>();

            foreach (SchedulerControlsItem schedulerControlsItem in this.data)
            {
                switch (ext)
                {
                case SourceType.JS:
                    DictionaryMerger.Join(ref first, schedulerControlsItem.GetJS());
                    continue;

                case SourceType.CSS:
                    DictionaryMerger.Join(ref first, schedulerControlsItem.GetCSS());
                    continue;

                default:
                    continue;
                }
            }
            return(first);
        }
        public void OverrideDuplicateKeyWithLatterValueWhenMergingDictionaries()
        {
            const string testKey   = "key1";
            const string testValue = "value1";

            Dictionary <string, string> sut1 = new Dictionary <string, string>(1)
            {
                { testKey, "value1" }
            };
            Dictionary <string, string> sut2 = new Dictionary <string, string>(1)
            {
                { testKey, testValue }
            };
            Dictionary <string, string> sut3 = new Dictionary <string, string>(1)
            {
                { "key2", "value3" }
            };

            var dictionaryMerger = new DictionaryMerger();
            Dictionary <int, Dictionary <string, string> > mergeInput = new Dictionary <int, Dictionary <string, string> >
            {
                { 0, sut1 },
                { 1, sut2 },
                { 2, sut3 }
            };
            Dictionary <string, string> merged = dictionaryMerger.MergeDictionaries(mergeInput);

            Assert.Equal(2, merged.Count);
            Assert.Equal(testValue, merged[testKey]);
        }
예제 #3
0
        private Dictionary <string, FileType> _getAttached(SourceType ext)
        {
            Dictionary <string, FileType> first = new Dictionary <string, FileType>();

            switch (ext)
            {
            case SourceType.JS:
                first = this.GetJS();
                foreach (SchedulerControlsBase control in this._Controls)
                {
                    DictionaryMerger.Join(ref first, control.GetJS());
                }
                foreach (SchedulerSettingsBase setting in this._Settings)
                {
                    DictionaryMerger.Join(ref first, setting.GetJS());
                }
                DictionaryMerger.Join(ref first, this.Data.GetJS());
                break;

            case SourceType.CSS:
                first = this.GetCSS();
                foreach (SchedulerControlsBase control in this._Controls)
                {
                    DictionaryMerger.Join(ref first, control.GetCSS());
                }
                using (List <SchedulerSettingsBase> .Enumerator enumerator = this._Settings.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        SchedulerSettingsBase current = enumerator.Current;
                        DictionaryMerger.Join(ref first, current.GetJS());
                    }
                    break;
                }
            }
            return(first);
        }