Exemple #1
0
        void DoInlineImport(XElement import, InlineImport inlineImport)
        {
            var importPath = ExpandPath(SourceDirectory, import.Attribute("Project").Value);

            var inlinedDoc = XDocument.Load(importPath);

            RelocateImports(Path.GetDirectoryName(importPath), inlinedDoc);

            var project = inlinedDoc.Root;

            List <XNode> filteredNodes = new List <XNode>();
            bool         inSample      = true;

            foreach (var node in project.Nodes())
            {
                if (node is XComment)
                {
                    var comment = (XComment)node;
                    if (comment.Value.Contains("[[NOT IN SAMPLE]]"))
                    {
                        inSample = false;
                        continue;
                    }
                    else if (comment.Value.Contains("[[IN SAMPLE]]"))
                    {
                        inSample = true;
                        continue;
                    }
                }

                if (inSample)
                {
                    filteredNodes.Add(node);
                }
            }

            import.AddBeforeSelf(filteredNodes);

            if (inlineImport.Elements.Count > 0)
            {
                import.AddBeforeSelf(inlineImport.Elements);
            }

            import.Remove();
        }
        void DoInlineImport(XElement import, InlineImport inlineImport)
        {
            var importPath = ExpandPath(SourceDirectory, import.Attribute("Project").Value);

            var inlinedDoc = XDocument.Load(importPath);

            RelocateImports(Path.GetDirectoryName(importPath), inlinedDoc);

            var project = inlinedDoc.Root;

            List<XNode> filteredNodes = new List<XNode>();
            bool inSample = true;
            foreach (var node in project.Nodes())
            {
                if (node is XComment)
                {
                    var comment = (XComment)node;
                    if (comment.Value.Contains("[[NOT IN SAMPLE]]"))
                    {
                        inSample = false;
                        continue;
                    }
                    else if (comment.Value.Contains("[[IN SAMPLE]]"))
                    {
                        inSample = true;
                        continue;
                    }
                }

                if (inSample)
                    filteredNodes.Add(node);
            }

            import.AddBeforeSelf(filteredNodes);

            if (inlineImport.Elements.Count > 0)
            {
                import.AddBeforeSelf(inlineImport.Elements);
            }

            import.Remove();
        }