Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#3.0 C#4.0 DLL Managed reflection , +
The DLL:
public static List<byte[]> RequestDialoge(int NPCID,int Control)
            List<byte[]> CombinedPacket = new List<byte[]>();
            CombinedPacket = Dialoge.Create(NPCID, Control);
            return CombinedPacket;
How i want to use it:
int NPCID = BitConverter.ToInt32(Packet, 4);
                            int Control = (int)Packet[10];
                            Cli.CurrentNPC = NPCID;
                            object[] Data = new object[2];
                            Data[0] = NPCID;
                            Data[1] = Control;
                            Assembly assembly = Assembly.LoadFile(@"Y:\OS Share\C#\DynamicNpcDialoge.dll\bin\Debug\DynamicNpcDialoge.dll");
                            Type T = assembly.GetType("DynamicNpcDialoge.dll.DynamicNpcDialog");
                            MethodInfo foo = T.GetMethod("RequestDialoge");
                            object Packers = foo.Invoke(T, Data);  
Got my solution already, i was just thinking too complicated
List<byte[]> packets = Packers as List<byte[]>;
Packers now becomes count 5
Every of that 5 contains a byte array,
however, i dont know how to access them...
Any Ideas?
Posted 7-Jan-12 10:09am
Edited 7-Jan-12 11:25am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your code is not quite clear to me, but providing a data structure that looks like an array for a user and is not an array in implementation is quite easy:
internal struct Element {/*..*/} //or class

class ElementContainer {
    internal Element Add(Element element) {/*...*/ return element; }
    internal void AddRange(Element[] elements) {/*...*/}
    internal Element this[int index] { get { return GetElement; } }
    #region implementation
        Element GetElement(int index) {/*...*/}
        //all complexity is hidden here :-)
    #endregion implementation

ElementContainer container = new ElementContainer(/*...*/);
Element myElement = container[3]; // :-)
Yukiiii at 7-Jan-12 19:52pm
Thank you, just what i needed!
SAKryukov at 8-Jan-12 0:18am
Sure, you are welcome.
Good luck, call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 8 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100