/// <summary>
        ///     Call Dispose on all columns.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // dispose of columns
                    if (_columnTable != null)
                    {
                        foreach (TreeGridDesignerColumnDescriptor column in _columnTable.Values)
                        {
                            column.Dispose();
                        }
                    }
                }

                if (_columnTable != null)
                {
                    _columnTable.Clear();
                    _columnTable = null;
                }

                _columnHost = null;
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
Example #2
0
        public static TableRow[] GetRowsFromTable(Database msidb, string tableName)
        {
            if (!msidb.TableExists(tableName))
            {
                Trace.WriteLine(string.Format("Table name does {0} not exist Found.", tableName));
                return new TableRow[0];
            }

            string query = string.Concat("SELECT * FROM `", tableName, "`");
            using (var view = new ViewWrapper(msidb.OpenExecuteView(query)))
            {
                var /*<TableRow>*/ rows = new ArrayList(view.Records.Count);

                ColumnInfo[] columns = view.Columns;
                foreach (object[] values in view.Records)
                {
                    HybridDictionary valueCollection = new HybridDictionary(values.Length);
                    for (int cIndex = 0; cIndex < columns.Length; cIndex++)
                    {
                        valueCollection[columns[cIndex].Name] = values[cIndex];
                    }
                    rows.Add(new TableRow(valueCollection));
                }
                return (TableRow[]) rows.ToArray(typeof(TableRow));
            }
        }
Example #3
0
        public BasicPropertiesWrapper(IBasicProperties basicProperties)
        {
            ContentType = basicProperties.ContentType;
            ContentEncoding = basicProperties.ContentEncoding;
            DeliveryMode = basicProperties.DeliveryMode;
            Priority = basicProperties.Priority;
            CorrelationId = basicProperties.CorrelationId;
            ReplyTo = basicProperties.ReplyTo;
            Expiration = basicProperties.Expiration;
            MessageId = basicProperties.MessageId;
            Timestamp = basicProperties.Timestamp.UnixTime;
            Type = basicProperties.Type;
            UserId = basicProperties.UserId;
            AppId = basicProperties.AppId;
            ClusterId = basicProperties.ClusterId;

            if (basicProperties.IsHeadersPresent())
            {
                Headers = new HybridDictionary();
                foreach (DictionaryEntry header in basicProperties.Headers)
                {
                    Headers.Add(header.Key, header.Value);
                }
            }
        }
Example #4
0
		static DataTypeParser()
		{
			Types = new HybridDictionary();
            Types[typeof(string)]   = DataType.String;
            Types[typeof(DateTime)] = DataType.DateTime;
            Types[typeof(Date)]     = DataType.Date;
            Types[typeof(Time)]     = DataType.Time;
            Types[typeof(bool)]     = DataType.Boolean;

            Types[typeof(byte)]     = DataType.Byte;
            Types[typeof(sbyte)]    = DataType.SByte;
            Types[typeof(decimal)]  = DataType.Decimal;
            Types[typeof(double)]   = DataType.Double;
            Types[typeof(float)]    = DataType.Single;

            Types[typeof(int)]      = DataType.Int32;
            Types[typeof(uint)]     = DataType.UInt32;
            Types[typeof(long)]     = DataType.Int64;
            Types[typeof(ulong)]    = DataType.UInt64;
            Types[typeof(short)]    = DataType.Int16;
            Types[typeof(ushort)]   = DataType.UInt16;

            Types[typeof(Guid)]     = DataType.Guid;
            Types[typeof(byte[])]   = DataType.Binary;
            Types[typeof(Enum)]     = DataType.Int32;

            Types[typeof(DBNull)]   = DataType.Single; // is that right?
        }
		/// <summary>
		/// Obtém o tamanho máximo de um campo no banco de dados.
		/// </summary>
		/// <param name="table">A tabela</param>
		/// <param name="field">O campo</param>
		/// <returns>
		/// O tamanho máximo do campo, ou 
		/// <c>null</c> caso não seja
		/// possível obter o tamanho máximo.
		/// </returns>
		public NullableInt32 MaxLength(string table, string field)
		{
			Type t = GetModelType(table);
			if (t == null) return null;

			EnsureMetadataCache(t);

			ActiveRecordModel model = ActiveRecordModel.GetModel(t);
			if (model == null) return null;

			IDictionary type2len = (IDictionary) type2lengths[t];
			if (type2len == null)
			{
				lock (type2lengths.SyncRoot)
				{
					type2len = new HybridDictionary(true);

					string physicalTableName = model.ActiveRecordAtt.Table;

					foreach (PropertyModel p in model.Properties)
					{
						string physicalColumnName = p.PropertyAtt.Column;
						type2len.Add(p.Property.Name, mdCache.MaxLength(physicalTableName, physicalColumnName));
					}

					type2lengths[t] = type2len;
				}
			}

			if (!type2len.Contains(field))
				return null;

			return (int) type2len[field];
		}
        internal ConfigurationLockCollection(ConfigurationElement thisElement, ConfigurationLockCollectionType lockType,
                    string ignoreName, ConfigurationLockCollection parentCollection) {
            _thisElement = thisElement;
            _lockType = lockType;
            internalDictionary = new HybridDictionary();
            internalArraylist = new ArrayList();
            _bModified = false;

            _bExceptionList = _lockType == ConfigurationLockCollectionType.LockedExceptionList ||
                              _lockType == ConfigurationLockCollectionType.LockedElementsExceptionList;
            _ignoreName = ignoreName;

            if (parentCollection != null) {
                foreach (string key in parentCollection) // seed the new collection
                {
                    Add(key, ConfigurationValueFlags.Inherited);  // add the local copy
                    if (_bExceptionList) {
                        if (SeedList.Length != 0)
                            SeedList += ",";
                        SeedList += key;
                    }
                }
            }

        }
