private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string[] files = GetFiles();

            var fileContent = new List <string>();

            for (int i = 0; i < files.Length; i++)
            {
                string bindingPrefix = GetBindingPrefix(i);

                fileContent.Add(this.GetBinding <string>(bindingPrefix + "Content"));
            }

            // Fixing html specific escape sequences in .master file
            string fixedMaster       = PageTemplateHelper.FixHtmlEscapeSequences(fileContent[0]);
            bool   viewNeedsUpdating = fileContent[0] != fixedMaster;

            fileContent[0] = fixedMaster;


            EntityToken newEntityToken;

            if (!CompileAndValidate(files, fileContent, out newEntityToken))
            {
                SetSaveStatus(false);
                return;
            }

            for (int i = 0; i < files.Length; i++)
            {
                var websiteFile = new WebsiteFile(files[i]);

                websiteFile.WriteAllText(fileContent[i]);
            }

            PageTemplateProviderRegistry.FlushTemplates();

            if (newEntityToken != null)
            {
                SetSaveStatus(true, newEntityToken);

                SerializedEntityToken = EntityTokenSerializer.Serialize(newEntityToken);
            }
            else
            {
                SetSaveStatus(true);
            }

            if (viewNeedsUpdating)
            {
                UpdateBinding(GetBindingPrefix(0) + "Content", fixedMaster);
                RerenderView();
            }

            this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken);
        }
        private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var functionEntityToken = (FileBasedFunctionEntityToken)this.EntityToken;

            FileBasedFunctionProvider <UserControlBasedFunction> provider;
            FileBasedFunction <UserControlBasedFunction>         function;

            GetProviderAndFunction(functionEntityToken, out provider, out function);

            string[] files = GetFiles(function);

            var fileContent = new List <string>();

            for (int i = 0; i < files.Length; i++)
            {
                string bindingPrefix = GetBindingPrefix(i);

                fileContent.Add(this.GetBinding <string>(bindingPrefix + "Content"));
            }

            string fixedMarkup         = PageTemplateHelper.FixHtmlEscapeSequences(fileContent[0]);
            bool   viewShouldBeUpdated = fixedMarkup != fileContent[0];

            fileContent[0] = fixedMarkup;

            if (!CompileAndValidate(files, fileContent))
            {
                SetSaveStatus(false);
                return;
            }

            for (int i = 0; i < files.Length; i++)
            {
                var websiteFile = new WebsiteFile(files[i]);

                websiteFile.WriteAllText(fileContent[i]);
            }

            provider.ReloadFunctions();

            this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken);

            SetSaveStatus(true);

            if (viewShouldBeUpdated)
            {
                UpdateBinding(GetBindingPrefix(0) + "Content", fileContent[0]);
                RerenderView();
            }
        }
        private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string virtualPath = GetFileVirtualPath();
            string filePath    = PathUtil.Resolve(virtualPath);

            WebsiteFile websiteFile = new WebsiteFile(filePath);

            string content     = this.GetBinding <string>("FileContent");
            string fixedSource = PageTemplateHelper.FixHtmlEscapeSequences(content);

            EntityToken newEntityToken;
            bool        isValid = ValidateMarkup(virtualPath, fixedSource, out newEntityToken);

            if (isValid)
            {
                websiteFile.WriteAllText(fixedSource);

                PageTemplateProviderRegistry.FlushTemplates();

                this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken);
            }

            if (isValid && newEntityToken != null)
            {
                SetSaveStatus(true, newEntityToken);

                SerializedEntityToken = EntityTokenSerializer.Serialize(newEntityToken);
            }
            else
            {
                SetSaveStatus(isValid);
            }

            if (isValid && fixedSource != content)
            {
                UpdateBinding("FileContent", fixedSource);
                RerenderView();
            }
        }
        private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var functionEntityToken = (FileBasedFunctionEntityToken)this.EntityToken;

            FileBasedFunctionProvider <RazorBasedFunction> provider;
            FileBasedFunction <RazorBasedFunction>         function;

            GetProviderAndFunction(functionEntityToken, out provider, out function);

            string file = GetFile(function);

            string fileContent      = this.GetBinding <string>("FileContent");
            string fixedFileContent = PageTemplateHelper.FixHtmlEscapeSequences(fileContent);

            if (!CompileAndValidate(file, fixedFileContent))
            {
                SetSaveStatus(false);
                return;
            }

            var websiteFile = new WebsiteFile(file);

            websiteFile.WriteAllText(fixedFileContent);


            provider.ReloadFunctions();

            this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken);

            SetSaveStatus(true);

            if (fixedFileContent != fileContent)
            {
                UpdateBinding("FileContent", fixedFileContent);
                RerenderView();
            }
        }