|
Hello,
Thanks for the link. Now I don't need anymore 3rd party ftp server just to transfer file
Thanks again,
DAN
|
|
|
|
|
Hello,
I have an activeMQ broker and .net(c#) application that send and consume message without problem.
Now, I want to add some security to broker to avoid anyone else send or consume my messages.
So, I add simpleAuthenticationPlugin with username/password in AMQ configuration file, now in .net client I can't send messages because username/passw should be provided.
Until now all is ok, the problem is I dont found where to supply this information from code.
I can't set it in CachingConnectionFactory or SimpleConnectionFactory, it is not allowed, I dont find any other type of ConnectionFactory available in Spring.Messagin.Nms namespace I could use.
So I need some hint from any of you.
spring conf file is very simple:
<object id="ActiveMqConnectionFactory" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
<property name="UserName" value="usertest"/>
<property name="Password" value="passwordtest"/>
</object>
<object id="ConnectionFactory" type="Spring.Messaging.Nms.Connections.CachingConnectionFactory, Spring.Messaging.Nms">
<constructor-arg index="0" ref="ActiveMqConnectionFactory"/>
<property name="SessionCacheSize" value="10"/>
</object>
<object id="NmsTemplate" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
<constructor-arg index="0" ref="ConnectionFactory"/>
<property name="MessageConverter" ref="SimpleMessageConverter"/>
</object>
and in c# code I just use NmsTemplate as:
this.NmsTemplate.ConvertAndSend(msg);
Thanks in advances
|
|
|
|
|
Hi everybody!
I want to know if it is possible to get the USB port current value when I plug the device in it. The value should be get programmatically using C#. The second parameter I need is USB save power mode. The correct name of the property in the device manager is "Allow the computer to turn off this device to save power".
I managed to detect the device (if it is connected or disconnected) and read data from it correctly. Do these two properties belong to USB device or to USB port?! WinUSB Api did not give me clear answers to my questions.
Thanks!
|
|
|
|
|
Ok, this is probably a very basic question, but how would I go about creating the following (bear with me. I'm new to oop):
Lets say I'm in the automotive industry and I build a c# class called "Cars". Within this class, I have 2 properties:
-Model
-Year
So I can call them via Cars.Model & Cars.Year via code like this:
public class Cars
{
public string Model { get; set; }
public string Year { get; set; }
}
So far, so good....HOWEVER....now, I want to do a sub-property of Model, called Color. I would want to call it with something like this:
Cars.Model.Color = "green";
How would I create this "Color" property so that it becomes a sub-property of "Model"?
Thanks
|
|
|
|
|
You give Model a type that has a property called Color
|
|
|
|
|
I don't think somebody likes us giving this poster answers.
|
|
|
|
|
So it would seem..
Oh well, we probably got more upvotes because of it
|
|
|
|
|
I have been repeatedly asking to make comments mandatory for downvotes. I understand that the voter may put some garbage in the comments just for the sake of it. But it would help us to identify the trolls and banish them. (It can also help Chris to delete those downvotes).
|
|
|
|
|
As your code currently stands, you can't. What you need to do is create a class that Model implements (let's call it the Model class). Now, in this Model class, you'll have your Color property, so you end up with something like the following:
public class Cars
{
public Model Model { get; set; }
public string Year { get; set; }
}
public class Model
{
public string Color { get; set; }
} Now, a couple of things to consider here. First of all, you shouldn't be using a string for the Year property - it's really a number. Secondly, you shouldn't really call your class Cars - it's describing a single car, so it should really be called Car.
|
|
|
|
|
I think you're going about it wrong.
I think the Model class should have the Year property, but not the Color property. Although the Model class could have an AvailableColors collections.
|
|
|
|
|
Hey Guys,
I want to write a C# WinForms application, which on clicking a button will go to a particular web page and input the user name and password correctly. Once this step is done, it will go to the inbox and here i want to click a button. All this needs to be done with the web page in hidden mode.
For eg, Go to mail.yahoo.com and correctly enter the user name and password. Now it should click on the "Delete" button in my inbox.
Is it possible? Any sample code is welcome.
Thanks in advance
|
|
|
|
|
Gmail offers access over it's own API[^], might be easier.
Bastard Programmer from Hell
|
|
|
|
|
.NET 4.0
I have just finished finally figuring out how (in WinForms) to make changes to Properties in an ObservableCollection<T> fire notifications ... attaching events to ObservableCollection items, like adds, and deletes, are, of course, easily handled ... and it required a rather ugly hack to do it which involved casting an instance of an Observable<t> to the INotifyPropertyChanged interface.
Attempting to figure out if I have created a monstrosity, or if there's a better way, I have been searching CP for information on generic ObservableCollections<T>, and INotifyPropertyChanged, and just about everything that comes up is WPF or SilverLight related.
My impression is that WPF and SilverLight offer much more flexibile facilities for wiring-up property changes than WinForms, that 'INotifyPropertyChanged' is a different critter in WPF, and that one would not have the problem I encountered in WinForms in getting Property changes to raise events.
But, I would appreciate an opinion from those of you who I am sure know both WinForms and WPF well, if my impression is correct.
In the unlikely case I have discovered some useful technique for WinForms, I'll certainly publish an article on it here on CP.
thanks, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
modified on Thursday, August 11, 2011 2:23 PM
|
|
|
|
|
First question, if you're data binding, why not use a BindingList<T>? Binding to that automatically causes the collection changes to be attached to, though I think that is the case for anything which implements INotifyCollectionChanged.
If your element type (i.e. 'T') implements INotifyPropertyChanged, the data consumer will hook to it and will update its display when you fire it (for the property which you declare as notified). I have tried this at least for a DataGridView and basic one-property controls (text box, check box etc) and it works as expected. You shouldn't need to do any casting if T implements that interface.
I'm not quite sure if you're asking a question here or just providing information about your experience so replying to the post is a bit tricky!
|
|
|
|
|
Hi Bob, thanks for your response !BobJanova wrote: if you're data binding, why not use a BindingList<T>? In this case I am not binding anything; there's no dataset in the woodpile I will go and take a look at Binding<T> now that you've pointed that out to me. fyi: I am familiar with implementing property notifications, like for the Text in a TextBox changing without any use of a dataset, or datasource.BobJanova wrote: not quite sure if you're asking a question here or just providing information about your experience I'm not quite sure either; I believe I am asking the question of whether the requirement, in the case of using an OC<T>, to cast an instance of it to INotifyPropertyChanged, in order to use its internally implemented property change notifications ... which I consider a very odd thing to have to do ... is worth the 'ugliness' involved.
And, I am hoping that you, or someone else here, who I am sure are at very advanced levels in .NET development, will give me some insights into what seems like a 'mystery' (to my 'naive' eyes). Perhaps, insights, based on your knowledge of how .NET has evolved. I know that OC<T> has changed library locations, and possibly some internal behavior, from .NET 3.0=>3.5=>4.0.
My intent in exploring this area is somewhat academic ... but certainly not homework (I'm nearing 68 years old) ... I am just deeply interested in understanding .NET's implementation, in WinForms, C#.
On a practical level, the ability to get a notification when a value is changed of a member of an arbitrarily typed collection, independent of binding to a datasource, seems valuable to me; I focused on OC<T> because that gives you 'out-of-the-box' notifcations when an item is added, or deleted, from the Collection<T>. It seemed natural, once I found out that OC<T> implemented property notification, to want to use that.
I did 'stumble' into finding out how to use the native property notification facility in OC<T>, but finding even a 'clue' about how to use it took pretty thorough research here, on StackOverFlow, and on MSDN. And, the way I found to actually use it, in a fairly standard scenario, I came up with on my own; didn't find a single example of that in my research (which of course doesn't mean it isn't there, somewhere on the internet).
Let me see if I can 'wrap this up:' for example, if you, or Pete O., or Shameel, or others here, said to me: 'yeah the fact that OC<T>'s INotifyPropertyChanged implementation is kind of 'sealed,' and you have to cast an instance of your collection to it to be able to use it, really is weird, probably better ... because of .?. not to use it, I'd feel enlightened, temporarily.
On the other hand, if I heard here that it might be valuable to use a technique for making an OC<T>'s property notifications available, I'd certainly at least write up a tip/trick for CP.
On the broader level, I do look forward to one-day, perhaps, having something like Property Extensions in .NET, and I understand that has been considered seriously, but is not on the .NET time-line now. I'd definitely like to be able to do some of the things that it seems WPF offers you in terms of property bindings, etc.
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
Unfortunately I'm not really that familiar with ObservableCollection, though I have used the Silverlight version (is it the same?).
If I understand you correctly, you want to get an event on the collection when a property of an element is changed (and notified through INotifyPropertyChanged on the element – T must implement INotifyPropertyChanged and fire the notification event for any method of having observer updates). The ObservableCollection explicitly implements the INotifyPropertyChanged interface, so yes, if that event is correctly fired when a member element is updated, you will need to cast the collection to hook it. I haven't tried it so I don't know if it works.
(I.e., does the event get fired in this test case, and if so are the arguments useful:
void Test(){
var c = new ObservableCollection<Notifier>();
((INotifyPropertyChanged)c).PropertyChanged += (s,e) => MessageBox.Show("Property "+e.PropertyName+" on "+s+" updated");
c.Add(new Notifier());
c[0].NotificationProperty = 42;
}
class Notifier : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public int NotificationProperty {
get { return notificationProperty; }
set { notificationProperty = value; PropertyChanged(this, "NotificationProperty"); }
}
}
)
The fact that they made that interface implementation explicit and force the cast implies they probably aren't expecting you to use it in this way, but if the event is fired when properties on the elements change and that is useful to you, I don't see a problem with using it in that fashion.
|
|
|
|
|
Thanks, Bob, for your response ! I will study your code over the weekend (I'm on GMT+7).
I think the best thing for me to do here, in order to clarify what I have found, and get reactions, is to go ahead and write up a Tip/Trick demonstrating fully what I started out to do, what the problem was I encountered in trying to do it, and what the 'odd' solution was that I finally came up with.
Then if the Tip/Trick leads to great gnashing of teeth, and I am cast into outer darkness, so be it.
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
I'm not sure what effect you are trying to achieve. ObservableCollection does not raise an PropertyChanged event - it raises events from INotifyCollectionChanged . What you could do, is inherit from ObservationChanged , and override the OnChanged method - and use this to raise a PropertyChanged event.
I hope that helps.
|
|
|
|
|
According to the documentation[^], ObservableCollection also implements INotifyPropertyChanged, but explicitly (i.e. requiring a cast to hook to).
|
|
|
|
|
Hi Pete, Thanks for responding !
As Bob says, in the post just above this one, ObservableCollection<t> does implement INotifyPropertyChanged, and my whole problem here was finding the way to use facility.
I think the best thing for me to do now, as I just wrote to Bob, in order to clarify what I have found, and get reactions, is to go ahead and write up a Tip/Trick demonstrating fully what I started out to do, what the problem was I encountered in trying to do it, and what the 'odd' solution was that I finally came up with.
Then, if the Tip/Trick leads to great gnashing of teeth, and I am cast into outer darkness, so be it.
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
process = Process.Start(psi);
process.WaitForExit(executionTimeOutSecs * 1000);
if (!process.HasExited)
{
StringBuilder text = new StringBuilder();
text.AppendFormat("Having to kill {0}, executed longer than timeout value, {1} sec.", taskName,
executionTimeOutSecs);
if (logging)
{
log.writeLogFile(text.ToString());
}
log.writeEventLogWarning(text.ToString());
process.Kill();
process.WaitForExit(1000);
}
process.Close();
Here i am getting "hasexited" false my process not exited in given time how to handle this.
|
|
|
|
|
Properly format your code snippet and people may answer you
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
process = Process.Start(psi);
process.WaitForExit(executionTimeOutSecs * 1000); // convert seconds to milliseconds
if (!process.HasExited)
{
StringBuilder text = new StringBuilder();
text.AppendFormat("Having to kill {0}, executed longer than timeout value, {1} sec.", taskName,
executionTimeOutSecs);
}
process.Close();
I think this is ok here Hasexited is retur nfalse i want to avoid this
|
|
|
|
|
I said FORMAT the code snippet not REPOST it.
Read the forum guidelines, that post at the top of this list that you have ignored.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The code which i pasted is enough to answer
see the question "How to get answer" and try to help developer
|
|
|
|
|