Beispiel #1
0
        public SourceFile CreateNewFile(string fileName)
        {
            if (string.IsNullOrWhiteSpace(FilePath))
            {
                throw new Exception("Sequence FilePath must be set.");
            }
            if (string.IsNullOrWhiteSpace(Language))
            {
                throw new Exception("Sequence Language must be set.");
            }
            if (_FileExists(fileName))
            {
                throw new InvalidOperationException("File already exists with that name.");
            }

            // Get the appropriate extension onto the file name.
            ScriptModuleManagement manager = Modules.GetManager <IScriptModuleInstance, ScriptModuleManagement>();

            fileName = Path.ChangeExtension(fileName, manager.GetFileExtension(Language));

            SourceFile sourceFile;

            if (_sourceFiles.Files.Count == 0)
            {
                sourceFile = _CreateSkeletonFile(fileName);
            }
            else
            {
                sourceFile = _CreateBlankFile(fileName);
            }

            return(sourceFile);
        }
Beispiel #2
0
        private SourceFile _CreateSkeletonFile(string fileName)
        {
            ScriptModuleManagement   manager = Modules.GetManager <IScriptModuleInstance, ScriptModuleManagement>();
            IScriptSkeletonGenerator skeletonFileGenerator = manager.GetSkeletonGenerator(Language);

            // Setting the class name any time the skeleton file is generated so that when
            // the framework is generated, it will be part of the same class.
            string nameSpace = ScriptHostGenerator.UserScriptNamespace;

            ClassName = ScriptHostGenerator.Mangle(Name);

            SourceFile sourceFile = _CreateBlankFile(fileName);

            sourceFile.Contents = skeletonFileGenerator.Generate(nameSpace, ClassName);

            return(sourceFile);
        }