Example #7
0
		private void AnalyzeEnum( Type enumType )
		{
			_enumName = enumType.Name;

			R.FieldInfo[] fieldInfos = enumType.GetFields( BindingFlags.Static | BindingFlags.Public );

			_namedValues = new HybridDictionary( fieldInfos.Length, false );
			_valuedNames = new HybridDictionary( fieldInfos.Length, false );

			foreach( R.FieldInfo fi in fieldInfos )
			{
				if( ( fi.Attributes & EnumField ) == EnumField )
				{
					string name = fi.Name;
					object value = fi.GetValue( null );

					Attribute[] attrs =
						Attribute.GetCustomAttributes( fi, typeof( XmlEnumAttribute ) );
					if( attrs.Length > 0 )
					{
						XmlEnumAttribute attr = (XmlEnumAttribute)attrs[0];
						name = attr.Name;
					}

					_namedValues.Add( name, value );
					if( !_valuedNames.Contains( value ))
						_valuedNames.Add( value, name );
				}
			}
		}
 internal DbConnectionPoolGroup(DbConnectionOptions connectionOptions, DbConnectionPoolGroupOptions poolGroupOptions)
 {
     this._connectionOptions = connectionOptions;
     this._poolGroupOptions = poolGroupOptions;
     this._poolCollection = new HybridDictionary(1, false);
     this._state = 1;
 }
        public WebPartDescriptionCollection(ICollection webPartDescriptions) {
            if (webPartDescriptions == null) {
                throw new ArgumentNullException("webPartDescriptions");
            }

            _ids = new HybridDictionary(webPartDescriptions.Count, true /* caseInsensitive */);
            foreach (object obj in webPartDescriptions) {
                if (obj == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "webPartDescriptions");
                }
                WebPartDescription description = obj as WebPartDescription;
                if (description == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPartDescription"),
                                                "webPartDescriptions");
                }
                string id = description.ID;
                if (!_ids.Contains(id)) {
                    InnerList.Add(description);
                    _ids.Add(id, description);
                }
                else {
                    throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "WebPartDescription", id), "webPartDescriptions");
                }
            }
        }
		public Func<IKernelInternal, IReleasePolicy, object> SelectComponent(MethodInfo method, Type type, object[] arguments)
		{
			return (k, p) =>
			{
				string key = null;
				var argument = arguments[0];

				if (arguments.Length == 2)
				{
					key = (string)argument;
					argument = arguments[1];
				}
				else if (argument is string)
				{
					return k.Resolve((string)argument, method.ReturnType, null, p);
				}

				if (argument is Uri)
				{
					argument = WcfEndpoint.At((Uri)argument);
				}

				var args = new HybridDictionary { { Guid.NewGuid().ToString(), argument } };

				if (key == null)
				{
					return k.Resolve(method.ReturnType, args, p);
				}

				return k.Resolve(key, method.ReturnType, args, p);
			};
		}
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BadgeComponent"/> class.
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="data">The data.</param>
 internal BadgeComponent(uint userId, UserData data)
 {
     BadgeList = new HybridDictionary();
     foreach (var current in data.Badges.Where(current => !BadgeList.Contains(current.Code)))
         BadgeList.Add(current.Code, current);
     _userId = userId;
 }
        internal ConfigurationLockCollection(ConfigurationElement thisElement, ConfigurationLockCollectionType lockType,
            string ignoreName, ConfigurationLockCollection parentCollection)
        {
            _thisElement = thisElement;
            LockType = lockType;
            _internalDictionary = new HybridDictionary();
            _internalArraylist = new ArrayList();
            IsModified = false;

            ExceptionList = (LockType == ConfigurationLockCollectionType.LockedExceptionList) ||
                (LockType == ConfigurationLockCollectionType.LockedElementsExceptionList);
            _ignoreName = ignoreName;

            if (parentCollection == null) return;

            foreach (string key in parentCollection) // seed the new collection
            {
                Add(key, ConfigurationValueFlags.Inherited); // add the local copy
                if (!ExceptionList) continue;

                if (_seedList.Length != 0)
                    _seedList += ",";
                _seedList += key;
            }
        }
 public ViewRendering GetViewRendering(Control control)
 {
     string str2;
     DesignerRegionCollection regions;
     CatalogPart part = control as CatalogPart;
     if (part == null)
     {
         return new ViewRendering(ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("CatalogZoneDesigner_OnlyCatalogParts"), null, control), new DesignerRegionCollection());
     }
     try
     {
         IDictionary data = new HybridDictionary(1);
         data["Zone"] = base.Zone;
         ((IControlDesignerAccessor) part).SetDesignModeState(data);
         this._partViewRendering = ControlDesigner.GetViewRendering(part);
         regions = this._partViewRendering.Regions;
         StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
         this.RenderCatalogPart(new DesignTimeHtmlTextWriter(writer), (CatalogPart) PartDesigner.GetViewControl(part));
         str2 = writer.ToString();
     }
     catch (Exception exception)
     {
         str2 = ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("ControlDesigner_UnhandledException"), exception, control);
         regions = new DesignerRegionCollection();
     }
     return new ViewRendering(str2, regions);
 }
        [FriendAccessAllowed]   // defined in Base, used in Core and Framework
        internal static bool HasReliableHashCode(object item)
        {
            // null doesn't actually have a hashcode at all.  This method can be
            // called with a representative item from a collection - if the
            // representative is null, we'll be pessimistic and assume the
            // items in the collection should not be hashed.
            if (item == null)
                return false;

            Type type = item.GetType();
            Assembly assembly = type.Assembly;
            HybridDictionary dictionary;

            lock(_table)
            {
                dictionary = (HybridDictionary)_table[assembly];
            }

            if (dictionary == null)
            {
                dictionary = new HybridDictionary();

                lock(_table)
                {
                    _table[assembly] = dictionary;
                }
            }

            return !dictionary.Contains(type);
        }
 public override string GetDesignTimeHtml()
 {
     string logoutText;
     IDictionary data = new HybridDictionary(2);
     data["LoggedIn"] = this._loggedIn;
     LoginStatus viewControl = (LoginStatus) base.ViewControl;
     ((IControlDesignerAccessor) viewControl).SetDesignModeState(data);
     if (this._loggedIn)
     {
         logoutText = viewControl.LogoutText;
         if (((logoutText == null) || (logoutText.Length == 0)) || (logoutText == " "))
         {
             viewControl.LogoutText = "[" + viewControl.ID + "]";
         }
     }
     else
     {
         logoutText = viewControl.LoginText;
         if (((logoutText == null) || (logoutText.Length == 0)) || (logoutText == " "))
         {
             viewControl.LoginText = "[" + viewControl.ID + "]";
         }
     }
     return base.GetDesignTimeHtml();
 }
 public void Dispose()
 {
     if (this._partitions != null)
     {
         try
         {
             this._lock.AcquireWriterLock(-1);
             if (this._partitions != null)
             {
                 foreach (PartitionInfo info in this._partitions.Values)
                 {
                     info.Dispose();
                 }
                 this._partitions = null;
             }
         }
         catch
         {
         }
         finally
         {
             if (this._lock.IsWriterLockHeld)
             {
                 this._lock.ReleaseWriterLock();
             }
         }
     }
 }
 protected RolePrincipal(SerializationInfo info, StreamingContext context)
 {
     this._Version = info.GetInt32("_Version");
     this._ExpireDate = info.GetDateTime("_ExpireDate");
     this._IssueDate = info.GetDateTime("_IssueDate");
     try
     {
         this._Identity = info.GetValue("_Identity", typeof(IIdentity)) as IIdentity;
     }
     catch
     {
     }
     this._ProviderName = info.GetString("_ProviderName");
     this._Username = info.GetString("_Username");
     this._IsRoleListCached = info.GetBoolean("_IsRoleListCached");
     this._Roles = new HybridDictionary(true);
     string str = info.GetString("_AllRoles");
     if (str != null)
     {
         foreach (string str2 in str.Split(new char[] { ',' }))
         {
             if (this._Roles[str2] == null)
             {
                 this._Roles.Add(str2, string.Empty);
             }
         }
     }
 }
		public static object ToXmlRpc(object val)
		{
			if (val == null)
				throw new ArgumentNullException("val");
			
			if (val is int || val is bool || val is string || val is double || val is DateTime || val is byte[])
				return val;
			
			if (val is IDictionary)
			{
				IDictionary results = new HybridDictionary();
				IDictionary dict = (IDictionary) val;
				foreach (string key in dict.Keys)
				{
					results[key] = ToXmlRpc(dict[key]);
				}
				return results;
			}

			object[] attributes = val.GetType().GetCustomAttributes(typeof (XmlRpcSerializableAttribute), false);
			if (attributes.Length > 0)
			{
				return ToDictionary(val);
			}
			
			if (val is IEnumerable)
			{
				ArrayList arrList = new ArrayList();
				foreach (object o in (IEnumerable) val)
					arrList.Add(ToXmlRpc(o));
				return arrList.ToArray();
			}

			throw new ArgumentException("Unable to serialize object of type " + val.GetType().Name);
		}
