Giter Site home page Giter Site logo

gist's Introduction

Hi there ๐Ÿ‘‹

GitHub Stats Top Langs

gist's People

Watchers

 avatar  avatar

gist's Issues

Find the duplicate package under packages folder, and it means you need consolidate it

  string packagesFolder = @"C:\workspace\repository\Solution\packages";
                var subfolders = Directory.GetDirectories(packagesFolder);
                List<string> folderList = new List<string>();
                foreach (var item in subfolders)
                {
                    var directoryName = Path.GetFileName(item);
                    //Console.WriteLine(directoryName);
                    folderList.Add(directoryName);
                }

                string pattern = string.Empty;
                //https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
                pattern =
                    "(?<name>.*)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?";
                Regex rgx = new Regex(pattern);

                List<string> list2 = new List<string>();
                foreach (var item in folderList)
                {
                    Match match = rgx.Match(item);
                    //Console.WriteLine(match.Groups["name"].Value);
                    list2.Add(match.Groups["name"].Value);
                }

                List<string> list3 = new List<string>();
                pattern = "(?<name>.*)\\.\\d{1,4}";
                Regex rgx2 = new Regex(pattern);
                foreach (var item in list2)
                {
                    Match match = rgx2.Match(item);
                    if (string.IsNullOrEmpty(match.Value))
                    {
                        list3.Add(item);
                    }
                    else
                    {
                        Console.WriteLine("did not match ==");
                        Console.WriteLine(match.Value);
                        Console.WriteLine("did not match ==");
                        list3.Add(match.Groups["name"].Value);
                    }
                    //Console.WriteLine(match.Value);
                }

                foreach (var item in list3)
                {
                    //Console.WriteLine(item);
                }

                var query = list3.GroupBy(x => x)
                    .Where(g => g.Count() > 1)
                    .Select(y => new { Element = y.Key, Counter = y.Count() })
                    .ToList();
                Console.WriteLine("Duplicates are as following:");
                foreach (var item in query)
                {
                   Console.WriteLine($"{item.Element} duplicate {item.Counter} times"); 
                }

DataSet and DataTable WriteXml

https://stackoverflow.com/questions/963870/dataset-writexml-to-string

    DataTable dataTable = new DataTable();
                dataTable.TableName = "table1";
                dataTable.Columns.Add(new DataColumn("column1"));
                dataTable.Columns.Add(new DataColumn("column2"));
                var row = dataTable.NewRow();
                row["column1"] = "chuck";
                row["column2"] = "lu";
                dataTable.Rows.Add(row);

                DataTable dataTable2 = new DataTable();
                dataTable2.TableName = "table2";
                dataTable2.Columns.Add(new DataColumn("column1"));
                dataTable2.Columns.Add(new DataColumn("column2"));
                var row2 = dataTable2.NewRow();
                row2["column1"] = "yong";
                row2["column2"] = "zhang";
                dataTable2.Rows.Add(row2);
                var row3 = dataTable2.NewRow();
                row3["column1"] = "joan";
                row3["column2"] = "zheng";
                dataTable2.Rows.Add(row3);

                DataSet dataSet = new DataSet();
                dataSet.DataSetName = "dataSet1";
                dataSet.Tables.Add(dataTable);
                dataSet.Tables.Add(dataTable2);

                StringWriter stringWriter = new StringWriter();
                dataSet.WriteXml(stringWriter);
                Console.WriteLine(stringWriter);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.