Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
The DLL:

C#
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:

C#
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

C#
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
Updated 7-Jan-12 10:25am
v2

1 solution

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:

C#
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
}

//usage:

ElementContainer container = new ElementContainer(/*...*/);
container.Add(/*...*/);
contaner.AddRange(/*...*/);
Element myElement = container[3]; // :-)


—SA
 
Share this answer
 
v4
Comments
EveryNameIsTakenEvenThisOne 7-Jan-12 19:52pm    
Thank you, just what i needed!
Sergey Alexandrovich Kryukov 8-Jan-12 0:18am    
Sure, you are welcome.
Good luck, call again.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900