本文整理汇总了C#中IViewContent.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# IViewContent.GetService方法的具体用法?C# IViewContent.GetService怎么用?C# IViewContent.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IViewContent
的用法示例。
在下文中一共展示了IViewContent.GetService方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
void Init(IViewContent view)
{
this.view = view;
editable = view.GetService<IEditable>();
textEditor = view.GetService<ITextEditor>();
textEditorOptions = textEditor.Options;
}
示例2: SetPosition
public static void SetPosition(IViewContent viewContent, int markerStartLine, int markerStartColumn, int markerEndLine, int markerEndColumn)
{
if (viewContent == null)
return;
ITextEditor editor = viewContent.GetService<ITextEditor>();
if (editor != null) {
SetPosition(editor.FileName, editor.Document, markerStartLine, markerStartColumn, markerEndLine, markerEndColumn);
}
}
示例3: FromWindow
internal static Document FromWindow(IViewContent viewContent)
{
if (viewContent == null)
return null;
ITextEditor editor = viewContent.GetService(typeof(ITextEditor)) as ITextEditor;
if (editor != null) {
return new Document(viewContent, editor.Document);
} else {
return null;
}
}
示例4: Save
internal static void Save(IViewContent content)
{
if (content != null && content.IsDirty) {
var customizedCommands = content.GetService<ICustomizedCommands>();
if (customizedCommands != null && customizedCommands.SaveCommand()) {
return;
}
if (content.IsViewOnly) {
return;
}
foreach (OpenedFile file in content.Files.ToArray()) {
if (file.IsDirty)
Save(file);
}
}
}
示例5: CanAttachTo
public bool CanAttachTo(IViewContent content)
{
if (Path.GetExtension(content.PrimaryFileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase)) {
IEditable editable = content.GetService<IEditable>();
if (editable != null) {
try {
XmlTextReader r = new XmlTextReader(editable.CreateSnapshot().CreateReader());
r.XmlResolver = null;
r.WhitespaceHandling = WhitespaceHandling.None;
while (r.NodeType != XmlNodeType.Element && r.Read());
if (r.LocalName == "ResourceDictionary" || r.LocalName == "Application" || r.LocalName == "Activity")
return false;
} catch (XmlException) {
return true;
}
return true;
}
}
return false;
}
示例6: CanAttachTo
public bool CanAttachTo(IViewContent viewContent)
{
ITextEditor textEditor = viewContent.GetService<ITextEditor>();
if (textEditor == null)
return false;
FileName fileName = viewContent.PrimaryFileName;
if (fileName == null)
return false;
var parsedFile = SD.ParserService.ParseFile(fileName, textEditor.Document);
var compilation = SD.ParserService.GetCompilationForFile(fileName);
return IsDesignable(parsedFile, compilation);
}
示例7: GetText
string GetText(IViewContent view)
{
ITextEditor textEditor = view.GetService<ITextEditor>();
return textEditor.Document.Text;
}
示例8: ShowCodeCoverage
static void ShowCodeCoverage(IViewContent view)
{
ITextEditor textEditor = view.GetService<ITextEditor>();
if (textEditor != null && view.PrimaryFileName != null) {
ShowCodeCoverage(textEditor, view.PrimaryFileName);
}
}
示例9: LoadViewContentMemento
void LoadViewContentMemento(IViewContent viewContent)
{
IMementoCapable mementoCapable = viewContent.GetService<IMementoCapable>();
if (mementoCapable != null && LoadDocumentProperties) {
if (viewContent.PrimaryFileName == null)
return;
try {
string key = GetMementoKeyName(viewContent);
LoggingService.Debug("Trying to restore memento of '" + viewContent.ToString() + "' from key '" + key + "'");
mementoCapable.SetMemento(this.LoadOrCreateViewContentMementos().NestedProperties(key));
} catch (Exception e) {
MessageService.ShowException(e, "Can't get/set memento");
}
}
}
示例10: StoreMemento
/// <summary>
/// Stores the memento for the view content.
/// Such mementos are automatically loaded in ShowView().
/// </summary>
public void StoreMemento(IViewContent viewContent)
{
IMementoCapable mementoCapable = viewContent.GetService<IMementoCapable>();
if (mementoCapable != null && LoadDocumentProperties) {
if (viewContent.PrimaryFileName == null)
return;
string key = GetMementoKeyName(viewContent);
LoggingService.Debug("Saving memento of '" + viewContent.ToString() + "' to key '" + key + "'");
Properties memento = mementoCapable.CreateMemento();
Properties p = this.LoadOrCreateViewContentMementos();
p.SetNestedProperties(key, memento);
FileUtility.ObservedSave(new NamedFileOperationDelegate(p.Save), this.ViewContentMementosFileName, FileErrorPolicy.Inform);
}
}
示例11: IsViewTextEditorProvider
bool IsViewTextEditorProvider(IViewContent view)
{
return view.GetService<ITextEditor>() != null;
}
示例12: GetMemento
static Properties GetMemento(IViewContent viewContent)
{
IMementoCapable mementoCapable = viewContent.GetService<IMementoCapable>();
if (mementoCapable == null) {
return null;
} else {
return mementoCapable.CreateMemento();
}
}