拜读websharp时,发现的几处问题(三)
6.在DEMO项目Ioffice中也有一些小问题,对于Ioffice.Interfaces项目中,实现对Schdule实体的操作接口ISchduleSystem 用此接口来实现对Schdule实现的操作,咋一看非常不错,但仔细想想还是有些小问题。问题在于,如果按照上面的实现 方式,我们需要对所有的实体都写一个相当于上面的接口来实现对每个实体的操作,如果能再次对实体进行抽象,改成一个通用的实体操作接口,是不是更好一些呢?
代码如下:
1
using System;
2
using Ioffice.Interfaces.EntityDefinition;
3
using Websharp.ORM.Base;
4
5
namespace Ioffice.Interfaces
6

using System;2
using Ioffice.Interfaces.EntityDefinition;3
using Websharp.ORM.Base;4

5
namespace Ioffice.Interfaces6


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Xml;
using System.Xml.Serialization;
using Ioffice.Interfaces;
using Ioffice.Interfaces.EntityDefinition;
using Websharp.Data;
using Websharp.ORM.Base;
using Websharp.ORM.Service;
namespace Ioffice.Interfaces


1
using System;
2
using Websharp.Data;
3
using Websharp.ORM.Base;
4
5
namespace Ioffice.Interfaces
6
{
7
/// <summary>
8
/// OjbectDALSystemFactory
9
/// </summary>
10
public class ObjectDALSystemFactory
11
{
12
private ObjectDALSystemFactory(){}
13
14
private static ObjectDALSystemFactory m_ObjectDALSystemFactory = new ObjectDALSystemFactory();
15
16
public static ObjectDALSystemFactory Instance()
17
{
18
return m_ObjectDALSystemFactory;
19
}
20
public IObjectSystem CreateIObjectSystem()
21
{
22
return p_CreateIObjectSystem();
23
}
24
25
private IObjectSystem p_CreateIObjectSystem()
26
{
27
return new ObjectDALSystem();
28
}
29
}
30
}
31
使用方法如下:
using System;2
using Websharp.Data;3
using Websharp.ORM.Base;4

5
namespace Ioffice.Interfaces6
{7
/// <summary>8
/// OjbectDALSystemFactory9
/// </summary>10
public class ObjectDALSystemFactory11
{12
private ObjectDALSystemFactory(){}13

14
private static ObjectDALSystemFactory m_ObjectDALSystemFactory = new ObjectDALSystemFactory();15

16
public static ObjectDALSystemFactory Instance()17
{18
return m_ObjectDALSystemFactory;19
}20
public IObjectSystem CreateIObjectSystem()21
{22
return p_CreateIObjectSystem();23
}24

25
private IObjectSystem p_CreateIObjectSystem()26
{27
return new ObjectDALSystem();28
}29
}30
}31

1
T1 t1 = EntityManager.CreateObject(typeof(T1)) as T1;
2
t1.A = "3333";
3
t1.B = null;
4
t1.C= 199;
5
t1.D = System.DateTime.Now;
6
t1.F = 2;
7
8
IObjectSystem IOS = ObjectDALSystemFactory.Instance().CreateIObjectSystem();
9
10
IOS.AddObject(t1);
T1 t1 = EntityManager.CreateObject(typeof(T1)) as T1;2
t1.A = "3333";3
t1.B = null;4
t1.C= 199;5
t1.D = System.DateTime.Now;6
t1.F = 2;7

8
IObjectSystem IOS = ObjectDALSystemFactory.Instance().CreateIObjectSystem();9

10
IOS.AddObject(t1);
浙公网安备 33010602011771号