草庐IT

this_and_that

全部标签

c# - 如何保留我的功能(对象/方法) 'lean and mean'

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭5年前。Improvethisquestion在我读到的所有(敏捷)文章中:保持您的代码和函数小且易于测试。我应该如何对“Controller”或“协调器”类执行此操作?在我的情况下,我必须导入数据。最后我有一个协调这个的对象,我想知道是否有一种方法可以使协调器保持精简(er)和mean(er)。我的协调员现在执行以下操作(伪代码)//WritetothelogthattheimporthasstartedLog.StartImpor

c# - 温莎城堡 : Auto-register types from one assembly that implement interfaces from another

我使用CastleWindsor作为我的IoCcontainer.我有一个具有类似于以下结构的应用程序:MyApp.Services.dllIEmployeeServiceIContractHoursService...MyApp.ServicesImpl.dll员工服务:MyApp.Services.IEmployeeServiceContractHoursService:MyApp.Services.IContractHoursService...我使用XMLconfiguration目前,每次我添加一个新的IService/Service对时,我都必须向XML配置文件添加一个新组

c# - 在此上下文中仅支持原始类型 ('such as Int32, String, and Guid' )

我收到以下错误:Unabletocreateaconstantvalueoftype'Phoenix.Intranet.Web.ClientSettings.ComponentRole'.Onlyprimitivetypes('suchasInt32,String,andGuid')aresupportedinthiscontext.我明白为什么会出现这个错误。我不明白的是为什么我的代码会产生错误。我的比较是针对原始类型的。所有的比较都是Guid到Guid。该错误明确指出Guids正常。错误发生在这一行(靠近底部):varvla=(fromcirinphoenixEntities.Co

ERROR: Could not find a version that satisfies the requirement matplotlib (from versions: none)

今天在Ubuntu中的pycharm软件安装matplotlib模块时出现,如下问题,提示pip版本不符合,需要更新ERROR:Couldnotfindaversionthatsatisfiestherequirementmatplotlib(fromversions:none)ERROR:Nomatchingdistributionfoundformatplotlib使用如下命令,更新pip版本,并没有成功python-mpipinstall--upgradepip提示如下的问题,CouldnotfetchURLhttps://pypi.org/simple/pip/:Therewasapr

c# - 我可以在 c# .NET 中强制使用 'this' 关键字吗?

有没有办法在引用当前实例成员时在VisualStudio中强制使用this关键字?构造函数中存在错误的示例:classMyClass{publicobjectFoo{get;set;}publicMyClass(objectfoo){Foo=Foo;//thisshouldofcoursebelowercasebutit'seasytomiss}}此代码稍后可能会在某处生成臭名昭著的“对象引用未设置为对象的实例”异常。如何让它工作但仍然很容易错过:classMyClass{publicobjectFoo{get;set;}publicMyClass(objectfoo){Foo=foo

c# - Entity Framework : difference between Detach and AsNoTracking

我的目标是复制一个现有的实体,稍微修改它,然后插入修改后的版本。我尝试了两种似乎都有效的不同方法:varthing=context.Things.Where(x=>x.SomeID==someid).AsNoTracking().Single();thing.AnotherID=1234;context.Things.AddObject(thing);context.SaveChanges();varthing=context.Things.Where(x=>x.SomeID==someid).Single();context.Detach(thing);thing.AnotherID

c# - 简易喷油器 : Factory classes that need to create classes with dependencies

我有一个工厂类,它创建了几个不同类型的类。工厂在容器中注册。鉴于它们也具有依赖性,在工厂内部创建类的推荐方法是什么。我显然想避免对容器的依赖,但如果我新建这些类,那么它们将不会使用容器。例如publicclassMyFactory{publicIMyWorkerCreateInstance(WorkerTypeworkerType){if(workerType==WorkerType.A)returnnewWorkerA(dependency1,dependency2);returnnewWorkerB(dependency1);}}所以问题是我从哪里获得这些依赖项。一种选择是使它们成

c# - C++/命令行界面 : How do I declare abstract (in C#) class and method in C++/CLI?

以下C#代码在C++/CLI中的等价物是什么?publicabstractclassSomeClass{publicabstractStringSomeMethod();} 最佳答案 只需稍微混合关键字即可获得正确的语法。abstract在C#中位于前面,但在C++/CLI中位于末尾。与override关键字相同,今天也被C++11兼容的编译器识别,它们期望它位于函数声明的末尾。就像传统C++中的=0标记函数抽象一样:publicrefclassSomeClassabstract{public:virtualString^SomeM

c# - : this() As a constructor

我正在尝试更好地理解一般实践...特别是在构造函数中派生this()。我知道它的代码较少,但我认为它的可读性较差。这样做是常见的/好的做法吗?还是编写第二个专门处理它的构造函数更好?publicSomeOtherStuff(stringrabble):this(rabble,"bloop"){}或PublicSomeOtherStuff(stringrabble){//setbloop}任何输入将不胜感激 最佳答案 最好尽可能使用this()。否则你将复制一些代码,这违反了DRY(不要重复自己)原则。重复自己的问题在于,每次您需要进

c# - 委托(delegate)给实例方法不能有 null 'this'

我正在开发一个C#.NET2.0应用程序,其中在运行时根据环境加载两个DLL之一。两个DLL包含相同的函数,但它们没有链接到相同的地址偏移量。我的问题是关于我的应用程序代码中的函数委托(delegate)。publicclassMyClass{publicdelegateintMyFunctionDelegate(int_some,string_args);publicMyFunctionDelegateMyFuncToCallFrmApp;publicMyClass():base(){this.MyFuncToCallFrmApp=newMyFunctionDelegate(this