コード例 #1
0
        private JObject GetTemplateJsonDataFromUser(Project proj)
        {
            //if (_templateInfo == null) {
            string fullPath = proj.FullName;
            string name     = Path.GetFileNameWithoutExtension(fullPath);
            var    win      = new InfoCollectorDialog(name);

            win.CenterInVs();
            if (win.ShowDialog().GetValueOrDefault())
            {
                const string solutionTemplate = @"{
    ""author"": ""<will-be-inserted>"",
    ""classifications"": [ ],
    ""description"": ""<will-be-inserted>"",
    ""name"": ""<will-be-inserted>"",
    ""defaultName"": ""<will-be-inserted>"",
    ""identity"": ""Sample.Template.CSharp"",
    ""groupIdentity"": ""Sample.Template"",
    ""tags"": {
        ""language"": ""C#"",
        ""type"": ""project""
    },
    ""shortName"": """",
    ""sourceName"": """",
    ""guids"": [ ],
    ""primaryOutputs"": [ { ""path"": """" } ]
}
            ";

                var o = JObject.Parse(solutionTemplate);
                o["author"]                    = win.Author;
                o["identity"]                  = win.Identity;
                o["groupIdentity"]             = win.GroupIdentity;
                o["name"]                      = win.DisplayName;
                o["defaultName"]               = win.DefaultName;
                o["sourceName"]                = Path.GetFileNameWithoutExtension(fullPath);
                o["shortName"]                 = win.ShortName;
                o["primaryOutputs"][0]["path"] = Path.GetFileName(fullPath);
                o["description"]               = win.Description;

                var    guids       = (JArray)o["guids"];
                string projectGuid = ExtractProjectGuid(fullPath);

                if (!string.IsNullOrEmpty(projectGuid))
                {
                    guids.Add(ExtractProjectGuid(fullPath));
                }

                _templateInfo = o;
            }
            //}

            return(_templateInfo);
        }
コード例 #2
0
        public static string CreateProjectTemplate(Project proj)
        {
            string fullPath = proj.FullName;
            string dir      = Path.GetDirectoryName(fullPath);
            string name     = Path.GetFileNameWithoutExtension(fullPath);

            var win = new InfoCollectorDialog(name);

            win.CenterInVs();
            if (win.ShowDialog().GetValueOrDefault())
            {
                const string solutionTemplate = @"{
    ""author"": """",
    ""classifications"": [ ],
    ""description"": """",
    ""name"": """",
    ""defaultName"": """",
    ""identity"": """",
    ""groupIdentity"": """",
    ""tags"": { },
    ""shortName"": """",
    ""sourceName"": """",
    ""guids"": [ ]
}";

                var o = JObject.Parse(solutionTemplate);
                o["author"]      = win.AuthorTextBox.Text;
                o["name"]        = win.FriendlyNameTextBox.Text;
                o["defaultName"] = win.DefaultNameTextBox.Text;
                o["sourceName"]  = Path.GetFileNameWithoutExtension(proj.FullName);
                o["shortName"]   = win.ShortNameTextBox.Text;

                var    guids       = (JArray)o["guids"];
                string projectGuid = ExtractProjectGuid(fullPath);

                if (!string.IsNullOrEmpty(projectGuid))
                {
                    guids.Add(ExtractProjectGuid(fullPath));
                }

                return(o.ToString());
            }

            return(null);
        }