コード例 #1
0
        private void FillPathways()
        {
            _pathways = new Dictionary <string, string>();
            var pathwaysSection = this.GetPathwaysSection();

            foreach (ImagePathElement item in pathwaysSection)
            {
                DirectoryInfo directory = new DirectoryInfo(item.Path);

                if (!directory.Exists)
                {
                    CommercialNotFound faultDetails = new CommercialNotFound
                    {
                        Message = "Commercials folder not found. Please, check path to image."
                    };
                    throw new FaultException <CommercialNotFound>(faultDetails);
                }

                FileInfo[] files = directory.GetFiles();
                foreach (var fileInfo in files)
                {
                    _pathways.Add(fileInfo.FullName, fileInfo.Extension);
                }
            }
        }
コード例 #2
0
        private ImagePathCollection GetPathwaysSection()
        {
            var configSection   = ConfigurationManager.GetSection(SECTION_NAME) as CommercialConfigSection;
            var pathwaysSection = configSection?.Pathways;

            if (pathwaysSection == null)
            {
                CommercialNotFound faultDetails = new CommercialNotFound
                {
                    Message = "Commercial not found. Please, check path to image."
                };
                throw new FaultException <CommercialNotFound>(faultDetails);
            }

            return(pathwaysSection);
        }