// Token: 0x060015FE RID: 5630 RVA: 0x0006D150 File Offset: 0x0006B350 public override string ConvertToString(object value, IValueSerializerContext context) { if (value == null) { return(string.Empty); } RoutedCommand routedCommand = value as RoutedCommand; if (routedCommand == null || !(null != routedCommand.OwnerType)) { throw base.GetConvertToException(value, typeof(string)); } if (CommandConverter.IsKnownType(routedCommand.OwnerType)) { return(routedCommand.Name); } if (context == null) { throw new InvalidOperationException(SR.Get("ValueSerializerContextUnavailable", new object[] { base.GetType().Name })); } ValueSerializer valueSerializerFor = context.GetValueSerializerFor(typeof(Type)); if (valueSerializerFor == null) { throw new InvalidOperationException(SR.Get("TypeValueSerializerUnavailable", new object[] { base.GetType().Name })); } return(valueSerializerFor.ConvertToString(routedCommand.OwnerType, context) + "." + routedCommand.Name + "Command"); }
// Token: 0x060015FC RID: 5628 RVA: 0x0006D0B4 File Offset: 0x0006B2B4 public override bool CanConvertToString(object value, IValueSerializerContext context) { if (context == null || context.GetValueSerializerFor(typeof(Type)) == null) { return(false); } RoutedCommand routedCommand = value as RoutedCommand; if (routedCommand == null || routedCommand.OwnerType == null) { return(false); } if (CommandConverter.IsKnownType(routedCommand.OwnerType)) { return(true); } string name = routedCommand.Name + "Command"; Type ownerType = routedCommand.OwnerType; string name2 = ownerType.Name; PropertyInfo property = ownerType.GetProperty(name, BindingFlags.Static | BindingFlags.Public); if (property != null) { return(true); } FieldInfo field = ownerType.GetField(name, BindingFlags.Static | BindingFlags.Public); return(field != null); }
// Token: 0x060015FF RID: 5631 RVA: 0x0006D230 File Offset: 0x0006B430 public override IEnumerable <Type> TypeReferences(object value, IValueSerializerContext context) { if (value != null) { RoutedCommand routedCommand = value as RoutedCommand; if (routedCommand != null && routedCommand.OwnerType != null && !CommandConverter.IsKnownType(routedCommand.OwnerType)) { return(new Type[] { routedCommand.OwnerType }); } } return(base.TypeReferences(value, context)); }
public override bool CanConvertToString(object value, IValueSerializerContext context) { if (context == null || context.GetValueSerializerFor(typeof(Type)) == null) { return(false); } // Can only convert routed commands RoutedCommand command = value as RoutedCommand; if (command == null || command.OwnerType == null) { return(false); } if (CommandConverter.IsKnownType(command.OwnerType)) { return(true); } else { string localName = command.Name + "Command"; Type ownerType = command.OwnerType; string typeName = ownerType.Name; // Get them from Properties PropertyInfo propertyInfo = ownerType.GetProperty(localName, BindingFlags.Public | BindingFlags.Static); if (propertyInfo != null) { return(true); } // Get them from Fields (ScrollViewer.PageDownCommand is a static readonly field FieldInfo fieldInfo = ownerType.GetField(localName, BindingFlags.Static | BindingFlags.Public); if (fieldInfo != null) { return(true); } } return(false); }
public override string ConvertToString(object value, IValueSerializerContext context) { if (value != null) { RoutedCommand command = value as RoutedCommand; if (null != command && null != command.OwnerType) { // Known Commands, so write shorter version if (CommandConverter.IsKnownType(command.OwnerType)) { return(command.Name); } else { ValueSerializer typeSerializer = null; if (context == null) { throw new InvalidOperationException(SR.Get(SRID.ValueSerializerContextUnavailable, this.GetType().Name)); } // Get the ValueSerializer for the System.Type type typeSerializer = context.GetValueSerializerFor(typeof(Type)); if (typeSerializer == null) { throw new InvalidOperationException(SR.Get(SRID.TypeValueSerializerUnavailable, this.GetType().Name)); } return(typeSerializer.ConvertToString(command.OwnerType, context) + "." + command.Name + "Command"); } } } else { return(string.Empty); } throw GetConvertToException(value, typeof(string)); }