Inheritance: IDictionary, IList, ICollection, IEnumerable, ICloneable
Exemple #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());
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #4
0
 public static AssocArray ToAssocArray(AssocArray value)
 {
     return value;
 }
Exemple #5
0
 public static ArrayList ToArrayList(AssocArray value)
 {
     if (value == null) {
         return null;
     }
     return value.toArrayList();
 }
Exemple #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;
     }
 }
Exemple #7
0
 public static Array ToArray(AssocArray value, Type conversionType, String charset)
 {
     return ToArray(value, conversionType, Encoding.GetEncoding(charset));
 }
Exemple #8
0
 public static Array ToArray(AssocArray value, Type conversionType)
 {
     return ToArray(value, conversionType, UTF8);
 }
Exemple #9
0
 public static Object ToObject(AssocArray value, Type conversionType, Encoding encoding)
 {
     if (value == null) {
         return null;
     }
     return ToObject(value.toHashtable(), conversionType, encoding);
 }
Exemple #10
0
 public static Object ToObject(AssocArray value, Type conversionType)
 {
     return ToObject(value, conversionType, UTF8);
 }
Exemple #11
0
 public static Hashtable ToHashtable(AssocArray value)
 {
     if (value == null) {
         return null;
     }
     return value.toHashtable();
 }
Exemple #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;
 }
Exemple #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;
 }