public void CreateRuntimeModule() { var str = $"public class RuntimeModule:{typeof(RuntimeModuleBase).FullName} {{ public RuntimeModule():base(){{}} }}\n"; Workspace.AddDocument(ModuleProject.Id, "RunttimeModule.cs", SourceText.From(str, Encoding.UTF8)); }
protected Document AddRoslynDocument(string filePath) { var backgroundDocumentId = DocumentId.CreateNewId(Project.Id); var backgroundDocumentInfo = DocumentInfo.Create(backgroundDocumentId, filePath ?? "EmptyFile", filePath: filePath); Workspace.AddDocument(backgroundDocumentInfo); var addedDocument = Workspace.CurrentSolution.GetDocument(backgroundDocumentId); return(addedDocument); }
private void CreateDocument(IDocumentProvider documentProvider) { var doc = Workspace.AddDocument(ModuleProject.Id, documentProvider.GetFileName() + ".cs", SourceText.From(documentProvider.GetCode(), Encoding.UTF8)); var updated = Workspace.TryApplyChanges(doc.Project.Solution); Debug.WriteLine("Updated:" + updated); Documents.Add(documentProvider.GetDocumentGuid(), doc); SemanticModels.Add(documentProvider.GetDocumentGuid(), doc.GetSemanticModelAsync().Result); }
public Document GetCurrentDocument(string source) { if (_currentDocument == null) { _currentDocument = Workspace.AddDocument(Project.Id, "MyFile.cs", SourceText.From(source)); } else { _currentDocument = _currentDocument.WithText(SourceText.From(source)); } return(_currentDocument); }
private void AddFile(string filePath, ProjectId projectId) { using (var stream = File.OpenRead(filePath)) using (var reader = new StreamReader(stream)) { var fileName = Path.GetFileName(filePath); var csxFile = reader.ReadToEnd(); var documentId = DocumentId.CreateNewId(projectId, fileName); var documentInfo = DocumentInfo.Create(documentId, fileName, null, SourceCodeKind.Script, null, filePath) .WithSourceCodeKind(SourceCodeKind.Script) .WithTextLoader(TextLoader.From(TextAndVersion.Create(SourceText.From(csxFile), VersionStamp.Create()))); Workspace.AddDocument(documentInfo); } }
public void CreateAssembyInfoDocument() { #region GetVersion var ver = BusinessBuilder.GetVersion(AdmiralEnvironment.UserDefineBusinessFile); if (ver != null) { ver = new Version(ver.Major + 1, ver.Minor, ver.Build, ver.Revision); } else { ver = new Version(1, 0, 0, 0); } #endregion var str = $"[assembly: {typeof (AssemblyVersionAttribute).FullName}(\"{ver.ToString()}\")]\n"; Workspace.AddDocument(ModuleProject.Id, "AssemblyInfo.cs", SourceText.From(str, Encoding.UTF8)); }
/// <summary> /// Adds a document to the workspace. /// </summary> public DocumentID AddDocument(ProjectID projectId, string name, string text) { return(Workspace.AddDocument(projectId, name, SourceText.From(text)).Id); }
public static void OpenLibrary(Application anApp, string aName, string aLang) { PdOOM.BaseObject modelObject; WorkspaceModel model = RetrieveModelByFile(anApp, aName); if (model == null) { Workspace activeWorkspace = (Workspace)anApp.ActiveWorkspace; if (activeWorkspace == null) { throw new Exception("Unable to reach the Workspace"); } modelObject = (PdOOM.BaseObject)activeWorkspace.AddDocument(aName, -1); if (modelObject == null) { return; } model = (WorkspaceModel)modelObject; } Model aModel = null; if (model.ModelKind == 0x18112060) { modelObject = (PdOOM.BaseObject)model.ModelObject; if (modelObject == null) { long interactiveMode = (long)anApp.InteractiveMode; anApp.InteractiveMode = InteractiveModeValue.im_Batch; try { modelObject = (PdOOM.BaseObject)model.Open(); } catch (Exception exception) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { exception.StackTrace }); } } finally { anApp.InteractiveMode = (InteractiveModeValue)((int)interactiveMode); } } if (modelObject != null) { aModel = (Model)modelObject; ObjectLanguage objectLanguage = (ObjectLanguage)aModel.ObjectLanguage; if (objectLanguage.Name == aLang) { string name; if (aModel.Name != aModel.Code) { name = aModel.Name + " (" + aModel.Code + ")"; } else { name = aModel.Name; } LZ.Reverse.Info.Write(new string[] { "... indexation of the library \"{0}\"", name }); IndexModelClassifiers(aModel); } } } }