コード例 #1
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var template = new FileTemplate() as ITemplate;
            template.Initialize(new FileTemplateModel
            {
                Toolchain = JsonSchema4.ToolchainVersion,
                Types = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(Settings.ProcessedExtensionCode)),

                HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
                ModuleName = Settings.ModuleName,

                ExtensionCodeBefore = Settings.ProcessedExtensionCode.CodeBefore,
                ExtensionCodeAfter = Settings.ProcessedExtensionCode.CodeAfter
            });
            return ConversionUtilities.TrimWhiteSpaces(template.Render());
        }
コード例 #2
0
ファイル: FileHelper.cs プロジェクト: TyrelBaux/Gibbo2D
        /// <summary>
        /// Creates a file with the given input
        /// </summary>
        /// <param name="path"></param>
        /// <returns>The path of the created file</returns>
        public static string CreateFile(string path, FileTemplate template)
        {
            // Resolve the selected filename
            path = ResolveFilename(path);

            // Create a file or append
            using (System.IO.FileStream fs = new System.IO.FileStream(path, FileMode.Append))
            {
              
            }

            switch (template)
            {
                case FileTemplate.Component:

                    //File.WriteAllText(path, Properties.Settings.Default.NewComponentTemplate);
                    break;

            }

            return path;
        }
コード例 #3
0
        private string CreateFile(string path, FileTemplate template, ImageSource imageSource = null)
        {
            if (this.SelectedItem == null) return string.Empty;

            path = FileHelper.CreateFile(path, template);

            // Add the new tree node to the TreeView
            TreeViewItem _node = AddNode(null, System.IO.Path.GetFileName(path), 10, imageSource);
            _node.Tag = "file";
            _node.ContextMenu = fileContextMenu;

            if (((SelectedItem as ExplorerTreeViewItem).Items.Count > 0 &&
                !((SelectedItem as ExplorerTreeViewItem).Items[0] as ExplorerTreeViewItem).Text.Equals("*")) ||
                (SelectedItem as ExplorerTreeViewItem).Items.Count == 0)
            {
                (SelectedItem as ExplorerTreeViewItem).Items.Add(_node);
            }

            (SelectedItem as ExplorerTreeViewItem).IsExpanded = true;

            return path;
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns>The path of the created file</returns>
        private string CreateFile(string path, FileTemplate template)
        {
            if (SelectedNode == null) return string.Empty;

            path = FileHelper.CreateFile(path, template);

            // Add the new tree node to the TreeView
            TreeNode newnode = new TreeNode(Path.GetFileName(path));
            newnode.ContextMenuStrip = fileContextMenu;
            HandleNewNode(newnode);
            newnode.Tag = "file";

            if ((SelectedNode.Nodes.Count > 0 && !SelectedNode.Nodes[0].Text.Equals("*")) || SelectedNode.Nodes.Count == 0)
            {
                SelectedNode.Nodes.Add(newnode);
            }

            SelectedNode.Expand();

            //treeView.Sort();

            return path;
        }
コード例 #5
0
			public TemplateItem(FileTemplate template) : base(((StringParserService)ServiceManager.Services.GetService(typeof(StringParserService))).Parse(template.Name))
			{
				this.template = template;
				ImageIndex    = 0;
			}