Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Trouble deleting items using generic xml provider.

Trouble deleting items using generic xml provider.

Scheduled Pinned Locked Moved C#
csharplinqdesignhostingxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JimBob SquarePants
    wrote on last edited by
    #1

    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
    
    A 1 Reply Last reply
    0
    • J JimBob SquarePants

      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
      
      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      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.

      [Forum Guidelines]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups