|
I don't know if it qualifies as a socket, but I'd use a Named Pipe.
Named Pipes are used for communication between processes, more info here (wikipedia)[^].
MSDN[^]
I can't find a good article on it (for .Net 3.5) at the moment, I guess I'll have to owe you.
|
|
|
|
|
Thanks! That seems to be a really good thing.
Will the following code work for me?: http://v01ver-howto.blogspot.com/2010/04/howto-use-named-pipes-to-communicate.html
|
|
|
|
|
One way to do this would be to create a wcf service that will be hosted in your main c# app. The Java app can then communicate with the c# app using a known Interface.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Thank you. Seems to be a reliable solution. But could you give me more details on this, please: "The Java app can then communicate with the c# app using a known Interface.".
|
|
|
|
|
CodeGust wrote: The java part must give strings
Explain that in more detail.
Examples:
Is this processing books?
Or a user is typing in words?
CodeGust wrote: So far I see the following ways to do this:
Or stdio.
I would probably use that or sockets.
|
|
|
|
|
>>> Explain that in more detail.
There is a Java program that uses Sphinx4.jar to recognize speech. It must send the recognized speech to the main program (written in .Net) in real time.
|
|
|
|
|
I don't think that answers the question.
First "speech" usually indicates vocal streams and you can't send 'speech' as a vocal stream in a String.
Second I doubt the library must process data in "real time". That might be your goal but is not a limitation of the library. It will accept its input at any time.
Third humans are slow compared to computers. So with care any of the methods you suggested would work.
Again I would use stdio or sockets. For text data. If you are using binary data then I would use a socket.
|
|
|
|
|
Hi,
In c#, I would like to validate the txtEmail by checking if a valid email address has been entered before moving away from the textbox.
If email is not valid then, txtemail should get the focus again.
The code below is what I have for this purpose but whether or not the email is valid the messagebox appears constantly and does not go away.
CAn you please see what is wrong?
Thanks
private static bool IsEmailAllowed(string text)
{
bool blnValidEmail = false;
Regex regEMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if (text.Length > 0)
{
blnValidEmail = regEMail.IsMatch(text);
}
return blnValidEmail;
}
private void txtEmail_LostFocus(object sender, RoutedEventArgs e)
{
if (IsEmailAllowed(txtEmail.Text.Trim()) == false)
{
MessageBox.Show("E-Mail expected", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
txtEmail.Focus();
}
}
|
|
|
|
|
Perhaps a better way is to use control validation. Take a look at this article as it seems to heading in the direction you want...
Here
|
|
|
|
|
Thanks for the link, But I have to get this to work in the current event.
Thanks
|
|
|
|
|
arkiboys wrote: But I have to get this to work in the current event.
Why? What requirement could possibly say where you have to get this to work?
|
|
|
|
|
Apologies for mis-understanding...
I would like to see if I can get it to work using the events.
Thanks
|
|
|
|
|
LostFocus event is a bad place to write validation code, try Validating (or Validate) event and set a property on the eventagr to flag a validation failure.
The best course of action would be to use built-in validator controls.
Alternatively your regex could be wrong, try stepping through your code.
|
|
|
|
|
Are you able to see if the regular expression is incorrect?
Thanks
|
|
|
|
|
Google for "Expresso". It's a great tool for writing and testing RegExs, and it's free!
As for your approach. it's bad. You're writing your code from the standpoint that users will do nothing else while your app is running. You are preventing them from possibly leaving your form or closing it without first entering a valid email address. What if they left it blank and want to go back to the previous window??
|
|
|
|
|
There is no validate event.
|
|
|
|
|
Hi,
I have this code:
object o = Csla.Serialization.Mobile.MobileFormatter.Deserialize(bin);
object val = ((Csla.Silverlight.PrimitiveCriteria)o).Value;
As you can see I get some object by deserialization. In this particular case I expect the object that is actually of Csla.Silverlight.PrimitiveCriteria type and I can cast the object in second line as I did above. In this case I know the type of object because I've seen it at debug time. But, what to do if I need to determine the type of object at runtime? What to do in case I want to parametrize the whole process? It means the class I get by deserialization can be different. How can I use that class to cast the object in second line?
Thank you in advance.
Goran Tesic
modified on Tuesday, May 10, 2011 6:19 AM
|
|
|
|
|
Tesic Goran wrote: How can I use that class to cast the object in second line?
I'd suggest to use a shared interface/common base class; if all the deserialized classes share something in common, you can use that to access it. That doesn't mean that you're restricted to a single interface; you can ask the object what interfaces are implemented and act based on that information.
I are Troll
|
|
|
|
|
Thank you for your answer.
In this case, there's a basic interface that Csla.Silverlight.PrimitiveCriteria class implements, but that interface contains only basic methods. For example, Value property is specific for Csla.Silverlight.PrimitiveCriteria class. Other properties can be specific for other classes. What to do in that case?
|
|
|
|
|
I'd add my own interface. It doesn't have to be implemented in the CSLA-classes, just in the classes that you're going to serialize.
That would give you the option to deserialize 'unknown', check if it matches an known interface and cast it thereto.
I are Troll
|
|
|
|
|
The problem is that I can't change the code in the classes I deserialize. They are all in some DLL that I use in my DLL.
|
|
|
|
|
Tesic Goran wrote: The problem is that I can't change the code in the classes I deserialize.
Are they sealed ? If not, inherit, wrap and add an interface
I are Troll
|
|
|
|
|
If I understand you correctly, I could create new class, for example PrimitiveCriteriaNew that inherits from Csla.Silverlight.PrimitiveCriteria and implements new IInterfaceNew in this way:
public interface IInterfaceNew
{
}
public class PrimitiveCriteriaNew : Csla.Silverlight.PrimitiveCriteria, IInterfaceNew
{
}
And use it in this way:
object o = Csla.Serialization.Mobile.MobileFormatter.Deserialize(bin);
object val = ((PrimitiveCriteriaNew)o).Value;
Is this correct? If so, if I have 1000 classes in that external DLL, I should do the same 1000 times?
|
|
|
|
|
Tesic Goran wrote: Is this correct?
Looks good to me, although I'd suggest you keep the interface-type after the cast, like this;
object o = Csla.Serialization.Mobile.MobileFormatter.Deserialize(bin);
IInterfaceNew val = ((IInterfaceNew)o).Value;
Tesic Goran wrote: If so, if I have 1000 classes in that external DLL, I should do the same 1000 times?
No, you can probably generalize some interfaces in a way that they can be re-used.
I are Troll
|
|
|
|
|
Hi,
Instead of writing :
object o = Csla.Serialization.Mobile.MobileFormatter.Deserialize(bin);
object val = ((Csla.Silverlight.PrimitiveCriteria)o).Value;
You may go with dynamic here: Simple reading and access
dynamic o = Csla.Serialization.Mobile.MobileFormatter.Deserialize(bin);
object val = o.Value;
You don't need to cast it any where
For more details about dynamic you may go on this.
Perform Reflection and XML Traversing Using the dynamic Keyword in C#[^]
This may be helpful to you.
Thank You
|
|
|
|