public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as GACFileVM; var s = parameter as string; if (vm == null || s == null) { return(null); } var gen = ColorizedTextElementProvider.Create(vm.Owner.SyntaxHighlight); var printer = new GACFilePrinter(gen.Output); if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name")) { printer.WriteName(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Version")) { printer.WriteVersion(vm); } else { return(null); } return(gen.CreateResult(true)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as GACFileVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new GACFilePrinter(writer); if (tag == PredefinedTextClassifierTags.GacDialogName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.GacDialogVersion) { printer.WriteVersion(vm); } else { return(null); } var context = new OpenFromGACTextClassifierContext(vm.Owner.SearchText, writer.Text, tag, vm.Owner.SyntaxHighlight, writer.Colors); return(vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.GacDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as GACFileVM; var tag = parameter as string; if (vm == null || tag == null) return null; var writer = Cache.GetWriter(); try { var printer = new GACFilePrinter(writer); if (tag == PredefinedTextClassifierTags.GacDialogName) printer.WriteName(vm); else if (tag == PredefinedTextClassifierTags.GacDialogVersion) printer.WriteVersion(vm); else return null; var context = new OpenFromGACTextClassifierContext(vm.Owner.SearchText, writer.Text, tag, vm.Owner.SyntaxHighlight, writer.Colors); return vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.GacDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis); } finally { Cache.FreeWriter(writer); } }