Inheritance: IDictionary, IList, ICollection, IEnumerable, ICloneable
Exemplo n.º 1
0
        public static Hashtable GetDHParams(UInt32 len)
        {
            AssocArray dhParams = (AssocArray)dhParamsGen[len];
            Random     ran      = new Random((Int32)DateTime.Now.Ticks);

            return(((AssocArray)dhParams[ran.Next(dhParams.Count)]).toHashtable());
        }
Exemplo n.º 2
0
        public virtual Object Clone()
        {
            AssocArray result = new AssocArray();

            result.arrayList   = (ArrayList)arrayList.Clone();
            result.hashtable   = (Hashtable)hashtable.Clone();
            result.arrayLength = arrayLength;
            result.maxNumber   = maxNumber;
            return(result);
        }
Exemplo n.º 3
0
        private AssocArray ReadAssocArray(Stream stream, ArrayList objectContainer)
        {
            Int32 n = ReadInteger(stream);

            stream.Position++;
            AssocArray a = new AssocArray(n);

            objectContainer.Add(a);
            for (Int32 i = 0; i < n; i++)
            {
                Int32 tag = stream.ReadByte();
                if (tag < 0)
                {
                    throw new SerializationException("End of Stream encountered before parsing was completed.");
                }
                Int32  index;
                String key;
                switch (tag)
                {
                case PHPSerializationTag.Integer:
                    index    = ReadInteger(stream);
                    a[index] = Deserialize(stream, objectContainer);
                    break;

                case PHPSerializationTag.BinaryString:
                    key    = GetString(ReadBinaryString(stream));
                    a[key] = Deserialize(stream, objectContainer);
                    break;

                case PHPSerializationTag.EscapedBinaryString:
                    key    = GetString(ReadEscapedBinaryString(stream));
                    a[key] = Deserialize(stream, objectContainer);
                    break;

                case PHPSerializationTag.UnicodeString:
                    key    = ReadUnicodeString(stream);
                    a[key] = Deserialize(stream, objectContainer);
                    break;

                default:
                    throw new SerializationException("Unexpected Tag: '" + (Char)tag + "'.");
                }
            }
            stream.Position++;
            return(a);
        }
Exemplo n.º 4
0
 public static AssocArray ToAssocArray(AssocArray value)
 {
     return value;
 }
Exemplo n.º 5
0
 public static ArrayList ToArrayList(AssocArray value)
 {
     if (value == null) {
         return null;
     }
     return value.toArrayList();
 }
Exemplo n.º 6
0
 public static Array ToArray(ICollection value, Type conversionType, Encoding encoding)
 {
     if (value == null) {
         return null;
     }
     if (conversionType == null) {
         throw new ArgumentNullException("conversionType");
     }
     if (!conversionType.IsArray) {
         throw new ArgumentException("Must be an array type.");
     }
     ArrayList arraylist = new AssocArray(value).toArrayList();
     if (conversionType == typeofObjectArray) {
         return arraylist.ToArray();
     }
     try {
         return arraylist.ToArray(conversionType.GetElementType());
     }
     catch (InvalidCastException) {
         Int32 length = arraylist.Count;
         Type elementType = conversionType.GetElementType();
         Array array = Array.CreateInstance(elementType, length);
         if (array.GetType() != conversionType) {
             throw new RankException("Only single dimension arrays are supported here.");
         }
         for (Int32 i = 0; i < length; i++) {
             array.SetValue(ChangeType(arraylist[i], elementType, encoding), i);
         }
         return array;
     }
 }
Exemplo n.º 7
0
 public static Array ToArray(AssocArray value, Type conversionType, String charset)
 {
     return ToArray(value, conversionType, Encoding.GetEncoding(charset));
 }
Exemplo n.º 8
0
 public static Array ToArray(AssocArray value, Type conversionType)
 {
     return ToArray(value, conversionType, UTF8);
 }
Exemplo n.º 9
0
 public static Object ToObject(AssocArray value, Type conversionType, Encoding encoding)
 {
     if (value == null) {
         return null;
     }
     return ToObject(value.toHashtable(), conversionType, encoding);
 }
Exemplo n.º 10
0
 public static Object ToObject(AssocArray value, Type conversionType)
 {
     return ToObject(value, conversionType, UTF8);
 }
Exemplo n.º 11
0
 public static Hashtable ToHashtable(AssocArray value)
 {
     if (value == null) {
         return null;
     }
     return value.toHashtable();
 }
Exemplo n.º 12
0
 private AssocArray ReadAssocArray(Stream stream, ArrayList objectContainer)
 {
     Int32 n = ReadInteger(stream);
     stream.Position++;
     AssocArray a = new AssocArray(n);
     objectContainer.Add(a);
     for (Int32 i = 0; i < n; i++) {
         Int32 tag = stream.ReadByte();
         if (tag < 0) {
             throw new SerializationException("End of Stream encountered before parsing was completed.");
         }
         Int32 index;
         String key;
         switch (tag) {
         case PHPSerializationTag.Integer:
             index = ReadInteger(stream);
             a[index] = Deserialize(stream, objectContainer);
             break;
         case PHPSerializationTag.BinaryString:
             key = GetString(ReadBinaryString(stream));
             a[key] = Deserialize(stream, objectContainer);
             break;
         case PHPSerializationTag.EscapedBinaryString:
             key = GetString(ReadEscapedBinaryString(stream));
             a[key] = Deserialize(stream, objectContainer);
             break;
         case PHPSerializationTag.UnicodeString:
             key = ReadUnicodeString(stream);
             a[key] = Deserialize(stream, objectContainer);
             break;
         default:
             throw new SerializationException("Unexpected Tag: '" + (Char)tag + "'.");
         }
     }
     stream.Position++;
     return a;
 }
Exemplo n.º 13
0
 public virtual Object Clone() {
     AssocArray result = new AssocArray();
     result.arrayList = (ArrayList)arrayList.Clone();
     result.hashtable = (Hashtable)hashtable.Clone();
     result.arrayLength = arrayLength;
     result.maxNumber = maxNumber;
     return result;
 }