Example #1
0
        public void Load(string filename)
        {
            try {
                Trace.WriteLine(string.Format("-- Loading config from \"{0}\"...", Path.GetFullPath(filename)));
                Trace.Indent();

                #region Validate parameters
                if (string.IsNullOrWhiteSpace(filename))
                {
                    Trace.WriteLine("Unable to load TConfigDocument : filename is null or empty");
                    return;
                }
                if (!File.Exists(filename))
                {
                    Trace.WriteLine(string.Format("Unable to load TConfigDocument \"{0}\" : file is missing or access is denied.", filename));
                    return;
                }
                #endregion Validate parameters
                try {
                    XDocument SourceDocument = XDocument.Load(filename);
                    DataFolderPath = SourceDocument.Root.SafeReadAttribute <string>("datafolderpath", DefaultDataFolderPath);
                    RootGroup      = new TConfigGroup(SourceDocument.Root.Element("group"));
                    //Name = SourceDocument.Root.SafeReadAttribute<string>("name", filename);
                } catch (Exception ex) {
                    Trace.WriteLine(string.Format("Error reading TConfigDocument \"{0}\" : {1}", filename, ex.Message));
                    return;
                }
            } finally {
                Trace.Unindent();
                Trace.WriteLine("Done.");
            }
        }
Example #2
0
 public TConfigGroup(TConfigGroup group)
     : this()
 {
     Name     = group.Name;
     Groups   = new TConfigGroupCollection(group.Groups);
     Channels = new TLocalChannelCollection(group.Channels);
 }
Example #3
0
        private TLocalChannelCollection _GetChannels(TConfigGroup group)
        {
            TLocalChannelCollection RetVal = new TLocalChannelCollection();

            RetVal.Add(group.Channels);
            foreach (TConfigGroup GroupItem in group.Groups)
            {
                RetVal.Add(_GetChannels(GroupItem));
            }
            return(RetVal);
        }
Example #4
0
 public void Import(TOpmlDocument opmlDocument)
 {
     if (opmlDocument.Load())
     {
         TConfigGroup ImportedGroup = new TConfigGroup();
         ImportedGroup.Name = opmlDocument.Name;
         foreach (TOpmlOutline OutlineItem in opmlDocument.Outlines)
         {
             ImportedGroup.ImportOpmlOutline(OutlineItem, DataFolderPath);
         }
         RootGroup.Groups.Add(ImportedGroup);
     }
     Save();
     if (ImportCompleted != null)
     {
         ImportCompleted(this, EventArgs.Empty);
     }
 }
Example #5
0
        public void ImportOpmlOutline(TOpmlOutline outline, string dataPath)
        {
            switch (outline.OutlineType)
            {
            case "rss":
                TLocalChannel NewChannel = new TLocalChannel(outline);
                NewChannel.StoragePath = dataPath;
                Channels.Add(NewChannel);
                break;

            case "group":
                TConfigGroup NewGroup = new TConfigGroup();
                NewGroup.Name = outline.Title;
                if (outline.Outlines.Count > 0)
                {
                    foreach (TOpmlOutline OutlineItem in outline.Outlines)
                    {
                        NewGroup.ImportOpmlOutline(OutlineItem, dataPath);
                    }
                }
                Groups.Add(NewGroup);
                break;
            }
        }
Example #6
0
 public TConfigDocument()
 {
     Name           = "";
     RootGroup      = new TConfigGroup();
     DataFolderPath = DefaultDataFolderPath;
 }