2010-01-18 4 views
0

상태 코드를 기반으로 일부 템플릿을 저장해야합니다. 데이터베이스에 저장할 수 없습니다. 그래서 나는 statecode를 키로하고 값으로리스트를 가진 사전을 만드는 것을 생각했다. 나는 라인별로 템플릿을 필요로하기 때문에 목록을 선택했다. 목록의 각 문자열은 라인이다. 이런 종류의 상황을 다루는 더 좋은 방법이 있습니까? 의견을 부탁합니다.C에서 사전을 사용하여 템플릿 저장하기 #

private static readonly Dictionary<string, List<string>> NotaryForStates = new Dictionary<string, List<string>>() 
    { 
     {"AR",new List<string> {"Per Steve Hollowell, ESQ from the Legal Division of the AR, SOS. Telephone number for the Legal Division of the SOS: (501)-682-3012. Arkansas Code 16-47-101.", "State of Arkansas", "County of <notary county>","On this day, <sign date> before me, <name of notary>, the undersigned notary, personally appeared, <name of signer> who acknowledged he/she is the <title of signer> of <name of company> and that he/she as such <title of signer>, being authorized so to do, executed the foregoing instrument for the purposes therein contained, by signing the name of the corporation by himself/herself as <title of signer>.","In witness whereof I hereunto set my hand and official seal.","______________________","Notary Public","<Notary name>","My Commission expires: <notary commission date>"}}, 
     {"CA",new List<string>{"State of California","County of <Notary County>","On <sign date> before me, <Notary Name>, Notary Public, personally appeared <Signing Party Name>, who proved to me on the basis of satisfactory evidence to be the person(s) whose name is subscribed to the within instrument and acknowledged to me that he/she executed the same in his/her authorized capacity, and that by his/her signature on the instrument the person, or the entity upon behalf of which the person acted, executed the instrument.","I certify under PENALTY OF PERJURY under the laws of the State of California that the foregoing paragraph is true and correct.","WITNESS my hand and official seal.","______________________________","Notary Public: «NotaryName»","My Comm. Expires: «NotaryCommExp»"}}, 
     {"FL",new List<string>{"State of Florida","County of <Notary County>","On <sign date> before me, the undersigned, a Notary Public, for said County and State, personally appeared <Signing Party Name>, personally known to me to be the person that executed the foregoing instrument and acknowledged that is a <signer title> of <name of company> and that he/she did execute the foregoing instrument. <Name of Signer> is personally known to me.","_____________________","Notary Public: «NotaryName»","My Comm. Expires: «NotaryCommExp»"}} 
    }; 
+0

@Rohit 파일에서 템플릿을 선택할 수도 있습니다. 장점은 템플릿을 조금만 변경하면 코드를 업데이트 할 필요가 없다는 것입니다. – Adeel

답변

0

첫 번째 대안 : 당신은 목록 대신 간단한 문자열을 사용하고 Environment.NewLine ("\ n")를 사용하여 각각의 라인을 분리 할 수 ​​있습니다. StringBuilder 개체를 사용하여 이러한 문자열을 쉽게 만들고 string.Split() 메서드로 다시 분할 할 수 있습니다 (필요한 경우). 이는 List<string> 접근 방식보다 (약간) 빠릅니다.

두 번째 대안 : 파일을 사용하고 사전에 파일 이름 만 저장할 수 있습니다.

위의 옵션 중 하나가 원래 방식보다 더 나은지 여부는 작업중인 구체적인 프로젝트에 따라 다릅니다. 대체로 List<string> 접근 방식이 좋습니다 ...

HTH!

0

다른 대안은 리소스 파일 (현지화에 일반적으로 사용되는)을 사용하는 것입니다. 리소스 파일은 웹 사이트, WPF 또는 Windows Forms 응용 프로그램에서 사용할 수있는 텍스트 또는 다른 유형의 개체를 저장할 위치를 제공하므로 텍스트 유지 관리를위한 중앙 위치를 만듭니다. 리소스 파일을 사용하면 응용 프로그램 유지 관리도 간단 해집니다.

관련 문제