ContainsValue() public method

public ContainsValue ( Object value ) : bool
value Object
return bool
 public override bool ContainsValue(object value)
 {
     lock (host.SyncRoot)
     {
         return(host.ContainsValue(value));
     }
 }
Example #2
0
 public override bool ContainsValue(Object key)
 {
     lock (_root)
     {
         return(_list.ContainsValue(key));
     }
 }
Example #3
0
 // Determine if this sorted list contains a particular value.
 public override bool ContainsValue(Object value)
 {
     lock (SyncRoot)
     {
         return(list.ContainsValue(value));
     }
 }
 static public int ContainsValue(IntPtr l)
 {
     try {
         System.Collections.SortedList self = (System.Collections.SortedList)checkSelf(l);
         System.Object a1;
         checkType(l, 2, out a1);
         var ret = self.ContainsValue(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #5
0
		/// <summary>
		/// Returns  List of tables ordered to allow inserts
		/// without violating constraints
		/// </summary>
		/// <param name="unorderedTables"></param>
		/// <returns></returns>
		public static SortedList OrderTablesByDependency( TableCollection unorderedTables)
		{
			ArrayList _referencedTables = new ArrayList();
			SortedList _sortedTables = new SortedList();

			//create a list of tables that are refernced by other tables
			foreach(Table tableObject in unorderedTables  )
			{
				if(tableObject.IsSystemObject) continue;
				
				foreach(string tableName in GetTableDependencies(tableObject))
				{
					if(!_referencedTables.Contains(tableName))
					{
						_referencedTables.Add(tableName);
					}
				}
			}
			//tables that are referenced have to be filled first
			while(true)
			{
				UpdateNonViolatingList(ref _referencedTables , ref _sortedTables ,ref unorderedTables);
				if(_referencedTables.Count == 0) break;
			}
			//tables that are not referenced at end
			foreach(Table tableObject in unorderedTables  )
			{
				if(tableObject.IsSystemObject) continue;

				if(!_sortedTables.ContainsValue(tableObject.Name))
				{
					_sortedTables.Add(_sortedTables.Count + 1 ,tableObject.Name );
				}
			}
			return _sortedTables;
		}
Example #6
0
        public static string GetIdEntidades(string familia)
        {
            //retorno un string con una lista de todos los iddeentidades de una familia determinada
            string aux = string.Empty;

            if (!_loaded)
            {
                //DeclareTypes(pathFamilia, _nameFamilia);
                DeclareTypes();
            }
            if (_nameFamilia.ContainsValue(familia))
            {
                for (int i = 0; i < _nameFamilia.Count; i++)
                {
                    if (Convert.ToString(_nameFamilia.GetValueList()[i]).Equals(familia))
                    {
                        aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]);
                    }
                }
            }
            if (familia.Equals(string.Empty))
            {
                for (int i = 0; i < _nameFamilia.Count; i++)
                {
                    aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]);
                }
            }
            if (aux != null && aux != string.Empty)
            {
                return(aux.Substring(1));                        //saco la primer coma
            }
            else
            {
                return(string.Empty);
            }
        }
Example #7
0
 public bool Contains(object?value)
 {
     return(sortedList.ContainsValue(value));
 }
Example #8
0
 public virtual bool Contains(object value)
 {
     return(host.ContainsValue(value));
 }
Example #9
0
 public bool Contains(Object value)
 {
     return(list.ContainsValue(value));
 }
Example #10
0
		public void TestContainsValue ()
		{
			SortedList sl1 = new SortedList (55);
			sl1.Add (0, "zero");
			sl1.Add (1, "one");
			sl1.Add (2, "two");
			sl1.Add (3, "three");
			sl1.Add (4, "four");

			Assert.IsTrue (sl1.ContainsValue ("zero"), "#1");
			Assert.IsFalse (sl1.ContainsValue ("ohoo"), "#2");
			Assert.IsFalse (sl1.ContainsValue (null), "#3");
		}
