博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Convert enumeraltor to Dictionary object
阅读量:6006 次
发布时间:2019-06-20

本文共 9735 字,大约阅读时间需要 32 分钟。

View Code
1 ///   2 ///  3 ///   4 public enum DRErrorMessage  5 {
6 German = 5, 7 Czech = 6, 8 Danish = 7, 9 Greek = 8, 10 Spanish = 9, 11 Finnish = 10, 12 French = 11, 13 Hungarian = 12, 14 Italian = 13, 15 Japanese = 14, 16 Korean = 15, 17 Dutch = 16, 18 Norwegian = 17, 19 Polish = 18, 20 Portuguese = 19, //pt-br (Portuguese-LatinAmer : Portuguese Brazil ) 21 PortugueseIberian = 20, //pt-PT (Portuguese) 22 Romanian = 21, 23 Russian = 22, 24 Swedish = 23, 25 Turkish = 24, 26 ChineseS = 25, //SimplifiedChinese 27 ChineseT = 26 //TraditionalChinese 28 } 29 30 /// 31 /// 32 /// 33 /// 34 ///
35 public static Dictionary
dtGetAllConfigurationFiles() 36 {
37 38 Dictionary
myDictionaryResult = new Dictionary
(); 39 40 #region add key value pair for dictionary. 41 42 //myDictionaryResult.Add((int)DRErrorMessage.German, DRErrorMessage.German.ToString() + suffixFileName); 43 //myDictionaryResult.Add((int)DRErrorMessage.Czech, DRErrorMessage.Czech.ToString() + suffixFileName); 44 //myDictionaryResult.Add((int)DRErrorMessage.Danish, DRErrorMessage.Danish.ToString() + suffixFileName); 45 //myDictionaryResult.Add((int)DRErrorMessage.Greek, DRErrorMessage.Greek.ToString() + suffixFileName); 46 //myDictionaryResult.Add((int)DRErrorMessage.Spanish, DRErrorMessage.Spanish.ToString() + suffixFileName); 47 //myDictionaryResult.Add((int)DRErrorMessage.Finnish, DRErrorMessage.Finnish.ToString() + suffixFileName); 48 49 //myDictionaryResult.Add((int)DRErrorMessage.French, DRErrorMessage.French.ToString() + suffixFileName); 50 //myDictionaryResult.Add((int)DRErrorMessage.Hungarian, DRErrorMessage.Hungarian.ToString() + suffixFileName); 51 //myDictionaryResult.Add((int)DRErrorMessage.Italian, DRErrorMessage.Italian.ToString() + suffixFileName); 52 //myDictionaryResult.Add((int)DRErrorMessage.Japanese, DRErrorMessage.Japanese.ToString() + suffixFileName); 53 //myDictionaryResult.Add((int)DRErrorMessage.Korean, DRErrorMessage.Korean.ToString() + suffixFileName); 54 //myDictionaryResult.Add((int)DRErrorMessage.Dutch, DRErrorMessage.Dutch.ToString() + suffixFileName); 55 56 //myDictionaryResult.Add((int)DRErrorMessage.Norwegian, DRErrorMessage.Norwegian.ToString() + suffixFileName); 57 //myDictionaryResult.Add((int)DRErrorMessage.Polish, DRErrorMessage.Polish.ToString() + suffixFileName); 58 //myDictionaryResult.Add((int)DRErrorMessage.Portuguese, DRErrorMessage.Portuguese.ToString() + suffixFileName); //pt-br (Portuguese-LatinAmer) 59 //myDictionaryResult.Add((int)DRErrorMessage.PortugueseIberian, DRErrorMessage.PortugueseIberian.ToString() + suffixFileName); //pt-PT (Portuguese) 60 //myDictionaryResult.Add((int)DRErrorMessage.Romanian, DRErrorMessage.Romanian.ToString() + suffixFileName); 61 //myDictionaryResult.Add((int)DRErrorMessage.Russian, DRErrorMessage.Russian.ToString() + suffixFileName); 62 63 //myDictionaryResult.Add((int)DRErrorMessage.Swedish, DRErrorMessage.Swedish.ToString() + suffixFileName); 64 //myDictionaryResult.Add((int)DRErrorMessage.Turkish, DRErrorMessage.Turkish.ToString() + suffixFileName); 65 //myDictionaryResult.Add((int)DRErrorMessage.ChineseS, DRErrorMessage.ChineseS.ToString() + suffixFileName); //SimplifiedChinese 66 //myDictionaryResult.Add((int)DRErrorMessage.ChineseT, DRErrorMessage.ChineseT.ToString() + suffixFileName); //TraditionalChinese 67 68 #endregion 69 70 foreach (DRErrorMessage enumDRErrorMessage in Enum.GetValues(typeof(DRErrorMessage))) 71 {
72 //myDictionaryResult.Add((int)enumDRErrorMessage, enumDRErrorMessage.ToString() + suffixFileName); 73 addDictionaryKeyValeuPairs( myDictionaryResult, enumDRErrorMessage); 74 } 75 76 return myDictionaryResult; 77 }

 

View Code
1 using System;   2 using System.Collections.Generic;   3 using System.Linq;   4 using System.Text;   5 using System.Collections;   6   7   8 namespace WindowsFormsApplication1   9 {
10 public class MatchCalssInitialition 11 {
12 public static string originalBinPath = @"C:\Program Files\Kodak\CaptureConsole\Bin\"; 13 14 public static string excelFilePath = @"D:\DRErrorMessageConfigurationFiles\segscbincidents_error_translations_form_011012_01(old) - Copy.xls"; 15 16 public static string suffixFileName = "DRErrorMessages.config"; 17 18 /// 19 /// 20 /// 21 public enum DRErrorMessage 22 {
23 German = 5, 24 Czech = 6, 25 Danish = 7, 26 Greek = 8, 27 Spanish = 9, 28 Finnish = 10, 29 French = 11, 30 Hungarian = 12, 31 Italian = 13, 32 Japanese = 14, 33 Korean = 15, 34 Dutch = 16, 35 Norwegian = 17, 36 Polish = 18, 37 Portuguese = 19, //pt-br (Portuguese-LatinAmer : Portuguese Brazil ) 38 PortugueseIberian = 20, //pt-PT (Portuguese) 39 Romanian = 21, 40 Russian = 22, 41 Swedish = 23, 42 Turkish = 24, 43 ChineseS = 25, //SimplifiedChinese 44 ChineseT = 26 //TraditionalChinese 45 } 46 47 /// 48 /// 49 /// 50 /// 51 ///
52 public static Dictionary
dtGetAllConfigurationFiles() 53 {
54 55 Dictionary
myDictionaryResult = new Dictionary
(); 56 57 #region add key value pair for dictionary. 58 59 //myDictionaryResult.Add((int)DRErrorMessage.German, DRErrorMessage.German.ToString() + suffixFileName); 60 //myDictionaryResult.Add((int)DRErrorMessage.Czech, DRErrorMessage.Czech.ToString() + suffixFileName); 61 //myDictionaryResult.Add((int)DRErrorMessage.Danish, DRErrorMessage.Danish.ToString() + suffixFileName); 62 //myDictionaryResult.Add((int)DRErrorMessage.Greek, DRErrorMessage.Greek.ToString() + suffixFileName); 63 //myDictionaryResult.Add((int)DRErrorMessage.Spanish, DRErrorMessage.Spanish.ToString() + suffixFileName); 64 //myDictionaryResult.Add((int)DRErrorMessage.Finnish, DRErrorMessage.Finnish.ToString() + suffixFileName); 65 66 //myDictionaryResult.Add((int)DRErrorMessage.French, DRErrorMessage.French.ToString() + suffixFileName); 67 //myDictionaryResult.Add((int)DRErrorMessage.Hungarian, DRErrorMessage.Hungarian.ToString() + suffixFileName); 68 //myDictionaryResult.Add((int)DRErrorMessage.Italian, DRErrorMessage.Italian.ToString() + suffixFileName); 69 //myDictionaryResult.Add((int)DRErrorMessage.Japanese, DRErrorMessage.Japanese.ToString() + suffixFileName); 70 //myDictionaryResult.Add((int)DRErrorMessage.Korean, DRErrorMessage.Korean.ToString() + suffixFileName); 71 //myDictionaryResult.Add((int)DRErrorMessage.Dutch, DRErrorMessage.Dutch.ToString() + suffixFileName); 72 73 //myDictionaryResult.Add((int)DRErrorMessage.Norwegian, DRErrorMessage.Norwegian.ToString() + suffixFileName); 74 //myDictionaryResult.Add((int)DRErrorMessage.Polish, DRErrorMessage.Polish.ToString() + suffixFileName); 75 //myDictionaryResult.Add((int)DRErrorMessage.Portuguese, DRErrorMessage.Portuguese.ToString() + suffixFileName); //pt-br (Portuguese-LatinAmer) 76 //myDictionaryResult.Add((int)DRErrorMessage.PortugueseIberian, DRErrorMessage.PortugueseIberian.ToString() + suffixFileName); //pt-PT (Portuguese) 77 //myDictionaryResult.Add((int)DRErrorMessage.Romanian, DRErrorMessage.Romanian.ToString() + suffixFileName); 78 //myDictionaryResult.Add((int)DRErrorMessage.Russian, DRErrorMessage.Russian.ToString() + suffixFileName); 79 80 //myDictionaryResult.Add((int)DRErrorMessage.Swedish, DRErrorMessage.Swedish.ToString() + suffixFileName); 81 //myDictionaryResult.Add((int)DRErrorMessage.Turkish, DRErrorMessage.Turkish.ToString() + suffixFileName); 82 //myDictionaryResult.Add((int)DRErrorMessage.ChineseS, DRErrorMessage.ChineseS.ToString() + suffixFileName); //SimplifiedChinese 83 //myDictionaryResult.Add((int)DRErrorMessage.ChineseT, DRErrorMessage.ChineseT.ToString() + suffixFileName); //TraditionalChinese 84 85 #endregion 86 87 foreach (DRErrorMessage enumDRErrorMessage in Enum.GetValues(typeof(DRErrorMessage))) 88 {
89 //myDictionaryResult.Add((int)enumDRErrorMessage, enumDRErrorMessage.ToString() + suffixFileName); 90 addDictionaryKeyValeuPairs( myDictionaryResult, enumDRErrorMessage); 91 } 92 93 return myDictionaryResult; 94 } 95 96 ///
97 /// 98 /// 99 ///
100 ///
101 public static string getSingleConfigurationFilePath(int columnIndex) 102 {
103 string path = string.Empty; 104 Dictionary
myDictionary = dtGetAllConfigurationFiles(); 105 foreach (KeyValuePair
keyValue in myDictionary) 106 {
107 if (keyValue.Key == columnIndex) 108 {
109 path = originalBinPath + keyValue.Value; 110 break; 111 } 112 } 113 return path; 114 } 115 116 ///
117 /// 118 /// 119 ///
120 ///
121 public static void addDictionaryKeyValeuPairs( Dictionary
myDictionary, DRErrorMessage drErrorMessage) 122 { 123 int index = (int)drErrorMessage; 124 if (!myDictionary.Keys.Contains(index)) 125 { 126 myDictionary.Add(index, drErrorMessage.ToString() + suffixFileName); 127 } 128 } 129 } 130 }

转载地址:http://eupmx.baihongyu.com/

你可能感兴趣的文章
Ubuntu 10.04升级git 到1.7.2或更高的可行方法
查看>>
MyBATIS(即iBATIS)问题集
查看>>
Linux下autoconf和automake使用
查看>>
UDP之socket编程
查看>>
Spring Security4实战与原理分析视频课程( 扩展+自定义)
查看>>
Centos6.5升级系统自带gcc4.4.7到gcc4.8.0
查看>>
redis安装与配置文件详解
查看>>
VMware安装失败 “Failed to create the requested registry key Key:installer Error:1021"
查看>>
虚拟化系列-VMware vSphere 5.1 VDP备份管理
查看>>
接口设计
查看>>
同步工具类 java.util.concurrent.CountDownLatch
查看>>
带动量因子的BP网络源码(C#实现)
查看>>
Skia深入分析9——延迟渲染和显示列表
查看>>
mmap函数实现共享内存
查看>>
java笔记
查看>>
贪吃蛇和俄罗斯方块软件
查看>>
消息队列服务器 memcacheq的搭建
查看>>
Bringing up interface eth0: Device eth0 does not seem to be present ,delayin
查看>>
解决输入ipconfig后出现ipconfig不是内部或外部命令
查看>>
跟我一起学docker(七)--网络
查看>>