Commit for development environment setup
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class CommandObject : CommandBase
|
||||
{
|
||||
#region Authorization Methods
|
||||
|
||||
public static bool CanExecuteCommand()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Client-side Code
|
||||
|
||||
// TODO: add your own fields and properties
|
||||
bool _result;
|
||||
|
||||
public bool Result
|
||||
{
|
||||
get { return _result; }
|
||||
}
|
||||
|
||||
private void BeforeServer()
|
||||
{
|
||||
// TODO: implement code to run on client
|
||||
// before server is called
|
||||
}
|
||||
|
||||
private void AfterServer()
|
||||
{
|
||||
// TODO: implement code to run on client
|
||||
// after server is called
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static bool Execute()
|
||||
{
|
||||
CommandObject cmd = new CommandObject();
|
||||
cmd.BeforeServer();
|
||||
cmd = DataPortal.Execute<CommandObject>(cmd);
|
||||
cmd.AfterServer();
|
||||
return cmd.Result;
|
||||
}
|
||||
|
||||
private CommandObject()
|
||||
{ /* require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Server-side Code
|
||||
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
// TODO: implement code to run on server
|
||||
// and set result value(s)
|
||||
_result = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
[Serializable()]
|
||||
public class DynamicRootList :
|
||||
EditableRootListBase<EditableRoot>
|
||||
{
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static DynamicRootList NewDynamicRootList()
|
||||
{
|
||||
return new DynamicRootList();
|
||||
}
|
||||
|
||||
public static DynamicRootList GetDynamicRootList()
|
||||
{
|
||||
return DataPortal.Fetch<DynamicRootList>();
|
||||
}
|
||||
|
||||
private DynamicRootList()
|
||||
{
|
||||
// require use of factory methods
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
private void DataPortal_Fetch()
|
||||
{
|
||||
|
||||
// TODO: load values
|
||||
RaiseListChangedEvents = false;
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
Add(EditableRoot.GetEditableRoot(dr));
|
||||
}
|
||||
}
|
||||
RaiseListChangedEvents = true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class EditableChild : BusinessBase<EditableChild>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
// TODO: add your own fields, properties and methods
|
||||
private int _id;
|
||||
|
||||
public int id
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _id;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation Rules
|
||||
|
||||
protected override void AddBusinessRules()
|
||||
{
|
||||
// TODO: add validation rules
|
||||
//ValidationRules.AddRule(null, "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
// TODO: add authorization rules
|
||||
//AuthorizationRules.AllowWrite("", "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
internal static EditableChild NewEditableChild()
|
||||
{
|
||||
// TODO: change to use new keyword if not loading defaults
|
||||
//return new EditableChild();
|
||||
return DataPortal.Create<EditableChild>();
|
||||
}
|
||||
|
||||
internal static EditableChild GetEditableChild(SqlDataReader dr)
|
||||
{
|
||||
return new EditableChild(dr);
|
||||
}
|
||||
|
||||
private EditableChild()
|
||||
{
|
||||
MarkAsChild();
|
||||
}
|
||||
|
||||
private EditableChild(SqlDataReader dr)
|
||||
{
|
||||
MarkAsChild();
|
||||
Fetch(dr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
protected override void DataPortal_Create()
|
||||
{
|
||||
// TODO: load default values, or remove method
|
||||
}
|
||||
|
||||
private void Fetch(SqlDataReader dr)
|
||||
{
|
||||
// TODO: load values
|
||||
MarkOld();
|
||||
}
|
||||
|
||||
internal void Insert(object parent)
|
||||
{
|
||||
// TODO: insert values
|
||||
MarkOld();
|
||||
}
|
||||
|
||||
internal void Update(object parent)
|
||||
{
|
||||
// TODO: update values
|
||||
MarkOld();
|
||||
}
|
||||
|
||||
internal void DeleteSelf()
|
||||
{
|
||||
// TODO: delete values
|
||||
MarkNew();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class EditableChildList :
|
||||
BusinessListBase<EditableChildList, EditableChild>
|
||||
{
|
||||
#region Factory Methods
|
||||
|
||||
internal static EditableChildList NewEditableChildList()
|
||||
{
|
||||
return new EditableChildList();
|
||||
}
|
||||
|
||||
internal static EditableChildList GetEditableChildList(
|
||||
SqlDataReader dr)
|
||||
{
|
||||
return new EditableChildList(dr);
|
||||
}
|
||||
|
||||
private EditableChildList()
|
||||
{
|
||||
MarkAsChild();
|
||||
}
|
||||
|
||||
private EditableChildList(SqlDataReader dr)
|
||||
{
|
||||
MarkAsChild();
|
||||
Fetch(dr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
private void Fetch(SqlDataReader dr)
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
while (dr.Read())
|
||||
{
|
||||
this.Add(EditableChild.GetEditableChild(dr));
|
||||
}
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
internal void Update(object parent)
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
foreach (EditableChild item in DeletedList)
|
||||
item.DeleteSelf();
|
||||
DeletedList.Clear();
|
||||
|
||||
foreach (EditableChild item in this)
|
||||
if (item.IsNew)
|
||||
item.Insert(parent);
|
||||
else
|
||||
item.Update(parent);
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class EditableRoot : BusinessBase<EditableRoot>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
// TODO: add your own fields, properties and methods
|
||||
private int _id;
|
||||
|
||||
public int id
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _id;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation Rules
|
||||
|
||||
protected override void AddBusinessRules()
|
||||
{
|
||||
// TODO: add validation rules
|
||||
//ValidationRules.AddRule(null, "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
// TODO: add authorization rules
|
||||
//AuthorizationRules.AllowWrite("", "");
|
||||
}
|
||||
|
||||
public static bool CanAddObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanDeleteObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static EditableRoot NewEditableRoot()
|
||||
{
|
||||
return DataPortal.Create<EditableRoot>();
|
||||
}
|
||||
|
||||
public static EditableRoot GetEditableRoot(int id)
|
||||
{
|
||||
return DataPortal.Fetch<EditableRoot>(new Criteria(id));
|
||||
}
|
||||
|
||||
public static void DeleteEditableRoot(int id)
|
||||
{
|
||||
DataPortal.Delete(new Criteria(id));
|
||||
}
|
||||
|
||||
private EditableRoot()
|
||||
{ /* Require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class Criteria
|
||||
{
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
public Criteria(int id)
|
||||
{ _id = id; }
|
||||
}
|
||||
|
||||
protected override void DataPortal_Create()
|
||||
{
|
||||
// TODO: load default values
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(Criteria criteria)
|
||||
{
|
||||
// TODO: load values
|
||||
}
|
||||
|
||||
protected override void DataPortal_Insert()
|
||||
{
|
||||
// TODO: insert values
|
||||
}
|
||||
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
// TODO: update values
|
||||
}
|
||||
|
||||
protected override void DataPortal_DeleteSelf()
|
||||
{
|
||||
DataPortal_Delete(new Criteria(_id));
|
||||
}
|
||||
|
||||
private void DataPortal_Delete(Criteria criteria)
|
||||
{
|
||||
// TODO: delete values
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class EditableRootList :
|
||||
BusinessListBase<EditableRootList, EditableChild>
|
||||
{
|
||||
#region Authorization Rules
|
||||
|
||||
public static bool CanAddObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanDeleteObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static EditableRootList NewEditableRootList()
|
||||
{
|
||||
return new EditableRootList();
|
||||
}
|
||||
|
||||
public static EditableRootList GetEditableRootList(int id)
|
||||
{
|
||||
return DataPortal.Fetch<EditableRootList>(new Criteria(id));
|
||||
}
|
||||
|
||||
private EditableRootList()
|
||||
{ /* Require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class Criteria
|
||||
{
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
public Criteria(int id)
|
||||
{ _id = id; }
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(Criteria criteria)
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
// TODO: load values
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
this.Add(EditableChild.GetEditableChild(dr));
|
||||
}
|
||||
}
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
foreach (EditableChild item in DeletedList)
|
||||
item.DeleteSelf();
|
||||
DeletedList.Clear();
|
||||
|
||||
foreach (EditableChild item in this)
|
||||
if (item.IsNew)
|
||||
item.Insert(this);
|
||||
else
|
||||
item.Update(this);
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class EditableRootParent : BusinessBase<EditableRootParent>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
private int _id;
|
||||
private EditableChildList _children =
|
||||
EditableChildList.NewEditableChildList();
|
||||
|
||||
public int id
|
||||
{
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _id;
|
||||
}
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public EditableChildList Children
|
||||
{
|
||||
get { return _children; }
|
||||
}
|
||||
|
||||
public override bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsValid && _children.IsValid;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsDirty || _children.IsDirty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation Rules
|
||||
|
||||
protected override void AddBusinessRules()
|
||||
{
|
||||
// TODO: add validation rules
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
// TODO: add authorization rules
|
||||
}
|
||||
|
||||
public static bool CanAddObject()
|
||||
{
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
public static bool CanDeleteObject()
|
||||
{
|
||||
return ApplicationContext.User.IsInRole("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static EditableRootParent NewEditableRootParent()
|
||||
{
|
||||
return DataPortal.Create<EditableRootParent>();
|
||||
}
|
||||
|
||||
public static EditableRootParent GetEditableRootParent(int id)
|
||||
{
|
||||
return DataPortal.Create<EditableRootParent>(new Criteria(id));
|
||||
}
|
||||
|
||||
public static void DeleteEditableRootParent(int id)
|
||||
{
|
||||
DataPortal.Delete(new Criteria(id));
|
||||
}
|
||||
|
||||
private EditableRootParent()
|
||||
{ /* Require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class Criteria
|
||||
{
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
public Criteria(int id)
|
||||
{ _id = id; }
|
||||
}
|
||||
|
||||
protected override void DataPortal_Create()
|
||||
{
|
||||
// TODO: load default values
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(Criteria criteria)
|
||||
{
|
||||
// TODO: load values
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
_children =
|
||||
EditableChildList.GetEditableChildList(dr);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DataPortal_Insert()
|
||||
{
|
||||
// TODO: insert values
|
||||
_children.Update(this);
|
||||
}
|
||||
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
// TODO: update values
|
||||
_children.Update(this);
|
||||
}
|
||||
|
||||
protected override void DataPortal_DeleteSelf()
|
||||
{
|
||||
DataPortal_Delete(new Criteria(_id));
|
||||
}
|
||||
|
||||
private void DataPortal_Delete(Criteria criteria)
|
||||
{
|
||||
// TODO: delete values
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class NameValueList : NameValueListBase<int, string>
|
||||
{
|
||||
#region Factory Methods
|
||||
|
||||
private static NameValueList _list;
|
||||
|
||||
public static NameValueList GetNameValueList()
|
||||
{
|
||||
if (_list == null)
|
||||
_list = DataPortal.Fetch<NameValueList>(
|
||||
new Criteria(typeof(NameValueList)));
|
||||
return _list;
|
||||
}
|
||||
|
||||
public static void InvalidateCache()
|
||||
{
|
||||
_list = null;
|
||||
}
|
||||
|
||||
private NameValueList()
|
||||
{ /* require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
protected override void DataPortal_Fetch(object criteria)
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
IsReadOnly = false;
|
||||
// TODO: load values
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
Add(new NameValueListBase<int, string>.
|
||||
NameValuePair(dr.GetInt32(0), dr.GetString(1)));
|
||||
}
|
||||
}
|
||||
IsReadOnly = true;
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Templates")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Magenic Technologies")]
|
||||
[assembly: AssemblyProduct("Templates")]
|
||||
[assembly: AssemblyCopyright("Copyright © Magenic Technologies 2006")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0e5f6790-52c6-495d-87ec-ec3dc6f1ea22")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class ReadOnlyChild : ReadOnlyBase<ReadOnlyChild>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
// TODO: add your own fields, properties and methods
|
||||
private int _id;
|
||||
private string _data = string.Empty;
|
||||
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
|
||||
public string Data
|
||||
{
|
||||
get { return _data; }
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
internal static ReadOnlyChild GetReadOnlyChild(SqlDataReader dr)
|
||||
{
|
||||
return new ReadOnlyChild(dr);
|
||||
}
|
||||
|
||||
private ReadOnlyChild()
|
||||
{ /* require use of factory methods */ }
|
||||
|
||||
private ReadOnlyChild(SqlDataReader dr)
|
||||
{
|
||||
Fetch(dr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
private void Fetch(SqlDataReader dr)
|
||||
{
|
||||
// load values
|
||||
_id = dr.GetInt32(0);
|
||||
_data = dr.GetString(1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class ReadOnlyList :
|
||||
ReadOnlyListBase<ReadOnlyList, ReadOnlyChild>
|
||||
{
|
||||
#region Authorization Rules
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static ReadOnlyList GetReadOnlyList(string filter)
|
||||
{
|
||||
return DataPortal.Fetch<ReadOnlyList>(new Criteria(filter));
|
||||
}
|
||||
|
||||
private ReadOnlyList()
|
||||
{ /* require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class Criteria
|
||||
{
|
||||
private string _filter;
|
||||
public string Filter
|
||||
{
|
||||
get { return _filter; }
|
||||
}
|
||||
public Criteria(string filter)
|
||||
{
|
||||
_filter = filter;
|
||||
}
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(Criteria criteria)
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
IsReadOnly = false;
|
||||
// TODO: load values
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
while (dr.Read())
|
||||
Add(ReadOnlyChild.GetReadOnlyChild(dr));
|
||||
}
|
||||
IsReadOnly = true;
|
||||
RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class ReadOnlyRoot : ReadOnlyBase<ReadOnlyRoot>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
// TODO: add your own fields, properties and methods
|
||||
private int _id;
|
||||
|
||||
public int Id
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
// TODO: add authorization rules
|
||||
//AuthorizationRules.AllowRead("", "");
|
||||
}
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static ReadOnlyRoot GetReadOnlyRoot(int id)
|
||||
{
|
||||
return DataPortal.Fetch<ReadOnlyRoot>(new Criteria(id));
|
||||
}
|
||||
|
||||
private ReadOnlyRoot()
|
||||
{ /* require use of factory methods */ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class Criteria
|
||||
{
|
||||
private int _id;
|
||||
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
public Criteria(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(Criteria criteria)
|
||||
{
|
||||
// TODO: load values
|
||||
_id = criteria.Id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
|
||||
namespace Templates
|
||||
{
|
||||
[Serializable()]
|
||||
class SwitchableObject : BusinessBase<SwitchableObject>
|
||||
{
|
||||
#region Business Methods
|
||||
|
||||
// TODO: add your own fields, properties and methods
|
||||
private int _id;
|
||||
|
||||
public int id
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _id;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation Rules
|
||||
|
||||
protected override void AddBusinessRules()
|
||||
{
|
||||
// TODO: add validation rules
|
||||
//ValidationRules.AddRule(null, "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Authorization Rules
|
||||
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
// TODO: add authorization rules
|
||||
//AuthorizationRules.AllowWrite("", "");
|
||||
}
|
||||
|
||||
public static bool CanAddObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanDeleteObject()
|
||||
{
|
||||
// TODO: customize to check user role
|
||||
//return ApplicationContext.User.IsInRole("");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Factory Methods
|
||||
|
||||
public static SwitchableObject NewSwitchableRoot()
|
||||
{
|
||||
return DataPortal.Create<SwitchableObject>(
|
||||
new RootCriteria());
|
||||
}
|
||||
|
||||
internal static SwitchableObject NewSwitchableChild()
|
||||
{
|
||||
return DataPortal.Create<SwitchableObject>(
|
||||
new ChildCriteria());
|
||||
}
|
||||
|
||||
public static SwitchableObject GetSwitchableRoot(int id)
|
||||
{
|
||||
return DataPortal.Fetch<SwitchableObject>(
|
||||
new RootCriteria(id));
|
||||
}
|
||||
|
||||
internal static SwitchableObject GetSwitchableChild(
|
||||
SqlDataReader dr)
|
||||
{
|
||||
return new SwitchableObject(dr);
|
||||
}
|
||||
|
||||
public static void DeleteSwitchableObject(int id)
|
||||
{
|
||||
DataPortal.Delete(new RootCriteria(id));
|
||||
}
|
||||
|
||||
private SwitchableObject()
|
||||
{ /* Require use of factory methods */ }
|
||||
|
||||
private SwitchableObject(SqlDataReader dr)
|
||||
{
|
||||
Fetch(dr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Access
|
||||
|
||||
[Serializable()]
|
||||
private class RootCriteria
|
||||
{
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
public RootCriteria(int id)
|
||||
{ _id = id; }
|
||||
public RootCriteria()
|
||||
{ }
|
||||
}
|
||||
|
||||
[Serializable()]
|
||||
private class ChildCriteria
|
||||
{ }
|
||||
|
||||
private void DataPortal_Create(RootCriteria criteria)
|
||||
{
|
||||
DoCreate();
|
||||
}
|
||||
|
||||
private void DataPortal_Create(ChildCriteria criteria)
|
||||
{
|
||||
MarkAsChild();
|
||||
DoCreate();
|
||||
}
|
||||
|
||||
private void DoCreate()
|
||||
{
|
||||
// TODO: load default values
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(RootCriteria criteria)
|
||||
{
|
||||
// TODO: create data reader to load values
|
||||
using (SqlDataReader dr = null)
|
||||
{
|
||||
DoFetch(dr);
|
||||
}
|
||||
}
|
||||
|
||||
private void Fetch(SqlDataReader dr)
|
||||
{
|
||||
MarkAsChild();
|
||||
DoFetch(dr);
|
||||
}
|
||||
|
||||
private void DoFetch(SqlDataReader dr)
|
||||
{
|
||||
// TODO: load values
|
||||
}
|
||||
|
||||
protected override void DataPortal_Insert()
|
||||
{
|
||||
// TODO: insert values
|
||||
}
|
||||
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
// TODO: update values
|
||||
}
|
||||
|
||||
protected override void DataPortal_DeleteSelf()
|
||||
{
|
||||
DataPortal_Delete(new RootCriteria(_id));
|
||||
}
|
||||
|
||||
private void DataPortal_Delete(RootCriteria criteria)
|
||||
{
|
||||
// TODO: delete values
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{614537E1-9171-4052-BA7C-044CE96BBD62}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Templates</RootNamespace>
|
||||
<AssemblyName>Templates</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Csla, Version=2.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Csla\bin\Debug\Csla.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommandObject.cs" />
|
||||
<Compile Include="DynamicRootList.cs" />
|
||||
<Compile Include="EditableChild.cs" />
|
||||
<Compile Include="EditableChildList.cs" />
|
||||
<Compile Include="EditableRoot.cs" />
|
||||
<Compile Include="EditableRootList.cs" />
|
||||
<Compile Include="EditableRootParent.cs" />
|
||||
<Compile Include="NameValueList.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReadOnlyChild.cs" />
|
||||
<Compile Include="ReadOnlyList.cs" />
|
||||
<Compile Include="ReadOnlyRoot.cs" />
|
||||
<Compile Include="SwitchableObject.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Templates", "Templates.csproj", "{614537E1-9171-4052-BA7C-044CE96BBD62}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{614537E1-9171-4052-BA7C-044CE96BBD62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{614537E1-9171-4052-BA7C-044CE96BBD62}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{614537E1-9171-4052-BA7C-044CE96BBD62}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{614537E1-9171-4052-BA7C-044CE96BBD62}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Reference in New Issue
Block a user