Example #11
0
        public void TestGetEnumeratorBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;

            IDictionaryEnumerator dicen = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i2 = 0;

            int i = 0;
            int j = 0;

            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null val
            sl2[(object)100] = (object)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2[(object)100] = 1;
            Assert.Equal(1, sl2.Count);

            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            //   Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }

            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;

                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));

                object o2 = sl2[(object)(j)]; //need to cast: Get (object key)
                Assert.NotNull(o2);
                i2 = (int)o2;

                i3 = (int)sl2.GetByIndex(i); //Get (index i)
                Assert.False((i3 != i) || (i2 != i));

                //  testcase: GetEnumerator
                dicen = (IDictionaryEnumerator)sl2.GetEnumerator();

                //  Boundary for Current
                Assert.Throws<InvalidOperationException>(() =>
                                 {
                                     object throwaway = dicen.Current;
                                 }
                );

                j = 0;
                //  go over the enumarator
                while (dicen.MoveNext())
                {
                    //  Current to see the order
                    i3 = (int)dicen.Value;
                    Assert.True(j.Equals(i3));

                    //  Current again to see the same order
                    i3 = (int)dicen.Value;
                    Assert.Equal(i3, j);

                    j++;
                }

                //  Boundary for Current
                Assert.Throws<InvalidOperationException>(() =>
                                 {
                                     object throwaway = dicen.Current;
                                 }
                );
                //  Boundary for MoveNext: call MoveNext to make sure it returns false
                Assert.False((dicen.MoveNext()) || (j != 100));

                //  call again MoveNext to make sure it still returns false
                Assert.False(dicen.MoveNext());
            }
        }
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// 	[jbrinkman]	5/6/2004	Created
		///		[jhenning] 2/22/2005	Added properties
		/// </history>
		/// -----------------------------------------------------------------------------
		protected override void RenderContents(HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
			writer.AddAttribute(HtmlTextWriterAttribute.Class, m_objMenu.CssClass);
			writer.AddAttribute(HtmlTextWriterAttribute.Name, m_objMenu.UniqueID);
			writer.AddAttribute(HtmlTextWriterAttribute.Id, m_objMenu.ClientID);

			writer.AddAttribute("orient", ((int)m_objMenu.Orientation).ToString());
			if (m_objMenu.SubMenuOrientation != Orientation.Vertical)
			{
				writer.AddAttribute("suborient", ((int)m_objMenu.SubMenuOrientation).ToString());
			}
			writer.AddAttribute("sysimgpath", m_objMenu.SystemImagesPath);
			if (!String.IsNullOrEmpty(m_objMenu.Target)) writer.AddAttribute("target", m_objMenu.Target); 

			//--- imagelist logic ---
			if (m_objMenu.ImageList.Count > 0)
			{
				SortedList objImagePaths = new SortedList();
				string strList = "";
				string strImagePathList = "";
				foreach (NodeImage objNodeImage in m_objMenu.ImageList) {
					if (objNodeImage.ImageUrl.IndexOf("/") > -1)
					{
						string strPath = objNodeImage.ImageUrl.Substring(0, objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						string strImage = objNodeImage.ImageUrl.Substring(objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						if (objImagePaths.ContainsValue(strPath) == false)
						{
							objImagePaths.Add(objImagePaths.Count, strPath);
						}
						objNodeImage.ImageUrl = string.Format("[{0}]{1}", objImagePaths.IndexOfValue(strPath).ToString(), strImage);
					}
                        strList += (String.IsNullOrEmpty(strList) ? "" : ",") + objNodeImage.ImageUrl;
				}
				for (int intPaths = 0; intPaths <= objImagePaths.Count - 1; intPaths++) 
                    {
                        strImagePathList += (String.IsNullOrEmpty(strImagePathList) ? "" : ",") + objImagePaths.GetByIndex(intPaths).ToString();
				}
				writer.AddAttribute("imagelist", strList);
				writer.AddAttribute("imagepaths", strImagePathList);
			}

			//--- urllist logic ---'
			//Dim objUsedTokens As ArrayList = New ArrayList
			//Me.AssignUrlTokens(m_objMenu.MenuNodes, Nothing, objUsedTokens)
			//If objUsedTokens.Count > 0 Then
			//	writer.AddAttribute("urllist", Join(objUsedTokens.ToArray(), ","))				  'comma safe?!?!?!
			//End If

			if (!String.IsNullOrEmpty(m_objMenu.RootArrowImage)) writer.AddAttribute("rarrowimg", m_objMenu.RootArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.ChildArrowImage)) writer.AddAttribute("carrowimg", m_objMenu.ChildArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.WorkImage)) writer.AddAttribute("workimg", m_objMenu.WorkImage); 

			//css attributes
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClass)) writer.AddAttribute("css", m_objMenu.DefaultNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultChildNodeCssClass)) writer.AddAttribute("csschild", m_objMenu.DefaultChildNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassOver)) writer.AddAttribute("csshover", m_objMenu.DefaultNodeCssClassOver); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassSelected)) writer.AddAttribute("csssel", m_objMenu.DefaultNodeCssClassSelected); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuBarCssClass)) writer.AddAttribute("mbcss", m_objMenu.MenuBarCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuCssClass)) writer.AddAttribute("mcss", m_objMenu.MenuCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultIconCssClass)) writer.AddAttribute("cssicon", m_objMenu.DefaultIconCssClass); 

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction)) writer.AddAttribute("js", m_objMenu.JSFunction); 
			if (m_objMenu.UseTables == false) writer.AddAttribute("usetables", "0"); 
			if (m_objMenu.EnablePostbackState) writer.AddAttribute("enablepbstate", "1"); 
			if (m_objMenu.MouseOutDelay != 500) writer.AddAttribute("moutdelay", m_objMenu.MouseOutDelay.ToString()); 
			if (m_objMenu.MouseInDelay != 250) writer.AddAttribute("mindelay", m_objMenu.MouseInDelay.ToString()); 

			writer.AddAttribute("postback", ClientAPI.GetPostBackEventReference(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "Click"));

			if (m_objMenu.PopulateNodesFromClient)
			{
				if (DotNetNuke.UI.Utilities.ClientAPI.BrowserSupportsFunctionality(Utilities.ClientAPI.ClientFunctionality.XMLHTTP))
				{
					writer.AddAttribute("callback", DotNetNuke.UI.Utilities.ClientAPI.GetCallbackEventReference(m_objMenu, "'[NODEXML]'", "this.callBackSuccess", "oMNode", "this.callBackFail", "this.callBackStatus"));
				}
				else
				{
					writer.AddAttribute("callback", ClientAPI.GetPostBackClientHyperlink(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "OnDemand"));
				}
				if (!String.IsNullOrEmpty(m_objMenu.CallbackStatusFunction))
				{
					writer.AddAttribute("callbacksf", m_objMenu.CallbackStatusFunction);
				}

			}

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction))
			{
				writer.AddAttribute("js", m_objMenu.JSFunction);
			}
			//writer.RenderBeginTag(HtmlTextWriterTag.P)			 '//SAFARI DOES NOT LIKE DIV TAG!!!
			writer.RenderBeginTag(HtmlTextWriterTag.Span);
			//TODO: TEST SAFARI!
			//RenderChildren(writer)	'no longer rendering children for uplevel, only sending down xml and client is responsible
			writer.RenderEndTag();
		}
