void Microsoft.Expression.Framework.Documents.IDocumentContainer.BeginCheckDocumentStatus(IDocument document) { ISolution currentSolution = base.Services.ProjectManager().CurrentSolution; if (currentSolution != null && currentSolution.IsSourceControlActive && SourceControlStatusCache.GetCachedStatus(this) == SourceControlStatus.CheckedIn) { ISourceControlProvider sourceControlProvider = base.Services.SourceControlProvider(); string[] path = new string[] { base.DocumentReference.Path }; if (sourceControlProvider.Checkout(path) == SourceControlSuccess.Success) { SourceControlStatusCache.SetCachedStatus(this, SourceControlStatus.CheckedOut); } } }
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()); }
public static SourceControlStatus GetCachedStatus(IDocumentItem item) { return(SourceControlStatusCache.GetCachedStatus(item.DocumentReference)); }