示例#1
0
 public static void LoadAvailableSources()
 {
     if (Constants.Application.XSettings != null)
     {
         foreach (var xElement in Constants.Application.XSettings.Descendants()
                                           .Elements("PluginSource"))
         {
             var xKey = Guid.Empty;
             var xSourceURI = (string) xElement.Element("SourceURI");
             var xEnabled = true;
             try
             {
                 xEnabled = (bool) xElement.Element("Enabled");
             }
             catch (Exception)
             {
             }
             try
             {
                 xKey = (Guid) xElement.Attribute("Key");
             }
             catch (Exception)
             {
             }
             if (String.IsNullOrWhiteSpace(xSourceURI))
             {
                 continue;
             }
             xKey = xKey != Guid.Empty ? xKey : Guid.NewGuid();
             var pluginSourceItem = new PluginSourceItem
             {
                 Key = xKey,
                 SourceURI = xSourceURI,
                 Enabled = xEnabled,
             };
             var found = UpdateViewModel.Instance.AvailableSources.Any(source => source.Key == pluginSourceItem.Key);
             if (!found)
             {
                 UpdateViewModel.Instance.AvailableSources.Add(pluginSourceItem);
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// </summary>
 private static void AddOrUpdateSource()
 {
     var selectedId = Guid.Empty;
     try
     {
         if (UpdateView.View.PluginSourceDG.SelectedItems.Count == 1)
         {
             selectedId = new Guid(GetValueBySelectedItem(UpdateView.View.PluginSourceDG, "Key"));
         }
     }
     catch (Exception ex)
     {
         Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
     }
     if (UpdateView.View.TSource.Text.Trim() == "")
     {
         return;
     }
     var pluginSourceItem = new PluginSourceItem
     {
         Enabled = true,
         SourceURI = UpdateView.View.TSource.Text
     };
     if (selectedId == Guid.Empty)
     {
         pluginSourceItem.Key = Guid.NewGuid();
         Instance.AvailableSources.Add(pluginSourceItem);
     }
     else
     {
         pluginSourceItem.Key = selectedId;
         var index = Instance.AvailableSources.TakeWhile(source => source.Key != selectedId)
                             .Count();
         Instance.AvailableSources[index] = pluginSourceItem;
     }
     UpdateView.View.PluginSourceDG.UnselectAll();
     UpdateView.View.TSource.Text = "";
 }