Blame view

netcore/.vscode/solution-explorer/template-parameters.js 1000 Bytes
de2bd2f9   “wangming”   项目初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  const path = require("path");
  
  module.exports = function(filename, projectPath, folderPath, xml) {
      let namespace;
      xml.elements.some(e => {
          if (e.name === 'PropertyGroup' && e.elements) {
              const rootNamespace = e.elements.find(p => p.name === 'RootNamespace');
              if (rootNamespace && rootNamespace.elements && rootNamespace.elements[0]) {
                  namespace = rootNamespace.elements[0].text;
                  return true;
              }
          }
      });
  
      if (!namespace && projectPath) {
          namespace = path.basename(projectPath, path.extname(projectPath));
          if (folderPath) {
              namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
          }
          namespace = namespace.replace(/[\\\-]/g, "_");
      }
  
      if (!namespace) {
          namespace = "Unknown";
      }
  
      return {
          namespace: namespace,
          name: path.basename(filename, path.extname(filename))
      }
  };