English 中文(简体)
是否有办法通过一个模板/与Resharper一道生成多个档案?
原标题:Is there a way to generate multiple files through one template/macro with Resharper?

当我写给申请的我的APICES时,我总是遵循一种固定模式(他会nt!) 参看:

User (Folder/Namespace)
    User.cs
    UserDao.cs
    UserDaoFactory.cs
    UserService.cs
    UserServiceFactory.cs

I know Resharper has file templates which I already utilize, but it would be great if I didn t have to individually add each file which can get extremely tedious when you are working with upwards of 30 entities in an app. If you can t do this with resharper is there anyway to make some kind of macro with Visual Studio that will execute your resharper file templates?

最佳回答
  1. Create all these classes in a single file (create a file template containing the set of standard classes if you want to)
  2. Write your logic
  3. Press Shift+Alt+L to put focus on the file in Solution Explorer
  4. Press Ctrl+Shift+R to display Refactor this menu with a list of applicable refactorings.
  5. Select Move Types into Matching Files, complete the refactoring wizard, and watch the classes separating into individual files.
  6. To put all the newly created classes into a folder, select them in Solution Explorer, and again invoke Refactor this.
  7. This time, select Move to Folder.
  8. Specify the name of the new folder in the refactoring wizard, press Create this folder, and complete the wizard.
问题回答

I would consider using .tt templates with ReSharper.

  1. create master file with ReSharper.
  2. using one or many tt files to auto generate dependent (.partial.cs) files with partial keyword in it.
  3. extend generated classes if needed.




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签