zoukankan      html  css  js  c++  java
  • 拜读websharp时,发现的几处问题(三)


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

     1using System;
     2using Websharp.Data;
     3using Websharp.ORM.Base;
     4
     5namespace 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

    使用方法如下:
     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);
     
  • 相关阅读:
    Thinkphp6.0/TP6框架中新增函数的解释及用法
    PHP7.1的几个新特性
    tp6数据库mysql调试
    nginx基本配置
    redis配置
    redis的笔记
    thinkphp学习笔记
    vsCode软件相关快捷键
    erlang随笔3--OTP
    文献综述二十:基于UML技术的客户关系管理系统实现
  • 原文地址:https://www.cnblogs.com/linfuguo/p/336718.html
Copyright © 2011-2022 走看看