Example #13
0
        public void TestGetSyncRootBasic()
        {
            SortedList arrSon;
            SortedList arrMother;

            Task[] workers;
            Action ts1;
            Action ts2;
            Int32 iNumberOfWorkers = 4;

            SortedList hshPossibleValues;
            IDictionaryEnumerator idic;

            // Vanila test case - testing SyncRoot is not as simple as its implementation looks like. This is the working
            //scenrio we have in mind.
            //1) Create your Down to earth mother SortedList
            //2) Get a synchronized wrapper from it
            //3) Get a Synchronized wrapper from 2)
            //4) Get a synchronized wrapper of the mother from 1)
            //5) all of these should SyncRoot to the mother earth

            arrMother = new SortedList();
            for (int i = 0; i < _iNumberOfElements; i++)
            {
                arrMother.Add("Key_" + i, "Value_" + i);
            }

            Assert.Equal(arrMother.SyncRoot.GetType(), typeof(Object));

            arrSon = SortedList.Synchronized(arrMother);
            _arrGrandDaughter = SortedList.Synchronized(arrSon);
            _arrDaughter = SortedList.Synchronized(arrMother);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(_arrGrandDaughter.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(_arrDaughter.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            //we are going to rumble with the SortedLists with some threads

            workers = new Task[iNumberOfWorkers];
            ts2 = new Action(RemoveElements);
            for (int iThreads = 0; iThreads < iNumberOfWorkers; iThreads += 2)
            {
                var name = "Thread_worker_" + iThreads;
                ts1 = new Action(() => AddMoreElements(name));

                workers[iThreads] = Task.Run(ts1);
                workers[iThreads + 1] = Task.Run(ts2);
            }

            Task.WaitAll(workers);

            //checking time
            //Now lets see how this is done.
            //Either there are some elements or none
            hshPossibleValues = new SortedList();
            for (int i = 0; i < _iNumberOfElements; i++)
            {
                hshPossibleValues.Add("Key_" + i, "Value_" + i);
            }
            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                hshPossibleValues.Add("Key_Thread_worker_" + i, "Thread_worker_" + i);
            }

            //lets check the values if
            idic = arrMother.GetEnumerator();
            while (idic.MoveNext())
            {
                Assert.True(hshPossibleValues.ContainsKey(idic.Key), "Error, Expected value not returned, " + idic.Key);
                Assert.True(hshPossibleValues.ContainsValue(idic.Value), "Error, Expected value not returned, " + idic.Value);
            }
        }
Example #14
0
 public virtual bool Contains(Object value)
 {
     return(_sortedList.ContainsValue(value));
 }
Example #15
0
        public void TestGetValueListBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;
            IEnumerator en = null;
            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i = 0;
            int j = 0;
            //
            // Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList();

            // Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            // Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            // Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            // Testcase: Set - null val
            sl2[(object)100] = (object)null;
            Assert.Equal(1, sl2.Count);

            // Testcase: vanila Set
            sl2[(object)100] = 1;
            Assert.Equal(1, sl2.Count);
            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            // Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }
            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;
                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));

                object o2 = sl2[(int)j];

                Assert.NotNull(o2);
                Assert.True(o2.Equals(i), "Error, entry for key " + j.ToString() + " is " + o2.ToString() + " but should have been " + i.ToString());
            } // FOR

            //  testcase: GetValueList
            // ICollection.GetEnumerator() first test the boundaries on the Remove method thru GetEnumerator implementation
            en = (IEnumerator)sl2.GetValueList().GetEnumerator();

            // Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                    {
                        object throwaway = en.Current;
                    }
            );

            j = 0;
            // go over the enumarator
            en = (IEnumerator)sl2.GetValueList().GetEnumerator();
            while (en.MoveNext())
            {
                // Current to see the order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                // GetObject again to see the same order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                j++;
            }

            // Boundary for GetObject
            Assert.Throws<InvalidOperationException>(() =>
                    {
                        object throwawayobj = en.Current;
                    }
            );

            // Boundary for MoveNext: call MoveNext to make sure it returns false
            Assert.False((en.MoveNext()) || (j != 100));
            // call again MoveNext to make sure it still returns false
            Assert.False(en.MoveNext());
            Assert.Equal(100, sl2.Count);

            // now modify the sortedlist while enumerator is still active
            en = (IEnumerator)sl2.GetKeyList().GetEnumerator(); //can remove an item thru en
            en.MoveNext();

            sl2[1] = 0;  // Set (int index, object val) // this works fine

            // Boundary for MoveNext
            Assert.Throws<InvalidOperationException>(() =>
                {
                    en.MoveNext();
                });
        }
