public static RecoverContent CreateTextContent(ITextEditor editor) { RecoverContent item = new RecoverContent(); item.Uid = editor.Uid; item.Content = editor.Content; item.SyntaxMode = editor.CurrentSytaxMode; item.Title = editor.Caption; item.FileName = String.IsNullOrEmpty(editor.FileName) ? String.Empty : editor.FileName; item.ObjectType = -1; switch (editor.ContentType) { case EditorContentType.Text: item.ItemType = RecoverContentType.Text; break; case EditorContentType.File: item.ItemType = RecoverContentType.TextFile; break; case EditorContentType.SharedSnippet: item.ItemType = RecoverContentType.SharedSnippet; break; case EditorContentType.SharedScript: item.ItemType = RecoverContentType.SharedScript; break; default: break; } return(item); }
public static void Save(string folderPath, RecoverContent item) { if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, item.Uid + ".recover"); ObjectXMLSerializer <RecoverContent> .Save(item, path, SerializedFormat.Document); }
public static RecoverContent CreateScriptContent(IScriptEditor editor) { RecoverContent item = new RecoverContent(); item.Uid = editor.Uid; item.Content = editor.Content; item.SyntaxMode = editor.CurrentSytaxMode; item.Title = editor.Caption; item.Server = editor.CurrentConnection == null ? String.Empty : editor.CurrentConnection.Server; item.Database = editor.CurrentConnection == null ? String.Empty : editor.CurrentConnection.Database; item.Username = editor.CurrentConnection == null ? String.Empty : editor.CurrentConnection.UserName; item.IntegratedSecurity = editor.CurrentConnection == null ? String.Empty : editor.CurrentConnection.IntegratedSecurity; item.FileName = String.IsNullOrEmpty(editor.FileName) ? String.Empty : editor.FileName; item.ObjectType = editor.ObjectType; switch (editor.ContentType) { case EditorContentType.Script: item.ItemType = RecoverContentType.Script; break; case EditorContentType.File: item.ItemType = RecoverContentType.ScriptFile; break; case EditorContentType.SharedSnippet: item.ItemType = RecoverContentType.SharedSnippet; break; case EditorContentType.SharedScript: item.ItemType = RecoverContentType.SharedScript; break; default: item.ItemType = RecoverContentType.SharedScript; break; } return(item); }
public static void Save(RecoverContent item) { Save(RecoverFolder, item); }