private void DoDefaultExpansion(TextBlock textBlock, object content, ContentPresenter container) { Debug.Assert(!(content is String) && !(content is UIElement)); // these are handled by different templates Inline inline; if ((inline = content as Inline) != null) { textBlock.Inlines.Add(inline); } else { bool succeeded = false; string stringFormat; XmlLanguage language = container.Language; System.Globalization.CultureInfo culture = language.GetSpecificCulture(); container.CacheLanguage(language); if ((stringFormat = container.ContentStringFormat) != null) { try { stringFormat = Helper.GetEffectiveStringFormat(stringFormat); textBlock.Text = String.Format(culture, stringFormat, content); succeeded = true; } catch (FormatException) { } } if (!succeeded) { TypeConverter tc = TypeDescriptor.GetConverter(ReflectionHelper.GetReflectionType(content)); TypeContext context = new TypeContext(content); if (tc != null && (tc.CanConvertTo(context, typeof(String)))) { textBlock.Text = (string)tc.ConvertTo(context, culture, content, typeof(string)); } else { Debug.Assert(!(tc != null && tc.CanConvertTo(typeof(UIElement)))); // this is handled by a different template textBlock.Text = String.Format(culture, "{0}", content); } } } }
// Token: 0x0600872F RID: 34607 RVA: 0x0024F1C0 File Offset: 0x0024D3C0 private void DoDefaultExpansion(TextBlock textBlock, object content, ContentPresenter container) { Inline item; if ((item = (content as Inline)) != null) { textBlock.Inlines.Add(item); return; } bool flag = false; XmlLanguage language = container.Language; CultureInfo specificCulture = language.GetSpecificCulture(); container.CacheLanguage(language); string text; if ((text = container.ContentStringFormat) != null) { try { text = Helper.GetEffectiveStringFormat(text); textBlock.Text = string.Format(specificCulture, text, new object[] { content }); flag = true; } catch (FormatException) { } } if (!flag) { TypeConverter converter = TypeDescriptor.GetConverter(ReflectionHelper.GetReflectionType(content)); ContentPresenter.DefaultTemplate.TypeContext context = new ContentPresenter.DefaultTemplate.TypeContext(content); if (converter != null && converter.CanConvertTo(context, typeof(string))) { textBlock.Text = (string)converter.ConvertTo(context, specificCulture, content, typeof(string)); return; } textBlock.Text = string.Format(specificCulture, "{0}", new object[] { content }); } }