public void updateEntry(PersistenceContainer currentPersistencePair)
        {
            XElement searchedPersistence = null;
            IEnumerable <XElement> searchedPersistences = rootElement.Elements(BDMTConstants.PERSISTENCE_TAG)
                                                          .Where(persistence => persistence.Attribute(BDMTConstants.PERSISTENCE_ATTRIBUTE_ID_TAG).Value == currentPersistencePair.key);

            if (searchedPersistences != null && searchedPersistences.Count() > 0)
            {
                searchedPersistence = searchedPersistences.First();
            }



            if (searchedPersistence != null)
            {
                searchedPersistence.RemoveNodes();
                searchedPersistence.Add(currentPersistencePair.content.Elements());
            }
            else
            {
                XElement newPersistenceElement = new XElement(BDMTConstants.PERSISTENCE_TAG, currentPersistencePair.content.Elements());
                newPersistenceElement.Add(new XAttribute(BDMTConstants.PERSISTENCE_ATTRIBUTE_ID_TAG, currentPersistencePair.key));
                newPersistenceElement.Add(new XAttribute(BDMTConstants.PERSISTENCE_ATTRIBUTE_TYPE_TAG, currentPersistencePair.type));

                rootElement.Add(newPersistenceElement);
            }
        }
示例#2
0
        public void addToPersistenceBuffer(PersistenceContainer currentPersistencePair) {
            if(persistenceBuffer.ContainsKey(currentPersistencePair.key)) {
                persistenceBuffer[currentPersistencePair.key] = currentPersistencePair;
            } else {
                while (!persistenceBuffer.TryAdd(currentPersistencePair.key, currentPersistencePair)) { }
            }

            checkForPersist();
        }