// Token: 0x06000186 RID: 390 RVA: 0x0000DE70 File Offset: 0x0000C070
        public static Gecko4 Create(byte[] dataToParse)
        {
            Gecko4 gecko = new Gecko4();

            for (int i = 0; i < dataToParse.Length; i++)
            {
                Gecko2 gecko2 = (Gecko2)dataToParse[i];
                Gecko2 gecko3 = gecko2;
                switch (gecko3)
                {
                case Gecko2.Integer:
                {
                    gecko.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.Integer,
                            ObjectLength = (int)dataToParse[i + 1]
                        });
                    byte[] array  = new byte[(int)dataToParse[i + 1]];
                    int    length = (i + 2 + (int)dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : ((int)dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array, 0, length);
                    gecko.Objects[gecko.Objects.Count - 1].ObjectData = array;
                    i = i + 1 + gecko.Objects[gecko.Objects.Count - 1].ObjectLength;
                    break;
                }

                case Gecko2.BitString:
                case Gecko2.Null:
                    break;

                case Gecko2.OctetString:
                {
                    gecko.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.OctetString,
                            ObjectLength = (int)dataToParse[i + 1]
                        });
                    byte[] array2 = new byte[(int)dataToParse[i + 1]];
                    int    length = (i + 2 + (int)dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : ((int)dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array2, 0, length);
                    gecko.Objects[gecko.Objects.Count - 1].ObjectData = array2;
                    i = i + 1 + gecko.Objects[gecko.Objects.Count - 1].ObjectLength;
                    break;
                }

                case Gecko2.ObjectIdentifier:
                {
                    gecko.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.ObjectIdentifier,
                            ObjectLength = (int)dataToParse[i + 1]
                        });
                    byte[] array3 = new byte[(int)dataToParse[i + 1]];
                    int    length = (i + 2 + (int)dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : ((int)dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array3, 0, length);
                    gecko.Objects[gecko.Objects.Count - 1].ObjectData = array3;
                    i = i + 1 + gecko.Objects[gecko.Objects.Count - 1].ObjectLength;
                    break;
                }

                default:
                    if (gecko3 == Gecko2.Sequence)
                    {
                        byte[] array4;
                        if (gecko.ObjectLength == 0)
                        {
                            gecko.ObjectType   = Gecko2.Sequence;
                            gecko.ObjectLength = dataToParse.Length - (i + 2);
                            array4             = new byte[gecko.ObjectLength];
                        }
                        else
                        {
                            gecko.Objects.Add(new Gecko4
                            {
                                ObjectType   = Gecko2.Sequence,
                                ObjectLength = (int)dataToParse[i + 1]
                            });
                            array4 = new byte[(int)dataToParse[i + 1]];
                        }
                        int num = (array4.Length > dataToParse.Length - (i + 2)) ? (dataToParse.Length - (i + 2)) : array4.Length;
                        Array.Copy(dataToParse, i + 2, array4, 0, array4.Length);
                        gecko.Objects.Add(Gecko1.Create(array4));
                        i = i + 1 + (int)dataToParse[i + 1];
                    }
                    break;
                }
            }
            return(gecko);
        }
Exemple #2
0
        public static Gecko4 Create(byte[] dataToParse)
        {
            Gecko4 Gecko4 = new Gecko4();

            for (int i = 0; i < dataToParse.Length; i++)
            {
                Gecko2 Gecko2 = (Gecko2)dataToParse[i];
                int    num    = 0;
                switch (Gecko2)
                {
                case Gecko2.Sequence:
                {
                    byte[] array;
                    if (Gecko4.ObjectLength == 0)
                    {
                        Gecko4.ObjectType   = Gecko2.Sequence;
                        Gecko4.ObjectLength = dataToParse.Length - (i + 2);
                        array = new byte[Gecko4.ObjectLength];
                    }
                    else
                    {
                        Gecko4.Objects.Add(new Gecko4
                            {
                                ObjectType   = Gecko2.Sequence,
                                ObjectLength = dataToParse[i + 1]
                            });
                        array = new byte[dataToParse[i + 1]];
                    }
                    num = ((array.Length > dataToParse.Length - (i + 2)) ? (dataToParse.Length - (i + 2)) : array.Length);
                    Array.Copy(dataToParse, i + 2, array, 0, array.Length);
                    Gecko4.Objects.Add(Create(array));
                    i = i + 1 + dataToParse[i + 1];
                    break;
                }

                case Gecko2.Integer:
                {
                    Gecko4.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.Integer,
                            ObjectLength = dataToParse[i + 1]
                        });
                    byte[] array = new byte[dataToParse[i + 1]];
                    num = ((i + 2 + dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array, 0, num);
                    Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectData = array;
                    i = i + 1 + Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectLength;
                    break;
                }

                case Gecko2.OctetString:
                {
                    Gecko4.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.OctetString,
                            ObjectLength = dataToParse[i + 1]
                        });
                    byte[] array = new byte[dataToParse[i + 1]];
                    num = ((i + 2 + dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array, 0, num);
                    Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectData = array;
                    i = i + 1 + Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectLength;
                    break;
                }

                case Gecko2.ObjectIdentifier:
                {
                    Gecko4.Objects.Add(new Gecko4
                        {
                            ObjectType   = Gecko2.ObjectIdentifier,
                            ObjectLength = dataToParse[i + 1]
                        });
                    byte[] array = new byte[dataToParse[i + 1]];
                    num = ((i + 2 + dataToParse[i + 1] > dataToParse.Length) ? (dataToParse.Length - (i + 2)) : dataToParse[i + 1]);
                    Array.Copy(dataToParse, i + 2, array, 0, num);
                    Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectData = array;
                    i = i + 1 + Gecko4.Objects[Gecko4.Objects.Count - 1].ObjectLength;
                    break;
                }
                }
            }
            return(Gecko4);
        }