首页 \ 问答 \ 架构问题:共享同类库的解决方案;(Architectural questions: solutions sharing same class libraries; project promotion; forking solutions)

架构问题:共享同类库的解决方案;(Architectural questions: solutions sharing same class libraries; project promotion; forking solutions)

我非常需要了解如何使用Visual Studio 2010管理c#中的一些非常基本的架构问题,我在查找教科书和网站中的解决方案时遇到了一些麻烦。 假设我有一个MyWinForm.sln解决方案基于:MyWinForm.cs和两个类库,让我们说:a.dll,b.dll我的目标:我想重构我编写的应用程序只是为了学习C#的顺序拥有一个体面的应用程序架构。

  1. 我希望设计一个必须包含通用方法的c.dll,以便在不同的应用程序中重用它:MyWinForm和yawfs.sln(还有另一个Windows窗体解决方案),以便我可以创建对c的引用。来自两个解决方案的DLL。 我想我应该创建一个新的类库解决方案 ,以便重用它的类。 但是,据我所知,我无法添加对不同解决方案的引用:我只能在当前解决方案(当前解决方案中的不同项目)或.Net程序集中添加对程序集的引用。 我应该使用导航面板选择a.dll程序集来添加对它的引用吗? 也许有一种方法可以将现有的程序集包含在当前的解决方案中,使其与相应解决方案中执行的更改保持同步? 我不明白。

  2. 如果我想从MyWinForm中提取b.dll来提升它以便服务于c.dll的相同目的,该怎么办? 我如何将其推广为新的解决方案?

  3. 现在让我们说我需要分叉MyWinForm,这样我就可以拥有MyWinFormLeft.sln和MyWinFormRight.sln; 两者都将以不同于普通共享代码的方式发展。 他们将使用(和共享)相同的a.dll和b.dll程序集(相同版本),但MyWinForm.cs中的代码将开始更改。 从现有解决方案创建新解决方案的正确方法是什么?

我知道我的问题听起来很混乱,但问题来自于我试图在我和前一段时间使用的C编译器/链接器循环的联合VS和C#使用模式之间进行的比较:编译代码以获取您的库然后链接到他们无论应用需要什么。 期。


I badly need to understand how to manage some very basic architectural issues in c# using Visual Studio 2010 and I have some trouble in finding solutions in textbooks and web sites. Let's say I have a MyWinForm.sln solution which is based on: MyWinForm.cs and two class libraries, let's say: a.dll, b.dll My aim: I want to refactor the application I have coded just to learn C# in order to have a decent application architecture.

  1. I wish to design a c.dll that must contain general purpose methods in order to reuse it in different applications: both MyWinForm and, let's say, yawfs.sln (yet another windows form solution) so that I could create a reference to c.dll from both the solutions. I guess that I should create a new class library solution in order to reuse its classes. But, as far as I know, I cannot add a reference to a different solution: I can only add references to assemblies within the current solutions (different projects within the current solution) or to .Net assemblies. Should i use the navigation panel to select the a.dll assembly to add the reference to it? Maybe there is a way to include an existing assembly to the current solution keeping it in sync with changes performed within the corresponding solution? I do not understand.

  2. What if I wish to extract b.dll from MyWinForm promoting it in order to serve to the very same purpose of c.dll? How I can promote it as a new solution?

  3. Now let's say that I need to fork MyWinForm so that I'll have MyWinFormLeft.sln and MyWinFormRight.sln; both will evolve in a different manner from a common shared code. They will use (and share) the very same a.dll and b.dll assemblies (same version) but the code in MyWinForm.cs will start to change. What is the correct method to create a new solution from the existing one?

I know that my questions sound quite messy but the trouble come from the comparison I am trying to perform between the joint VS and C# usage pattern against the C compiler/linker cycle I used time ago: compile the code to get your libraries then link to them whatever application need them. Period.


原文:https://stackoverflow.com/questions/15165180
更新时间:2022-04-04 19:04

最满意答案

应用程序中的所有数据访问对象( xxxDAOBean )都扩展了GenericDAOBeanGenericDAOBean合并方法是:

public T merge(T entity) {
    entity = em.merge(entity);
    return entity;
}

其中T是实体的类型。 因此,对于post对象(实体类型Post ),合并应该与postDao.merge(post);


All Data Access Objects in application (xxxDAOBean) extend GenericDAOBean, and merging method in GenericDAOBean is:

public T merge(T entity) {
    entity = em.merge(entity);
    return entity;
}

