Make Class Singleton Plugin - Question

Hey,

I'm currently creating a plugin that turn a class to a singlton which
includes,

Adding these 3 line of code to the class: (Assume class name is MyClass)

public class MyClass
{
// Added Code
private static readonly MyClass m_obj = new MyClass ();
public static MyClass Instance { get { return m_obj; } }
private MyClass () {}
//Rest of class code
}
Later, i want to replace all the creations of the class (with empty c-tor)
to the call of the MyClass.Instance. ...
at the start, i just extracted the class name and added the code as a string
to the related docuement object.
but now i want to add a three statements: member, get-property, and a class.
After a Exctract the IClassDeclartion object:

IClassDeclaration classDeclaration =
token.GetContainingElement]]>(false);

I want to add member declartion objects to it and i don't find the factory
object for creating it...
could someone give me a little guidance (or example) on how creating one of
the three statements?

thanks for the patience,
i'm really thrilled on working with R# api,
Guy.





Please sign in to leave a comment.