As I said, I committed the changes so that the ConfigurationManager now works a bit more like its .NET counterpart. For example, the signature is now the same: object GetSection(string sectionName);
Plus, the configuration file now asks for a valid configuration section:
<configuration>
<configSections>
<section name="mySection" type="assembly-qualified name for an IConfigurationSectionHandler" />
</configSections>
...
<mySection value="abc" />
</configuration>
Ah! So anonymous types are internal by default... Something I wasn't aware of. Which probably leads to the more general statement : You can't bind to internal types.
Can't get it to work. Command property always returns nothing. Here is my code. Any help would be appreciated.
Namespace CommandControls
Public Class CommandButton : Inherits System.Windows.Controls.Button
Public Shared ReadOnly CommandProperty As DependencyProperty
Public Shared ReadOnly CommandParameterProperty As DependencyProperty
Shared Sub New()
CommandProperty = DependencyProperty.Register("Command", GetType(ICommand), GetType(CommandButton), _
New PropertyMetadata(Nothing, New PropertyChangedCallback(AddressOf OnCommandChanged)))
CommandParameterProperty = DependencyProperty.Register("CommandParam", GetType(Object), GetType(CommandButton), _
New PropertyMetadata(Nothing, New PropertyChangedCallback(AddressOf OnCommandParamChanged)))
End Sub
Public Sub New()
MyBase.New()
AddHandler Me.Click, New RoutedEventHandler(AddressOf CommandButton_Click)
End Sub
Private Sub CommandButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
If (Command IsNot Nothing) Then
Command.Execute(Me.CommandParam)
End If
End Sub
Public Property Command() As ICommand
Get
Return DirectCast(GetValue(CommandProperty), ICommand)
End Get
Set(ByVal Value As ICommand)
SetValue(CommandProperty, Value)
End Set
End Property
Public Property CommandParam() As Object
Get
Return GetValue(CommandParameterProperty)
End Get
Set(ByVal Value As Object)
SetValue(CommandParameterProperty, Value)
End Set
End Property
Private Shared Sub OnCommandChanged(ByVal sender As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim button As CommandButton = DirectCast(sender, CommandButton)
button.UpdateCanExecute()
End Sub
Private Shared Sub OnCommandParamChanged(ByVal sender As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim button As CommandButton = DirectCast(sender, CommandButton)
button.UpdateCanExecute()
End Sub
Private Sub UpdateCanExecute()
Dim canExecute As Boolean = True
If Command Is Nothing Then
canExecute = False
End If
If canExecute Then
canExecute = Command.CanExecute(CommandParam)
Me.IsEnabled = canExecute
End If
End Sub
End Class
End Namespace
I'm currently improving ConfigurationManager so that it mimics even more precisely what .NET's ConfigurationManager does. I'll post changes to it here later today.
This is not really a corporate blog; my corporate web site is this: http://www.omniscient.ca. This blog is built around Foundation, the open-source project I lead. Thanks for coming to the code camp ;-)
Hey Rob, how are you? That article is quite interesting. It remembers me something I thought years ago about the biologic model; when you look at cities, you can see living cells, with a center where the information is treated, with surrounding plants (I think those are called ribosomes, something like that). Roads are just like artery and veins, while electric grids look like a nervous system. If you push the analogy, then you can compare a computer to a neuron. I guess one could go from there to pushing the analogy even further and develop a "new way" of looking at computer science...
But I camp my position concerning 3GL ;-)
Well, when you think of it, tools built on top of stable tools eventually become the new tools, and everybody forgets about what's under it. I'm not against that, it's the way things evolute. I rather warn about the temptation of building THE framework, the one that solves everything, since there's a direct correlation between the magnitude of what the framework can do and its complexity. The danger lies in the fact that the framework may tend to a complexity comparable to that of the systems it tries to abstract. The framework itself becomes the new product that you have to feed with almost the same quantity of human effort than any other "real" system...
I agree with the general point of this article but take the example below which might put a wrench in your time based calculation around using frameworks that builds code for us... :)
I have been thinking about this a lot lately because of Microsoft Oslo. I think the Oslo idea has some merit. It falls into the category of "Software that builds software" but only for a certain, redundant and somewhat boring and very changing facet of software development. It is of course built with extensions in mind and the day where it actually generates your ado.net entities is not very far away.
The idea that developers have to manage a set of entities and map them to a data layer has been there since the inception of computers. I think it is about time that someone integrates this part of software into an automated process. In the last 5 years, developers in the .NET community have been busting their asses around creating the perfect ORM. We have a bunch of solution out there and for what I know, a lot of good and open solutions (take nHibernate as an example).
ORMs are one of those defacto standards out there now. Of course, they fall into the category of "Software that builds software" because once configure properly, they generate the SQL queries necessary for you application to function the way they were written to work.
Now take a very pro efficient SQL and ADO developer and ask him to build CRUD operation like software for 5 or 6 tables in a given database and ask the same thing to someone who knows nHibernate very well. Which one do you think will complete his work first?
One comment thought. I would enjoy reading your posts with C# code to illustrate what you're talking about a bit more. Your post can be heavy to read at times and for someone not to familiar with the concepts, I am sure they could get lost easily. As they say, a picture is worth a thousand words. :)
You should know, however, the code snippet in the section "Second, diagnose the problem" is getting truncated because of the layout (in Firefox and IE anyway).