Esempio n. 1
0
        private AddressDetail GetAddressDetail(string region)
        {
            var addressSettingData =
                SettingDataUtils.GetSettingData <AddressSettingData>(Constant.Configuration.AddressSettingData);
            var detail = new AddressDetail();

            Type type = detail.GetType();

            PropertyInfo[] properties = type.GetProperties();

            foreach (PropertyInfo property in properties)
            {
                var address = addressSettingData.Addresses.FirstOrDefault(a =>
                                                                          a.Type.Equals(property.Name, StringComparison.CurrentCultureIgnoreCase) &&
                                                                          a.Region.Equals(region, StringComparison.CurrentCultureIgnoreCase));
                if (address == null)
                {
                    address = addressSettingData.Addresses.FirstOrDefault(a =>
                                                                          a.Type.Equals(property.Name, StringComparison.CurrentCultureIgnoreCase) &&
                                                                          string.IsNullOrWhiteSpace(a.Region));
                    if (!string.IsNullOrWhiteSpace(address?.File))
                    {
                        var file = Path.Combine(addressSettingData.RootDir, address.File);
                        property.SetValue(detail, Convert.ChangeType(file, property.PropertyType), null);
                    }
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(address.File))
                    {
                        var file = Path.Combine(addressSettingData.RootDir, address.File);
                        property.SetValue(detail, Convert.ChangeType(file, property.PropertyType), null);
                    }
                }
            }

            return(detail);
        }
Esempio n. 2
0
        private SymbolDetail GetSymbolDetail(string region)
        {
            var symbolSettingData =
                SettingDataUtils.GetSettingData <SymbolSettingData>(Constant.Configuration.SymbolSettingData);

            var symbol =
                symbolSettingData.Symbols.First(
                    s => s.Region.Equals(region, StringComparison.CurrentCultureIgnoreCase));

            return(new SymbolDetail
            {
                IconDetail = new SymbolDetail.Icon
                {
                    Symbol1Icon = Path.Combine(symbolSettingData.RootDir, symbol.Symbol1),
                    Symbol2Icon = Path.Combine(symbolSettingData.RootDir, symbol.Symbol2)
                },
                TextDetail = new SymbolDetail.Text
                {
                    Symbol1Text = symbol.Symbol1.Split('.').First(),
                    Symbol2Text = symbol.Symbol2.Split('.').First()
                }
            });
        }