protected override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var newTypeDeclaration = (TypeDeclarationSyntax)base.VisitClassDeclaration(node);

            if (_fields.Count > 0 || _methods.Count > 0)
            {
                var members = new List<MemberDeclarationSyntax>(newTypeDeclaration.Members);
                members.InsertRange(0, _methods);
                members.InsertRange(0, _fields);

                return ((ClassDeclarationSyntax)newTypeDeclaration).Update(
                    newTypeDeclaration.Attributes,
                    newTypeDeclaration.Modifiers,
                    newTypeDeclaration.Keyword,
                    newTypeDeclaration.Identifier,
                    newTypeDeclaration.TypeParameterListOpt,
                    newTypeDeclaration.BaseListOpt,
                    newTypeDeclaration.ConstraintClauses,
                    newTypeDeclaration.OpenBraceToken,
                    Syntax.List(members.AsEnumerable()),
                    newTypeDeclaration.CloseBraceToken,
                    newTypeDeclaration.SemicolonTokenOpt);
            }

            return newTypeDeclaration;
        }
Example #2
0
 public List<string> GetAllArt()
 {
     List<string> paths = new List<string>();
     paths.InsertRange(0, GetPlaylistArt());
     paths.InsertRange(paths.Count - 1, GetAlbumArt());
     return paths;
 } 
