---------------------------------------------------
CSLA 3.5 CodeSmith Templates for C#
Version: Preview Release
Released: October 4, 2006
Author: Ricky A. Supit (rsupit@hotmail.com)
Download Site: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=CSLAcontrib
---------------------------------------------------
This is a collection of CodeSmith templates to generate CSLA 3.5 business object for C#. In this version I choose to drop the split method using base class since the new compiler trick with partial method provide much better implementation.
This is a collection of CodeSmith templates to generate CSLA 3.5 business object for C#. I completely rewrote the 1.x version in order to support code generation from xml file. In addition to support xml data source, there are numbers of new features that was added such as view as data source, and partial class generation.
Unlike version 1.x, these templates no longer used TableSchema and ColumnSchema directly as data source to generate Csla business object. The current template uses custom classes called ObjectInfo and PropertyInfo. This implementation permits one template to have multiple data sources such as table, view, and xml file.
This collection templates is design to work with the freeware version (v2.6) of CodeSmith and has not been tested with other version.
This set of templates and the template base support code are provided free charge. You're free to use and modify anyway you want it. The only request is for you to give back and share any improvement made to these templates if you feel many would benefit from it. I reserve the right to include (or not include) any of your improvements in future version and in return give credit to you.
Enjoy them,
Ricky Supit
===================================================
Contributor(s)
===================================================
- Tom Cooley (TEC)
Stored Procedure support.
===================================================
Known Issues
===================================================
- Split class by using partial classes requires Csla Framework version 2.0.1 or later. Initialize() method was added in this version so hook for validation rules can be initialized before AddBusinessRules method is called.
- Split class by using base/abstract class requires Csla Framework version 2.0.1 or later. The earlier version was not able to find DataPortal_xxx methods when it's in generic abstract class.
===================================================
How to Use
===================================================
Method A:
Generate single Business Object by directly open specific template for Csla object type.
1. Double click on template based on Csla object type.
2. Enter the following:
- ClassNamespace: type namespace of your generated object.
- ObjectName: type name of your generated object.
3. If you choose to generate your class based on a table
- RootTable: select table from table picker.
If you choose to generate your class based on a view
- RootView: select view from view picker.
- UniqueColumnNames: type unique column(s) on selected view.
If you choose to generate your class based on StoredProcedure (Fetch SP).
- RootCommand: select stored procedure from stored procedure picker.
- ResultSetIndex: change this value is the index is different from the result sets returned from sp. (this is usually the case for child object)
- UniqueColumnNames: required for child objects; type unique columns of chosen (ResultSetIndex) result set.
4. Based on your generation method, enter the following:
- GenerationMethod: Select one:
Single: to generate once and modify it as needed.
SplitBase: split classes using abstract class as base and implemented on user class.
SplitPartial: split classes using partial classes.
- ClassType: if you choose split method, select either 'generated' or 'user' class.
5. Security options on your generated object.
- AuthorizationRules: 'True' to include access security in factory methods.
- PropertyAuthorization:
To include property level access security. options are 'Both', 'Read', 'Write'
6. Click Generate Button to generate code.
7. Copy the generated template output and paste it into your project.
Method B:
Generate single Business Object by open a master template
1. Double click on Csla.cst
2. Enter the following:
- OutputToFile: 'True' to generate as file, or 'False' to generate on template output screen.
- OutputDirectory: select folder where output file will be generated.
- Template: select Csla object type.
3. Follow step 2 to 6 of Method A.
4. If you choose OutputToFile=False, Copy the generated template output and paste it into your project.
Method C:
Generate multiple Business Objects using xml source file.
1. Double click on CslaXml.cst
2. Enter the following:
- OutputToFile: 'True' to generate as file, or 'False' to generate on template output screen.
- OutputDirectory: select folder where output file will be generated.
- XmlFileName: select xml file from file picker.
3. Click Generate Button to generate files.
===================================================
Templates
===================================================
- EditableRoot (ER)
- EditableRootList (ERL)
- EditableChild (EC)
- EditableChildList (ECL)
- EditableSwitchable (ES)
- ReadOnlyRoot (ROR)
- ReadOnlyRootList (RORL)
- ReadOnlyChild (ROC)
- ReadOnlyChildList (ROCL)
- NameValueList (NVL)
- Csla
- CslaXml
===================================================
Parameters
===================================================
--------------------------------------------------------------------------------------------
Parameter Description Template
--------------------------------------------------------------------------------------------
ClassNameSpace Namespace of your generated object All
ObjectName Name of your generated object. All
ParentName Name of your parent object. EC, ECL, ES
ChildName Name of your list item/child object. ERL, ECL, RORL, ROCL
RootTable DB Table name to be used as data source. All
RootView DB View name to be used as data source. All
RootCommand DB Stored Procedure to be used as data source. All
XmlFileName Xml file contains metadata that describe CslaXml
the objects.
ResultSetIndex Result set index (zero based) which result set All
to use from the stored procedure.
UniqueColumnNames Unique column name(s) when RootView or ER, EC, ROR, ROC, ES
RootCommand is the data source.
FilterColumnNames Filter column name(s) as retrieve criteria ERL, RORL
when RootView is the data source.
ChildCollectionTypes Child collection object name(s). ER, EC, ROR, ROC, ES
ChildPropertyNames Property name(s) accessing the child ER, EC, ROR, ROC, ES
collection object(s).
AuthorizationRules Option to include/exclude access security All
in factory methods.
PropertyAuthrization Option to include/exclude property level All
access security.
- Read : Access security on property getter.
- Write : Access security on property setter.
- Both : Access security on both getter and
setter
TransactionalType Data access transactional type. All
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这个是在CSLA 3.5的版本上改的,只适合我自己方式,修改也数据访问的方法。原来使用是Linq to SQL,我改成自己采用的SafeDataReader的方式 CSLA 3.5 CodeSmith Templates for C# Version: Preview Release Released: October 4, 2006 Author: Ricky A. Supit (rsupit@hotmail.com) Download Site: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=CSLAcontrib
资源推荐
资源详情
资源评论
收起资源包目录
CSLA36.rar (35个子文件)
CSLA36
DataPortalFetchList.inc 2KB
DataPortalCreate.inc 1016B
ChildCreate.inc 1KB
ReadOnlyRootList.cst 4KB
ReadOnlyRoot.cst 3KB
CslaXml.cst 6KB
EditableRootList.cst 5KB
ValidationRules.inc 472B
TemplateBase.cs 91KB
ReadOnlyChildList.cst 3KB
ObjectFactoryMethods.inc 1KB
ChildDelete.inc 2KB
ChildFetch.inc 2KB
AuthorizationRules.inc 2KB
ChildUpdate.inc 5KB
PropertiesMethods.inc 3KB
EditableRoot.cst 3KB
MySample.xml 3KB
EditableChildList.cst 3KB
EditableChild.cst 4KB
DataPortalFetch.inc 2KB
Readme.txt 11KB
RevisionHistory.txt 721B
AutoGenWarning.inc 710B
ChildFetchList.inc 1KB
ReadOnlyChild.cst 4KB
ReadOnlyProperties.inc 732B
ChildFactoryMethods.inc 936B
DataPortalUpdate.inc 3KB
DataPortalFetchList2.inc 3KB
ObjectCriteria.inc 624B
Csla.cst 7KB
DataPortalDelete.inc 2KB
CslaProject.xsd 8KB
FilterCriteria.inc 578B
共 35 条
- 1
资源评论
大聪
- 粉丝: 289
- 资源: 64
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功