처음으로 프로젝트에 N 계층 아키텍처를 구현하려고합니다. C에서 N 계층 아키텍처 #
나는 BLL, DAL 및 GUI을 만든 다음 여기에 GUI에
XmlSettingsBLL xmlSettings = new XmlSettingsBLL();
var newDict = new NewDictionary()
{
StrDataSourceType = "AccessMdb",// DataSourceType.AccessMdb,
DictionaryID = Guid.NewGuid().ToString(),
FirstColumnName = "Kelime",
SecondColumnName = "Karsilik",
TableName = "kelimelerpro",
LastShowedID = 0,
Name = "kpds",
Path = "kelimeler.mdb"
};
xmlSettings.AddNewDictionary(newDict);
입니다 BLL
public bool AddNewDictionary(NewDictionary list)
{
list.DatasourceType = (DataSourceType)Enum.Parse(typeof (DataSourceType), list.StrDataSourceType);
IDictionaryList newDictionary =list;
try
{
helper.AddDictionary(newDictionary);
return true;
}
catch
{
return false;
}
}
public class NewDictionary : IDictionaryList
{
public string Name { get; set; }
public string Path { get; set; }
public string DictionaryID { get; set; }
public string TableName { get; set; }
public int LastShowedID { get; set; }
public string FirstColumnName { get; set; }
public string SecondColumnName { get; set; }
public DataSourceType DatasourceType { get; set; }
public string StrDataSourceType { get; set; }
}
에 여기 DAL
public void AddDictionary(IDictionaryList list)
{
var channelElem = xdoc.Element("MemorizeSettings");
var dictionaries = channelElem.Element("Dictionaries");
XAttribute[] attrs = new XAttribute[8];
attrs[0] = new XAttribute("Name", list.Name);
attrs[1] = new XAttribute("Path", list.Path);
attrs[2] = new XAttribute("TableName", list.TableName);
attrs[3] = new XAttribute("DatasourceType", Enum.GetName(typeof(DataSourceType),list.DatasourceType));
attrs[4] = new XAttribute("LastShowedID", "0");
attrs[5] = new XAttribute("FirstColumnName", list.FirstColumnName);
attrs[6] = new XAttribute("SecondColumnName", list.SecondColumnName);
attrs[7] = new XAttribute("DictionaryID", list.DictionaryID);
var newdict = new XElement("Dictionary", attrs);
dictionaries.Add(newdict);
xdoc.Save(fileName);
}
public interface IDictionaryList
{
string Name { get; set; }
string Path { get; set; }
string DictionaryID { get; set; }
string TableName { get; set; }
int LastShowedID { get; set; }
string FirstColumnName { get; set; }
string SecondColumnName { get; set; }
DataSourceType DatasourceType { get; set; }
}
너무에 , GUI에서는 당연히 광고를해야합니다. DAL에있는 IDictionary에서 NewDictionary를 파생했기 때문에 dAL을 참조로 사용했습니다. 하지만 GUI와 DAL을 서로 분리하려고합니다.
IDictionary 개체를 만드는 것과는 별도로 어떻게 할 수 있습니까? 질문이 명확하길 바란다.
IDictionaryList에서 파생 된 문제는 무엇입니까? 참조 문제가 있다면 계약 인터페이스를 다른 프로젝트로 옮기십시오. 같은 핵심/프레임 워크 또는 기본 –
당신의 답변을 주셔서 감사합니다,하지만 난 그런 식으로하고 싶지 않아. 참조를 추가 할 필요가 없거나 인터페이스를 내 GUI 프로젝트로 옮기는 방법을 찾고 있습니다. 그렇지 않으면 이미 할 수 있습니다. – ertan2002