Make Glimpse check if things are enabled in DataBoundControlAdapter (fix for #779) #789

Merged
merged 2 commits into from Apr 29, 2014

Projects

None yet

3 participants

@grahammendick

When Glimpse is enabled and then disabled the DataBoundControlAdapter is still registered but GlimpseConfiguration.GetConfiguredTimerStrategy()() returns null. Defensive checks added so event listeners only added when Glimpse enabled.
@CGijbels Couldn't use GlimpseConfiguration.RuntimePolicyStrategy() because couldn't access Glimpse context from the ControlAdapter (it's not like a normal Inspector). Also I tried moving the Adapter registration into Setup but the DataBoundControlAdapter wasn't registered successfully. Try it yourself and you'll see that the DataBound information doesn't appear in the tab.

@grahammendick grahammendick Added check for non-null TimerStrategy()
When Glimpse is disabled GetConfiguredTimerStrategy() returns null so
added defensive checks
0b14689
@grahammendick grahammendick commented on an outdated diff Apr 29, 2014
...Glimpse.WebForms/Inspector/DataBoundControlAdapter.cs
@@ -157,7 +160,7 @@ public DataBoundControlAdapter()
private bool AdapterStateCopied { get; set; }
- private static readonly MethodInfo BeginRenderInfo = typeof(System.Web.UI.Adapters.PageAdapter).GetMethod("BeginRender", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static readonly MethodInfo BeginRenderInfo = typeof(ControlAdapter).GetMethod("BeginRender", BindingFlags.Instance | BindingFlags.NonPublic);
@grahammendick
grahammendick Apr 29, 2014

Changed PageAdapter to ControlAdapter (not necessary for the fix but it's clearer)

@grahammendick grahammendick and 1 other commented on an outdated diff Apr 29, 2014
...Glimpse.WebForms/Inspector/DataBoundControlAdapter.cs
@@ -73,10 +73,13 @@ private TimeSpan Offset
protected override void OnInit(EventArgs e)
{
+ if (GlimpseConfiguration.GetConfiguredTimerStrategy()() != null)
@avanderhoorn
avanderhoorn Apr 29, 2014 Member

Looks good. But I think the tabs/spaces are off here. See here.

@grahammendick grahammendick commented on an outdated diff Apr 29, 2014
...Glimpse.WebForms/Inspector/DataBoundControlAdapter.cs
protected override void OnInit(EventArgs e)
{
CopyAccessState();
+ if (GlimpseConfiguration.GetConfiguredTimerStrategy()() != null)
@avanderhoorn
Member

This looks good to me and if its tested, etc, I'm happy for it to come it. Let me know.

@grahammendick

Sorry about the tabs, it's fixed now

@grahammendick grahammendick reopened this Apr 29, 2014
@CGijbels
Member

@grahammendick thanks for the fix. Maybe you already had the issue with the adapter not registering during setup while developing the feature and that that is why it is now part of the GetData method, so no worries there 😉

Regarding

Couldn't use GlimpseConfiguration.RuntimePolicyStrategy() because couldn't access Glimpse context from the ControlAdapter

I see what you mean, as it is an instance property and not statically accessible (but that has been fixed in v2 😉)

Just wondering why you also changed the reflection parts aka from System.Web.UI.Adapters.PageAdapter to ControlAdapter ?
Was it related to the issue or something that had to be done and piggybacked on this fix? (Not that it matters, I'm just curious 😉)

@grahammendick

@CGijbels I just piggybacked off the work @avanderhoorn had already done for the PageAdapter so that's why the code was in the GetData.

The reflection change was fixing my earlier sloppy paste from the PageAdapter. It worked fine because PageAdapter inherits from ControlAdapter but it was misleading because the DataBoundControlAdapter didn't inherit from PageAdapter.

@avanderhoorn
Member

We all good for this to go?

@avanderhoorn avanderhoorn added this to the vNext milestone Apr 29, 2014
@avanderhoorn avanderhoorn self-assigned this Apr 29, 2014
@CGijbels
Member

:shipit:

@avanderhoorn avanderhoorn merged commit 8f05d51 into Glimpse:master Apr 29, 2014
@avanderhoorn avanderhoorn changed the title from Issue #779 Fix - Check Glimpse is enabled in DataBoundControlAdapter to Check Glimpse is enabled in DataBoundControlAdapter (fix for #779) Apr 29, 2014
@avanderhoorn avanderhoorn changed the title from Check Glimpse is enabled in DataBoundControlAdapter (fix for #779) to Make Glimpse check if things are enabled in DataBoundControlAdapter (fix for #779) Apr 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment