Click here to Skip to main content
15,172,297 members

Comments by bh_ (Top 18 by date)

bh_ 9-Mar-21 8:41am View
Thanks for your reply and your time.

So, I do have what you describe as a DAL - this is a class library that I wrote to handle the actual interaction with the database.

But, since this class library does not have access to BLL's config files (appsettings.json in my case) then I need a way to send in the required connection string to the DAL from the BLL.

And that's what I'm doing here - the user makes their API query and specifies the server that will be used. Then the BLL uses this decision to extract a connection string from appsettings.json and it sends it to the DAL which is responsible for doing the actual work with the database.

Does this sound correct to you? Well... I suppose it *is* correct in that it definitely works. But would your appraisal of that be good or bad?
bh_ 1-Sep-18 8:45am View
Yes this makes perfect sense. Thank you Graeme!

I was mainly concerned that I was not using the MVVM framework as it is intended and I didn't want to carry on writing an entire application just for it to be pointed out that I was totally misunderstanding what I was supposed to be doing.

You have given me the confidence to proceed and I consider the question answered, thanks!
bh_ 1-Sep-18 7:40am View
Thanks for the response Graeme. I believe you have slightly misunderstood my question: I want to inform the Model of a change in the ViewModel, not the other way around.
However, your answer is still useful as I am confused about this exchange of information more generally and that is really the purpose of my question.

So, inevitably the ViewModels and the Models will be linked through code like this and there will not be 100% seperation of concerns. It seems that there cannot be: how else can the Models do useful work in response to changes to the ViewModels?

That said I think I am also misunderstanding the purpose of Models. It is explained in many tutorials that the Models contain your data and this drives the ViewModel to inform the GUI of changes to data.
This makes sense with the direction in which you have answered my question.

But I have a different application to this. I have pieces of equipment which do things, and I can set the equipment up and operate them from the GUI. So it seems to me that the data flow is more from ViewModel -> Model than Model -> ViewModel. But also the data flow can be both ways I think?

I get the general impression that I am misunderstanding something fundamental about MVVM but so far no amount of googling or tutorial reading has helped me make progress.
bh_ 2-Sep-16 5:43am View
That is a perfect solution, and exactly what I had in mind.

but... where can I learn more about the technique you have employed here?
bh_ 2-Sep-16 4:36am View
Thanks very much for the response F-ES Sitecore. I have tried to improve my question. I will look into generics and reflection to see if either of these give me other ideas about how to solve the problem.
bh_ 11-Aug-15 10:20am View
Yep I have verified that the information in the article was correct.

Thank you for taking the time to help.
bh_ 11-Aug-15 9:47am View
Yep, definitely.

I have found this Code project article, which suggests that user settings get stored somewhere strange:

I haven't been able to verify this yet.
bh_ 11-Aug-15 8:27am View
I already have that line in my code, so that can't be it.

Aside from anything else, in my save settings code, I have this line:


...which I believe writes the settings out to the file. It must be writing it somewhere, but it isn't writing it to any config files inside my project's directory.
bh_ 11-Aug-15 6:53am View
I wonder, perhaps, if the scope has anything to do with it. I have the scope set to 'User' for all my settings. Will check if this has anything to do with it after lunch.
bh_ 11-Aug-15 6:51am View

I have already checked around, but I cannot locate either of the files associated with debug and release. I have even widened my search to include the entire C:\ drive but I cannot find them.

That's really the point of my question - I would like to know how to locate the files.
bh_ 18-Dec-13 7:33am View
Thanks for the solution. Your solution is actually the method I was already evaluating, but it transpires that I was lead down the garden path with it! I tested the solution using my own username/password and it returned valid. But I am the logged in user on my machine so to test it with someone else's credentials I asked a colleague to try his username/password on it for me. It then failed to authenticate him. He tried it a few times but it failed every time. I therefore assumed that my solution was only working for myself. I've now tried the code on his machine with my username/password and it authenticates just fine. So he must have been typing his password wrong when I asked him earlier!!!

I guess there is still a problem for me to solve though; I now want to be able to check the verified credentials against a group to ensure that the user is a member of a specific admin group that I will set up and add users to. I will crack on with that.

Thanks again!
bh_ 30-Nov-13 8:48am View
Thank you everyone for the responses. I was thinking that someone would come along and say "you doofus, you're doing it all wrong!" and then they'd point me in the right direction.

Instead what I've found is there is nothing wrong with my programming and that it's actually not possible to raise events across threads without using some special techniques. The techniques proposed by Adam [Invoke] appear to be what most professionals are proposing as a solution to this problem, hence why I have accepted Adam's solution as the answer to my question.
Here is a good tutorial I found:
bh_ 29-Nov-13 6:53am View
Thanks for the response Rahul.

To clarify, there is one background worker thread which runs a loop. The loop iterates through my collection of objects calling the run() method on each one. Each run() method generates some data, and then on each iteration of the loop I am using the background worker's progress changed event to update all of my text boxes. But really what I wanted was for each object to raise its own event that I could subscribe to on my main form and only update the text boxes that are relevant to each objects data.

Is this a bit more clear? It's quite difficult to put across in a clear manner.
bh_ 8-Oct-13 11:25am View
That's great - fully understood. Now that you've written the delegate assignment in full I can recognise it and it makes perfect sense to me. It also seems pretty obvious now that you've pointed it out!

Thanks for the link as well I will read that with interest.
bh_ 1-Oct-13 5:55am View
Thanks Sergey.

All: I found the following reference to give a good overview/use of the various collection types available in C#
bh_ 25-Sep-13 10:51am View
Okay, this sounds like it could be the solution for me. In light of your explanation I accept your "dirty code" criticism. The only thing I would say in defense is that use of "legacy software units" clearly doesn't make sense, as you said, but the problem is having the knowledge that it is a legacy software unit in the first place, which I certainly did not have. I have a background in perl which is where my habit of hashtables comes from.

Thanks for the reply I will be looking into your suggestion this afternoon and I'll give it a try!

Thanks again,

bh_ 25-Sep-13 10:38am View
Thanks Jameel. My confusion is still present because I expected the type of the hashtable value to already be a string, hence no need for a cast.
bh_ 25-Sep-13 10:33am View
Hello richcb, thanks for the reply.

So the story behind this hashtable is that I have a text file with some settings in it, like this:

<pre lang="vb">
AutoHighLimit = 2E
ModIndex = 2B
AutoLowLimit = 2B
AutoUpdateRange = 10
ModIndexMode = Manual
TestMode = Engineering</pre>

And then I have a function called GetSettings() which iterates through the lines of the text file, first populating the keys with the text value on the far left, and then making the value of that key equal to the text on the other side of the '=' sign, not including the whitespace. So, as an example, after running GetSettings() there will be a key called AutoHighLimit and its value will be "2E".

And that's where the source of my confusion begins. My understanding was that the hashtable already contained string values. Why, then, do I have to cast to a string in the example I gave above? Clearly my understanding is not correct! :)