static public string ContentId(ILayoutContentViewModel contentViewModel) { var sb = new StringBuilder(); sb.Append(PackagePartType(contentViewModel)); //used to get the type of this content sb.Append("-_-"); sb.Append(PackagePartID(contentViewModel)); //used to get the stream from package return(sb.ToString()); }
internal static void SetContentViewModelID(string contentId, ILayoutContentViewModel contentViewModel) { var contentIdSplits = contentId.Split(new string[] { "-_-" }, StringSplitOptions.RemoveEmptyEntries); System.Diagnostics.Debug.Assert(contentIdSplits.Length == 2); var layoutContentViewModel = contentViewModel as LayoutContentViewModel; if (layoutContentViewModel == null) { return; } layoutContentViewModel.ID = new Guid(contentIdSplits[1].Substring(2, 38)); }
public void DeleteDocument(ILayoutContentViewModel document) { if (document is IDocumentViewModel) { var d = document as IDocumentViewModel; if (!this.CloseDocument(d)) { return; } } foreach (var unopenDoc in this.DocumentsUnopen) { if (unopenDoc.ContentId == document.ContentId) { if (unopenDoc.KeepAliveWhenClose) { unopenDoc.DocClosedButAlive.CloseViewModel(true); } this.DocumentsUnopen.Remove(unopenDoc); break; } } }
/// <summary> /// the name of the file in package /// "/" + pluginAssembleName + "/" + ILayoutContentViewModel.PackagePartName + ".xml"; /// should not contains changable part, because it is the url of the packagepart, if not we will get a lot dead packagepart in the package when we change the title and save the package part; /// </summary> static public string PackagePartName(ILayoutContentViewModel contentViewModel) { return(contentViewModel.GetType().FullName + "-_-" + PackagePartID(contentViewModel));//this.GetType().FullName + "-_-" + Title + "-_-" + PackagePartID; }
/// <summary> /// used by packagerelationship id of the package part. /// should not contains parts that maybe changed /// shold not contains "-_-" /// So the lenth is 38=2+36 /// string packagePartID = contentID_Splits[1].Substring(0,38); /// </summary> static public string PackagePartID(ILayoutContentViewModel contentViewModel) { return("ID" + contentViewModel.ID.ToString()); }
/// <summary> /// assembly qualified type name /// </summary> static public string PackagePartType(ILayoutContentViewModel contentViewModel) { var type = contentViewModel.GetType(); return(type.FullName + "," + type.Assembly.GetName().Name); }