where T is type of an entity. So, for post object (entity type Post), merging should be used with postDao.merge(post);

相关问答

更多
  • 经过大量调查后,我发现: 它没有按预期工作,因为我将@ManyToOne和@JoinTable注释放在属性级别。 我手工创建了一个getter,并在其上添加了注释,并将它们考虑在内 它仍然无法正常工作,因为Hibernate在运行时没有在USAGE_LOG_PAGE表中找到“USER_ACTION_ID”列。 由于某种原因(我没有找到),这一栏不在可用字段中。 在实体“UsageLogPage”中添加字段“usage_action_id”时,它找到该属性,但拒绝创建映射,因为USAGE_ACTION_ID不 ...
  • 我猜这是使用@JsonIdentityInfo的结果。 通过使用该注释,您可以告诉它响应应该包含一个完全序列化的实例,然后返回引用该完全序列化实例的ID。 I'm guessing this is a result of using @JsonIdentityInfo. By using that annotation, you're telling it that the response should include one fully serialized instance and subsequen ...
  • 好吧,你可以简化你的代码,有这样的东西 @Transactional public void save(User user, String name) { Hometown hometown = getEntityManager().createQuery("SELECT h FROM Hometown h WHERE h.name = :name", Hometown.class).setParameter("name", name).getSingleResult(); if (home ...
  • 您应该能够发出以下查询来实现您的目标: SELECT b FROM BuyerEntity b JOIN FETCH b.employee 您会注意到我正在应用JOIN FETCH ,它告诉Hibernate不仅要将EmployeeEntity表与BuyerEntity表连接起来,还要将数据作为对数据库的单个查询的一部分提取到关系中。 如果你想使用JPA Criteria API CriteriaBuilder cb = entityManager.getCriteriaBuilder(); Criter ...
  • 您无法将关系映射到@MappedSuperclass。 请在此处查看参考文档。 @MappedSuperclass允许您仅在域模型中实现继承。 从数据库的角度来看,这使它成为一个实现细节。 @MappedSuperclass可以很容易地在通常抽象的超类中对公共字段和注释进行分组,但是您无法与它建立关系。 如果你使用@Inheritance ,你可以放弃这个映射(注意我必须将GROUP更改为其他东西,因为它是大多数数据库中的保留字): BaseCustomerDemographicDetails.java i ...
  • 在该示例中,ClassC和ClassE都已标记为@Entity,因此使用了“每个类的层次结构”继承策略。 默认情况下,鉴别器列名称为“DTYPE”。 您可以使用'ClassC'上的'每个类的表'层次结构策略来尝试它。 但是,生成的表与“每个类层次结构表”有很大不同。 您可能希望根据域模型检查所需的继承策略。 这个链接可以很好地指导: http : //docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch10.html Like Alan Hay sugg ...
  • 你的问题在于你需要记住,有些比赛是“在家”,有些比赛是“离开”。 像homeTeam和awayTeam一样考虑它会比homeTeam和awayTeam更容易。 每支球队都将拥有OneToMany主场比赛和另外一场比赛的OneToMany 。 然后,您可以添加便捷方法以获取所有匹配项(如果需要)。 @Entity public class Team { @OneToMany(mappedBy="homeTeam") private Set homeMatches = new H ...
  • 问题1:这是一个很好的问题,但为了回答它,你需要理解owning实体的概念。 具有@ManyToOne注释的Entity是关系的所有者。 这对于开发人员来说很重要,因为除非在拥有方进行,否则不会保持任何关系,在这种情况下,这意味着设置Order.user 。 但是,由于您在非拥有User上具有cascade注释,因此您必须执行额外的工作才能使用级联功能: // create Order Order order = new Order(); // create User and Set of orders U ...
  • 应用程序中的所有数据访问对象( xxxDAOBean )都扩展了GenericDAOBean , GenericDAOBean合并方法是: public T merge(T entity) { entity = em.merge(entity); return entity; } 其中T是实体的类型。 因此,对于post对象(实体类型Post ),合并应该与postDao.merge(post); All Data Access Objects in application (xxxDAO ...
  • 目前尚不清楚您想要做什么,但是如果您想要引用该集合中的最终项目,则可以使用一些可行的选项。 将集合标记为“extra-lazy”,这将允许您访问列表中的最后一项而不加载整个集合。 如果您确实需要加载集合中的其他项目,则可能会出现问题。 https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/performance.html “Extra-lazy”集合获取:根据需要从数据库中访问集合的各个元素。 除非绝对需要,否则Hibernate会尝试不将整个 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)