-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add strture for project in projectManager
- Loading branch information
1 parent
650ad9d
commit d077b2c
Showing
8 changed files
with
103 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Fiona.IDE.ProjectManager.Models; | ||
|
||
public sealed class Class | ||
{ | ||
public IReadOnlyCollection<Dependency> Dependencies => _dependencies.AsReadOnly(); | ||
|
||
private List<Dependency> _dependencies = new(); | ||
private string _route; | ||
Check warning on line 8 in ide/src/Fiona.IDE.ProjectManager/Models/Class.cs
|
||
private List<Endpoint> _endpoints = new(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Fiona.IDE.ProjectManager.Models; | ||
|
||
public sealed class Endpoint | ||
{ | ||
private string? _route; | ||
private string[] _methods; | ||
Check warning on line 6 in ide/src/Fiona.IDE.ProjectManager/Models/Endpoint.cs
|
||
private string _returnType; | ||
Check warning on line 7 in ide/src/Fiona.IDE.ProjectManager/Models/Endpoint.cs
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Fiona.IDE.ProjectManager.Models; | ||
|
||
public sealed class Input | ||
{ | ||
private string _name; | ||
private string _type; | ||
private string _attribute; | ||
|
||
public Input(string name, string type, string attribute) | ||
{ | ||
_name = name; | ||
_type = type; | ||
_attribute = attribute; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,62 @@ | ||
using Fiona.IDE.ProjectManager.Exceptions; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Fiona.IDE.ProjectManager.Models | ||
namespace Fiona.IDE.ProjectManager.Models; | ||
|
||
public sealed class ProjectFile | ||
{ | ||
public sealed class ProjectFile | ||
{ | ||
public string Path { get; } | ||
public string Name { get; } | ||
public string Namespace { get; } | ||
public const string Extension = "fn"; | ||
public string Path { get; } | ||
public string Name { get; } | ||
public string Namespace { get; } | ||
|
||
public const string Extension = "fn"; | ||
|
||
private Class @class; | ||
Check warning on line 14 in ide/src/Fiona.IDE.ProjectManager/Models/ProjectFile.cs
|
||
|
||
[JsonConstructor] | ||
private ProjectFile(string path) | ||
{ | ||
Path = path; | ||
Name = path.Split(System.IO.Path.DirectorySeparatorChar).Last(); | ||
Namespace = path.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), ".").Split(":").Last().Replace(".fn", "")[1..]; | ||
} | ||
|
||
internal static ProjectFile Create(string path) | ||
[JsonConstructor] | ||
private ProjectFile(string path) | ||
{ | ||
Path = path; | ||
Name = path.Split(System.IO.Path.DirectorySeparatorChar).Last(); | ||
Namespace = path.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), ".").Split(":").Last().Replace(".fn", "")[1..]; | ||
} | ||
|
||
internal static async Task<ProjectFile> Create(string path) | ||
{ | ||
if (File.Exists(path)) | ||
{ | ||
if (File.Exists(path)) | ||
{ | ||
throw new FileAlreadyExistsException(path); | ||
} | ||
File.Create(path); | ||
|
||
|
||
|
||
return new ProjectFile(path); | ||
throw new FileAlreadyExistsException(path); | ||
} | ||
File.Create(path); | ||
|
||
ProjectFile projectFile = new(path); | ||
|
||
await projectFile.SaveContentAsync(projectFile.GetBaseContent()); | ||
|
||
return projectFile; | ||
} | ||
|
||
private async Task SaveContentAsync(string content) | ||
{ | ||
await File.WriteAllTextAsync(Path, content); | ||
} | ||
|
||
} | ||
|
||
internal static class ProjectFileExtensions | ||
{ | ||
public static string GetBaseContent(this ProjectFile projectFile) | ||
{ | ||
return $""" | ||
usingBegin; | ||
using Fiona.Hosting.Controller.Attributes; | ||
using Fiona.Hosting.Routing; | ||
using Fiona.Hosting.Routing.Attributes; | ||
usingEnd; | ||
namespace: {projectFile.Namespace} | ||
class: {projectFile.Name} | ||
"""; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters