ArtemisComm.GameMessagePacket.GetSubPacket C# (CSharp) Method

GetSubPacket() private method

private GetSubPacket ( Stream stream, int index ) : IPackage
stream Stream
index int
return IPackage
        IPackage GetSubPacket(Stream stream, int index)
        {
            IPackage retVal = null;
            try
            {
                if (stream.CanSeek)
                {
                    stream.Position = index;
                }

                object[] parms = { stream, index };
                Type[] constructorSignature = { typeof(Stream), typeof(int) };

                Type t = Type.GetType(typeof(GameMessageSubPacketType).Namespace + "." + this.SubPacketType.ToString());


                if (t != null)
                {
                    ConstructorInfo constructor = t.GetConstructor(constructorSignature);
                    object obj = constructor.Invoke(parms);
                    retVal = obj as IPackage;
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex);
            }
            return retVal;
        }