|
I'm really guessing now, but have you tried using Invalidate? It may force Windows to redraw the desktop (it is, after all, just a different kind of window). If not, I'm afraid I'm stumped, sorry.
|
|
|
|
|
how to use invalidate?
please advice me...
i read invalidaterect from dllimport user32.dll but don't understand
if have another function or other as same as invalidate.
please advice me.
thanks a lot...
|
|
|
|
|
hello
How not to hardcode conn string username/pwd in plaintext for log4net ADO.NET appender?
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="0" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<!-- How not to have username/pwd in plaintext? -->
<connectionString value="data source=LAPPC2;initial catalog=SomeDB;integrated security=false;persist security info=True;User ID=dev;Password=somepwd" />
...
</appender>
See above, username "dev" and password are in plaintext.
Same question for nhibernate - see example below:
<configuration>
<configSections>
<section
name="nhibernate_SomeDB"
type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
<section
name="nhibernate_AuditTrail"
type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate_SomeDB>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=SomeDB;User Id=dev;Password=somepwd;Min Pool Size=2" />
</nhibernate_SomeDB>
<nhibernate_AuditTrail>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=SomeOtherDB;User Id=dev;Password=somepwd;Min Pool Size=2" />
</nhibernate_AuditTrail>
</configuration>
dev
|
|
|
|
|
You can put the connection string in your app and set the connection string before attempting to use the database.
Or, you can encrypt it in the app.config file.
Google is your friend.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: You can put the connection string in your app and set the connection string before attempting to use the database.
That's how I do it with ADONET. But what about Hibernate and log4net? I can change connection strings on the fly/programmatically with log4net/nhibernate?
dev
|
|
|
|
|
I want to declare a simple array of stuct with the struct containing an array as shown below. But it does not compile. If you can't tell I'm very new to C#.
public struct ChangeRec
{
public datetime LastTimeStamp;
public int last ;
public int mode[10] ; // I want an integer array of values
}
if I change the last line as shown, it will compile, but how do I control the size and access the elements?
public int [] mode ;
This seems too simple to be this hard. Thanks
|
|
|
|
|
You declare an array with int[] and then you set it's size when you create it.
mode = new int[10]; This can go in your contructor.
If your array was of a class then they would all be null and would need to be newd individually, too. As they are int, they will all be fine, but I mention this for future reference.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Why does it have to be a struct? Unless this is for Interop I don't see the value in storing a reference type within a value type - why not just declare it as a class?
It definitely isn't definatley
|
|
|
|
|
moon_stick wrote: storing a reference type within a value type
What reference type?
only two letters away from being an asset
|
|
|
|
|
An array is a reference type, no? Of type System.Array??
It definitely isn't definatley
|
|
|
|
|
I guess I looked at the data type and ignored the array
only two letters away from being an asset
|
|
|
|
|
Personally, I'd make your struct a class, and use a generic list instead of an array.
At that point you could do something like this:
public class ChangeRec
{
private List<int> m_modes = new List<int>();
public DateTime LastTimeStamp { get; set; }
public int LastValue { get; set; }
public List<int> Modes { get { return m_modes; } }
public ChangeRec() {}
}
There is now no need to initialize the list beyond what's done in the class.
One other thing... I the variable "Last" refers to the last value added to the list. If that's the case, you can do this (uif you're using the code I posted above):
ChangeRec changeRec = new ChangeRec();
changeRec.Modes.Add(1);
changeRec.Modes.Add(2);
changeRec.Modes.Add(3);
changeRec.Modes.Add(4);
int lastValue = (int)(changeRec.Modes.Last());
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Monday, January 5, 2009 11:42 AM
|
|
|
|
|
i think the fixed keyword might help you
unsafe public struct ChangeRec
{
public DateTime LastTimeStamp;
public int last ;
public fixed int mode[10] ; // I want an integer array of values
}
}
The big problem here is that you'll have to allow unsafe code within your project so it's probably not the best plan unless you're planning to use interop.
i'd be tempted to implement the thing as a class and create getMode(int i) and setMode(int i) methods.
Russ
|
|
|
|
|
The reason is that C# does not allow us to have instance field initializer in struct.
there is a workaround if you do not want to use the unsafe code, such as:
struct MyStruct
{
public int last;
public int[] mode;
public int[] Mode
{
get
{
if (this.mode == null)
{
this.mode = new int[10];
}
return this.mode;
}
}
}
The code above can be compiled successfully.
Tan Li
I Love KongFu~
|
|
|
|
|
Like everyone else, I would question why this is not a class. That doesn't answer your question, however. If you do indeed need a struct...which indicates you need it to be allocated on the stack, I would do something like the following (this might not be exact...havn't used stackalloc in a long time):
public struct ChangeRec
{
public ChangeRec(byte modeSize)
{
mode = stackalloc int[modeSize];
}
public DateTime LastTimeStamp;
public int Last;
public int[] mode;
}
|
|
|
|
|
Thanks for all your inputs, I've got it working as a class. I still don't know how to make this an array using this structure. What I need is an array of 200 records with each record having the structure as originally shown and guidance on how to actually use it.
|
|
|
|
|
I want to know if I can inherit a class and then make it so one of the members that is inherited is not visible. My reason is that on top of memory issues, I don't want the empty member because i am going to use a list of members of the inherited class as a datasource of a gridview and if i have the extra member, it will appear on the gridview. I am up for other suggestions on how to deal with this problem.
|
|
|
|
|
bfis108137 wrote: My reason is that on top of memory issues
You can't fix this, and if the object is empty, the memory usage is negligible anyhow.
bfis108137 wrote: and if i have the extra member, it will appear on the gridview
Only if you make the gridview auto generate column s
bfis108137 wrote: I am up for other suggestions on how to deal with this problem.
Create an interface that only exposes the items you want to see, and then bind to a collection of that.
You can't make a property on the base class disappear.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello everyone,
Suppose I have the following XML file, I want to use XPath query based technologies to iterate all attributes for all rules nodes and all attributes for each sub rule nodes (under each rules node).
Could anyone provide some pseudo code please? I know how to query rules and related attribute but do not know how to loop inside embed node rule under each rules node.
<Abc>
<rules name="USA">
<rule foo="123" goo="345"/>
</rules>
<rules name="CAN">
<rule foo="321" goo="543"/>
<rule foo="321" goo="234"/>
</rules>
</Abc>
thanks in advance,
George
|
|
|
|
|
Suppose you have the following to query the rules nodes:
XmlNodeList rulesNodes = myDoc.SelectNodes("//rules");
Then, in order to loop the rule nodes:
foreach (XmlNode rulesNode in rulesNodes)
{
XmlNodeList ruleNodes = rulesNode.SelectNodes("rule");
foreach (XmlNode ruleNode in ruleNodes)
{
....
}
}
Hope this helps.
|
|
|
|
|
Thanks Le Centriste,
For this statement -- "myDoc.SelectNodes("//rules");", XMLDocument class does not contain a method called SelectNodes. Any comments?
regards,
George
|
|
|
|
|
George_George wrote: XMLDocument class does not contain a method called SelectNodes. Any comments?
Yes it does[^]
|
|
|
|
|
Sorry, Le Centriste!
My typo.
regards,
George
|
|
|
|
|
George_George wrote: For this statement -- "myDoc.SelectNodes("//rules");"
How did you created the XMLDocuments?
XmlDocument xmlDoc = new XmlDocument();
Now Check xmlDoc.SelectedNodes() is there or not ?
cheers,
Abhijit
|
|
|
|
|
Thanks Abhijit!
My typo in my code before.
regards,
George
|
|
|
|