请问关于c的具体应用场景有哪些?

2026-04-29 01:242阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计314个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

plaintext定义一个领域对象类和仓储接口:public class DomainObjectT, TRepo where T : DomainObjectT where TRepo : IRepository{ public static TRepo Repository { get; private set; }}

仓储接口:public interface IRepository { // 注释:T 为领域对象类型}

我有以下域对象:

public class DomainObject<T,TRepo> where T : DomainObject<T> where TRepo : IRepository<T> { public static TRepo Repository { get;private set; } }

存储库接口:

public interface IRepository<T> //where T : DomainObject<T> // The catch 22 { void Save(T domainObject); }

2的实现:

public class User : DomainObject<User,MyRepository> { public string Name { get;private set;} } public class MyRepository : IRepository<User> { public List<User> UsersWithNameBob() { } }

所以添加另一个不在IRepository中的方法.

我想将存储库强制为IRepository,而在它上面它可以是任何类型.

一个小旁注:我正在为很少有域对象的小型系统编写这个.我不打算创建任何使用IoC的东西,而是简单易用的东西.

谢谢

不完全确定你想要什么,但这样的东西编译:

请问关于c的具体应用场景有哪些?

public class DomainObject<T, TRepo> where T: DomainObject<T, TRepo> where TRepo: IRepository<T, TRepo> { public static TRepo Repository { get; private set; } } public interface IRepository<T, TRepo> where T: DomainObject<T, TRepo> where TRepo: IRepository<T, TRepo> { void Save(T domainObject); }

本文共计314个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

plaintext定义一个领域对象类和仓储接口:public class DomainObjectT, TRepo where T : DomainObjectT where TRepo : IRepository{ public static TRepo Repository { get; private set; }}

仓储接口:public interface IRepository { // 注释:T 为领域对象类型}

我有以下域对象:

public class DomainObject<T,TRepo> where T : DomainObject<T> where TRepo : IRepository<T> { public static TRepo Repository { get;private set; } }

存储库接口:

public interface IRepository<T> //where T : DomainObject<T> // The catch 22 { void Save(T domainObject); }

2的实现:

public class User : DomainObject<User,MyRepository> { public string Name { get;private set;} } public class MyRepository : IRepository<User> { public List<User> UsersWithNameBob() { } }

所以添加另一个不在IRepository中的方法.

我想将存储库强制为IRepository,而在它上面它可以是任何类型.

一个小旁注:我正在为很少有域对象的小型系统编写这个.我不打算创建任何使用IoC的东西,而是简单易用的东西.

谢谢

不完全确定你想要什么,但这样的东西编译:

请问关于c的具体应用场景有哪些?

public class DomainObject<T, TRepo> where T: DomainObject<T, TRepo> where TRepo: IRepository<T, TRepo> { public static TRepo Repository { get; private set; } } public interface IRepository<T, TRepo> where T: DomainObject<T, TRepo> where TRepo: IRepository<T, TRepo> { void Save(T domainObject); }