|
If the URL is hardcoded, then you could in theory use a background thread which loads it into a MemoryStream before you click play. Then you could set up a System.Media.SoundPlayer(Stream) instance when button1 is clicked. Load the rest of the file into the MemoryStream and invoke the Play method
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi All,
I have been studing some OOP books and some of them present this solution to break down an application beetween Presentation, Business and DB Layer.
Quick Example in pseudo-code
Business Layer
Class Customer
ID
Name
Surname
SaveCustomer {...}
void LoadCustomer(ID){
this = CustomerDB.LoadCustomer(ID)
}
end
DB Layer
Class CustomerDB
SaveCustomer{....}
Customer customer = LoadCustomer(ID){
//connect to a DB and load ID, Name, Surname
c = new Customer()
c.Name = DB.Name;
.....
return c
}
End
Here Class Customer delegate SaveCustomer, LoadCustomer to CustomerDB.
A presentation layer call would be
Custoer c = new Customer()
c.LoadCustomer(3)
print c.Name
Why do many books suggest this solution?
Personally I see these shortcomings
1) The Business Layers will not compile byitself, because has a reference to the DBLayer
2) The Customer object contains preperties that are not tipical of a Customer (Save, Load)
3) The Customer object is thightly coupled with CustomerDB
Would not be a better solution this one?
My solution
Class Customer
ID
Name
Surname
end
Class CustomerDB
Customer customer = Load(ID)
bool save(Customer customer)
end
and the presentation Layer will call
CustomerDB customerDB = new CustmerDB();
Custmer c = customerDB.Load(ID);
print c.Name
this way
1) The Business Layer is completely indipendent from the Business and Presentation Layer
2) It compiles byitself
3) The Customer Class does not have any strange property (Save, Load)
4) Customer is loosely cupled with CustomerDB
but
5) The presentation Layer must know about both business and DB Layer. (I don't like this)
What solution from a OOP programming is better?
Using the solution I suggested how can I let the presentation layer to be decoupled with the DB Layer?
Thanks
Pierpaolo
|
|
|
|
|
pierpaolo paparo wrote: What solution from a OOP programming is better?
You might want to look into IoC containers.
That way the dependecies are abstracted out elsewhere. Things become dependent on interfaces, noth the implementation. So long as you keep the same interface the implementation can change as much as it needs to. This also helps in testing as you can swap out the real database and use something else very easily.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
Hi Colin,
My understanding is that if I code the Customer Class
BusinessLayer
Class Customer
ICustomerDB _customerDB
Customer(ICustomerBD customerDB) {
_customerDB = customerDB
}
void Save()
_custmerDB.Save(this)
end
end
Interface ICustomerDB
void Save(customer Customer)
end
DATABASE LAYER
Class CustomerDB : ICustomerDB
void Save(Customer customer){
//some code to save Customer in the DB
}
end
PRESENTATION LAYER
CustomerDB customerDB = new CustomerDB()
Customer customer = new Customer(customerDB)
customer.Name = 'Mario'
customer.Save();
Injecting the ICustomerDB into the Customer class using the constructor,
I manage to separate the Business Layer and the DB Layer.
Is this right?
Thanks
|
|
|
|
|
Hello Experts!!
I got an above errro during running my project.i dont knw how to remove it....Please Help!!!!
|
|
|
|
|
|
SK Genius wrote: What was your program doing
Without seeing any code, I would say nothing most useful, but filling a stack.
Probable causes: an unbound recursion by
- a property calling itself instead of accessing a member variable;
- a method calling itself, never hitting the exit condition.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Program doing sql connection n i got this error at this point--->
SqlConnection sqlcon = new SqlConnection("Data Source=localhost;Initial Catalog=DB;Integrated Security=True");
|
|
|
|
|
KIDYA wrote: Hello Experts!!
It is curious - Along the road to expertise is the realisation of one's own limitations. It is the understanding not just of what one knows, but most importantly what one does not know. And in this one understands what knowledge gaps need to be filled in order to solve a problem.
In order to solve this problem the appropriate excerpt of code that is broken is needed.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
When you run your app in debug mode, look at the call stack when you get the StackOverflowException. You can open it from Debug - Windows - Call Stack when an app is running in VS.
Dybs
|
|
|
|
|
what is the use of Httphandlers , how can i use it, where can i use this handler, where can be used in real time
|
|
|
|
|
What did you try to before posting this question. Did you try to google even once?
Anyway, this [^]one gives a nice answer to all your questions.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Hello experts!!
I am importing two projects into my main project.Now i want to publish it.But after running setup my that two outside project forms doesnt work.i set all preferences and depencies of projects.What to do????
tel me way for deploying such project into one setup.
|
|
|
|
|
There is no way for us to tell with the description you've given.
But, the general checklist would include making sure that both outputs end up in the installer and that your .EXE's/.DLL's end up in the proper directory during the install. If you have one project that outputs an .EXE and the other outputs a .DLL, and the .EXE uses the .DLL, then it's assumed that your design requires the .DLL to be in the same directory as the .EXE. All you have to do is make sure your installer arranges the files to do this.
|
|
|
|
|
I created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly. Then what is the use of Global assembly ? How i utilize i know how to make the Assembly as Global but i don't know how to use, can u please any body tell me
|
|
|
|
|
Shaik Haneef wrote: I created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly.
How else is your code going to know where to look when it needs to call something in that assembly?
Shaik Haneef wrote: Then what is the use of Global assembly ?
If you have a common assembly that lots of projects use then instead of installing it many times for the many applications that use it you can install it once and all applications that need it can share the version in the GAC.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
I created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly. Then what is the use of Global assembly ? How i utilize i know how to make the Assembly as Global but i don't know how to use, can u please any body tell me
|
|
|
|
|
Hi to all,
I have a 'Child' class as follows,
public class Child<br />
{<br />
public string FirstName, MiddleName, LastName;<br />
public string Sex;<br />
public DateTime DOB;<br />
public string EducationDetails;<br />
public string Health;<br />
}
In my application, I am having multiple objects of 'Child' class storing information of each Child.
Using those objects, I want to generate Crystal Reports for each child showing his details. And then I will convert those reports to PDF files.
How to do this? How to generate multiple crystal reports from multiple objects of 'Child' class or any class?
Please help.
I appreciate any and all comments and suggestions.
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
I am working on a RAT (Remote Administration Tool)... Below is an explanation and the question... If you'd like you can skip the rest and read the question
[Program Explanation]
A program working on the Admin-side sends a command to the Client-side program (through TCP/IP), and after interpreting the instruction, it does the requested action.
For example, if the Admin-side sends "list drives", the Client-side program interprets the command and sends a string[] back to the Admin as a byte[]... The admin-side would convert the byte[] to a string[] That's no big deal...
[End of Program Explanation]
[Question]
The question is... Can I send multiple Network Streams at one time, and each are separately recognized by the receiving-end? This is important if more than one task are performed at one time - such as getting a file and keyboard logs... (Since the conversion at the receiving-end needs to be made for the relevant response...
Last I tried, I sent two different Network Streams exactly after each other and the receiving end had thought that it was the same stream!! - It resulted in total chaos
[End of Question]
[Program Coding]
To send a command, there are two important methods
public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}
public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}
On the receiving end, a similar system is used, being Receive and DeSerialize...
[End of Program Coding]
|
|
|
|
|
You can never be sure that the message sent is recieved as one piece at the client.
To be sure, you may use some Start and End indentifier for each message you send. At the client side, write a function which
makes sure that stream is completely recieved and if not retrieve the remaining message from the next received.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
How to create a Pipe through the API createNamedPipe in c#, and how to do the send a message from one exe to other using callNamedPipe in c#?
|
|
|
|
|
|
how can access other controls such as button, textbox etc. in an other application from C#. For example I want to design a form that has a combo box with some data in it, and by choosing an Item from the combo box, that item will be copied to the search box of Internet Explorer (for example).
|
|
|
|
|
Member 6289976 wrote: how can access other controls such as button, textbox etc. in an other application from C#.
With extreme difficulty.
Controlling another appication requires you to use Win32 API functions to search for windows, then search those windows for other windows, representing buttons and other controls, to find the one you want, get it's window handle, craft an appropriate window message to send to it and then send the message. There is also no guarantee that the control you're "talking" to will respond to the message you send.
IE complicates this even further, because now you have to use an entirely different method, using IE's Document Object Model, to get at the controls on a web form.
|
|
|
|