예제 #1
0
        static internal HttpStaticObjectsCollection Deserialize(BinaryReader reader)
        {
            int    count;
            string name;
            string typename;
            bool   hasInstance;
            Object instance;
            HttpStaticObjectsEntry      entry;
            HttpStaticObjectsCollection col;

            col = new HttpStaticObjectsCollection();

            count = reader.ReadInt32();
            while (count-- > 0)
            {
                name        = reader.ReadString();
                hasInstance = reader.ReadBoolean();
                if (hasInstance)
                {
                    instance = AltSerialization.ReadValueFromStream(reader);
                    entry    = new HttpStaticObjectsEntry(name, instance, 0);
                }
                else
                {
                    typename = reader.ReadString();
                    bool lateBound = reader.ReadBoolean();
                    entry = new HttpStaticObjectsEntry(name, Type.GetType(typename), lateBound);
                }

                col._objects.Add(name, entry);
            }

            return(col);
        }
예제 #2
0
        //
        // Implementation of standard collection stuff
        //

        /// <include file='doc\httpstaticobjectscollection.uex' path='docs/doc[@for="HttpStaticObjectsCollection.this"]/*' />
        /// <devdoc>
        ///    <para>Gets the object in the collection with the given name (case
        ///       insensitive). </para>
        /// </devdoc>
        public Object this[String name]
        {
            get {
                HttpStaticObjectsEntry e = (HttpStaticObjectsEntry)_objects[name];
                return((e != null) ? e.Instance : null);
            }
        }
예제 #3
0
        internal HttpStaticObjectsCollection Clone()
        {
            HttpStaticObjectsCollection objectss   = new HttpStaticObjectsCollection();
            IDictionaryEnumerator       enumerator = this._objects.GetEnumerator();

            while (enumerator.MoveNext())
            {
                HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)enumerator.Value;
                objectss.Add(entry.Name, entry.ObjectType, entry.LateBound);
            }
            return(objectss);
        }
예제 #4
0
 public object this[string name]
 {
     get
     {
         HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)this._objects[name];
         if (entry == null)
         {
             return(null);
         }
         return(entry.Instance);
     }
 }
예제 #5
0
        /*
         * Create a copy without copying instances (names and types only)
         */
        internal HttpStaticObjectsCollection Clone()
        {
            HttpStaticObjectsCollection c = new HttpStaticObjectsCollection();

            IDictionaryEnumerator e = _objects.GetEnumerator();

            while (e.MoveNext())
            {
                HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)e.Value;
                c.Add(entry.Name, entry.ObjectType, entry.LateBound);
            }

            return(c);
        }
예제 #6
0
        internal int GetInstanceCount()
        {
            int num = 0;
            IDictionaryEnumerator enumerator = this._objects.GetEnumerator();

            while (enumerator.MoveNext())
            {
                HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)enumerator.Value;
                if (entry.HasInstance)
                {
                    num++;
                }
            }
            return(num);
        }
예제 #7
0
        /*
         * Get number of real instances created
         */
        internal int GetInstanceCount()
        {
            int count = 0;

            IDictionaryEnumerator e = _objects.GetEnumerator();

            while (e.MoveNext())
            {
                HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)e.Value;

                if (entry.HasInstance)
                {
                    count++;
                }
            }

            return(count);
        }
예제 #8
0
        public void Serialize(BinaryWriter writer)
        {
            writer.Write(this.Count);
            IDictionaryEnumerator enumerator = this._objects.GetEnumerator();

            while (enumerator.MoveNext())
            {
                HttpStaticObjectsEntry entry = (HttpStaticObjectsEntry)enumerator.Value;
                writer.Write(entry.Name);
                bool hasInstance = entry.HasInstance;
                writer.Write(hasInstance);
                if (hasInstance)
                {
                    AltSerialization.WriteValueToStream(entry.Instance, writer);
                }
                else
                {
                    writer.Write(entry.ObjectType.FullName);
                    writer.Write(entry.LateBound);
                }
            }
        }
 public static HttpStaticObjectsCollection Deserialize(BinaryReader reader)
 {
     HttpStaticObjectsCollection objectss = new HttpStaticObjectsCollection();
     int num = reader.ReadInt32();
     while (num-- > 0)
     {
         HttpStaticObjectsEntry entry;
         string name = reader.ReadString();
         if (reader.ReadBoolean())
         {
             object instance = AltSerialization.ReadValueFromStream(reader);
             entry = new HttpStaticObjectsEntry(name, instance, 0);
         }
         else
         {
             string typeName = reader.ReadString();
             bool lateBound = reader.ReadBoolean();
             entry = new HttpStaticObjectsEntry(name, Type.GetType(typeName), lateBound);
         }
         objectss._objects.Add(name, entry);
     }
     return objectss;
 }
예제 #10
0
        public static HttpStaticObjectsCollection Deserialize(BinaryReader reader)
        {
            HttpStaticObjectsCollection objectss = new HttpStaticObjectsCollection();
            int num = reader.ReadInt32();

            while (num-- > 0)
            {
                HttpStaticObjectsEntry entry;
                string name = reader.ReadString();
                if (reader.ReadBoolean())
                {
                    object instance = AltSerialization.ReadValueFromStream(reader);
                    entry = new HttpStaticObjectsEntry(name, instance, 0);
                }
                else
                {
                    string typeName  = reader.ReadString();
                    bool   lateBound = reader.ReadBoolean();
                    entry = new HttpStaticObjectsEntry(name, Type.GetType(typeName), lateBound);
                }
                objectss._objects.Add(name, entry);
            }
            return(objectss);
        }
        static public HttpStaticObjectsCollection Deserialize(BinaryReader reader) {
            int     count;
            string  name;
            string  typename;
            bool    hasInstance;
            Object  instance;
            HttpStaticObjectsEntry  entry;
            HttpStaticObjectsCollection col;

            col = new HttpStaticObjectsCollection();

            count = reader.ReadInt32();
            while (count-- > 0) {
                name = reader.ReadString();
                hasInstance = reader.ReadBoolean();
                if (hasInstance) {
                    instance = AltSerialization.ReadValueFromStream(reader);
                    entry = new HttpStaticObjectsEntry(name, instance, 0);
                }
                else {
                    typename = reader.ReadString();
                    bool lateBound = reader.ReadBoolean();
                    entry = new HttpStaticObjectsEntry(name, Type.GetType(typename), lateBound);
                }

                col._objects.Add(name, entry);
            }

            return col;
        }