|
I don't know if this will address your question or not but it is bad practice to directly use the Session object in code. By using a static wrapper class you can have all calls to session centralized as well as strongly and statically typed (a good thing). You then have the freedom to completely control the underlying implementation.
The link below addresses a custom provider.
http://msdn.microsoft.com/en-us/library/ms178587.aspx[^]
|
|
|
|
|
My Qestion: It is possible to call the Class instance name I get with
FieldInfo[] myFieldInfo;
.......
myFieldInfo[i].Name
(Example from MSDN)
Thanks
|
|
|
|
|
Your question is not very clear. Could you clarify what exactly it is that you want to do?
|
|
|
|
|
Sorry for my unclear question.
What I want is to call a method via its class-instance name (I have already create a instance) at runtime from another class in the same assembly.
The problem is, I don´t know the class instance name at compile time.
So I get the name via reflection (FieldInfo class).
Probably a method like "methodInfo.Invoke" can do the job, but so far I´m understand
the class instance must known at compile time.
Thanks
|
|
|
|
|
Just to be clear on that, you have a field of a particular type, and you want to invoke a method on this field instance at run-time. Is that right?
|
|
|
|
|
Something like this should work:
class SomeType
{
public void Foo()
{
Console.WriteLine("SomeType.Foo");
}
}
class AnotherType
{
private SomeType someType = new SomeType();
}
class App
{
static void Main()
{
AnotherType another = new AnotherType();
string fieldName = "someType";
FieldInfo fi = another.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
object fieldValue = fi.GetValue(another);
SomeType someType = fieldValue as SomeType;
if(someType != null)
{
someType.Foo();
}
}
}
|
|
|
|
|
Works perfect! Exactly what I´m searching for.
Thanks.
Regards
|
|
|
|
|
I've just spent a few days creating a User Control in a library, and for a project I want several similar controls. The new controls will contain some of the same elements, in different positions perhaps, and with different names, but the overall User Controls should be of the same size, color, font, etc.
Is there an easier way than manually creating each User Control and adding back all the elements, just to make something almost, but not quite identical to the original?
[EDIT]
I opened the project folder, located the three basic files for the control - .cs, .resx, .Designer - and copied them to a subfolder. I then renamed them and copied them back to the original project folder. Then I used Add Existing Item in VS to locate the renamed files and add them to my project. It choked, of course, because of ambiguity. Using Find and Replace, I opened all the new files, closed all the files I wanted to keep, and selected the option to Find and Replace in all open files, using the original filename and new file name as arguments. It worked like a charm, and will save me hours of manual editing. It even builds without error...
[/EDIT]
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
A good user control is like an onion...
But seriously, make a user control with the basic shape and colour and then specialize from that.
|
|
|
|
|
I have, but now I want to duplicate it several times within the project, but using different names for each copy. I'm thinking I might be able to get away with building the project now, then adding "existing items" from the project folder and giving them new names. Will that work?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Sounds dreadful... maybe you're looking implants[^].
|
|
|
|
|
Your Implant idea is excellent, but I've already done what I added to the original post. Easy stuff, and no tedious retyping. Change the text in the labels, drag 'em around a bit, file off the serial numbers and, voila! A new control is born.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I have a treeview that I populate with data from various tables in mysql db. I also update the tables based on user actions. I was wondering, is it more efficient to use a mysqlDataAdapter for this or just CommandText and MySql Reader for populating and then separate CommandText statements for updating?
|
|
|
|
|
A reader done right is usually, almost always, faster than a data adapter, dataset solution. In the cases where timings show a data adapter executing faster there is usually a flaw in logic. Where the Data Adapter and data set solutions are usually faster is in Dev/Time not run time.
|
|
|
|
|
|
While I wasn't looking for an answer to that question, it will certainly come in handy for a project I'm working on - one of several. Thanks!
Is not a reader a one-way solution, though; that is, for reading from a database in one direction? And a data adapter is more of a random access solution? Such additional overhead would certainly explain the performance difference.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
A common misconception. ADO.NET is exclusively a fast-forward, read-only cursor. The data adapter uses a data reader behind the scenes to get the data. What the data adapter does is attempt to infer the schema from the available result sets and then read to the end of all cursors populating a data set. You then get your data in a handy data set with associated overhead.
AFAIK there is not an ADO.NET solution intended to maintain an open cursor to the DB at all.
|
|
|
|
|
with associated unnecessary overhead
|
|
|
|
|
Back to the books...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
DataReaders underly all ADO.net access; including ExecuteScalar, ExecuteNonQuery, and DataAdapter.Fill and .Update
Learning to use them effectively will make you a better developer. And chicks dig it.
|
|
|
|
|
PIEBALDconsult wrote: And chicks dig it
Well, that's good enough for me!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Avoid DataAdapters for real work; their only purpose is to allow MS demonstrators at launch events to produce a barely-working program in the time allowed.
|
|
|
|
|
thanks for all the info. I've been using DataReaders so far and just came across the adapter. So I'll stick with the reader.
|
|
|
|
|
Hello,
I try to find how to set the property " User must change password at next log on " and i don't found.
somebody knows how to change this property ?
ThankYOU !!
|
|
|
|
|
See the "Where Password Attributes Reside" section at this[^] page.
/ravi
|
|
|
|