Exemplo n.º 1
0
 public static void Update(IProjectStore projectStore, IProjectActionContext context, ConversionType initialVersion, ConversionType targetVersion)
 {
     if (initialVersion != ConversionType.ProjectWpf30 && initialVersion != ConversionType.ProjectWpf35)
     {
         return;
     }
     if (targetVersion != ConversionType.ProjectWpf40)
     {
         return;
     }
     (new WpfToolkitRemover(projectStore, context)).Update();
 }
Exemplo n.º 2
0
 private WpfToolkitRemover(IProjectStore projectStore, IProjectActionContext context)
 {
     this.projectStore = projectStore;
     this.context      = context;
 }
Exemplo n.º 3
0
        public static bool AttemptToMakeWritable(DocumentReference documentReference, IProjectActionContext context)
        {
            bool flag;

            if (!documentReference.IsValidPathFormat || Microsoft.Expression.Framework.Documents.PathHelper.IsDirectory(documentReference.Path))
            {
                return(false);
            }
            if (!Microsoft.Expression.Framework.Documents.PathHelper.FileOrDirectoryExists(documentReference.Path))
            {
                return(true);
            }
            if (context == null)
            {
                return(false);
            }
            SourceControlHelper.UpdateSourceControl(EnumerableExtensions.AsEnumerable <DocumentReference>(documentReference), UpdateSourceControlActions.Checkout, context);
            try
            {
                FileAttributes attributes = File.GetAttributes(documentReference.Path);
                if ((attributes & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
                {
                    flag = true;
                }
                else if (!context.CanOverwrite(documentReference))
                {
                    ProjectLog.LogError(documentReference.Path, StringTable.ActionCanceled, StringTable.MakeWritableAction, new object[0]);
                    flag = false;
                }
                else if (!Microsoft.Expression.Framework.Documents.PathHelper.ClearFileOrDirectoryReadOnlyAttribute(documentReference.Path))
                {
                    attributes = attributes & (FileAttributes.Hidden | FileAttributes.System | FileAttributes.Directory | FileAttributes.Archive | FileAttributes.Device | FileAttributes.Normal | FileAttributes.Temporary | FileAttributes.SparseFile | FileAttributes.ReparsePoint | FileAttributes.Compressed | FileAttributes.Offline | FileAttributes.NotContentIndexed | FileAttributes.Encrypted | FileAttributes.IntegrityStream | FileAttributes.NoScrubData);
                    File.SetAttributes(documentReference.Path, attributes);
                    ProjectLog.LogSuccess(documentReference.Path, StringTable.MakeWritableAction, new object[0]);
                    flag = true;
                }
                else
                {
                    ProjectLog.LogSuccess(documentReference.Path, StringTable.MakeWritableAction, new object[0]);
                    flag = true;
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ProjectLog.LogError(documentReference.Path, exception, StringTable.MakeWritableAction, new object[0]);
                if (!context.HandleException(documentReference, exception))
                {
                    throw;
                }
                return(false);
            }
            return(flag);
        }
Exemplo n.º 4
0
        internal static void UpdateSourceControl(IEnumerable <DocumentReference> paths, UpdateSourceControlActions updateSourceControlAction, IProjectActionContext context)
        {
            if (context == null)
            {
                return;
            }
            IProjectManager projectManager = context.ServiceProvider.ProjectManager();

            if (projectManager == null)
            {
                return;
            }
            ISolution currentSolution = projectManager.CurrentSolution;

            if (currentSolution == null || !currentSolution.IsSourceControlActive)
            {
                return;
            }
            SourceControlStatusCache.UpdateStatus(paths, context.ServiceProvider.SourceControlProvider());
            IEnumerable <DocumentReference> documentReferences = paths.Where <DocumentReference>((DocumentReference path) => {
                if (!context.IsSourceControlled(path))
                {
                    return(false);
                }
                return(PathHelper.FileExists(path.Path));
            });
            IEnumerable <DocumentReference> documentReferences1 = Enumerable.Empty <DocumentReference>();

            if ((updateSourceControlAction & UpdateSourceControlActions.Checkout) == UpdateSourceControlActions.Checkout)
            {
                IEnumerable <DocumentReference> cachedStatus =
                    from path in documentReferences
                    where SourceControlStatusCache.GetCachedStatus(path) == SourceControlStatus.CheckedIn
                    select path;
                if (context.ServiceProvider.SourceControlProvider().Checkout((
                                                                                 from path in cachedStatus
                                                                                 select path.Path).ToArray <string>()) != SourceControlSuccess.Success)
                {
                    documentReferences1.Concat <DocumentReference>(cachedStatus);
                }
                else
                {
                    SourceControlStatusCache.SetCachedStatus(cachedStatus, SourceControlStatus.CheckedOut);
                    foreach (DocumentReference cachedStatu in cachedStatus)
                    {
                        ProjectLog.LogSuccess(cachedStatu.Path, StringTable.MakeWritableAction, new object[0]);
                    }
                }
            }
            if ((updateSourceControlAction & UpdateSourceControlActions.PendAdd) == UpdateSourceControlActions.PendAdd)
            {
                IEnumerable <DocumentReference> cachedStatus1 =
                    from path in documentReferences
                    where SourceControlStatusCache.GetCachedStatus(path) == SourceControlStatus.None
                    select path;
                if (context.ServiceProvider.SourceControlProvider().Add((
                                                                            from path in cachedStatus1
                                                                            select path.Path).ToArray <string>()) != SourceControlSuccess.Success)
                {
                    documentReferences1.Concat <DocumentReference>(cachedStatus1);
                }
                else
                {
                    SourceControlStatusCache.SetCachedStatus(cachedStatus1, SourceControlStatus.Add);
                }
            }
            SourceControlStatusCache.UpdateStatus(documentReferences1, context.ServiceProvider.SourceControlProvider());
        }