Example #19
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="InventoryComponent" /> class.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="client">The client.</param>
        /// <param name="userData">The user data.</param>
        internal InventoryComponent(uint userId, GameClient client, UserData userData)
        {
            _mClient = client;
            UserId = userId;
            _floorItems = new HybridDictionary();
            _wallItems = new HybridDictionary();
            SongDisks = new HybridDictionary();

            foreach (UserItem current in userData.Inventory)
            {
                if (current.BaseItem.InteractionType == Interaction.MusicDisc)
                    SongDisks.Add(current.Id, current);
                if (current.IsWallItem)
                    _wallItems.Add(current.Id, current);
                else
                    _floorItems.Add(current.Id, current);
            }

            _inventoryPets = new HybridDictionary();
            _inventoryBots = new HybridDictionary();
            _mAddedItems = new HybridDictionary();
            _mRemovedItems = new HybridDictionary();
            _isUpdated = false;

            foreach (KeyValuePair<uint, RoomBot> bot in userData.Bots)
                AddBot(bot.Value);

            foreach (KeyValuePair<uint, Pet> pets in userData.Pets)
                AddPets(pets.Value);
        }
Example #20
0
        /// <summary>
        /// Creates a new <see cref="AnsiEdit"/> instance.
        /// </summary>
        public AnsiEdit()
            : base()
        {
            rtfColor = new HybridDictionary();
            rtfColor.Add(RtfColor.Black, RtfColorDef.Black);
            rtfColor.Add(RtfColor.Red, RtfColorDef.Red);
            rtfColor.Add(RtfColor.Green, RtfColorDef.Green);
            rtfColor.Add(RtfColor.Yellow, RtfColorDef.Yellow);
            rtfColor.Add(RtfColor.Blue, RtfColorDef.Blue);
            rtfColor.Add(RtfColor.Magenta, RtfColorDef.Magenta);
            rtfColor.Add(RtfColor.Cyan, RtfColorDef.Cyan);
            rtfColor.Add(RtfColor.White, RtfColorDef.White);
            rtfColor.Add(RtfColor.BrightBlack, RtfColorDef.BrightBlack);
            rtfColor.Add(RtfColor.BrightRed, RtfColorDef.BrightRed);
            rtfColor.Add(RtfColor.BrightGreen, RtfColorDef.BrightGreen);
            rtfColor.Add(RtfColor.BrightYellow, RtfColorDef.BrightYellow);
            rtfColor.Add(RtfColor.BrightBlue, RtfColorDef.BrightBlue);
            rtfColor.Add(RtfColor.BrightMagenta, RtfColorDef.BrightMagenta);
            rtfColor.Add(RtfColor.BrightCyan, RtfColorDef.BrightCyan);
            rtfColor.Add(RtfColor.BrightWhite, RtfColorDef.BrightWhite);

            rtfFontFamily = new HybridDictionary();
            rtfFontFamily.Add(FontFamily.GenericMonospace.Name, RtfFontFamilyDef.Modern);
            rtfFontFamily.Add(FontFamily.GenericSansSerif, RtfFontFamilyDef.Swiss);
            rtfFontFamily.Add(FontFamily.GenericSerif, RtfFontFamilyDef.Roman);
            rtfFontFamily.Add(FF_UNKNOWN, RtfFontFamilyDef.Unknown);

            this.SetStyle(ControlStyles.DoubleBuffer, true);
        }
