Trouble deleting items using generic xml provider.
-
Hi folks, Firstly, I apologise for the length of this question, The classes I'm working with are quite complicated so I didn't want to ask a question without giving you a decent idea of what you are looking at. I've been working all day on a specialized XML provider for use as a datastore on websites. The idea is that I can use the same provider to serialize and deserialize any classes that I initialize the provider with so that everything is strong typed. eg If I want to initialize a provider for a
Person
class I just say:XmlProvider<Person> xp = new XmlProvider<Person>(directory, fileName);
If I want to initialize a provider for a
Client
class I just say:XmlProvider<Client> xp = new XmlProvider<Client>(directory, fileName);
This has been all going well, I can add a serialized class instance and update values but not delete them. Here's what's going on in my provider class.
//-----------------------------------------------------------------------
// <copyright file="XmlProvider.cs" company="Empirical Design">
// Copyright (c) Empirical Design. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------namespace XmlProviders
{
#region Using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;
using System.Reflection;
#endregion/// <summary> /// A specialized generic provider that uses an xml file to store its data. /// </summary> /// <typeparam name="T">class or struct with all the data-fields that must be persisted.</typeparam> public class XmlProvider<T> where T : new() { #region Fields /// <summary> /// Our object to lock against. /// </summary> private object syncRoot = new object(); /// <summary> /// The virtual path to our datastore. /// </summary> private string path; /// <summary> /// The filename of the datastore. /// </summary> private string fileName; /// <summary> /// The weak reference to our store. /// </summary> private WeakReference storeRef; /// <summary> /// The full physical
-
Hi folks, Firstly, I apologise for the length of this question, The classes I'm working with are quite complicated so I didn't want to ask a question without giving you a decent idea of what you are looking at. I've been working all day on a specialized XML provider for use as a datastore on websites. The idea is that I can use the same provider to serialize and deserialize any classes that I initialize the provider with so that everything is strong typed. eg If I want to initialize a provider for a
Person
class I just say:XmlProvider<Person> xp = new XmlProvider<Person>(directory, fileName);
If I want to initialize a provider for a
Client
class I just say:XmlProvider<Client> xp = new XmlProvider<Client>(directory, fileName);
This has been all going well, I can add a serialized class instance and update values but not delete them. Here's what's going on in my provider class.
//-----------------------------------------------------------------------
// <copyright file="XmlProvider.cs" company="Empirical Design">
// Copyright (c) Empirical Design. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------namespace XmlProviders
{
#region Using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;
using System.Reflection;
#endregion/// <summary> /// A specialized generic provider that uses an xml file to store its data. /// </summary> /// <typeparam name="T">class or struct with all the data-fields that must be persisted.</typeparam> public class XmlProvider<T> where T : new() { #region Fields /// <summary> /// Our object to lock against. /// </summary> private object syncRoot = new object(); /// <summary> /// The virtual path to our datastore. /// </summary> private string path; /// <summary> /// The filename of the datastore. /// </summary> private string fileName; /// <summary> /// The weak reference to our store. /// </summary> private WeakReference storeRef; /// <summary> /// The full physical
My initial impressions: See if GetItem() is returning the correct item. See if Items.Remove() is actually reducing the size of the collection. Post the Store.Save() method so we can see what's going on in there.