Beispiel #1
0
        /*
         * Appends all the real estate agents to a dictionary and updates the property count
         * based on the number of properties in the results.
         *
         */
        public bool AddAgentsIntoDict(XmlDocument xmlContent)
        {
            XmlNodeList objectList = xmlContent["LocatieFeed"]["Objects"].ChildNodes;

            foreach (XmlNode property in objectList)
            {
                string          realEstateAgentId   = property["MakelaarId"].InnerText;
                string          realEstateAgentName = property["MakelaarNaam"].InnerText;
                RealEstateAgent realEstateAgent     = new RealEstateAgent(realEstateAgentId, realEstateAgentName, 1);
                if (realEstateAgents.ContainsKey(realEstateAgentId))
                {
                    realEstateAgents[realEstateAgentId].Count++;
                }
                else
                {
                    realEstateAgents.Add(realEstateAgentId, realEstateAgent);
                }
            }

            if (objectList.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
            int IComparer.Compare(object a, object b)
            {
                RealEstateAgent a1 = (RealEstateAgent)a;
                RealEstateAgent a2 = (RealEstateAgent)b;

                if (a1.Count < a2.Count)
                {
                    return(1);
                }

                if (a1.Count > a2.Count)
                {
                    return(-1);
                }

                else
                {
                    return(0);
                }
            }
        /*
         * Default sort method based on the RealEstateAgent id
         *
         */
        int IComparable.CompareTo(object obj)
        {
            RealEstateAgent agent = (RealEstateAgent)obj;

            return(String.Compare(this.Id, agent.Id));
        }
Beispiel #4
0
 /*
  * Sorts an array of the dictionary of real estate agents based on the property count.
  *
  */
 public RealEstateAgent[] GetSortedArray()
 {
     RealEstateAgent[] agentsArray = realEstateAgents.Values.ToArray();
     Array.Sort(agentsArray, RealEstateAgent.SortCount());
     return(agentsArray);
 }