- nettiergeneratorsample.zip
- database
- sample
- BusinessLogic
- Common
- Config
- DalFactory
- GUI
- WinGUI
- IDAL
- Model
- MsSqlDal
- OP_CACHE.ATR
- OP_CACHE.IDX
- Sample.sln
- Security
- TierModel
- Tools
- EnterpriseLibrary
- Microsoft.Practices.EnterpriseLibrary.Caching.dll
- Microsoft.Practices.EnterpriseLibrary.Caching.XML
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.Common.XML
- Microsoft.Practices.ObjectBuilder.dll
- Microsoft.Practices.ObjectBuilder.XML
- TierGenerator
- nettiergenerator.zip
- netTierGenerator
- BusinessLogic
- Common
- Common.csproj
- Data
- Exception
- OP_CACHE.ATR
- OP_CACHE.IDX
- Properties
- Util
- Config
- Console
- DalFactory
- IDal
- Model
- MsSqlDal
- netTierGenerator.sln
- OP_CACHE.ATR
- OP_CACHE.IDX
- TierGenerator
- TierModel
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using TierGenerator.Common.Util.Settings;
using TierGenerator.Common.Exception;
using TierGenerator.Common.Util.Generate;
namespace TierGenerator.Common.Util.Model
{
public class TierModel
{
#region Class Members
private string _solution;
private TierGeneratorSettings _settings;
private string _namespace;
private string _serviceName;
private string _modelPath;
private XmlDocument xmlDoc;
private string additionalDeclarationList;
private IList<Declaration> declarationList;
private IList<Include> includeList;
private IList<ItemInfo> itemInfoList;
private IList<ListItem> listItemList;
private IList<UdfInfo> selectMethodList;
private IList<UdfInfo> updateMethodList;
private IList<UdfInfo> deleteMethodList;
#endregion
public TierModel()
{
additionalDeclarationList = string.Empty;
declarationList = new List<Declaration>();
includeList = new List<Include>();
itemInfoList = new List<ItemInfo>();
listItemList = new List<ListItem>();
selectMethodList = new List<UdfInfo>();
updateMethodList = new List<UdfInfo>();
deleteMethodList = new List<UdfInfo>();
}
#region Public Properties
public string Solution
{
get { return this._solution; }
set { this._solution = value; }
}
public TierGeneratorSettings Settings
{
get { return this._settings; }
set { this._settings = value; }
}
public string Namespace
{
get { return this._namespace; }
set { this._namespace = value; }
}
public string ServiceName
{
get { return this._serviceName; }
set { this._serviceName = value; }
}
public string ModelPath
{
get { return this._modelPath; }
set { this._modelPath = value; }
}
public XmlDocument XmlDocument
{
get { return this.xmlDoc; }
set { this.xmlDoc = value; }
}
public string AdditionalUsingString
{
get
{
if (string.IsNullOrEmpty(this.additionalDeclarationList))
{
StringBuilder result = new StringBuilder(500);
IList<string> addedUsingList = new List<string>();
foreach (Declaration declaration in declarationList)
{
string usingString = ServiceBuilderHelper.GetNamespaceFromFullTypeName(declaration.FullType);
bool isAdded = false;
foreach (string addedUsing in addedUsingList)
{
if (usingString.Equals(addedUsing))
{
isAdded = true;
break;
}
}
if (!isAdded)
{
result.AppendLine(string.Format("using {0};", usingString));
addedUsingList.Add(usingString);
}
}
additionalDeclarationList = result.ToString();
}
return additionalDeclarationList;
}
}
public IList<Declaration> DeclarationList
{
get { return declarationList; }
set { declarationList = value; }
}
public IList<Include> IncludeList
{
get { return includeList; }
set { includeList = value; }
}
public IList<ItemInfo> ItemInfoList
{
get { return itemInfoList; }
set { itemInfoList = value; }
}
public IList<ListItem> ListItemList
{
get { return listItemList; }
set { listItemList = value; }
}
public IList<UdfInfo> SelectMethodList
{
get { return selectMethodList; }
set { selectMethodList = value; }
}
public IList<UdfInfo> UpdateMethodList
{
get { return updateMethodList; }
set { updateMethodList = value; }
}
public IList<UdfInfo> DeleteMethodList
{
get { return deleteMethodList; }
set { deleteMethodList = value; }
}
#endregion
#region Public Methods
/// <summary>
/// First - is internal, Second - is info type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public ItemAttributes GetDeclaredTypeAttributes(string type)
{
if (String.IsNullOrEmpty(type))
{
return new ItemAttributes(false, false, false, String.Empty);
}
ItemAttributes result = new ItemAttributes(false, false, false, String.Empty);
if (CSharpTypeHelper.IsSimpleType(CSharpTypeHelper.GetCSharpTypeEnum(type)))
{
// there is a simple type
result.IsLocal = true;
return result;
}
foreach (ItemInfo itemInfo in this.ItemInfoList)
{
if (itemInfo.ClassName == type)
{
result.IsLocal = true;
result.IsItemInfo = true;
return result;
}
}
foreach (ListItem listItem in this.ListItemList)
{
if (listItem.ClassName == type)
{
result.IsLocal = true;
result.IsListItem = true;
return result;
}
}
foreach (ListItem listItem in this.ListItemList)
{
if (listItem.ClassName == type)
{
result.IsLocal = true;
result.IsItemInfo = false;
return result;
}
}
foreach (Include include in this.IncludeList)
{
if (include.Item.ClassName == type)
{
result.IsLocal = false;
result.IsItemInfo = include.Item.GetType().Equals(typeof(ItemInfo));
result.IncludeServiceName = include.ServiceName;
return result;
}
}
return result;
}
public ItemInfo GetItemInfoByName(string itemInfoName)
{
foreach (ItemInfo itemInfo in ItemInfoList)
{
if (itemInfo.ClassName == itemInfoName)
{
return itemInfo;
}
}
return null;
//throw new InvalidDataException(string.Format("ItemInfo {0} not found", itemInfoName));
}
public ListItem GetListItemByName(string listItemName)
{
foreach (ListItem listItem in ListItemList)
{
if (listItem.ClassName == listItemName)
{
return listItem;
}
}
return null;
//throw new InvalidDataException(string.Format("ListItem {0} not found", listItemList));
}
#endregion Public Methods
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.