Example #3
0
        /// <summary>
        /// Gets the bytes matching the expected Kafka structure. 
        /// </summary>
        /// <returns>The byte array of the request.</returns>
        public override byte[] GetBytes()
        {
            List<byte> encodedMessageSet = new List<byte>();
            encodedMessageSet.AddRange(GetInternalBytes());

            byte[] requestBytes = BitWorks.GetBytesReversed(Convert.ToInt16((int)RequestType.Produce));
            encodedMessageSet.InsertRange(0, requestBytes);
            encodedMessageSet.InsertRange(0, BitWorks.GetBytesReversed(encodedMessageSet.Count));

            return encodedMessageSet.ToArray();
        }
        /// <summary>
        /// Returns Artifacts files'information list from a given folder respecting include and exclude pattern
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <param name="includePatterns"></param>
        /// <param name="excludePatterns"></param>
        public static IList<FileInfo> GetMatchingArtifactsFrom(string directoryPath, string includePatterns, string excludePatterns)
        {
            var fileInfos = new List<FileInfo>();

            if (Directory.Exists((directoryPath)))
            {
                var includeFiles = new List<string>();
                if (!string.IsNullOrEmpty(includePatterns))
                {
                    foreach (var includePattern in includePatterns.Split(','))
                    {

                        if (includePattern.Contains(@"\") || includePattern.Contains(@"/"))
                        {
                            var regex = WildcardToRegex(includePattern);
                            includeFiles.InsertRange(0,
                                Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories)
                                    .Where(x => Regex.IsMatch(x, regex)));
                            ;
                        }
                        else
                        {
                            includeFiles.InsertRange(0,
                                Directory.GetFiles(directoryPath, includePattern, SearchOption.AllDirectories));
                        }

                    }
                }
                var exludeFiles= new List<string>();
                if (!string.IsNullOrEmpty(excludePatterns))
                {
                    foreach (var excludePattern in excludePatterns.Split(','))
                    {

                        if (excludePattern.Contains(@"/") || excludePattern.Contains(@"\"))
                        {
                            var regex = WildcardToRegex(excludePattern);
                            exludeFiles.InsertRange(0,
                                Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories)
                                    .Where(x => Regex.IsMatch(x, regex)));
                        }
                        else
                        {
                            exludeFiles.InsertRange(0,
                                Directory.GetFiles(directoryPath, excludePattern, SearchOption.AllDirectories));
                        }
                    }
                }
                fileInfos = includeFiles.Except(exludeFiles)
                    .Select(x=> new FileInfo(x)).ToList();
            }

            return fileInfos;
        }
Example #5
0
 private byte[] ToByteArray()
 {
     List<byte> messageBytes = new List<byte>();
     foreach (STUNAttributeTLV attribute in this.Attributes)
     {   
         messageBytes.InsertRange(messageBytes.Count, attribute.Bytes);
         MessageHeader.Length += attribute.Length;
     }
     messageBytes.InsertRange(0, MessageHeader.Bytes);
     return messageBytes.ToArray();
 }
Example #6
0
        public static void Main(string[] args)
        {
            Dictionary<string,int> dict=new Dictionary<string,int>();
            dict.Add("one",1);
            dict.Add("two",2);
            dict.Add("three",3);
            dict.Add("four",4);
            dict.Remove("one");

            Console.WriteLine(dict.ContainsKey("dsaf"));
            Console.WriteLine("Key Value Pairs after Dictionary related operations:");
            foreach (var pair in dict)
            {
                Console.WriteLine("{0}, {1}",
                    pair.Key,
                    pair.Value);
            }
            dict.Clear ();

            List<string> strList = new List<string> ();
            strList.Add ("one");
            strList.Add ("two");
            strList.Add ("three");
            strList.Add ("four");
            strList.Add ("five");
            strList.Insert (3, "great");
            string[] newList = new string[3]{ "ten", "eleven", "twelve" };
            strList.AddRange (newList);
            strList.InsertRange (3, newList);

            Console.WriteLine ("Output after all list related  operations i.e. add, insert, addrange, insertrange,remove");
            foreach (var i in strList)
                Console.WriteLine (i);
        }
Example #7
0
 public static void Main () {
     List<int> array = new List<int> { 1, 2, 3 };
     List<int> array2 = new List<int> { 4, 5, 6 };
     array.InsertRange(1, array2);
     foreach (var member in array)
         Console.WriteLine(member);
 }
        public byte[] Write(ScenarioFile file)
        {
            var scenarioData = new List<byte>();

            scenarioData.AddRange(Encoding.ASCII.GetBytes("SCENARIO\r\n"));
            scenarioData.AddRange(BitConverter.GetBytes(Version));
            scenarioData.AddRange(BitConverter.GetBytes(file.ContentFiles.Count));

            file.ContentFiles[0] = CreateAreaSubFile(file.ZoneData);

            var ndfBinWriter = new NdfbinWriter();
            file.ContentFiles[1] = ndfBinWriter.Write(file.NdfBinary, false);

            foreach (var contentFile in file.ContentFiles)
            {
                scenarioData.AddRange(BitConverter.GetBytes(contentFile.Length));
                scenarioData.AddRange(contentFile);
            }

            byte[] hash = MD5.Create().ComputeHash(scenarioData.ToArray());

            scenarioData.InsertRange(10, hash.Concat(new byte[] { 0x00, 0x00 }));

            return scenarioData.ToArray();
        }
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Insert the collection to the beginning of the list");

        try
        {
            string[] strArray = { "apple", "dog", "banana", "chocolate", "dog", "food" };
            List<string> listObject = new List<string>(strArray);
            string[] insert = { "Hello", "World" };
            listObject.InsertRange(0, insert);
            if (listObject.Count != 8)
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected,Count is: " + listObject.Count);
                retVal = false;
            }
            if ((listObject[0] != "Hello") || (listObject[1] != "World"))
            {
                TestLibrary.TestFramework.LogError("004", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("005", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #10
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: The generic type is int");

        try
        {
            int[] iArray = { 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14 };
            List<int> listObject = new List<int>(iArray);
            int[] insert = { 4, 5, 6, 7 };
            listObject.InsertRange(4, insert);
            for (int i = 0; i < 15; i++)
            {
                if (listObject[i] != i)
                {
                    TestLibrary.TestFramework.LogError("001", "The result is not the value as expected,listObject is: " + listObject[i]);
                    retVal = false;
                }
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #11
0
        static void Main(string[] args)
        {
            List<string> words = new List<string>(); // New string-typed list
            words.Add("melon");
            words.Add("avocado");
            words.AddRange(new[] { "banana", "plum" });
            words.Insert(0, "lemon"); // Insert at start
            words.InsertRange(0, new[] { "peach", "nashi" }); // Insert at start
            words.Remove("melon");
            words.RemoveAt(3); // Remove the 4th element
            words.RemoveRange(0, 2); // Remove first 2 elements
            words.RemoveAll(s => s.StartsWith("n"));// Remove all strings starting in 'n'
            Console.WriteLine(words[0]); // first word
            Console.WriteLine(words[words.Count - 1]); // last word
            foreach (string s in words) Console.WriteLine(s); // all words
            List<string> subset = words.GetRange(1, 2); // 2nd->3rd words
            string[] wordsArray = words.ToArray(); // Creates a new typed array
            string[] existing = new string[1000];// Copy first two elements to the end of an existing array
            words.CopyTo(0, existing, 998, 2);
            List<string> upperCastWords = words.ConvertAll(s => s.ToUpper());
            List<int> lengths = words.ConvertAll(s => s.Length);

            ArrayList al = new ArrayList();
            al.Add("hello");
            string first = (string)al[0];
            string[] strArr = (string[])al.ToArray(typeof(string));
            List<string> list = al.Cast<string>().ToList();
        }
        public List<AphidExpression> ExpandControlFlowExpressions(List<AphidExpression> ast)
        {
            var ast2 = new List<AphidExpression>(ast);

            var ifs = ast
                .Select(x => new
                {
                    Expression = x,
                    Expanded = ExpandControlFlowExpressions(x),
                })
                .Where(x => x.Expanded != null)
                .ToArray();

            foreach (var expandedIf in ifs)
            {
                var i = ast2.IndexOf(expandedIf.Expression);
                ast2.RemoveAt(i);
                ast2.InsertRange(i, expandedIf.Expanded);
            }

            if (AnyControlFlowExpressions(ast2))
            {
                return ExpandControlFlowExpressions(ast2);
            }
            else
            {
                //foreach (var n in ast.OfType<IParentNode>())
                //{
                //    ExpandControlFlowExpressions(n.GetChildren().ToList());
                //}

                return ast2;
            }
        }
Example #13
0
    public static byte[] CombineFiles(FileEx[] data)
    {
        List<byte> result = new List<byte>();

            // Generating the header
            int pos = 0;
            string toAdd  = "";
            foreach(var file in data)
            {
                int future = pos + file.data.Length;
                toAdd += string.Format("[|{0}|{1}|{2}|]", file.name, pos, file.data.Length);
                pos = future;
            }
            result.AddRange(GetBytes(toAdd));

            //Adding the header's size
            result.InsertRange(0, BitConverter.GetBytes(result.Count));

            //Adding the file data
            foreach(var file in data)
            {
                result.AddRange(file.data);
            }
            return result.ToArray();
    }
Example #14
0
        public void Send(string name, string content)
        {
            // Sends text EV3Packet in this format:

            // bbbbmmmmttssllaaaLLLLppp
            // bbbb = bytes in the message, little endian
            // mmmm = message counter
            // tt   = 0×81
            // ss   = 0x9E
            // ll   = mailbox name length INCLUDING the \0 terminator
            // aaa… = mailbox name, should be terminated with a \0
            // LLLL = payload length INCLUDING the , little endian
            // ppp… = payload, should be terminated with the \0

            List<byte> MessageHeaderList = new List<byte>();

            MessageHeaderList.AddRange(new byte[] { 0x00, 0x01, 0x81, 0x9E }); // mmmmm + tt + ss
            List<byte> by = BitConverter.GetBytes((Int16)(name.Length + 1)).Reverse().ToList();
            by.RemoveAt(0);
            MessageHeaderList.AddRange(by.ToArray()); // ll
            MessageHeaderList.AddRange(Encoding.ASCII.GetBytes(name)); // aaa…
            MessageHeaderList.AddRange(new byte[] { 0x00 }); // \0
            MessageHeaderList.AddRange(BitConverter.GetBytes((Int16)(content.Length + 1))); // LLLL
            MessageHeaderList.AddRange(Encoding.ASCII.GetBytes(content)); // ppp…
            MessageHeaderList.AddRange(new byte[] { 0x00 }); // \0
            MessageHeaderList.InsertRange(0, BitConverter.GetBytes((Int16)(MessageHeaderList.Count))); // bbbb

            EV3ComPort.Write(MessageHeaderList.ToArray(), 0, MessageHeaderList.ToArray().Length);
        }
        // Method to retrieve all directories, recursively, within a store.
        public static List<String> GetAllDirectories(string pattern, IsolatedStorageFile storeFile)
        {
            // Get the root of the search string.
            string root = Path.GetDirectoryName(pattern);

            if (root != "")
            {
                root += "/";
            }

            // Retrieve directories.
            List<String> directoryList = new List<String>(storeFile.GetDirectoryNames(pattern));

            // Retrieve subdirectories of matches.
            for (int i = 0, max = directoryList.Count; i < max; i++)
            {
                string directory = directoryList[i] + "/";
                List<String> more = GetAllDirectories(root + directory + "*", storeFile);

                // For each subdirectory found, add in the base path.
                for (int j = 0; j < more.Count; j++)
                {
                    more[j] = directory + more[j];
                }

                // Insert the subdirectories into the list and
                // update the counter and upper bound.
                directoryList.InsertRange(i + 1, more);
                i += more.Count;
                max += more.Count;
            }

            return directoryList;
        }
Example #16
0
        private void SortGlobalSections(List<Line> lines)
        {
            var begin = lines
                .Where(line => line.Content.Trim().StartsWith("GlobalSection(", StringComparison.OrdinalIgnoreCase))
                .ToList();

            var sections = begin.Select(line => new
                {
                    Begin = line,
                    Entries = lines.Skip(line.Index + 1)
                        .TakeWhile(x => !x.Content.Trim().Equals("EndGlobalSection", StringComparison.OrdinalIgnoreCase))
                        .OrderBy(x => x.Content)
                        .ToList(),
                    End = lines.Skip(line.Index + 1)
                        .First(x => x.Content.Trim().Equals("EndGlobalSection", StringComparison.OrdinalIgnoreCase))
                }).ToList();

            foreach (var section in sections)
            {
                lines.RemoveRange(section.Begin.Index + 1, section.Entries.Count);
                lines.InsertRange(section.Begin.Index + 1, section.Entries);
            }

            ResetIndexes(lines);
        }
Example #17
0
        /// <summary>
        /// Gets the bytes matching the expected Kafka structure. 
        /// </summary>
        /// <returns>The byte array of the request.</returns>
        public override byte[] GetBytes()
        {
            List<byte> messagePack = new List<byte>();
            foreach (Message message in Messages)
            {
                byte[] messageBytes = message.GetBytes();
                messagePack.AddRange(BitWorks.GetBytesReversed(messageBytes.Length));
                messagePack.AddRange(messageBytes);
            }

            byte[] requestBytes = BitWorks.GetBytesReversed(Convert.ToInt16((int)RequestType.Produce));
            byte[] topicLengthBytes = BitWorks.GetBytesReversed(Convert.ToInt16(Topic.Length));
            byte[] topicBytes = Encoding.UTF8.GetBytes(Topic);
            byte[] partitionBytes = BitWorks.GetBytesReversed(Partition);
            byte[] messagePackLengthBytes = BitWorks.GetBytesReversed(messagePack.Count);
            byte[] messagePackBytes = messagePack.ToArray();

            List<byte> encodedMessageSet = new List<byte>();
            encodedMessageSet.AddRange(requestBytes);
            encodedMessageSet.AddRange(topicLengthBytes);
            encodedMessageSet.AddRange(topicBytes);
            encodedMessageSet.AddRange(partitionBytes);
            encodedMessageSet.AddRange(messagePackLengthBytes);
            encodedMessageSet.AddRange(messagePackBytes);
            encodedMessageSet.InsertRange(0, BitWorks.GetBytesReversed(encodedMessageSet.Count));

            return encodedMessageSet.ToArray();
        }
Example #18
0
        public void Test(int arg)
        {
            ArrayList items = new ArrayList();
            items.Add(1);
            items.AddRange(1, 2, 3);
            items.Clear();
            bool b1 = items.Contains(2);
            items.Insert(0, 1);
            items.InsertRange(1, 0, 5);
            items.RemoveAt(4);
            items.RemoveRange(4, 3);
            items.Remove(1);
            object[] newItems = items.GetRange(5, 2);
            object[] newItems2 = items.GetRange(5, arg);

            List<int> numbers = new List<int>();
            numbers.Add(1);
            numbers.AddRange(1, 2, 3);
            numbers.Clear();
            bool b2 = numbers.Contains(4);
            numbers.Insert(1, 10);
            numbers.InsertRange(2, 10, 3);
            numbers.RemoveAt(4);
            numbers.RemoveRange(4, 2);
            int[] newNumbers = items.GetRange(5, 2);
            int[] newNumbers2 = items.GetRange(5, arg);

            string[] words = new string[5];
            words[0] = "hello";
            words[1] = "world";
            bool b3 = words.Contains("hi");
            string[] newWords = words.GetRange(5, 2);
            string[] newWords2 = words.GetRange(5, arg);
        }
        public static PropertyInfo[] GetPublicProperties(this Type type) {
            if (type.IsInterface) {
                var propertyInfos = new List<PropertyInfo>();

                var considered = new List<Type>();
                var queue = new Queue<Type>();
                considered.Add(type);
                queue.Enqueue(type);
                while (queue.Count > 0) {
                    var subType = queue.Dequeue();
                    foreach (var subInterface in subType.GetInterfaces()) {
                        if (considered.Contains(subInterface))
                            continue;

                        considered.Add(subInterface);
                        queue.Enqueue(subInterface);
                    }

                    var typeProperties = subType.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance);

                    var newPropertyInfos = typeProperties.Where(x => !propertyInfos.Contains(x));

                    propertyInfos.InsertRange(0, newPropertyInfos);
                }

                return propertyInfos.ToArray();
            }

            return type.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance);
        }
 public override byte[] GetBytes()
 {
     var bytes = new List<byte>(base.GetBytes());
     uint messageLength = (uint)bytes.Count;
     bytes.InsertRange(0, messageLength.GetBytes());
     return bytes.ToArray();
 }
Example #21
0
 /// <summary>
 /// Downloads tweets since the most recent tweet in the list
 /// The list is assumed to be in descending chronological order, so the most recent is first
 /// Twitter restrict how far back tweets can be retrieved - we get as many as possible
 /// Only original tweets and RTs are included - not replies
 /// </summary>
 /// <param name="username">A Twitter username whose tweets are to be downloaded</param>
 /// <param name="tweets">Previously downloaded tweets for this user, most recent first</param>
 /// <returns>A list of tweets</returns>
 public static int DownloadNewTweets(string username, List<Tweet> tweets)
 {
     string sinceId = tweets.First().Id;
     List<Tweet> newTweets = DownloadTweets(username, sinceId, null);
     tweets.InsertRange(0, newTweets);
     return newTweets.Count;
 }
 public void BindSelected()
 {
     var selectedList = Position.GetPositionList()
         .Where(p => this.SelectedList.Contains(p.Id))
         .ToList();
     var fullNameList = new List<string>();
     foreach (Position postion in selectedList)
     {
         if (postion == null) continue;
         List<string> buffer = new List<string>();
         buffer.Insert(0, postion.Name);
         var org = postion.GetOrganization();
         if (org != null)
         {
             buffer.Insert(0, org.Name);
             var parentOrgList = org.DeepParentList;
             if (parentOrgList != null)
             {
                 buffer.InsertRange(0, parentOrgList.Select(o2 => o2.Name));
             }
         }
         fullNameList.Add(string.Join("/", buffer.ToArray()));
     }
     this.selectedDataList.DataSource = fullNameList;
     this.selectedDataList.DataBind();
     this.PageEngine.UpdateControlRender(this.selectedDataListArea);
 }
Example #23
0
        void DetermineFields()
        {
            var currentType = _typeToProcess;
            _fields = currentType.GetFields(TestRunManager.FieldsToRetrieve).ToList();

            while ((currentType = currentType.BaseType) != null)
                _fields.InsertRange(0, currentType.GetFields(TestRunManager.FieldsToRetrieve));
        }
Example #24
0
 private void BindComboBoxToDrives()
 {
     List<string> sysDriveList = new List<string>();
     sysDriveList.InsertRange(0, System.IO.Directory.GetLogicalDrives());
     BindingSource drvSource = new BindingSource();
     drvSource.DataSource = sysDriveList;
     cmbDriveSelect.DataSource = drvSource;
 }
        private static void ExecuteRollRightCommand(string[] commandArgs, List<string> collection)
        {
            int numberOfRolls = int.Parse(commandArgs[1]) % collection.Count;

            var elementsToMove = collection.Skip(collection.Count - numberOfRolls).Take(numberOfRolls).ToArray();

            collection.InsertRange(0, elementsToMove);
            collection.RemoveRange(collection.Count - numberOfRolls, numberOfRolls);
        }
        public static MemberInfo[] GetProperties(Type type)
        {
            var flags = BindingFlags.Public | BindingFlags.Instance;

            if (type.IsInterface)
            {
                var propertyInfos = new List<PropertyInfo>();

                var considered = new List<Type>();
                var queue = new Queue<Type>();
                considered.Add(type);
                queue.Enqueue(type);
                while (queue.Count > 0)
                {
                    var subType = queue.Dequeue();
                    foreach (var subInterface in subType.GetInterfaces())
                    {
                        if (considered.Contains(subInterface))
                            continue;

                        considered.Add(subInterface);
                        queue.Enqueue(subInterface);
                    }

                    var typeProperties = subType.GetProperties(flags)
                        .Where(o => !o.HasAttribute<HideInInspector>())
                        .Where(o => !o.Module.Name.Contains("UnityEngine"))
                        .OrderBy(o => o.Name);

                    var newPropertyInfos = typeProperties
                        .Where(x => !propertyInfos.Contains(x));

                    propertyInfos.InsertRange(0, newPropertyInfos);
                }

                return propertyInfos.ToArray();
            }
            else
            {

                var propertyInfos = new List<MemberInfo>();
                var props = type.GetProperties(flags).Where(o => !o.HasAttribute<HideInInspector>() && !o.Module.Name.Contains("UnityEngine")).OrderBy(o => o.Name);
                foreach (var prop in props)
                {
                    if (prop.IsSpecialName)
                        continue;

                    propertyInfos.Add(prop);
                }
                var fields = type.GetFields(flags).Where(o => !o.HasAttribute<HideInInspector>() && !o.Module.Name.Contains("UnityEngine")).OrderBy(o => o.Name);
                foreach (var prop in fields)
                {
                    propertyInfos.Add(prop);
                }
                return propertyInfos.ToArray();
            }
        }
Example #27
0
        private static void processDirectory(string inputFilename, string outputPath, int cellWidth, int cellHeight)
        {
            string[] pngFilenames = Directory.GetFiles(inputFilename, "*.png");
            string[] bmpFilenames = Directory.GetFiles(inputFilename, "*.bmp");
            string[] tgaFilenames = Directory.GetFiles(inputFilename, "*.tga");

            List<string> allFilenames = new List<string>();

            allFilenames.InsertRange(0, tgaFilenames);
            allFilenames.InsertRange(0, bmpFilenames);
            allFilenames.InsertRange(0, pngFilenames);

            // now process all files
            foreach (string filename in allFilenames)
            {
                processFile(filename, outputPath, cellWidth, cellHeight);
            }
        }
 private static List<avm.ComponentInstance> RecursivelyGetAllComponentInstances(avm.Design dm_root)
 {
     List<avm.ComponentInstance> lci_rtn = new List<avm.ComponentInstance>();
     foreach (Compound c in dm_root.RootContainer.Container1.Where(c => c is Compound))
     {
         lci_rtn.InsertRange(0, RecursivelyGetAllComponentInstances(c));
     }
     return lci_rtn;
 }
Example #29
0
        public static void Test(Assert assert)
        {
            assert.Expect(10);

            List<string> magic1 = new List<string>();
            magic1.Insert(magic1.Count, "first");
            magic1.Insert(magic1.Count, "second");

            assert.Equal(magic1[0], "first", "magic1[0]");
            assert.Equal(magic1[1], "second", "magic1[1]");

            List<string> magic2 = new List<string>();
            magic2.InsertRange(magic2.Count, new[] { "first", "second" });
            magic2.InsertRange(magic2.Count, new[] { "third", "fourth" });

            assert.Equal(magic2[0], "first", "magic1[0]");
            assert.Equal(magic2[1], "second", "magic1[1]");
            assert.Equal(magic2[2], "third", "magic1[2]");
            assert.Equal(magic2[3], "fourth", "magic1[3]");

            assert.Throws(() =>
            {
                List<string> magic = new List<string>();
                magic.Insert(1, "first");
            }, "Insert at length + 1");

            assert.Throws(() =>
            {
                List<string> magic = new List<string>();
                magic.Insert(-1, "first");
            }, "Insert at -1");

            assert.Throws(() =>
            {
                List<string> magic = new List<string>();
                magic.InsertRange(1, new[] { "first", "second" });
            }, "InsertRange at length + 1");

            assert.Throws(() =>
            {
                List<string> magic = new List<string>();
                magic.InsertRange(-1, new[] { "first", "second" });
            }, "InsertRange at -1");
        }
        private static List<avm.ComponentInstance> RecursivelyGetAllComponentInstances(Compound c_root)
        {
            List<avm.ComponentInstance> lci_rtn = new List<avm.ComponentInstance>();

            if (c_root.ComponentInstance != null)
            {
                lci_rtn.InsertRange(0, c_root.ComponentInstance);
            }

            if (c_root.Container1 != null)
            {
                foreach (Compound c in c_root.Container1.Where(c => c is Compound))
                {
                    lci_rtn.InsertRange(0, RecursivelyGetAllComponentInstances(c));
                }
            }

            return lci_rtn;
        }