Example #16
0
        public void TestGetKeyListBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;
            IEnumerator en = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i = 0;
            int j = 0;

            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(); //using default IComparable implementation from Integer4
            // which is used here as key-val elements.

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null val
            sl2[(Object)100] = (Object)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2[(Object)100] = 1;
            Assert.Equal(1, sl2.Count);

            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            //   Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }

            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;
                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));
            }

            //  testcase: GetKeyList
            //  first test the boundaries on the Remove method thru GetEnumerator implementation
            en = (IEnumerator)sl2.GetKeyList().GetEnumerator();

            //  Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                             {
                                 Object objThrowAway = en.Current;
                             }
            );

            j = 100;
            //  go over the enumarator
            en = (IEnumerator)sl2.GetKeyList().GetEnumerator();
            while (en.MoveNext())
            {
                //  Current to see the order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                //  Current again to see the same order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                j++;
            }


            //  Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                             {
                                 Object objThrowAway = en.Current;
                             }
            );

            //  Boundary for MoveNext: call MoveNext to make sure it returns false
            Assert.False((en.MoveNext()) || (j != 200));

            //  call again MoveNext to make sure it still returns false
            Assert.False(en.MoveNext());
        }
	public void TestContainsValue() {
		SortedList sl1 = new SortedList(55);
                sl1.Add(0, "zero");
                sl1.Add(1, "one");
                sl1.Add(2, "two");
                sl1.Add(3, "three");
                sl1.Add(4, "four");

		Assert("sl.ContainsValue: can't find existing value", sl1.ContainsValue("zero"));
		Assert("sl.ContainsValue: finds non-existing value", !sl1.ContainsValue("ohoo"));
		Assert("sl.ContainsValue: finds non-existing value", !sl1.ContainsValue(null));
	}
