Ejemplo n.º 1
0
        private static void InheritSources(SIDocument doc2, Round round, Theme theme)
        {
            var sources = theme.Info.Sources;

            if (sources.Count == 0)
            {
                sources = round.Info.Sources;
                if (sources.Count == 0)
                {
                    sources = doc2.Package.Info.Sources;
                }

                if (sources.Count > 0)
                {
                    var realSources = doc2.GetRealSources(sources);
                    theme.Info.Sources.Clear();

                    foreach (var item in realSources)
                    {
                        theme.Info.Sources.Add(item);
                    }
                }
            }
            else
            {
                for (int i = 0; i < sources.Count; i++)
                {
                    var link = doc2.GetLink(theme.Info.Sources, i, out string tail);
                    if (link != null)
                    {
                        theme.Info.Sources[i] = link + tail;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void InheritAuthors(SIDocument doc2, Round round, Theme theme)
        {
            var authors = theme.Info.Authors;

            if (authors.Count == 0)
            {
                authors = round.Info.Authors;
                if (authors.Count == 0)
                {
                    authors = doc2.Package.Info.Authors;
                }

                if (authors.Count > 0)
                {
                    var realAuthors = doc2.GetRealAuthors(authors);
                    theme.Info.Authors.Clear();

                    foreach (var item in realAuthors)
                    {
                        theme.Info.Authors.Add(item);
                    }
                }
            }
            else
            {
                for (int i = 0; i < authors.Count; i++)
                {
                    var link = doc2.GetLink(theme.Info.Authors, i, out string tail);
                    if (link != null)
                    {
                        theme.Info.Authors[i] = link + tail;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Получить полные данные для объекта, включая присоединённые элементы коллекций
        /// </summary>
        /// <returns></returns>
        public void GetFullData(SIDocument document, InfoOwner owner)
        {
            var length = owner.Info.Authors.Count;

            for (int i = 0; i < length; i++)
            {
                var docAuthor = document.GetLink(owner.Info.Authors, i);
                if (docAuthor != null)
                {
                    if (Authors == null)
                    {
                        Authors = new List <AuthorInfo>();
                    }

                    if (!Authors.Contains(docAuthor))
                    {
                        Authors.Add(docAuthor);
                    }
                }
            }

            length = owner.Info.Sources.Count;
            for (int i = 0; i < length; i++)
            {
                var docSource = document.GetLink(owner.Info.Sources, i);
                if (docSource != null)
                {
                    if (Sources == null)
                    {
                        Sources = new List <SourceInfo>();
                    }

                    if (!Sources.Contains(docSource))
                    {
                        Sources.Add(docSource);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static void InheritSources(SIDocument doc2, Question question)
        {
            var sources = question.Info.Sources;

            if (sources.Count > 0)
            {
                for (int i = 0; i < sources.Count; i++)
                {
                    var link = doc2.GetLink(question.Info.Sources, i, out string tail);
                    if (link != null)
                    {
                        question.Info.Sources[i] = link + tail;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private static void InheritAuthors(SIDocument doc2, Question question)
        {
            var authors = question.Info.Authors;

            if (authors.Count > 0)
            {
                for (int i = 0; i < authors.Count; i++)
                {
                    var link = doc2.GetLink(question.Info.Authors, i, out string tail);
                    if (link != null)
                    {
                        question.Info.Authors[i] = link + tail;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private static async Task InheritContent(SIDocument doc, SIDocument doc2, Question question)
        {
            foreach (var atom in question.Scenario)
            {
                if (atom.Type == AtomTypes.Text || atom.Type == AtomTypes.Oral)
                {
                    continue;
                }

                var link = doc2.GetLink(atom);
                if (link.GetStream != null)
                {
                    DataCollection collection = null;
                    switch (atom.Type)
                    {
                    case AtomTypes.Video:
                        collection = doc.Video;
                        break;

                    case AtomTypes.Audio:
                        collection = doc.Audio;
                        break;

                    case AtomTypes.Image:
                        collection = doc.Images;
                        break;
                    }

                    if (collection != null)
                    {
                        using (var stream = link.GetStream().Stream)
                        {
                            await collection.AddFile(link.Uri, stream);
                        }
                    }
                }
            }
        }