private void Close() { if (_parseData == null) { return; } ParseData parseData = _parseData; lock (parseData) { _fullPath = null; _htmlDocument.OnDocumentClosing -= OnClose; _htmlDocument.MassiveChangeEnded -= OnMassiveChangeEnded; _htmlDocument = null; ServiceManager.RemoveService <RazorCodeGenerator>(_viewBuffer); ServiceManager.RemoveService <IRazorCodeGenerator>(_viewBuffer); ServiceManager.RemoveService <IContainedCodeGenerator>(_viewBuffer); _parseData = null; _runtimeError.Close(); _viewBuffer.Changed -= TextBuffer_OnChanged; _viewBuffer.PostChanged -= TextBuffer_OnPostChanged; SetProvisionallyAcceptedState(false); _viewBuffer = null; if (_razorEditorParser != null) { _razorEditorParser.DocumentParseComplete -= DocumentParseComplete; _razorEditorParser.Close(); _razorEditorParser = null; } } }
public ShimRazorEditorParserImpl(string virtualPath, string physicalPath) { WebPageRazorHost razorWebPageRazorHost = ShimRazorEditorParserImpl.GetRazorWebPageRazorHost(virtualPath, physicalPath); HtmlSettings.Changed += OnSettingsChanged; razorWebPageRazorHost.DesignTimeMode = true; OnSettingsChanged(razorWebPageRazorHost); _codeDomProviderType = razorWebPageRazorHost.CodeLanguage.CodeDomProviderType; RazorEditorParser = new RazorEditorParser(razorWebPageRazorHost, physicalPath); RazorEditorParser.DocumentParseComplete += OnDocumentParseComplete; }
private RazorCodeGenerator(Microsoft.VisualStudio.Text.ITextBuffer buffer, Version razorVersion, string physicalPath, string virtualPath) { WebEditor.CompositionService.SatisfyImportsOnce(this); _parseData = new ParseData(); _viewBuffer = buffer; _viewBuffer.Changed += TextBuffer_OnChanged; _viewBuffer.PostChanged += TextBuffer_OnPostChanged; _htmlDocument = ServiceManager.GetService <HtmlEditorDocument>(_viewBuffer); _htmlDocument.OnDocumentClosing += OnClose; _htmlDocument.MassiveChangeEnded += OnMassiveChangeEnded; _fullPath = ((!string.IsNullOrEmpty(physicalPath)) ? physicalPath : "Default.cshtml"); if (virtualPath == null) { virtualPath = "Default.cshtml"; } _runtimeError = new RazorRuntimeError(_viewBuffer); _razorEditorParser = new ShimRazorEditorParserImpl(virtualPath, _fullPath); _razorEditorParser.DocumentParseComplete += DocumentParseComplete; ReparseFile(); WebEditor.OnIdle += OnFirstIdle; ServiceManager.AddService(this, _viewBuffer); ServiceManager.AddService <IRazorCodeGenerator>(this, _viewBuffer); ServiceManager.AddService <IContainedCodeGenerator>(this, _viewBuffer); }
private void Close() { if (_parseData == null) { return; } ParseData parseData = _parseData; lock (parseData) { _fullPath = null; _htmlDocument.OnDocumentClosing -= OnClose; _htmlDocument.MassiveChangeEnded -= OnMassiveChangeEnded; _htmlDocument = null; ServiceManager.RemoveService<RazorCodeGenerator>(_viewBuffer); ServiceManager.RemoveService<IRazorCodeGenerator>(_viewBuffer); ServiceManager.RemoveService<IContainedCodeGenerator>(_viewBuffer); _parseData = null; _runtimeError.Close(); _viewBuffer.Changed -= TextBuffer_OnChanged; _viewBuffer.PostChanged -= TextBuffer_OnPostChanged; SetProvisionallyAcceptedState(false); _viewBuffer = null; if (_razorEditorParser != null) { _razorEditorParser.DocumentParseComplete -= DocumentParseComplete; _razorEditorParser.Close(); _razorEditorParser = null; } } }
private RazorCodeGenerator(Microsoft.VisualStudio.Text.ITextBuffer buffer, Version razorVersion, string physicalPath, string virtualPath) { WebEditor.CompositionService.SatisfyImportsOnce(this); _parseData = new ParseData(); _viewBuffer = buffer; _viewBuffer.Changed += TextBuffer_OnChanged; _viewBuffer.PostChanged += TextBuffer_OnPostChanged; _htmlDocument = ServiceManager.GetService<HtmlEditorDocument>(_viewBuffer); _htmlDocument.OnDocumentClosing += OnClose; _htmlDocument.MassiveChangeEnded += OnMassiveChangeEnded; _fullPath = ((!string.IsNullOrEmpty(physicalPath)) ? physicalPath : "Default.cshtml"); if (virtualPath == null) { virtualPath = "Default.cshtml"; } _runtimeError = new RazorRuntimeError(_viewBuffer); _razorEditorParser = new ShimRazorEditorParserImpl(virtualPath, _fullPath); _razorEditorParser.DocumentParseComplete += DocumentParseComplete; ReparseFile(); WebEditor.OnIdle += OnFirstIdle; ServiceManager.AddService(this, _viewBuffer); ServiceManager.AddService<IRazorCodeGenerator>(this, _viewBuffer); ServiceManager.AddService<IContainedCodeGenerator>(this, _viewBuffer); }