Jon написав:
The normal way to overcome this is to use an interface if possible.
and then use Runtime.InteropServices._Type.GetInterface Method (String)
No, and then call methods in the interface.
I guess it depends on the exact situation - but I would *generally*
rather see a "strongly called" interface member than futz around with
reflection. It does depend though.
let me explain .. this *program and it's parts* may be used by
different peope:
coders which work's on some modules(not core),artists who add new gfx
and add info about it in XML resource list file and designers who via
tool or directly in XML will place objects/ai rules(logic)/actions
etc... so one of core script side task:
1) is to load XML
2) try to find requested command(which type/state is unknown , only
name in string(or hash number,btw. functions may be created/changed by
modules at
runtime or even via DCOM))
3) find appropriate type/object,initalize it in
C# type
4) perform actions on it,which described in XML(partialy solved thnx
to you).
So as i thnk reflection and dynamic types is a good way, but as
a former C++ coder i'v hardly hitted in typecast of C#, in this way C#
to be more *plastic* on base synatx have a long way to go....well you
can call me *stuped C# green*...but i wanna make long look on C# in my
coding(i'm buyed by some ideas and toolz :).
thanks it's was a great help!.
now i only need find a way to get object by its name in string..
Objects don't have names. What exactly do you mean?
Object's don't have,some of (pre)boxed data have type and possibly can
still have intalization variable name, other part of objects directly
after
initalization(in some type) putted in some ArrayList as objects.
Objects in my cases in original type is user classes, mostly have
inside (public string name;)
so i need to get collection of initalized objects of .GetType( *XML
suppiled type name*
) and/or get collection of initalized objects which in pre-boxed type
have public string name; == *XML suppiled value* in some domain
assembly.
and still i'm not found a good solution to dynamicaly
typecast(unboxing) any *unknown type* to object at runtime.
Hang on - casting and unboxing are very different things. Casting at
runtime doesn't make sense because the point of casting is to give the
*compiler* more information, which clearly isn't relevant at runtime.
?give struct of data,rule to access data parts in memory at runtime,at
least this was so in C++!
this as i think was one of ideas to keep original GetType for objects
and for conversions
too...
Casting is not relevant if some data(and code data) is unmodified(in
compiled form)at
runtime(to get new type of data you need to make a copy of current with
new type) ,and make sense if same data at runtime maybe used in
different
means(types,forms,purpose) without modification or creating new data.