Example #21
0
		public void All ()
		{
			HybridDictionary dict = new HybridDictionary (true);
			dict.Add ("CCC", "ccc");
			dict.Add ("BBB", "bbb");
			dict.Add ("fff", "fff");
			dict ["EEE"] = "eee";
			dict ["ddd"] = "ddd";
			
			Assert.AreEqual (5, dict.Count, "#1");
			Assert.AreEqual ("eee", dict["eee"], "#2");
			
			dict.Add ("CCC2", "ccc");
			dict.Add ("BBB2", "bbb");
			dict.Add ("fff2", "fff");
			dict ["EEE2"] = "eee";
			dict ["ddd2"] = "ddd";
			dict ["xxx"] = "xxx";
			dict ["yyy"] = "yyy";

			Assert.AreEqual (12, dict.Count, "#3");
			Assert.AreEqual ("eee", dict["eee"], "#4");

			dict.Remove ("eee");
			Assert.AreEqual (11, dict.Count, "Removed/Count");
			Assert.IsFalse (dict.Contains ("eee"), "Removed/Contains(xxx)");
			DictionaryEntry[] entries = new DictionaryEntry [11];
			dict.CopyTo (entries, 0);

			Assert.IsTrue (dict.Contains ("xxx"), "Contains(xxx)");
			dict.Clear ();
			Assert.AreEqual (0, dict.Count, "Cleared/Count");
			Assert.IsFalse (dict.Contains ("xxx"), "Cleared/Contains(xxx)");
		}
 internal DbConnectionPoolGroup(System.Data.Common.DbConnectionOptions connectionOptions, System.Data.ProviderBase.DbConnectionPoolGroupOptions poolGroupOptions)
 {
     this._connectionOptions = connectionOptions;
     this._poolGroupOptions = poolGroupOptions;
     this._poolCollection = new HybridDictionary(1, false);
     this._state = 1;
 }
 public ConsumerConnectionPointCollection(ICollection connectionPoints)
 {
     if (connectionPoints == null)
     {
         throw new ArgumentNullException("connectionPoints");
     }
     this._ids = new HybridDictionary(connectionPoints.Count, true);
     foreach (object obj2 in connectionPoints)
     {
         if (obj2 == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_CantAddNull"), "connectionPoints");
         }
         ConsumerConnectionPoint point = obj2 as ConsumerConnectionPoint;
         if (point == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_InvalidType", new object[] { "ConsumerConnectionPoint" }), "connectionPoints");
         }
         string iD = point.ID;
         if (this._ids.Contains(iD))
         {
             throw new ArgumentException(System.Web.SR.GetString("WebPart_Collection_DuplicateID", new object[] { "ConsumerConnectionPoint", iD }), "connectionPoints");
         }
         base.InnerList.Add(point);
         this._ids.Add(iD, point);
     }
 }
        public ConsumerConnectionPointCollection(ICollection connectionPoints) {
            if (connectionPoints == null) {
                throw new ArgumentNullException("connectionPoints");
            }

            _ids = new HybridDictionary(connectionPoints.Count, true /* caseInsensitive */);
            foreach (object obj in connectionPoints) {
                if (obj == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "connectionPoints");
                }
                ConsumerConnectionPoint point = obj as ConsumerConnectionPoint;
                if (point == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "ConsumerConnectionPoint"),
                                                "connectionPoints");
                }
                string id = point.ID;
                if (!_ids.Contains(id)) {
                    InnerList.Add(point);
                    _ids.Add(id, point);
                }
                else {
                    throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "ConsumerConnectionPoint", id), "connectionPoints");
                }
            }
        }
