예제 #1
0
        private void CreateControl(string viewPath, bool createCodeBehind, DotvvmProjectMetadata dotvvmProjectMetadata)
        {
            var codeBehindPath           = PathHelpers.ChangeExtension(viewPath, "cs");
            var codeBehindClassName      = NamingHelpers.GetClassNameFromPath(viewPath);
            var codeBehindClassNamespace = NamingHelpers.GetNamespaceFromPath(viewPath, dotvvmProjectMetadata.ProjectDirectory, dotvvmProjectMetadata.RootNamespace);

            // create control
            var controlTemplate = new ControlTemplate()
            {
                CreateCodeBehind = createCodeBehind
            };

            if (createCodeBehind)
            {
                controlTemplate.CodeBehindClassName          = codeBehindClassName;
                controlTemplate.CodeBehindClassNamespace     = codeBehindClassNamespace;
                controlTemplate.CodeBehindClassRootNamespace = dotvvmProjectMetadata.RootNamespace;
            }
            FileSystemHelpers.WriteFile(viewPath, controlTemplate.TransformText());

            // create code behind
            if (createCodeBehind)
            {
                var codeBehindTemplate = new ControlCodeBehindTemplate()
                {
                    CodeBehindClassNamespace = codeBehindClassNamespace,
                    CodeBehindClassName      = codeBehindClassName
                };
                FileSystemHelpers.WriteFile(codeBehindPath, codeBehindTemplate.TransformText());
            }
        }
예제 #2
0
        private void CreatePage(string viewPath, string masterPagePath, DotvvmProjectMetadata dotvvmProjectMetadata)
        {
            var viewModelPath      = NamingHelpers.GenerateViewModelPath(viewPath);
            var viewModelName      = NamingHelpers.GetClassNameFromPath(viewModelPath);
            var viewModelNamespace = NamingHelpers.GetNamespaceFromPath(viewModelPath, dotvvmProjectMetadata.ProjectDirectory, dotvvmProjectMetadata.RootNamespace);

            // create page
            var pageTemplate = new PageTemplate()
            {
                ViewModelRootNamespace = dotvvmProjectMetadata.RootNamespace,
                ViewModelName          = viewModelName,
                ViewModelNamespace     = viewModelNamespace,
                IsMasterPage           = true
            };

            if (!string.IsNullOrEmpty(masterPagePath))
            {
                pageTemplate.EmbedInMasterPage     = true;
                pageTemplate.MasterPageLocation    = masterPagePath;
                pageTemplate.ContentPlaceHolderIds = new MasterPageBuilder().ExtractPlaceHolderIds(masterPagePath);
            }
            FileSystemHelpers.WriteFile(viewPath, pageTemplate.TransformText());

            // create viewmodel
            var viewModelTemplate = new ViewModelTemplate()
            {
                ViewModelName      = viewModelName,
                ViewModelNamespace = viewModelNamespace
                                     // TODO: BaseViewModel
            };

            FileSystemHelpers.WriteFile(viewModelPath, viewModelTemplate.TransformText());
        }
예제 #3
0
        private void CreateViewModel(string viewModelPath, DotvvmProjectMetadata dotvvmProjectMetadata)
        {
            var viewModelName      = NamingHelpers.GetClassNameFromPath(viewModelPath);
            var viewModelNamespace = NamingHelpers.GetNamespaceFromPath(viewModelPath, dotvvmProjectMetadata.ProjectDirectory, dotvvmProjectMetadata.RootNamespace);

            // create viewmodel
            var viewModelTemplate = new ViewModelTemplate()
            {
                ViewModelName      = viewModelName,
                ViewModelNamespace = viewModelNamespace
                                     // TODO: BaseViewModel
            };

            FileSystemHelpers.WriteFile(viewModelPath, viewModelTemplate.TransformText());
        }