Example #18
0
        public void TestContainsValueBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            String s1 = null;
            String s2 = null;
            int i = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: No_Such_Key
            Assert.False(sl2.ContainsKey("No_Such_Val"));

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }
            //
            //   Testcase: test ContainsValue
            //
            for (i = 0; i < sl2.Count; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                Assert.True(sl2.ContainsValue(s2));
            }

            //
            // Remove a key and then check
            //
            sblMsg.Length = 0;
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            sl2.Remove(s1); //removes "Key_50"

            sblMsg.Length = 0;
            sblMsg.Append("val_50");
            s2 = sblMsg.ToString();

            Assert.False(sl2.ContainsKey(s2));
        }
    /// <summary>
    /// Called when the tool is activated.
    /// </summary>
    protected override void OnActivateTool() {
      if (this.Controller.Model.Selection.SelectedItems != null && this.Controller.Model.Selection.SelectedItems.Count > 0) {
        /*
       * They should give me a Nobel prize for so much thinking early in the morning...
       */
        #region Preparation of the ordering
        Debug.Assert(this.Controller.Model.Selection.SelectedItems[0] != null, "A selection cannot contain a 'null' entity.");
        //the items have to be moved in the order of the Paintables; the SortedList automatically orders things for us.
        SortedList<int, IDiagramEntity> list = new SortedList<int, IDiagramEntity>();
        //We fetch a flattened selection, which means that if there is a group the constituents will be
        //returned rather than the group itself.
        foreach (IDiagramEntity entity in this.Controller.Model.Selection.FlattenedSelectionItems) {
          //the addition will automatically put the item in increasing order
          list.Add(this.Controller.Model.Paintables.IndexOf(entity), entity);
        }
        //if the lowest z-value is the first one in the paintables we cannot shift anything, so we quit
        if (list.Keys[0] == 0) return;

        /*Send them forwards but make sure it's a visible effect!
        It's not enough to move it only once since the shape(s) above might be of
        high z-order degree, so we have to find which is the first shape overlapping with 
        the selection and take as many steps as it takes to surpass it.
         If there is no overlap we'll shift the z-order with just one unit.
        */
        int delta = 1;
        int lowestZInSelection = list.Keys[0];
        bool found = false;
        //we can speed up the loop by noticing that the previous shape in the z-stack is necessarily
        //below the first one of the selection
        for (int m = lowestZInSelection - 1; m >= 0 && !found; m--) {
          //the overlap has to be with an entity, not from the selection
          if (list.ContainsValue(this.Controller.Model.Paintables[m])) continue;
          for (int s = 0; s < list.Count; s++) {
            //if there is an overlap we found the required index
            if (this.Controller.Model.Paintables[m].Rectangle.IntersectsWith(list.Values[s].Rectangle)) {
              //an additional complication here; if the found shape is part of a group we have
              //to take the upper z-value of the group...
              if (this.Controller.Model.Paintables[m].Group != null) {
                int min = int.MaxValue;
                CollectionBase<IDiagramEntity> leafs = new CollectionBase<IDiagramEntity>();
                Utils.TraverseCollect(this.Controller.Model.Paintables[m].Group, ref leafs);
                foreach (IDiagramEntity groupMember in leafs) {
                  min = Math.Min(min, this.Controller.Model.Paintables.IndexOf(groupMember));
                }
                //take the found z-value of the group rather than the one of the group-child
                m = min;
              }
              delta = lowestZInSelection - m;
              found = true;
              break;
            }

          }
        }
        #endregion
        Debug.Assert(delta >= 1, "The shift cannot be less than one since we checked previous situations earlier.");
        for (int k = 0; k < list.Count; k++) {
          this.Controller.Model.SendBackwards(list.Values[k], delta);
        }
      }
      DeactivateTool();
    }