Example #25
0
 public DbEnum(int type)
 {
     IList dic = DbEntry
         .From<LeafingEnum>()
         .Where(CK.K["Type"] == type)
         .OrderBy("Id")
         .Select();
     _dict = new HybridDictionary();
     _vdic = new HybridDictionary();
     _list = new string[dic.Count];
     int n = 0;
     int m = 0;
     foreach (LeafingEnum e in dic)
     {
         _list[n] = e.Name;
         if (e.Value != null)
         {
             m = (int)e.Value;
         }
         _dict[e.Name.ToLower()] = m;
         _vdic[m] = e.Name;
         n++;
         m++;
     }
 }
			public override object Resolve(IKernel kernel)
			{
				string key = null;
				var argument = arguments[0];

				if (arguments.Length == 2)
				{
					key = (string)argument;
					argument = arguments[1];
				}
				else if (argument is string)
				{
					return kernel.Resolve((string)argument, ComponentType);
				}

				if (argument is Uri)
				{
					argument = WcfEndpoint.At((Uri)argument);
				}

				var args = new HybridDictionary { { Guid.NewGuid().ToString(), argument } };

				if (key == null)
				{
					return kernel.Resolve(ComponentType, args);
				}

				return kernel.Resolve(key, ComponentType, args);
			}
 public WebPartDescriptionCollection(ICollection webPartDescriptions)
 {
     if (webPartDescriptions == null)
     {
         throw new ArgumentNullException("webPartDescriptions");
     }
     this._ids = new HybridDictionary(webPartDescriptions.Count, true);
     foreach (object obj2 in webPartDescriptions)
     {
         if (obj2 == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_CantAddNull"), "webPartDescriptions");
         }
         WebPartDescription description = obj2 as WebPartDescription;
         if (description == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_InvalidType", new object[] { "WebPartDescription" }), "webPartDescriptions");
         }
         string iD = description.ID;
         if (this._ids.Contains(iD))
         {
             throw new ArgumentException(System.Web.SR.GetString("WebPart_Collection_DuplicateID", new object[] { "WebPartDescription", iD }), "webPartDescriptions");
         }
         base.InnerList.Add(description);
         this._ids.Add(iD, description);
     }
 }
		internal InventoryComponent(uint UserId, GameClient Client, UserData UserData)
		{
			this.mClient = Client;
			this.UserId = UserId;
			this.floorItems = new HybridDictionary();
			this.wallItems = new HybridDictionary();
			this.discs = new HybridDictionary();
			foreach (UserItem current in UserData.inventory)
			{
				if (current.GetBaseItem().InteractionType == InteractionType.musicdisc)
				{
					this.discs.Add(current.Id, current);
				}
				if (current.isWallItem)
				{
					this.wallItems.Add(current.Id, current);
				}
				else
				{
					this.floorItems.Add(current.Id, current);
				}
			}
			this.InventoryPets = new SafeDictionary<uint, Pet>(UserData.pets);
			this.InventoryBots = new SafeDictionary<uint, RoomBot>(UserData.Botinv);
			this.mAddedItems = new HybridDictionary();
			this.mRemovedItems = new HybridDictionary();
			this.isUpdated = false;
		}
Example #29
0
 private void LookupMember(string name, HybridDictionary visitedAliases, out PSMemberInfo returnedMember, out bool hasCycle)
 {
     returnedMember = null;
     if (base.instance == null)
     {
         throw new ExtendedTypeSystemException("AliasLookupMemberOutsidePSObject", null, ExtendedTypeSystem.AccessMemberOutsidePSObject, new object[] { name });
     }
     PSMemberInfo info = PSObject.AsPSObject(base.instance).Properties[name];
     if (info == null)
     {
         throw new ExtendedTypeSystemException("AliasLookupMemberNotPresent", null, ExtendedTypeSystem.MemberNotPresent, new object[] { name });
     }
     PSAliasProperty property = info as PSAliasProperty;
     if (property == null)
     {
         hasCycle = false;
         returnedMember = info;
     }
     else if (visitedAliases.Contains(name))
     {
         hasCycle = true;
     }
     else
     {
         visitedAliases.Add(name, name);
         this.LookupMember(property.ReferencedMemberName, visitedAliases, out returnedMember, out hasCycle);
     }
 }
        /// <summary>Finds an existing <see cref="T:System.Net.ServicePoint" /> object or creates a new <see cref="T:System.Net.ServicePoint" /> object to manage communications with the specified <see cref="T:System.Uri" /> object.</summary>
        /// <returns>The <see cref="T:System.Net.ServicePoint" /> object that manages communications for the request.</returns>
        /// <param name="address">A <see cref="T:System.Uri" /> object that contains the address of the Internet resource to contact. </param>
        /// <param name="proxy">The proxy data for this request. </param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="address" /> is null. </exception>
        /// <exception cref="T:System.InvalidOperationException">The maximum number of <see cref="T:System.Net.ServicePoint" /> objects defined in <see cref="P:System.Net.ServicePointManager.MaxServicePoints" /> has been reached. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
        /// </PermissionSet>
        public static ServicePoint FindServicePoint(System.Uri address, IWebProxy proxy)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            ServicePointManager.RecycleServicePoints();
            bool usesProxy = false;
            bool flag      = false;

            if (proxy != null && !proxy.IsBypassed(address))
            {
                usesProxy = true;
                bool flag2 = address.Scheme == "https";
                address = proxy.GetProxy(address);
                if (address.Scheme != "http" && !flag2)
                {
                    throw new NotSupportedException("Proxy scheme not supported.");
                }
                if (flag2 && address.Scheme == "http")
                {
                    flag = true;
                }
            }
            address = new System.Uri(address.Scheme + "://" + address.Authority);
            ServicePoint servicePoint = null;

            System.Collections.Specialized.HybridDictionary obj = ServicePointManager.servicePoints;
            lock (obj)
            {
                ServicePointManager.SPKey key = new ServicePointManager.SPKey(address, flag);
                servicePoint = (ServicePointManager.servicePoints[key] as ServicePoint);
                if (servicePoint != null)
                {
                    return(servicePoint);
                }
                if (ServicePointManager.maxServicePoints > 0 && ServicePointManager.servicePoints.Count >= ServicePointManager.maxServicePoints)
                {
                    throw new InvalidOperationException("maximum number of service points reached");
                }
                string text            = address.ToString();
                int    connectionLimit = ServicePointManager.defaultConnectionLimit;
                servicePoint = new ServicePoint(address, connectionLimit, ServicePointManager.maxServicePointIdleTime);
                servicePoint.Expect100Continue = ServicePointManager.expectContinue;
                servicePoint.UseNagleAlgorithm = ServicePointManager.useNagle;
                servicePoint.UsesProxy         = usesProxy;
                servicePoint.UseConnect        = flag;
                ServicePointManager.servicePoints.Add(key, servicePoint);
            }
            return(servicePoint);
        }
        internal static void RecycleServicePoints()
        {
            ArrayList arrayList = new ArrayList();

            System.Collections.Specialized.HybridDictionary obj = ServicePointManager.servicePoints;
            lock (obj)
            {
                IDictionaryEnumerator enumerator = ServicePointManager.servicePoints.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    ServicePoint servicePoint = (ServicePoint)enumerator.Value;
                    if (servicePoint.AvailableForRecycling)
                    {
                        arrayList.Add(enumerator.Key);
                    }
                }
                for (int i = 0; i < arrayList.Count; i++)
                {
                    ServicePointManager.servicePoints.Remove(arrayList[i]);
                }
                if (ServicePointManager.maxServicePoints != 0 && ServicePointManager.servicePoints.Count > ServicePointManager.maxServicePoints)
                {
                    SortedList sortedList = new SortedList(ServicePointManager.servicePoints.Count);
                    enumerator = ServicePointManager.servicePoints.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        ServicePoint servicePoint2 = (ServicePoint)enumerator.Value;
                        if (servicePoint2.CurrentConnections == 0)
                        {
                            while (sortedList.ContainsKey(servicePoint2.IdleSince))
                            {
                                servicePoint2.IdleSince = servicePoint2.IdleSince.AddMilliseconds(1.0);
                            }
                            sortedList.Add(servicePoint2.IdleSince, servicePoint2.Address);
                        }
                    }
                    int num = 0;
                    while (num < sortedList.Count && ServicePointManager.servicePoints.Count > ServicePointManager.maxServicePoints)
                    {
                        ServicePointManager.servicePoints.Remove(sortedList.GetByIndex(num));
                        num++;
                    }
                }
            }
        }
