ArtemisComm.Packet.GetPackage C# (CSharp) Method

GetPackage() static private method

static private GetPackage ( MemoryStream stream, int index, Type packageType ) : IPackage
stream System.IO.MemoryStream
index int
packageType System.Type
return IPackage
        internal static IPackage GetPackage(MemoryStream stream, int index, Type packageType)
        {
            IPackage retVal = null;

            object[] parms = { stream, index };
            Type[] constructorSignature = { typeof(MemoryStream), typeof(int) };
            if (packageType != null)
            {
                ConstructorInfo constructor = packageType.GetConstructor(constructorSignature);
                object obj = constructor.Invoke(parms);
                retVal = obj as IPackage;
            }

            return retVal;
        }