Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Create wrapper
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dusan
Whole Tomato Software

Slovakia
177 Posts

Posted - Jun 07 2012 :  06:34:06 AM  Show Profile  Reply with Quote
Lets say I have a class foo and I need its wrapper.

foo looks as follows:

class foo
{
  public foo (int arg1, long arg2)
  {
    // constructor code
  }

  public int GetInt()
  {
    return 0;
  }

  public void DoSomething(bool useful)
  {
    useSomehow(useful);
  }
  
  double m_doubleProperty = 0;
  public double DoubleProperty 
  { 
    get { return m_doubleProperty; } 
    set { m_doubleProperty = value; } 
  }
}


If I rightClick on 'foo' and choose Create wrapper, VAX should do:

class fooWrapper
{
  private foo;
  public fooWrapper(int arg1, long arg2)
  {
    this.foo = new foo(arg1, arg2);
  }

  public int GetInt()
  {
    return foo.GetInt();
  }

  public void DoSomething(bool useful)
  {
    foo.DoSomething(useful);
  }

  public double DoubleProperty 
  { 
    get { return foo.DoubleProperty; } 
    set { foo.DoubleProperty = value; } 
  }
}

Dusan

Edited by - Dusan on Jun 07 2012 06:38:53 AM

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Jun 07 2012 :  9:48:06 PM  Show Profile  Reply with Quote
Is this something you do often? I can see how doing this manually is going to be quite slow, I am just wondering how useful this refactoring command would be.

zen is the art of being at one with the two'ness
Go to Top of Page

Dusan
Whole Tomato Software

Slovakia
177 Posts

Posted - Jun 08 2012 :  01:49:31 AM  Show Profile  Reply with Quote
I use this usually when I need to call some code before any method is called in original class and class is sealed (not inheritable). As a good example is Console class usable in Windows Vista Service, where Write function is better to check if environment is interactive.
For example:

ServiceConsole
{
  public void Write(string value)
  { 
    if (Environment.UserInteractive)
      Console.Write(value);
  }
}


Also when I need reference type from value type.

For example:
struct Point
{
  public int x;
  public int y;
}

// As I am C++ programmer, this is what I need often
// as pointers are missing in 'safe' C# :) 
class RefPoint
{
  public Point pt = new Point();
  public int x 
  {
    get { return pt.x; }
    set { pt.x = value; }
  }
  public int y 
  {
    get { return pt.y; }
    set { pt.y = value; }
  }
}


This all should VAX be able to do.

Dusan


Edited by - Dusan on Jun 08 2012 01:57:44 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Jun 08 2012 :  9:12:54 PM  Show Profile  Reply with Quote
Doing this when working with sealed classes makes sense. I have put in a feature request to see what our developers make of this:

case=67156

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000