Exemple #1
0
        /// <summary>
        /// Creates a new empty definition instance and adds it to the block list.
        /// </summary>
        /// <param name="isInternal">Used to determine if the internal block count should be incremented.</param>
        /// <returns>Index of the new block, -1 if the opperation did not complete successfully.</returns>
        private int AddBlock(bool isInternal)
        {
            // Check to make sure we can add another block.
            if (isInternal == false && maxBlockCount != -1 && blockCount >= maxBlockCount)
            {
                return(-1);
            }

            // Create a new definition array.
            MetaNode[] block = new MetaNode[definition.Length];

            // Clone all the fields in the definition.
            for (int i = 0; i < definition.Length; i++)
            {
                block[i] = (MetaNode)definition[i].Clone();
            }

            // Add it to the blocks list.
            blocks.Add(block);

            // Check if we should increment the internal block count.
            if (isInternal == false)
            {
                blockCount++;
            }

            // Return the new block index.
            return(blocks.Count - 1);
        }
Exemple #2
0
        /// <summary>
        /// Inserts a new definition instance into the block list at the specified index.
        /// </summary>
        /// <param name="blockIndex">Index to insert the new block at.</param>
        /// <returns>True if the block was successully inserted, false otherwise.</returns>
        public bool InsertBlock(int blockIndex)
        {
            // Check to make sure we can add another block.
            if (maxBlockCount != -1 && blockCount >= maxBlockCount)
            {
                return(false);
            }

            // Make sure the index passed was valid.
            if (blockIndex < 0 || blockIndex >= blockCount)
            {
                return(false);
            }

            // Create a new definition array.
            MetaNode[] block = new MetaNode[definition.Length];

            // Clone all the fields in the definition.
            for (int i = 0; i < definition.Length; i++)
            {
                block[i] = (MetaNode)definition[i].Clone();
            }

            // Insert it into the list at the specified position.
            blocks.Insert(blockIndex, block);

            // The block has been successully inserted.
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Adds a meganode to the current assembly by adding it's constituent nodes and
        /// discarding any information form the meganode itself.
        /// </summary>
        /// <param name="nodeToAdd"></param>
        public void AddMetaNode(MetaNode nodeToAdd)
        {
            foreach (var node in nodeToAdd.ConstituentNodes)
            {
                this.constituentNodes.Add(node);
            }
            int kmerLength = nodeToAdd.LeadingKmer.Length;

            this.contigSequence.AddRange(new Sequence(DnaAlphabet.Instance, nodeToAdd.Sequence.Substring(kmerLength, nodeToAdd.Sequence.Length - kmerLength)));
        }
Exemple #4
0
        private void CreateContentFiles()
        {
            if (!projectDocument.ContentFiles.Any())
            {
                return;
            }

            XmlElement contentFilesNode = MetaNode.CreateChildNode(CONTENT_FILES);

            foreach (string cf in projectDocument.ContentFiles)
            {
                contentFilesNode.CreateChildNode(FILES_NODE,
                                                 (INCLUDE_ATTRIBUTE, ANY_PATH + cf.Replace('\\', '/')),
                                                 BuildAttribute,
                                                 CopyAttribute);
            }
        }
Exemple #5
0
        private void CreateDependencies()
        {
            if (!projectDocument.AllPackages.Any())
            {
                return;
            }

            XmlElement dependencies = MetaNode.CreateChildNode(DEPENDENCIES_NODE);
            XmlElement group        = dependencies.CreateChildNode(GROUP_NODE);

            CreateDependencyNodes(group);

            foreach (NuGetFramework fw in nuspecMetaData.TargetFramework)
            {
                XmlNode frameworkGroupNode = dependencies.CreateChildNode(GROUP_NODE, (TARGET_FRAMEWORK_ATTRIBUTE, fw.GetShortFolderName()));
                CreateDependencyNodes(frameworkGroupNode);
            }
        }
Exemple #6
0
        private void CreateReferences()
        {
            if (!projectDocument.AllProjectReferences.Any() && !nuspecMetaData.CustomReference.Any())
            {
                return;
            }

            XmlElement references = MetaNode.CreateChildNode(REFERENCES_NODE);
            XmlElement refGroup   = references.CreateChildNode(GROUP_NODE);

            CreateReferences(refGroup);

            foreach (NuGetFramework fw in nuspecMetaData.TargetFramework)
            {
                XmlNode refFrameworkNode = references.CreateChildNode(GROUP_NODE,
                                                                      (TARGET_FRAMEWORK_ATTRIBUTE, fw.GetShortFolderName()));

                CreateReferences(refFrameworkNode);
            }
        }
        private IEnumerable <PossibleAssembly> ExtendChain(PossibleAssembly currentPath, DeBruijnNode nextNeighbor, bool goingRight, bool sameOrientation)
        {
            byte nextSymbol = MetaNode.GetNextSymbol(nextNeighbor, KmerLength, !goingRight);

            currentPath.Add(nextNeighbor, nextSymbol);
            nextNeighbor.IsVisited = true;
            bool nextRight = !goingRight ^ sameOrientation;
            List <KeyValuePair <DeBruijnNode, bool> > nextNodes = nextRight ? nextNeighbor.GetRightExtensionNodesWithOrientationMarkingEdgeAsVisited() :
                                                                  nextNeighbor.GetLeftExtensionNodesWithOrientationMarkingEdgeAsVisited();
            DeBruijnNode next;

            //DeBruijnNode last = currentPath.constituentNodes[currentPath.constituentNodes.Count-1];
            //DeBruijnNode first=currentPath.constituentNodes[0];
            while (nextNodes.Count == 1)
            {
                var nextSet = nextNodes.First();
                next            = nextSet.Key;
                sameOrientation = nextSet.Value;
                nextRight       = (!nextRight) ^ sameOrientation;
                nextSymbol      = MetaNode.GetNextSymbol(next, KmerLength, !nextRight);
                //now check if we are in a circle or a loop at the end, these are very annoying situtations, basic criteria, can't leave
                //the same node the same way twice
                if (next.IsVisited && currentPath.constituentNodes.Contains(next))
                {
                    //okay, if we are equal to the first node or the last node, we can't leave or return the same way we came, otherwise we are done.
                    var excludedNextNodes = currentPath.GetPreviousWaysNodeWasLeft(next);
                    //how many neighbors dow we have in this group?
                    var temp = nextRight ? next.GetRightExtensionNodesWithOrientationMarkingEdgeAsVisited() : next.GetLeftExtensionNodesWithOrientationMarkingEdgeAsVisited();
                    temp = temp.Where(x => !excludedNextNodes.Contains(x.Key)).ToList();
                    //only one way to go
                    if (temp.Count == 1)
                    {
                        nextNodes = temp;
                        //currentPath.contigSequence.Add(nextSymbol);
                        currentPath.Add(next, nextSymbol);
                        next.IsVisited = true; //flag not actually used though
                    }
                    else if (temp.Count == 0)  //done
                    {
                        if (currentPath.constituentNodes[0] == next)
                        {
                            currentPath.CircularLoop = true;
                        }
                        yield return(currentPath);

                        //nextNodes.Clear();//we are done
                        yield break;
                    }
                    else //Extend path using all feasible options, then continue.
                    {
                        foreach (var neighbor in temp)
                        {
                            foreach (var v in ExtendChain(currentPath.Clone(), neighbor.Key, nextRight, neighbor.Value))
                            {
                                yield return(v);
                            }
                        }
                        //nextNodes.Clear();//done
                        yield break;
                    }
                }
                else
                {
                    //currentPath.contigSequence.Add(nextSymbol);
                    currentPath.Add(next, nextSymbol);
                    next.IsVisited = true;//flag not actually used though
                    nextNodes      = nextRight ? next.GetRightExtensionNodesWithOrientationMarkingEdgeAsVisited() : next.GetLeftExtensionNodesWithOrientationMarkingEdgeAsVisited();
                }
            }
            //If we have more than one node remaining, have to kick it off.
            if (nextNodes.Count > 1)
            {
                foreach (var neighbor in nextNodes)
                {
                    foreach (var v in ExtendChain(currentPath.Clone(), neighbor.Key, nextRight, neighbor.Value))
                    {
                        yield return(v);
                    }
                }
            }
            if (nextNodes.Count == 0)
            {
                yield return(currentPath);
            }
        }
        void add_transition(MetaNode item, ISpeechGrammarRuleState source, ISpeechGrammarRuleState destination, ISpeechGrammarRule rule)
        {
            object prop = item.get_path();

            source.AddRuleTransition(destination, rule, (string)prop, ++cx, ref prop, 1.0f);
        }
        void add_node(MetaNode item, ISpeechGrammarRuleState source, ISpeechGrammarRuleState destination)
        {
            object prop = item.get_path();

            source.AddWordTransition(destination, (string)item["words"].value, " ", SpeechGrammarWordType.SGLexical, (string)prop, ++cx, ref prop, 1.0f);
        }
Exemple #10
0
        public MetaNode this[string Name]
        {
            get
            {
                // Loop through the fields list
                bool     found = false;
                MetaNode node  = null;
                for (int i = 0; i < Fields.Count; i++)
                {
#if (PLUGIN_SANITY_CHECK)
                    // Check field name
                    if (Fields[i].GetName().Equals(Name))
                    {
                        // Check if found is true
                        if (found == true)
                        {
                            Console.WriteLine("[HaloPlugins.TagDefinition.this[string] Meta object " +
                                              this.GetName() + " has duplicate child nodes with name \"" + Name + "\"");
                        }
                    }
                    else
                    {
                        // Save meta node
                        node  = Fields[i];
                        found = true;
                    }
#else
                    // Check field name
                    if (Fields[i].Name.Equals(Name))
                    {
                        return(Fields[i]);
                    }
#endif
                }

                // Done
                return(node);
            }
            set
            {
                // Loop through the fields list
                bool found = false;
                for (int i = 0; i < Fields.Count; i++)
                {
#if (PLUGIN_SANITY_CHECK)
                    // Check field name
                    if (Fields[i].GetName().Equals(Name))
                    {
                        // Check if found is true
                        if (found == true)
                        {
                            Console.WriteLine("[HaloPlugins.TagDefinition.this[string] Meta object " +
                                              this.GetName() + " has duplicate child nodes with name \"" + Name + "\"");
                        }
                    }
                    else
                    {
                        // Set new value
                        Fields[i] = value;
                        found     = true;
                    }
#else
                    // Check field name
                    if (Fields[i].Name.Equals(Name))
                    {
                        Fields[i] = value;
                    }
#endif
                }
            }
        }