/// <summary>
        /// Retourne un analyseur de flux de syndication en fonction
        ///  du type de format contenant dans le fichier XML.
        /// </summary>
        /// <param name="document">fichier XML du flux RSS</param>
        /// <param name="channel">channel associé à ce flux</param>
        /// <returns>analyseur XML</returns>
        public static AbstractSyndicationParser GetParser(XmlDocument document, Channel channel)
        {
            // DECLARATION
            AbstractSyndicationParser parser;
            SyndicationFormat format;

            // INITIALISATION
            format = SyndicationFormat.NONE;
            parser = null;

            // type de format du flux de syndication
            format = GetSyndicationFormat(document);
            switch (format)
            {
                case SyndicationFormat.RSS_0_91:
                    parser = new RSS_0_91_Parser(document, channel, "RSS 0.91");
                    break;
                case SyndicationFormat.RSS_0_92:
                    parser = new RSS_0_92_Parser(document, channel, "RSS 0.92");
                    break;
                case SyndicationFormat.RSS_2_0:
                    //Enum.GetName(typeof(SyndicationFormat), SyndicationFormat.RSS_2_0);
                    parser = new RSS_2_0_Parser(document, channel, "RSS 2.0");
                    break;
                case SyndicationFormat.ATOM_1_0:
                    parser = new ATOM_1_0_Parser(document, channel, "Atom 1.0");
                    break;
                default:
                    // TODO exception
                    break;
            }

            return parser;
        }
예제 #2
0
        /// <summary>
        /// Instancie un nouveau analyseur de fichier XML 
        ///   correspondant un flux de syndication RSS 0.92
        /// </summary>
        /// <param name="document">fichier xml à analyser</param>
        /// <param name="link">lien du site web associé à ce fichier XML</param>
        /// <param name="format">type du format du flux de syndication</param>
        public RSS_0_92_Parser(XmlDocument document, Channel channel, String format)
            : base(document, channel, format)
        {
            ChannelNode = Root.GetElementsByTagName("channel").Item(0);

            if (ChannelNode == null)
            {
                //throw new SyndicationParserException();
            }
        }
예제 #3
0
        /// <summary>
        /// Instancie un nouveau analyseur de fichier XML
        ///  correspondant à un flux ATOM 1.0.
        /// </summary>
        /// <param name="document">fichier XML</param>
        /// <param name="channel">channel associé à ce fichier</param>
        /// <param name="format">nom du format du flux</param>
        public ATOM_1_0_Parser(XmlDocument document, Channel channel, String format)
            : base(document, channel, format)
        {
            // recupere l'element 'feed' du fichier XML
            FeedNode = Root;

            if (FeedNode == null)
            {
                //throw new SyndicationParserException();
            }
        }
        /// <summary>
        /// Instancie un analyseur de fichier XML
        /// </summary>
        /// <param name="document">representation en memoire du fichier XML associé au flux</param>
        /// <param name="channel">channel associé à l'analyseur XML</param>
        /// <param name="format">format du flux de syndication utilisé par le channel</param>
        protected AbstractSyndicationParser(XmlDocument document, Channel channel, String format)
        {
            Document = document;
            Link = channel.Link;
            Format = format;
            Channel = channel;

            Items = new Dictionary<string, Item>();
            Categories = new List<string>();

            // TODO expcetion si null
            if (Document != null)
                Root = Document.DocumentElement;
        }
        /// <summary>
        /// Deplace le channel spécifié en parametre
        ///  dans ce repertoire
        /// </summary>
        /// <param name="channel">
        /// channel à deplacer dans le repertoire
        /// </param>
        public void Move(Channel channel)
        {
            if ((channel.IsMoved) && (channel.FolderMovedTo == Path))
            {
                if (ExistsChannel(channel.Name))
                {
                    throw new FolderAlreadyCreatedException("Un channel avec le meme nom existe dans ce repertoire");
                }

                // ajoute le channel
                _channels.Add(channel.Name, channel);
                channel.DeleteChannelRequest += new DeleteRequestDelegate(OnDeleteChannelRequest);

                // update la table de hachage "link" => "path"
                _mapLinkToPath.Remove(channel.Link);
                _mapLinkToPath.Add(channel.Link, channel.Path);
            }
        }
        /// <summary>
        /// Creation d'un nouveau channel associé à ce repertoire.
        /// Si un channel dont le nom correspond à "name",
        ///   le channel ne sera pas crée.
        /// </summary>
        /// <param name="name">nom du channel</param>
        /// <param name="url">url du channel</param>
        public Channel CreateChannel(String name, String link)
        {
            // on verifie la taille du nom du channel
            if (name.Length > MAX_NAME_SIZE)
            {
                throw new IllegalNameException("Le nom du channel est limité à " + MAX_NAME_SIZE + " caractères.");
            }
            // on verifie que le nom du channel ne possede pas de caracteres interdits
            else if (!pattern.IsMatch(name))
            {
                throw new IllegalNameException("Le nom du channel est limité aux lettres, aux chiffres et aux espaces.");
            }
            // on verifie que le channel n'existe pas dans ce repertoire
            else if (ExistsChannel(name))
            {
                throw new ChannelAlreadyCreatedException("Le channel " + name + " existe déjà dans le repertoire \"" + Path + "\".");
            }

            // creation du channel
            Channel channel = new Channel(name, link, this);

            // on ecoute l'evenement
            channel.DeleteChannelRequest += new DeleteRequestDelegate(OnDeleteChannelRequest);

            // ajout du channel
            _channels.Add(name, channel);
            _mapLinkToPath.Add(channel.Link, channel.Path);

            return channel;
        }
        public void Initialize()
        {
            folder = SyndicationManager.getInstance().Root;

            channel = new Channel("Zdnet", "http://www.zdnet.fr/feeds/rss/", folder);
        }
 /// <summary>
 /// Methode de l'evenement declenché lors de l'ajout
 ///  d'un channel dans le model de l'application.
 /// On met à jour la treeview de la frame principale
 /// </summary>
 void NewChannelAdded(Channel channel)
 {
     Manager.Save(filename);
     View.AddTreeViewNode(channel);
     View.UpdateTreeViewText(Manager.Root);
     // ancienne methode
     //View.UpdateTreeView(Manager.Root);
 }