Beispiel #1
0
        private void UpdateToolkitXmlNamespace()
        {
            string str;

            if (string.Compare(Path.GetExtension(this.currentXamlPath), ".xaml", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return;
            }
            if (!this.ContainsWpfToolkitNamespace(this.currentXamlPath, out str))
            {
                return;
            }
            string str1 = File.ReadAllText(this.currentXamlPath, Encoding.UTF8);
            string str2 = this.ReplaceWpfToolkitNamespace(str1, str);

            if (str2 != null)
            {
                try
                {
                    if (this.context == null || ProjectPathHelper.AttemptToMakeWritable(DocumentReference.Create(this.currentXamlPath), this.context))
                    {
                        File.WriteAllText(this.currentXamlPath, str2, Encoding.UTF8);
                        ProjectLog.LogSuccess(this.currentXamlPath, StringTable.SaveAction, new object[0]);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    ProjectLog.LogError(this.currentXamlPath, exception, StringTable.SaveAction, new object[0]);
                }
            }
        }
Beispiel #2
0
 private MigratingMSBuildStore(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider)
 {
     this.DocumentReference = documentReference;
     this.serviceProvider   = serviceProvider;
     this.AttemptToMigrate  = (bool callerSuccess) => {
         if (!callerSuccess)
         {
             return(callerSuccess);
         }
         try
         {
             ProjectPathHelper.AttemptToMakeWritable(this.DocumentReference, this.serviceProvider);
             this.Save();
             IProjectStore projectStore = MSBuildBasedProjectStore.CreateInstance(this.DocumentReference, this.serviceProvider);
             this.NestedStore.Dispose();
             this.NestedStore      = projectStore;
             this.AttemptToMigrate = (bool value) => value;
         }
         catch (InvalidProjectFileException invalidProjectFileException)
         {
             this.LastError = invalidProjectFileException;
         }
         return(callerSuccess);
     };
 }
Beispiel #3
0
        public static bool AttemptToMakeWritable(DocumentReference documentReference, IServiceProvider serviceProvider)
        {
            HandlerBasedProjectActionContext handlerBasedProjectActionContext = new HandlerBasedProjectActionContext(serviceProvider)
            {
                ExceptionHandler = (DocumentReference doc, Exception exception) => {
                    if (!ErrorHandling.ShouldHandleExceptions(exception))
                    {
                        return(false);
                    }
                    serviceProvider.MessageDisplayService().ShowError(string.Format(CultureInfo.CurrentCulture, StringTable.FileAccessErrorDialogMessage, new object[] { doc.DisplayNameShort, exception.Message }));
                    return(true);
                },
                CanOverwriteHandler = (DocumentReference doc) => ProjectPathHelper.PromptToOverwrite(doc, serviceProvider)
            };

            return(ProjectPathHelper.AttemptToMakeWritable(documentReference, handlerBasedProjectActionContext));
        }