Programmatically adding a file to a Mist Project

gravatar

David

Add a file that exists in the File System to the current Mist project.

published 10.29.13

last updated 10.29.13


Share

Tags

  • C#
  • Script
                            


<#
/*============================================================================= 
Description:     
This script will include a file that exists in the file system in the
current Mist Project.  This script uses an Invoke since the operation occurs
on a separate thread.

This is a useful pattern to combine with auto-generated Biml.

===============================================================================
History:
20131028    david.darden    Initial Version 
=============================================================================*/
#>

<#@ template language="C#" hostspecific="True"#>
<#@ assembly name="C:\Program Files\Varigence\Mist\3.4\Mist.exe" #>
<#@ assembly name="C:\Program Files\Varigence\Mist\3.4\WpfControls.dll" #>
<#@ assembly name="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationFramework.dll" #>
<#@ assembly name="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xaml.dll" #>
<#@ import namespace="Varigence.Mist.Managers" #>
 
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
</Biml>
<# 
WriteLine("<!--");
// Display the project context; this might be useful to find the relative location of a file.
var model = ProjectManager.GetInstance().CurrentProjectViewModel;
WriteLine("Project Directory: {0}", model.DirectoryPath);
WriteLine("Project File Path: {0}", model.FilePath);
 
// Add a file that exists in the File System to the current Mist project.
System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { ProjectManager.GetInstance().Project.AddNewPathToModel(@"C:\SVN\edw\edw3\trunk\Jobs\MyAwesomeJob\MyFile.txt", Varigence.Utility.Files.ExplorerItemType.File); }));
WriteLine("-->");
#>
                        

This script will include a file that exists in the file system in the current Mist Project. This script uses an Invoke since the operation occurs on a separate thread.

This is a useful pattern to combine with auto-generated Biml.

You are not authorized to comment. A verification email has been sent to your email address. Please verify your account.

Comments

There are no comments yet.