Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DesignMode

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Support
View previous topic :: View next topic  
Author Message
Hernan Martinez



Joined: 19 Nov 2009
Posts: 13

PostPosted: Mon Jan 18, 2010 4:30 pm    Post subject: DesignMode Reply with quote

While evaluating Globalizer we were faced with the problem of having initializing code in our Forms and Controls constructors. The proposed solution--overloading the default constructor--impose us an important penalty because it would imply a global API change for every consumer.

Theoretically this is what Control.DesignMode property is for but regretably it doesn't always work (for instance, Visual Studio doesn't honor it when designing UserControls).

Fortunatly we found out that the hack for Controls that avoid the VS bug also works for Globalizer and Forms. Just override DesignMode to:

Code:

[Browsable(false)]
public new bool DesignMode {
  get {
    return (AppDomain.CurrentDomain.FriendlyName == "DefaultDomain");
  }
}


I didn't find any mention of this hack in the help and forums and I think that some of you might prefer it over default constructor overload.

Regards,
-Hernán.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jan 18, 2010 11:08 pm    Post subject: Reply with quote

Thanks for the suggestion - we may include that in the help for future releases as an alternative.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Hernan Martinez



Joined: 19 Nov 2009
Posts: 13

PostPosted: Tue Jan 19, 2010 10:10 am    Post subject: Reply with quote

I think it's understood in the OP but just to be clear, the programmer should put the external dependency initializer code inside a DesignMode test. IE:

Code:

public MyForm MyForm() {
    InitializeComponent();
    if (!this.DesignMode) {
       // other initializers.
       OpenDatabase(); // or whatever.
    }
}

Also works for UserControl.
Regards,
-Hernán.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group