public string CompileScript(FileTemplate item, FileDescriptionTemplate file)
		{
			if (file.Content == null)
				throw new ArgumentException("file must have textual content");
			Match m = scriptRegex.Match(file.Content);
			m = m.NextMatch();
			if (m.Success) {
				this.item = item;
				this.file = file;
				return CompileAndGetOutput(GenerateCode());
			}
			return file.Content;
		}
Exemple #2
0
		public string CompileScript(FileTemplate item, FileDescriptionTemplate file)
		{
			if (file.Content == null)
				throw new ArgumentException("file must have textual content");
			Match m = scriptRegex.Match(file.Content);
			// A file must have at least two "<% %>" segments to be recognized as script.
			// I consider this a bug, but we'll keep it for backwards compatibility;
			// at least until the ScriptRunner gets replaced by something more sane.
			m = m.NextMatch();
			if (m.Success) {
				this.item = item;
				this.file = file;
				return CompileAndGetOutput(GenerateCode());
			}
			return file.Content;
		}
Exemple #3
0
        public string CompileScript(FileTemplate item, FileDescriptionTemplate file)
        {
            if (file.Content == null)
            {
                throw new ArgumentException("file must have textual content");
            }
            Match m = scriptRegex.Match(file.Content);

            m = m.NextMatch();
            if (m.Success)
            {
                this.item = item;
                this.file = file;
                return(CompileAndGetOutput(GenerateCode()));
            }
            return(file.Content);
        }
Exemple #4
0
        public string CompileScript(FileTemplate item, FileDescriptionTemplate file)
        {
            if (file.Content == null)
            {
                throw new ArgumentException("file must have textual content");
            }
            Match m = scriptRegex.Match(file.Content);

            // A file must have at least two "<% %>" segments to be recognized as script.
            // I consider this a bug, but we'll keep it for backwards compatibility;
            // at least until the ScriptRunner gets replaced by something more sane.
            m = m.NextMatch();
            if (m.Success)
            {
                this.item = item;
                this.file = file;
                return(CompileAndGetOutput(GenerateCode()));
            }
            return(file.Content);
        }
Exemple #5
0
		public void SaveFile(FileDescriptionTemplate newfile, string content, string binaryFileName)
		{
			string parsedFileName = StringParser.Parse(newfile.Name);
			// Parse twice so that tags used in included standard header are parsed
			string parsedContent = StringParser.Parse(StringParser.Parse(content));
			
			if (parsedContent != null) {
				if (EditorControlService.GlobalOptions.IndentationString != "\t") {
					parsedContent = parsedContent.Replace("\t", EditorControlService.GlobalOptions.IndentationString);
				}
			}
			
			
			// when newFile.Name is "${Path}/${FileName}", there might be a useless '/' in front of the file name
			// if the file is created when no project is opened. So we remove single '/' or '\', but not double
			// '\\' (project is saved on network share).
			if (parsedFileName.StartsWith("/") && !parsedFileName.StartsWith("//")
			    || parsedFileName.StartsWith("\\") && !parsedFileName.StartsWith("\\\\"))
			{
				parsedFileName = parsedFileName.Substring(1);
			}
			
			if (newfile.IsDependentFile && Path.IsPathRooted(parsedFileName)) {
				Directory.CreateDirectory(Path.GetDirectoryName(parsedFileName));
				if (!String.IsNullOrEmpty(binaryFileName))
					File.Copy(binaryFileName, parsedFileName);
				else
					File.WriteAllText(parsedFileName, parsedContent, ParserService.DefaultFileEncoding);
				ParserService.ParseFile(parsedFileName, new StringTextBuffer(parsedContent));
			} else {
				if (!String.IsNullOrEmpty(binaryFileName)) {
					LoggingService.Warn("binary file was skipped");
					return;
				}
				IViewContent viewContent = FileService.NewFile(Path.GetFileName(parsedFileName), parsedContent);
				if (viewContent == null) {
					return;
				}
				if (Path.IsPathRooted(parsedFileName)) {
					Directory.CreateDirectory(Path.GetDirectoryName(parsedFileName));
					viewContent.PrimaryFile.SaveToDisk(parsedFileName);
				}
			}
			createdFiles.Add(new KeyValuePair<string, FileDescriptionTemplate>(parsedFileName, newfile));
		}
		public void SaveFile(FileDescriptionTemplate newfile, string content, byte[] binaryContent)
		{
			string parsedFileName = StringParser.Parse(newfile.Name);
			// Parse twice so that tags used in included standard header are parsed
			string parsedContent = StringParser.Parse(StringParser.Parse(content));
			
			// when newFile.Name is "${Path}/${FileName}", there might be a useless '/' in front of the file name
			// if the file is created when no project is opened. So we remove single '/' or '\', but not double
			// '\\' (project is saved on network share).
			if (parsedFileName.StartsWith("/") && !parsedFileName.StartsWith("//")
			    || parsedFileName.StartsWith("\\") && !parsedFileName.StartsWith("\\\\"))
			{
				parsedFileName = parsedFileName.Substring(1);
			}
			
			if (newfile.IsDependentFile && Path.IsPathRooted(parsedFileName)) {
				Directory.CreateDirectory(Path.GetDirectoryName(parsedFileName));
				if (binaryContent != null)
					File.WriteAllBytes(parsedFileName, binaryContent);
				else
					File.WriteAllText(parsedFileName, parsedContent, ParserService.DefaultFileEncoding);
				ParserService.ParseFile(parsedFileName, parsedContent);
			} else {
				if (binaryContent != null) {
					LoggingService.Warn("binary file was skipped");
					return;
				}
				IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(newfile.Language), parsedContent);
				if (window == null) {
					return;
				}
				if (Path.IsPathRooted(parsedFileName)) {
					Directory.CreateDirectory(Path.GetDirectoryName(parsedFileName));
					window.ViewContent.Save(parsedFileName);
				}
			}
			createdFiles.Add(new KeyValuePair<string, FileDescriptionTemplate>(parsedFileName, newfile));
		}