async Task ExecuteLoadAuthorsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Authors.Clear();
                var authors = await dataStore.GetAuthors();

                foreach (var author in authors)
                {
                    Authors.Add(author);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void Open(string filename)
        {
            var doc = new XmlDocument();

            doc.Load(filename);

            var xmlHelper = new XmlHelper(doc);

            XmlNode root = doc.DocumentElement;

            Version = xmlHelper.GetValidChild(root, "version").InnerText;

            Authors.Clear();
            List <XmlNode> authors = xmlHelper.GetChildren(root, "author");

            foreach (XmlNode node in authors)
            {
                var author = new Pair <string, string>(node.Attributes["name"].InnerText, node.Attributes["email"].InnerText);
                Authors.Add(author);
            }

            CreatedDate = xmlHelper.GetValidChild(root, "created_date").InnerText;

            DataDependancy = xmlHelper.GetValidChild(root, "data_dependency").InnerText;

            QuantLevel = xmlHelper.GetValidChild(root, "quantLevel").InnerText;

            XmlNode profile = xmlHelper.GetValidChild(root, "PeptideProfile");

            this.nextProtein = xmlHelper.GetFirstChild(root, "Protein");
        }
示例#3
0
        public void SetAuthor(Author author)
        {
            if (Authors == null)
            {
                Authors = new HashSet <Author>();
            }

            Authors.Clear();
            Authors.Add(author);
        }
示例#4
0
        private void RunSelect()
        {
            Authors.Clear();
            ObservableCollection <SmallAuthorObject> tmp = new ObservableCollection <SmallAuthorObject>(DatabaseAccess.SelectAuthorList(FirstName, LastName));

            foreach (var item in tmp)
            {
                Authors.Add(item);
            }
        }
示例#5
0
        public static void Clear()
        {
            SingletonMod <Mod> .Logger.Debug($"{nameof(TemplateManager)} {nameof(Clear)}");

            SingletonManager <StyleTemplateManager> .Instance.ClearData();

            SingletonManager <IntersectionTemplateManager> .Instance.ClearData();

            SingletonManager <RoadTemplateManager> .Instance.ClearData();

            Authors.Clear();
        }
示例#6
0
        public void FillAuthorsList()
        {
            _commandSelect = "SELECT Id, Name FROM Authors";
            _sqlDataAdapter.SelectCommand = new SqlCommand(_commandSelect, _sqlConnection);

            _dataSet.Clear();
            _sqlDataAdapter.Fill(_dataSet);
            Authors.Clear();

            Authors = _dataSet.Tables[0].AsEnumerable().Select(dataRow =>
                                                               new Author
            {
                Id   = dataRow.Field <long>("Id"),
                Name = dataRow.Field <string>("Name")
            }).ToList();
        }
        public bool RetrieveSpawnsetList()
        {
            try
            {
                Spawnsets.Clear();
                Authors.Clear();

                string downloadString = string.Empty;
                using (TimeoutWebClient client = new TimeoutWebClient(Timeout))
                    downloadString = client.DownloadString(UrlUtils.ApiGetSpawnsets);
                List <SpawnsetFile> spawnsetFiles = JsonConvert.DeserializeObject <List <SpawnsetFile> >(downloadString);

                Authors.Add(new AuthorListEntry(SpawnsetListHandler.AllAuthors, spawnsetFiles.Count));
                foreach (SpawnsetFile sf in spawnsetFiles)
                {
                    AuthorListEntry author = new AuthorListEntry(sf.Author, spawnsetFiles.Where(s => s.Author == sf.Author).Count());
                    if (!Authors.Any(a => a.Name == author.Name))
                    {
                        Authors.Add(author);
                    }
                }

                foreach (SpawnsetFile spawnsetFile in spawnsetFiles)
                {
                    Spawnsets.Add(new SpawnsetListEntry {
                        SpawnsetFile = spawnsetFile
                    });
                }

                return(true);
            }
            catch (WebException ex)
            {
                App.Instance.ShowError("Error retrieving spawnset list", $"Could not connect to '{UrlUtils.ApiGetSpawnsets}'.", ex);
                return(false);
            }
            catch (Exception ex)
            {
                App.Instance.ShowError("Unexpected error", "An unexpected error occurred.", ex);
                return(false);
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        #endregion

        //////////////////////////////////////////////////////////////////////

        /// <summary>given a stream, parses it to construct the Feed object out of it</summary>
        /// <param name="stream"> a stream representing hopefully valid XML</param>
        /// <param name="format"> indicates if the stream is Atom or Rss</param>
        //////////////////////////////////////////////////////////////////////
        public void Parse(Stream stream, AlternativeFormat format)
        {
            Tracing.TraceCall("parsing stream -> Start:" + format.ToString());
            BaseFeedParser feedParser = null;

            // make sure we reset our collections
            Authors.Clear();
            Contributors.Clear();
            Links.Clear();
            Categories.Clear();

            feedParser = new AtomFeedParser(this);

            // create a new delegate for the parser
            feedParser.NewAtomEntry        += new FeedParserEventHandler(OnParsedNewEntry);
            feedParser.NewExtensionElement += new ExtensionElementEventHandler(OnNewExtensionElement);
            feedParser.Parse(stream, this);

            Tracing.TraceInfo("Parsing stream -> Done");
            // done parsing
        }
示例#9
0
 public void Clear_Author()
 {
     Authors = Authors.Clear();
 }
示例#10
0
 public void AuthorClear()
 {
     Authors = Authors.Clear();
 }
示例#11
0
文件: AtomItem.cs 项目: caoxk/coapp
        /// <summary>
        ///   This needs to be called after anything in the model is changed.
        /// </summary>
        public void SyncFromModel()
        {
            // this pulls down information from the Model element into the atom item.
            Id          = Model.CanonicalName;
            Title       = new TextSyndicationContent(Model.CosmeticName);
            Summary     = new TextSyndicationContent(Model.PackageDetails.SummaryDescription);
            PublishDate = Model.PackageDetails.PublishDate;
            Authors.Clear();
            Contributors.Clear();
            Categories.Clear();
            Links.Clear();

            if (Model.PackageDetails.Publisher != null)
            {
                Authors.Add(CreatePerson().With(a => {
                    a.Name  = Model.PackageDetails.Publisher.Name;
                    a.Email = Model.PackageDetails.Publisher.Email;
                    a.Uri   = Model.PackageDetails.Publisher.Location == null ? string.Empty : Model.PackageDetails.Publisher.Location.ToString();
                }));
            }
            if (!Model.PackageDetails.Contributors.IsNullOrEmpty())
            {
                foreach (var c in Model.PackageDetails.Contributors)
                {
                    var contributor = c;
                    Contributors.Add(CreatePerson().With(a => {
                        a.Name  = contributor.Name;
                        a.Email = contributor.Email;
                        a.Uri   = contributor.Location == null ? string.Empty : contributor.Location.ToString();
                    }));
                }
            }

            if (!string.IsNullOrEmpty(Model.PackageDetails.CopyrightStatement))
            {
                Copyright = new TextSyndicationContent(Model.PackageDetails.CopyrightStatement);
            }

            if (!Model.PackageDetails.Tags.IsNullOrEmpty())
            {
                foreach (var tag in Model.PackageDetails.Tags)
                {
                    Categories.Add(new SyndicationCategory(tag, "/Tags", tag));
                }
            }

            if (!Model.PackageDetails.Categories.IsNullOrEmpty())
            {
                foreach (var category in Model.PackageDetails.Categories)
                {
                    Categories.Add(new SyndicationCategory(category, "/Categories", category));
                }
            }

            if (Model.PackageDetails.Description != null)
            {
                Content = SyndicationContent.CreateHtmlContent(Model.PackageDetails.Description);
            }

            if (!Model.Locations.IsNullOrEmpty())
            {
                foreach (var l in Model.Locations)
                {
                    var location = l;
                    Links.Add(CreateLink().With(link => {
                        link.RelationshipType = "enclosure";
                        link.MediaType        = "application/package";
                        link.Uri   = location;
                        link.Title = Model.Name;
                    }));

                    Links.Add(CreateLink().With(link => {
                        link.Uri = location;
                    }));
                }
            }
            // and serialize that out.
            ElementExtensions.Add(Model, Model.XmlSerializer);
        }