Example #32
0
    public void Populate()
    {
        #region Types of Keywords

        FieldPublicDynamic = new { PropPublic1 = "A", PropPublic2 = 1, PropPublic3 = "B", PropPublic4 = "B", PropPublic5 = "B", PropPublic6 = "B", PropPublic7 = "B", PropPublic8 = "B", PropPublic9 = "B", PropPublic10 = "B", PropPublic11 = "B", PropPublic12 = new { PropSubPublic1 = 0, PropSubPublic2 = 1, PropSubPublic3 = 2 } };
        FieldPublicObject  = new StringBuilder("Object - StringBuilder");
        FieldPublicInt32   = int.MaxValue;
        FieldPublicInt64   = long.MaxValue;
        FieldPublicULong   = ulong.MaxValue;
        FieldPublicUInt    = uint.MaxValue;
        FieldPublicDecimal = 100000.999999m;
        FieldPublicDouble  = 100000.999999d;
        FieldPublicChar    = 'A';
        FieldPublicByte    = byte.MaxValue;
        FieldPublicBoolean = true;
        FieldPublicSByte   = sbyte.MaxValue;
        FieldPublicShort   = short.MaxValue;
        FieldPublicUShort  = ushort.MaxValue;
        FieldPublicFloat   = 100000.675555f;

        FieldPublicInt32Nullable   = int.MaxValue;
        FieldPublicInt64Nullable   = 2;
        FieldPublicULongNullable   = ulong.MaxValue;
        FieldPublicUIntNullable    = uint.MaxValue;
        FieldPublicDecimalNullable = 100000.999999m;
        FieldPublicDoubleNullable  = 100000.999999d;
        FieldPublicCharNullable    = 'A';
        FieldPublicByteNullable    = byte.MaxValue;
        FieldPublicBooleanNullable = true;
        FieldPublicSByteNullable   = sbyte.MaxValue;
        FieldPublicShortNullable   = short.MaxValue;
        FieldPublicUShortNullable  = ushort.MaxValue;
        FieldPublicFloatNullable   = 100000.675555f;

        #endregion

        #region System

        FieldPublicDateTime         = new DateTime(2000, 1, 1, 1, 1, 1);
        FieldPublicTimeSpan         = new TimeSpan(1, 10, 40);
        FieldPublicEnumDateTimeKind = DateTimeKind.Local;

        // Instantiate date and time using Persian calendar with years,
        // months, days, hours, minutes, seconds, and milliseconds
        FieldPublicDateTimeOffset = new DateTimeOffset(1387, 2, 12, 8, 6, 32, 545,
                                                       new System.Globalization.PersianCalendar(),
                                                       new TimeSpan(1, 0, 0));

        FieldPublicIntPtr         = new IntPtr(100);
        FieldPublicTimeZone       = TimeZone.CurrentTimeZone;
        FieldPublicTimeZoneInfo   = TimeZoneInfo.Utc;
        FieldPublicTuple          = Tuple.Create <string, int, decimal>("T-string\"", 1, 1.1m);
        FieldPublicType           = typeof(object);
        FieldPublicUIntPtr        = new UIntPtr(100);
        FieldPublicUri            = new Uri("http://www.site.com");
        FieldPublicVersion        = new Version(1, 0, 100, 1);
        FieldPublicGuid           = new Guid("d5010f5b-0cd1-44ca-aacb-5678b9947e6c");
        FieldPublicSingle         = Single.MaxValue;
        FieldPublicException      = new Exception("Test error", new Exception("inner exception"));
        FieldPublicEnumNonGeneric = EnumTest.ValueA;
        FieldPublicAction         = () => true.Equals(true);
        FieldPublicAction2        = (a, b) => true.Equals(true);
        FieldPublicFunc           = () => true;
        FieldPublicFunc2          = (a, b) => true;

        #endregion

        #region Arrays and Collections

        FieldPublicArrayUni    = new string[2];
        FieldPublicArrayUni[0] = "[0]";
        FieldPublicArrayUni[1] = "[1]";

        FieldPublicArrayTwo       = new string[2, 2];
        FieldPublicArrayTwo[0, 0] = "[0, 0]";
        FieldPublicArrayTwo[0, 1] = "[0, 1]";
        FieldPublicArrayTwo[1, 0] = "[1, 0]";
        FieldPublicArrayTwo[1, 1] = "[1, 1]";

        FieldPublicArrayThree          = new string[1, 1, 2];
        FieldPublicArrayThree[0, 0, 0] = "[0, 0, 0]";
        FieldPublicArrayThree[0, 0, 1] = "[0, 0, 1]";

        FieldPublicJaggedArrayTwo    = new string[2][];
        FieldPublicJaggedArrayTwo[0] = new string[5] {
            "a", "b", "c", "d", "e"
        };
        FieldPublicJaggedArrayTwo[1] = new string[4] {
            "a1", "b1", "c1", "d1"
        };

        FieldPublicJaggedArrayThree          = new string[1][][];
        FieldPublicJaggedArrayThree[0]       = new string[1][];
        FieldPublicJaggedArrayThree[0][0]    = new string[2];
        FieldPublicJaggedArrayThree[0][0][0] = "[0][0][0]";
        FieldPublicJaggedArrayThree[0][0][1] = "[0][0][1]";

        FieldPublicMixedArrayAndJagged = new int[3][, ]
        {
            new int[, ] {
                { 1, 3 }, { 5, 7 }
            },
            new int[, ] {
                { 0, 2 }, { 4, 6 }, { 8, 10 }
            },
            new int[, ] {
                { 11, 22 }, { 99, 88 }, { 0, 9 }
            }
        };

        FieldPublicDictionary = new System.Collections.Generic.Dictionary <string, string>();
        FieldPublicDictionary.Add("Key1", "Value1");
        FieldPublicDictionary.Add("Key2", "Value2");
        FieldPublicDictionary.Add("Key3", "Value3");
        FieldPublicDictionary.Add("Key4", "Value4");

        FieldPublicList = new System.Collections.Generic.List <int>();
        FieldPublicList.Add(0);
        FieldPublicList.Add(1);
        FieldPublicList.Add(2);

        FieldPublicQueue = new System.Collections.Generic.Queue <int>();
        FieldPublicQueue.Enqueue(10);
        FieldPublicQueue.Enqueue(11);
        FieldPublicQueue.Enqueue(12);

        FieldPublicHashSet = new System.Collections.Generic.HashSet <string>();
        FieldPublicHashSet.Add("HashSet1");
        FieldPublicHashSet.Add("HashSet2");

        FieldPublicSortedSet = new System.Collections.Generic.SortedSet <string>();
        FieldPublicSortedSet.Add("SortedSet1");
        FieldPublicSortedSet.Add("SortedSet2");
        FieldPublicSortedSet.Add("SortedSet3");

        FieldPublicStack = new System.Collections.Generic.Stack <string>();
        FieldPublicStack.Push("Stack1");
        FieldPublicStack.Push("Stack2");
        FieldPublicStack.Push("Stack3");

        FieldPublicLinkedList = new System.Collections.Generic.LinkedList <string>();
        FieldPublicLinkedList.AddFirst("LinkedList1");
        FieldPublicLinkedList.AddLast("LinkedList2");
        FieldPublicLinkedList.AddAfter(FieldPublicLinkedList.Find("LinkedList1"), "LinkedList1.1");

        FieldPublicObservableCollection = new System.Collections.ObjectModel.ObservableCollection <string>();
        FieldPublicObservableCollection.Add("ObservableCollection1");
        FieldPublicObservableCollection.Add("ObservableCollection2");

        FieldPublicKeyedCollection = new MyDataKeyedCollection();
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data1", Id = 0
        });
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data2", Id = 1
        });

        var list = new List <string>();
        list.Add("list1");
        list.Add("list2");
        list.Add("list3");

        FieldPublicReadOnlyCollection = new ReadOnlyCollection <string>(list);

        FieldPublicReadOnlyDictionary           = new ReadOnlyDictionary <string, string>(FieldPublicDictionary);
        FieldPublicReadOnlyObservableCollection = new ReadOnlyObservableCollection <string>(FieldPublicObservableCollection);
        FieldPublicCollection = new Collection <string>();
        FieldPublicCollection.Add("collection1");
        FieldPublicCollection.Add("collection2");
        FieldPublicCollection.Add("collection3");

        FieldPublicArrayListNonGeneric = new System.Collections.ArrayList();
        FieldPublicArrayListNonGeneric.Add(1);
        FieldPublicArrayListNonGeneric.Add("a");
        FieldPublicArrayListNonGeneric.Add(10.0m);
        FieldPublicArrayListNonGeneric.Add(new DateTime(2000, 01, 01));

        FieldPublicBitArray    = new System.Collections.BitArray(3);
        FieldPublicBitArray[2] = true;

        FieldPublicSortedList = new System.Collections.SortedList();
        FieldPublicSortedList.Add("key1", 1);
        FieldPublicSortedList.Add("key2", 2);
        FieldPublicSortedList.Add("key3", 3);
        FieldPublicSortedList.Add("key4", 4);

        FieldPublicHashtableNonGeneric = new System.Collections.Hashtable();
        FieldPublicHashtableNonGeneric.Add("key1", 1);
        FieldPublicHashtableNonGeneric.Add("key2", 2);
        FieldPublicHashtableNonGeneric.Add("key3", 3);
        FieldPublicHashtableNonGeneric.Add("key4", 4);

        FieldPublicQueueNonGeneric = new System.Collections.Queue();
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric1");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric2");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric3");

        FieldPublicStackNonGeneric = new System.Collections.Stack();
        FieldPublicStackNonGeneric.Push("StackNonGeneric1");
        FieldPublicStackNonGeneric.Push("StackNonGeneric2");

        FieldPublicIEnumerable = FieldPublicSortedList;

        FieldPublicBlockingCollection = new System.Collections.Concurrent.BlockingCollection <string>();
        FieldPublicBlockingCollection.Add("BlockingCollection1");
        FieldPublicBlockingCollection.Add("BlockingCollection2");

        FieldPublicConcurrentBag = new System.Collections.Concurrent.ConcurrentBag <string>();
        FieldPublicConcurrentBag.Add("ConcurrentBag1");
        FieldPublicConcurrentBag.Add("ConcurrentBag2");
        FieldPublicConcurrentBag.Add("ConcurrentBag3");

        FieldPublicConcurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary <string, int>();
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary1", 0);
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary2", 0);

        FieldPublicConcurrentQueue = new System.Collections.Concurrent.ConcurrentQueue <string>();
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue1");
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue2");

        FieldPublicConcurrentStack = new System.Collections.Concurrent.ConcurrentStack <string>();
        FieldPublicConcurrentStack.Push("ConcurrentStack1");
        FieldPublicConcurrentStack.Push("ConcurrentStack2");

        // FieldPublicOrderablePartitioner = new OrderablePartitioner();
        // FieldPublicPartitioner;
        // FieldPublicPartitionerNonGeneric;

        FieldPublicHybridDictionary = new System.Collections.Specialized.HybridDictionary();
        FieldPublicHybridDictionary.Add("HybridDictionaryKey1", "HybridDictionary1");
        FieldPublicHybridDictionary.Add("HybridDictionaryKey2", "HybridDictionary2");

        FieldPublicListDictionary = new System.Collections.Specialized.ListDictionary();
        FieldPublicListDictionary.Add("ListDictionaryKey1", "ListDictionary1");
        FieldPublicListDictionary.Add("ListDictionaryKey2", "ListDictionary2");
        FieldPublicNameValueCollection = new System.Collections.Specialized.NameValueCollection();
        FieldPublicNameValueCollection.Add("Key1", "Value1");
        FieldPublicNameValueCollection.Add("Key2", "Value2");

        FieldPublicOrderedDictionary = new System.Collections.Specialized.OrderedDictionary();
        FieldPublicOrderedDictionary.Add(1, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add(2, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add("OrderedDictionaryKey2", "OrderedDictionary2");

        FieldPublicStringCollection = new System.Collections.Specialized.StringCollection();
        FieldPublicStringCollection.Add("StringCollection1");
        FieldPublicStringCollection.Add("StringCollection2");

        #endregion

        #region Several

        PropXmlDocument = new XmlDocument();
        PropXmlDocument.LoadXml("<xml>something</xml>");

        var tr = new StringReader("<Root>Content</Root>");
        PropXDocument         = XDocument.Load(tr);
        PropStream            = GenerateStreamFromString("Stream");
        PropBigInteger        = new System.Numerics.BigInteger(100);
        PropStringBuilder     = new StringBuilder("StringBuilder");
        FieldPublicIQueryable = new List <string>()
        {
            "IQueryable"
        }.AsQueryable();

        #endregion

        #region Custom

        FieldPublicMyCollectionPublicGetEnumerator           = new MyCollectionPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsPublicGetEnumerator   = new MyCollectionInheritsPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionExplicitGetEnumerator         = new MyCollectionExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsExplicitGetEnumerator = new MyCollectionInheritsExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsTooIEnumerable        = new MyCollectionInheritsTooIEnumerable("a b c", new char[] { ' ' });

        FieldPublicEnumSpecific = EnumTest.ValueB;
        MyDelegate            = MethodDelegate;
        EmptyClass            = new EmptyClass();
        StructGeneric         = new ThreeTuple <int>(0, 1, 2);
        StructGenericNullable = new ThreeTuple <int>(0, 1, 2);
        FieldPublicNullable   = new Nullable <ThreeTuple <int> >(StructGeneric);

        #endregion
    }
Example #33
0
    public string setInLineStyles(string htmlContent)
    {
        htmlContent = this.removeStylesForFirstDiv(htmlContent);

        int startIndex = 0;
        int indexClass = htmlContent.IndexOf("class", startIndex);

        HybridDictionary hdStyles = new System.Collections.Specialized.HybridDictionary();

        // The token class was found:
        while (indexClass >= 0)
        {
            int nextChar = indexClass + 5;

            string className = string.Empty;

            // It is a class attribute applied to a html tag:
            if (nextChar < htmlContent.Length && htmlContent[nextChar] == '=')
            {
                // Get the class name:
                for (int i = nextChar + 1; htmlContent[i] != ' ' && htmlContent[i] != '>'; i++)
                {
                    className += htmlContent[i];
                }
            }

            if (!string.IsNullOrEmpty(className) && !hdStyles.Contains(className))
            {
                string classDef = this.getClassDefinition(htmlContent, className);

                if (!string.IsNullOrEmpty(classDef) && !hdStyles.Contains(className))
                {
                    hdStyles.Add(className, classDef);
                }
            }

            startIndex = indexClass + 5;
            indexClass = htmlContent.IndexOf("class", startIndex);
        }

        string htmlContentChanged = string.Empty;

        // We finished to collect all the class elements and its definitions:
        if (hdStyles.Count > 0)
        {
            StringBuilder sbClasses = new StringBuilder(htmlContent);

            // We are ready to replace class entries to inline styles:
            IDictionaryEnumerator e = hdStyles.GetEnumerator();

            while (e.MoveNext())
            {
                string classToReplace = "class=" + e.Key.ToString();
                string inlineStyle    = "style=\"" + e.Value.ToString() + "\"";

                // First option:
                sbClasses.Replace(classToReplace, inlineStyle);

                // Second option:
                classToReplace = "class=\"" + e.Key.ToString() + "\"";
                sbClasses.Replace(classToReplace, inlineStyle);
            }

            htmlContentChanged = sbClasses.ToString();
        }
        else
        {
            htmlContentChanged = htmlContent;
        }

        return(htmlContentChanged);
    }
Example #34
0
 private Cache()
 {
     _data = new CacheCollection();
     _rwl  = new ReaderWriterLock();
 }
 public HttpListenerContextAdapter(HttpListenerContext inner)
 {
     _inner = inner;
     Request = new HttpListenerRequestAdapter(inner.Request);
     Response = new HttpListenerResponseAdapter(inner.Response);
     Items = new HybridDictionary(true);
 }