|
I have a solution with various projects, normally I gather the logon credentials via the UI and settings and pass 1 copy to the DAL. In this project there will be multiple DAL implementations all requiring a set of credentials. Credentials is declared as a class in the intermediate layer (server,DB,User & password) which is referenced by the UI.
Now I have the requirement of passing the creds to many objects which do not reference where the Credentials class resides. I initially created a copy of the Credentials class in the target object and attempted to pass Credentials as an object and then converting to the local Credentials type.
DAL.Server = (Creds as Credentials).Server;
This gets an error to use NEW. Creds is an object and has data in it.
Any recommendations on how to do this properly
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
you should use interfaces. Define a Credentials-interface, which will be accessible by all objects (do this by putting the interface into a seperate assembly). Let your Credentials-class implement the interface. Within all objects you can now use the interface to interact with the object, without knowing how it is implemented (how it should be within OOP).
interface ICredentials {
}
Your credentials-class:
class Credentials:ICredentials {
}
How to use it:
DAL.Server = MyCreds.Server
Hope this helps.
Regards
Sebastian
|
|
|
|
|
There you go, ask for a simple casting solution get the application of a whole different technology. What a way to learn, I have not used interfaces except when building services, will be working with this info today.
Thanks
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It turns out the interface does not meet the requirements - one of the assemblies will need to be isolated for use with another solution and will not have access to the interface. Changed it to use a list<string>.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i developed an application for a mobile device using ce 5.in the application i have two forms A ,and B. A is the main form and B is the child form most of the times form B is created, used and closed.but before showing the Form B the memory
usage (ex: 15MB) when form B is loaded the mem is (ex:16MB),but when the form is closed the mem is still 16 MB.i there might be a memory leak . do you
have any suggestions on this
|
|
|
|
|
Hi all,
I am currently make use of the Assembly.LoadFile to get hold of some of the attributes.
The problem that I am experiencing is that the LoadFile method holds on to the assembly, thus preventing me from taking actions on the assembly file like: deleting the file or moving the file. Only when the program closes does the release on the assembly take place.
How can I load the attribute data of the assembly without running into this issue.
Many thanks in advance
Regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Look at this[^]
or
This[^]
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Ahh, the "I realised google can answer me quicker than a forum post" reply. Well done sir!
|
|
|
|
|
yeah, someone should make a tutorial on the subject - apparently its not an easy task
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Indeed. If only somebody here on Code Project had written this[^] article. Oh how I wish somebody would.
|
|
|
|
|
ahhh... now with my new found knowledge i will never not find an already created tutorial that im suggesting to be written again
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Hi,
I'm trying to find the existence of a child node in Treeview control. I used the following find(), Contains(), ContainsKey() methods.
1. TreeNode[] ad= treeView2.Nodes.Find("child2",true);
2. bool res= treeView2.Nodes[0].Nodes.Contains(selNode);
3. res = treeView2.Nodes[0].Nodes.ContainsKey("child2");
None of the above is giving result. Please let me know how to find a child node in a treeview control.
Thanks in advance.
|
|
|
|
|
what are you searching for and is it in the base level only?
the Find method should work fine, "child2" should be the key of the node to find, i.e. the Name property, change false to true if you want to search deeper than the base level.
what results are you getting from you find function?
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Try the following code for the same:
For Each LeftMenuNode As TreeNode In LeftMenu.Nodes ' LeftMenuNode will give you Nodes in TreeView
For Each LeftChildNode As TreeNode In LeftMenuNode.ChildNodes 'LeftChildNode will give u childnodes if any
If LeftChildNode.Text <> "Child Nodes" Then
LeftChildNode.NavigateUrl = "#"
End If
Next
Next
Regards,
Kaushal Arora
|
|
|
|
|
Ive never seen a more non-sense programming language lol
Anyway after translation it is a good suggestion, but from what i gather this will only search levels 0 and 1 of the treeview. No?
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
infact your code s k to find the child the treeview control
what more u have to do is to select that child node.
[code]
if (treV.Nodes.Find("child",true).Length>0)
{
treV.Focus();
treV.SelectedNode=treV.Nodes.Find("child",true)[0];
treV.SelectedNode.EnsureVisible();
}
[/code]
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hi All
Im trying to make an address look up application using sql.
I want it so that when the user selects a country the window will change and match the country Address Formart.
For Example if i choose UK from the combobox the form will change to this
address formart :
Building
Road
Town
PostCode
United Kingdom
but if i click USA
Holtsville NY 00501
United States
How can i achieve this...
|
|
|
|
|
create the maximum number of different textboxes you need, then assign them a number each i.e.
TBLine1 = 0
TBLine2 = 1
TBCity = 2
TBRegion = 3
TBPostcode = 4
TBCountry = 5
Then in your database you have a list of countries and also a column with the order the address should be displayed split with a non numeric character, i.e.
UK 0;1;2;3;4;5
USA 2;3;4;5
Then you can parse the column and dynamically set the location of the fields based on the ordering
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Thank You
|
|
|
|
|
Hi,
I need to create a simple application where a user types in an abbreviation of a word and this is automatically changed into the full word. The text can be entered in any application e.g. MS Word, MS Excel, Notepad, E-mail, Blog, etc.
A simple example:
Use enters.. tc<space>mw.
System recognizes a space, comma or any other punctuation and replaces the text to.. take care Matthew White.
tc -> take care
<space> triggers the previous action
mw -> Matthew White
fullstop triggers the previous action
Basically, the application matches the entered text to a dictionary (edited by user) and replaces the word with the meaning. Also the program can be running in the task bar allowing the user to disable the feature.
10x
|
|
|
|
|
|
M3rov1ngian wrote: I need to create a simple application
Well, what you are descibing does not fit this category, at least to my mind, but if you think its a simple application go ahead and create it - I would be interested in seeing the finished product.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks for the reply Bob,
I already have the program working for text entered in a win form in my application , but I need this functionality to work system wide automatically for other applications. Have you got any idea how can I achieve this?
Thanks
|
|
|
|
|
As I said, its far from simple and to be honest I have no idea how you are going to do it - you need to hook into ANY app that has a text area and monitor key presses.
All I can say is good luck.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi,
kindly help me, I want to change date format setting example => 21-01-2009 of "Regional and Language Option" using C#.
Thank you in advance
(Riaz)
|
|
|
|