Friday, 15 May 2015

c# - How do I provide an implementation of ProjectItem.get_FileNames(i)? -


I'm trying to set up a good REPL to run csharp code. However, I do not seem to implement the code for the implementation of the ENV.Program Item (interface).

Definition of property misbehaving on the interface is in the indexer:

string filename [abbreviate i] {get}}

Based on I tried

  [index name ("filename")] string project itam [this small]  In this clear interface announcement 'this' is not a member of the interface  Public string {[i.ic. i] {back {return "test";}}  [indexerName ("FileNames")]  

Accessor 'UserQuery.ProjectItemFake.this give Ta [Short] .get 'Interface Member' can not apply to 'EnvDTE.ProjectItem.get_FileNames (short)' type 'UserQuery.ProjectItemFake'. Use a clear interface implementation.

  [index name ("filename")] string project itam. [In summary] {{return "test";}}  

returns In the clear interface announcement 'this' is not a member of the interface

I'm completely open to pure languages ​​with primary understanding C #, F #, or VBnet.

Can you type an implementation of the interface EnvDTE.ProjectItem in? Net?

Just apply the method get_FileNames (short i) .

Attributes (including indexed ones) are actually converted into methods under get_PropertyName and set_PropertyName hood. In most cases, the compiler does not allow you to apply such properties, but only because this member relies on metadata. Named index is not available in C #, but they are available in VB.NET, and I think the transfer was defined in VB.NET (they are, but I'm not sure they are compatible).

The C # compiler lets you apply VB.NET indexed properties as get_PropertyName (whichever X) because the only way to implement them is to try it And it works for me.

A complete C # implementation is as follows:

  class ProjectItemMock: ProjectItem {public bool SaveAs (string newFilename) {return false; } Public EnvDTE.Window Open {Name of String} {return null;} Public Zero Extract () {} Public Zero ExpandView () {} Public Zero Save (String Filename) {} Public Zero Removal () {} public bool IsDirty { Get; Set;} public string get_FileNames (short index) {return "test";} public short file count {get; Set;} public string name {get; Set;} public string type {get; Set; } Public EnvDTE.ProjectItems Archive {get; Set;} Public EnvDTE.Properties Properties {get; Set;} Received public EnvDTE.DTE DTE { Set;} public EnvDTE.ProjectItemsProjectItems {get; Set; } Public Bull get_IsOpen (strings) {return false;} public object object {get; Set; } Public object get_Extender (strings) {return tap;} public object ExtenderNames {get; Set; } Public string ExtenderCATID {get; Set; } Public bullet saved {get; Set; } Public EnvDTE.configurationManager ConfigurationManager {get; Set; } Public EnvDTE.FileCodeModel FileCodeModel {get; Set; } Public EnvDTE.Document Document {get; Set; } Public EnvDTE.Project SubProject {get; Set; } Public EnvDTE.Project ContainingProject {get; Set; }}  

No comments:

Post a Comment