partial-classes

Partial classes in separate dlls

社会主义新天地 提交于 2019-11-27 01:43:24
问题 Is it possible to have two parts (same namespace, same class name) to a partial class in separate DLLs? 回答1: From MSDN -Partial Classes and Methods: All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules. 回答2: No. Partial classes are a purely language feature. When an assembly is compiled, the files are combined to create the type. It isn't possible to spread

Override Default Constructor of Partial Class with Another Partial Class

一曲冷凌霜 提交于 2019-11-27 01:32:38
问题 I don't think this is possible, but if is then I need it :) I have a auto-generated proxy file from the wsdl.exe command line tool by Visual Studio 2008. The proxy output is partial classes. I want to override the default constructor that is generated. I would rather not modify the code since it is auto-generated. I tried making another partial class and redefining the default constructor, but that doesn't work. I then tried using the override and new keywords, but that doesn't work. I know I

Is it possible to add an attribute to a property in a partial class?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 23:34:41
问题 I don't think it's possible but since I haven't got a definite clarity from MSDN, I feel that it's best to ask. Suppose that we have a class as follows. public partial class Hazaa { public int Shazoo { get; set; } } Then, I'd like Shazoo to be attributed as SuperCool but I wish to do so in another file. Since I'm using partial classes, I can add new properties as follows. public partial class Hazaa { [SuperCool] public int Wheee { get; set; } } But can I attribute a property declared in the

Is it possible to have two partial classes in different assemblies represent the same class?

。_饼干妹妹 提交于 2019-11-26 20:14:26
I have a class called 'Article' in a project called 'MyProject.Data', which acts as the data layer for my web application. I have a separate project called 'MyProject.Admin', which is a web-based admin system for viewing/editing the data, and was build using ASP.NET Dynamic Data. Basically I want to extend the Article class, using a partial class, so that I can augment one of its properties with a "UIHint" extender, which will allow me to replace the normal multi-line textbox with an FCKEdit control. My partial class and extender would look like this: [MetadataType(typeof(ProjectMetaData))]

Is there any Python equivalent to partial classes?

这一生的挚爱 提交于 2019-11-26 20:06:23
Using "new" style classes (I'm in python 3.2) is there a way to split a class over multiple files? I've got a large class (which really should be a single class from an object-oriented design perspective, considering coupling, etc, but it'd be nice to split over a few files just for ease of editing the class. If your problem really is just working with a large class in an editor, the first solution I'd actually look for is a better way to break down the problem. The second solution would be a better editor, preferably one with code folding. That said, there are a couple of ways you might break

Should you use a partial class across projects?

最后都变了- 提交于 2019-11-26 18:30:52
问题 I have a class library with all my database logic. My DAL/BLL. I have a few web projects which will use the same database and classes, so I thought it was a good idea to abstract the data layer into its own project. However, when it comes to adding functionality to classes for certain projects I want to add methods to certain classes. For example, my data layer has Product and SomeItem objects: // Data Access Layer project namespace DAL { public class Product { //implementation here } public

Naming Conventions For Partial Class Files

浪子不回头ぞ 提交于 2019-11-26 15:17:35
问题 I'm generating the bulk of my ASP.NET MVC scaffolding code. All generated files are partial classes which use standard naming conventions. For example, my employee controller file is named EmployeeController.cs. If I wish to extend the EmployeeController with custom, non-generated logic, I create a second partial class file named EmployeeControllerCustom.cs. I separate the custom and generated logic into two different files so the next time I generate the EmployeeController my custom changes

Can I define properties in partial classes, then mark them with attributes in another partial class?

情到浓时终转凉″ 提交于 2019-11-26 15:16:22
问题 Is there a way I can have a generated code file like so: public partial class A { public string a {get; set;} } and then in another file: public partial class A { [Attribute("etc")] public string a {get; set;} } So that I can have a class generated from the database and then use a non-generated file to mark it up? 回答1: I've seen something like this done in an article by Scott Guthrie (near the end of it) - didn't try it myself, though. http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net

Is there any Python equivalent to partial classes?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 08:59:50
问题 Using \"new\" style classes (I\'m in python 3.2) is there a way to split a class over multiple files? I\'ve got a large class (which really should be a single class from an object-oriented design perspective, considering coupling, etc, but it\'d be nice to split over a few files just for ease of editing the class. 回答1: If your problem really is just working with a large class in an editor, the first solution I'd actually look for is a better way to break down the problem. The second solution