|
i thought it was OK it just didn't seem quite right to me for a while there.
Thanks for your response,
Russell
|
|
|
|
|
arachnoid wrote: i'm worried that i now have a superclass that knows too much about its subclasses
Personally, I'd have stuck with the factory class and kept the abstract base class blissfully ignorant of its derivatives. If you ever have to add a new concrete type then you will have to update the base class as well. I suppose you would have had to update the factory class anyway, but by putting the creation aspect into a factory class I feel it leaves you open to more options in the future.
|
|
|
|
|
arachnoid wrote: is it asking for trouble
Yes. A separate factory static class is the right way to go.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
There is no (valid) reason for this logic to reside in the base class.
|
|
|
|
|
It seems odd (to me) to have a nonvirtual method in an abstract base class. I'd create a separate MessageFactory class that served up instances of SystemMessage , ErrorMessage , etc.
/ravi
|
|
|
|
|
Hi,
how to get the duration of an mp3 file using c#
Regards,
Sivaprasad
|
|
|
|
|
This isn't something you can do natively in the .NET framework. You'll need to use a 3rd party library to do this. For example, Managed DirectX has APIs to do this.
|
|
|
|
|
If you know the samplingsfrequency Fs and number of samples N: duration = N/Fs [sec]
Cheers Al
|
|
|
|
|
If I oversimplify this or you all ready know parts of this, I appologize. But here goes...
MP3 files are made up of a bunch of music sections, each having a header. At the end of the
file is a TAG 128 bytes long.
The Gist of getting the duration of an MP3 is to first get the size of the file, then subtract
128 bytes for the TAG. Divide the number of remaining "Bits" in the file by the bitrate.
So to get the file length:
.
.
using System.IO;
.
.
FileStream MP3File;
.
MP3File = new FileStream("C:\\mySong.mp3", FileMode.Open);
.
FileLength = MP3File.Length; // gives file length in bytes
.
And for the duration:
.
Duration = ((FileLength - 128) * 8) / bitrate; //gives duration in seconds
.
The problem now lies in getting the bitrate. If you know all your files are say 128kbits/sec
you can cheat an get a pretty good estimate. So your formula would be.
Duration = ((FileLength - 128) * 8) / (1024*128);
The problem is real MP3 files can have different bitrates within individiual song blocks.
So it would be neccessary to read each block header for the bitrate and then add everything
up at the end. Rather a tedious exercise.
Hope that helps a bit
greycrow
|
|
|
|
|
Hi All
the string value is:
strValue = "ABCD*XYZ";
I want to know the possition of sterik *
thank you
|
|
|
|
|
int pos=strValue.IndexOf("*"):
Luc Pattyn
|
|
|
|
|
Use something like:
int asteriskPosition = strValue.IndexOf("*");
This returns the index of the * in the string.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thank you sir
|
|
|
|
|
I have a (simple) custom control, a NumericTextBox. This control allow to the user to type only numbers (0..9) inside.
I do this OnKeyPress and OnKeyDown events.
The problem is if the user do paste from Clipboard. I don't know how to deny "paste" operation if the content of the clipboard is not a number. (in each textbox you have an context menu, with "paste" function).
Or... better, not to deny the "paste" operation, but to add to the existing text of the textbox only numeric part of the clipboard content. (if the clipboard contains 12ad3 in my textbox to be added 123).
Any suggestion?
|
|
|
|
|
Hello,
I would suggest to validate the text in the OnTextChanged.
Store your valid nunber first and if the Conversion or better double.TryParse is not ok, insert the stored value again.
All the best,
Martin
|
|
|
|
|
why don't you use minimum and maximum properties??
life is study!!!
|
|
|
|
|
how to use this? min and max?
|
|
|
|
|
Hello! I working with 2005 MS Visual Studio. Wrote a function in c++: int func(LPWSTR lpszName){... return 0;}. I want to call it from c#: classname.func("name");, but compiler get error : Argument '1': cannot convert from 'string' to 'char*'. What can I do? Thanks
|
|
|
|
|
Your DllImport should just use "string" as the type:
[DllImport...]
public static extern void func(string name);
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi all,
i'm trying to develope a windows service which will listen on a database table (Oracle database) , when a record updated ,the service will store it on another database . (Sql Server database)
the question is what is the best methodology to detect database update?
my idea is to run a query periodically and check the update ?
is anyone have a better solution ?
thanks.
Hosam Kamel
Software Developer
|
|
|
|
|
Why not use a trigger on the Oracle table to insert a notification into another table that a record has been updated. Then, your service would simply scan the notifications table and retrieve the details from here. Architecturally, you would want the item to be removed from the notifications table when it has SUCCESSFULLY saved into SQL Server.
To be honest though, you don't need a windows service to do this. All you need to do is create a DTS/SSIS package in SQL Server that does the read and save for you, and then schedule it to run as a scheduled database job.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
We can run the SQL Profiler and store the changes for checking updates
Regards,
Sylvester G
|
|
|
|
|
hi all,
how can i check that a word file is open or not through C#.
thanks
|
|
|
|
|
Try to open it exclusive. If an exception occurs, it's already open.
|
|
|
|
|
Using the interop assemblies.
How to open a document with word in all Office versions?
(Can't add more than 1 refernce to the Microsoft Word X.0 Object Library)
|
|
|
|