English 中文(简体)
捐赠或财产
原标题:Attributes or Properties
  • 时间:2009-09-11 17:03:19
  •  标签:

我想为每个单元/插图添加一些功能,例如:

作者、公司、日期等

这代表它来自何处,是谁写的。 然后,方案管理员可以在一个单一的DLLL中拥有多种金gin。 我应如何支持这些提议,以便我能够进入主要应用系统? 一般说来,1个原始产品是单一公共部门。

我是否应该使用财产或特性? 我也应当使用接口?

我希望这些事情能够由方案者来完成,而不是使之具有选择性。

最佳回答

由于数据是关于该类别的技术元数据,而不是原始数据所要求的实际状态,我将使用属性。 投稿意在成为有关代码的元数据,这是你想要的。

就执行这些建议而言,如果元数据缺失,你可能会有东道方的申请未能装上原始数据。 这样,原始开发商无法在没有提供数据的情况下测试原始产品。 然而,你应当提供大量文件,以便了解他们失踪的情况,或在你未能装上假肢时提供详细的错误。

大部分议会已经掌握了一些基本信息(Company, FCCC/SBI/2007/INF.1号文件)。 你们也可以发挥这种作用。

此外,为了防止出现缺失的数据问题,你可以使用一个单一的PluginAttribute,将所有元数据作为财产参数,并要求将这一特性赋予你的主人装载这一类别。 我首先想到的是你希望记录的每一件物品,但一个单一的特性会更好。

问题回答

I would use an interface, myself. nice thing is, you can add it to an existing class and not have to do a major re-write of existing code, just add the properties/methods of your interface.

我现在谈谈属性,因为正如你希望追踪的物品一样,它不需要成为申请的一部分,而是对守则本身的赞扬。

此外,我认为,如果方案人员是个属性,那么,让方案人员在实际上属于这一方面增加其他陪审团的诱惑将会减少。

I think using an interface is a better approach. Because either way every one who wants to write a plugin should do it based on a contract (implementing an interface or putting some attributes over his class members) so it doesn t matter from the plugin developer point of view , but it would be easier ,more structured (and I think faster) for your program to recognize and utilize an implemented class based on an interface.

如果你使用属性,则让原始执行者难以注意到,如果他们愿意填充其中一个领域的话。 如果有抽象的财产,他们将被迫执行或编纂错误:

public abstract class PluginBase
{
    protected PluginBase()
    {
    }

    public abstract string Author
    {
        get;
    }

    // ...
}

唯一的倒数是,这种信息实际上是元数据,因此,你可以认为,从“主观正确”的角度来看,属性较好。

这一点已经存在,因此为什么要重新发明轮子?

using System.Reflection;

[assembly: AssemblyTitle("my app")]
[assembly: AssemblyDescription("good app")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("mycorp")]
[assembly: AssemblyProduct("my prod")]
[assembly: AssemblyCopyright("Copyright © me 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]

他们在案卷“Info.cs”。

这是在议会中储存版本信息和其他元数据的标准方法。 其他 你们也有兴趣,你们也可以为此创造自己的贡献。

从个人角度讲,我会说是属性的,但会把价值分配到建筑商的只读物。

两个世界的最佳区域:





相关问题
热门标签