Example #20
0
        public static string GetHtmlInstructionTable()
        {
            string result = "";

            result +=
                @"
                <TABLE BORDER=""1"" ALIGN=""CENTER"" WIDTH=""100%"" rules=""all"" frame=""box"" cellspacing=""0"" cellpadding=""0"" bordercolor=""#A0A0A0"">
                    <THEAD bgcolor=""#C0C0C0"">
                        <TH style=""border-left: thin"">Simple</TH>
                        <TH style=""border-left: thin"">IL</TH>
                        <TH style=""border-left: thin"">Param</TH>
                    </THEAD>

                    <TBODY>
                ";

            string[] paramTypes = new string[10]
                                                                {
                                                                    "none",
                                                                    "Int32",
                                                                    "Int32",
                                                                    "Int64",
                                                                    "Int32",
                                                                    "Int32",
                                                                    "double",
                                                                    "double",
                                                                    "(reflection object)",
                                                                    "Int32[]"
                                                                };

            for (InstructionCode code = InstructionCode.ADD; code <= InstructionCode.XOR; code++)
            {
                SortedList hash = new SortedList();

                int i;
                string il = "", parms = "";
                for (i = 0; i < instructions.Length; i++)
                    if (instructions[i].code == code && instructions[i].name != "-")
                    {
                        il += instructions[i].name+" ";

                        ParamType pType = instructions[i].pType;
                        string pTypeStr = paramTypes[(int)pType];
                        if (pType != ParamType.pNone && ! hash.ContainsValue(pTypeStr))
                            hash.Add(i,pTypeStr);
                    }

                for (i = 0; i < hash.Count; i++)
                    parms += hash.GetByIndex(i)+" ";

                result += "                        <TR>\n";

                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+code+"</TD>";
                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+il+"</TD>";
                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+parms+"</TD>";

                result += "                        </TR>\n";
            }

            result +=
                @"
                    </TBODY>
                </TABLE>
                ";

            return result;
        }