コード例 #1
0
        private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
        {
            ArrayList addList = new ArrayList();
            ArrayList delList = new ArrayList();

            foreach (RenderableObject newObject in newList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject curObject in curList.ChildObjects)
                {
                    string xmlSource = curObject.MetaData["XmlSource"] as string;

                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        UpdateRenderable(curObject, newObject);
                        break;
                    }
                }

                if (!foundObject)
                {
                    addList.Add(newObject);
                }
            }

            foreach (RenderableObject curObject in curList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject newObject in newList.ChildObjects)
                {
                    string xmlSource = newObject.MetaData["XmlSource"] as string;
                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        break;
                    }
                }

                if (!foundObject)
                {
                    string src = (string)curObject.MetaData["XmlSource"];

                    if (src != null || src == m_DataSource)
                    {
                        delList.Add(curObject);
                    }
                }
            }

            foreach (RenderableObject o in addList)
            {
                curList.Add(o);
            }

            foreach (RenderableObject o in delList)
            {
                curList.Remove(o);
            }
        }