コード例 #1
0
        private void PerformPartialCompile(IProjectItem xamlProjectItem)
        {
            if (this.lastDirtyStateBeforePartialCompileIndex.ContainsKey(xamlProjectItem.DocumentReference) && xamlProjectItem.Document != null)
            {
                CodeProject.PartialCompileDirtyState compileDirtyState = new CodeProject.PartialCompileDirtyState()
                {
                    DirtyState         = xamlProjectItem.Document.IsDirty,
                    PartialCompileTime = DateTime.UtcNow
                };
                this.lastDirtyStateBeforePartialCompileIndex[xamlProjectItem.DocumentReference] = new CodeProject.PartialCompileDirtyState?(compileDirtyState);
            }
            string fileName = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(this.project.DocumentReference.Path)).GetRelativePath(xamlProjectItem.DocumentReference);

            foreach (char oldChar in Microsoft.Expression.Framework.Documents.PathHelper.GetDirectorySeparatorCharacters())
            {
                fileName = fileName.Replace(oldChar, '_');
            }
            string documentText = this.GetDocumentText(xamlProjectItem);

            if (documentText == null)
            {
                return;
            }
            PartialXamlBuilder partialXamlBuilder = new PartialXamlBuilder(this.project, xamlProjectItem, documentText, fileName, this.buildManager);

            partialXamlBuilder.BuildFinished += new EventHandler <PartialXamlBuildFinishedEventArgs>(this.XamlBuilder_BuildFinished);
            partialXamlBuilder.Build();
        }
コード例 #2
0
 public void InvalidateGeneratedCodeFromPartialCompile(IProjectItem item)
 {
     this.actions.Add((AsyncProcess) new DelegateAsyncProcess((Action <object, DoWorkEventArgs>)((sender, args) =>
     {
         this.codeProject.RemoveGeneratedCode(item);
         PartialXamlBuilder.CleanPartialCompileDirectory();
     })), this.startProcessing);
 }
コード例 #3
0
 public void UpdateGeneratedCodeFromPartialCompile(IProjectItem item, string fileName)
 {
     this.actions.Add((AsyncProcess) new DelegateAsyncProcess((Action <object, DoWorkEventArgs>)((sender, args) =>
     {
         if (this.codeProject.IsGeneratedFileName(fileName))
         {
             return;
         }
         this.codeProject.RemoveGeneratedCode(item);
         this.codeProject.AddGeneratedCode(item, fileName, true);
         PartialXamlBuilder.CleanPartialCompileDirectory();
     })), this.startProcessing);
 }
コード例 #4
0
        private void XamlBuilder_BuildFinished(object sender, PartialXamlBuildFinishedEventArgs e)
        {
            if (e.BuildResult == BuildResult.Succeeded)
            {
                this.asyncManager.UpdateGeneratedCodeFromPartialCompile(e.ProjectItem, e.XamlFileLocation);
            }
            else if (e.BuildResult == BuildResult.Failed)
            {
                this.asyncManager.InvalidateGeneratedCodeFromPartialCompile(e.ProjectItem);
            }
            PartialXamlBuilder partialXamlBuilder = (PartialXamlBuilder)sender;

            if (partialXamlBuilder == null)
            {
                return;
            }
            partialXamlBuilder.BuildFinished -= new EventHandler <PartialXamlBuildFinishedEventArgs>(this.XamlBuilder_BuildFinished);
        }