private void Logic_AddToParentDictionary(ObjectWriterContext ctx, object key, object value) { if (ctx.CurrentKeyIsUnconverted && !ctx.ParentShouldNotConvertChildKeys) { if (!ctx.ParentShouldConvertChildKeys) { try { this.Runtime.AddToDictionary(ctx.ParentCollection, ctx.ParentType, value, ctx.CurrentType, key); ctx.ParentShouldNotConvertChildKeys = true; return; } catch (XamlObjectWriterException exception) { if (!(exception.InnerException is ArgumentException) && !(exception.InnerException is InvalidCastException)) { throw; } Debugger.IsLogging(); } ctx.ParentShouldConvertChildKeys = true; } ctx.CurrentProperty = XamlLanguage.Key; ctx.PushScope(); ctx.CurrentInstance = key; this.Logic_CreatePropertyValueFromValue(ctx); key = ctx.CurrentInstance; ctx.PopScope(); ctx.CurrentProperty = null; } this.Runtime.AddToDictionary(ctx.ParentCollection, ctx.ParentType, value, ctx.CurrentType, key); }
private void Logic_CreateFromInitializationValue(ObjectWriterContext ctx) { XamlType parentType = ctx.ParentType; XamlValueConverter<TypeConverter> typeConverter = parentType.TypeConverter; object currentInstance = ctx.CurrentInstance; object obj3 = null; if (parentType.IsUnknown) { string message = System.Xaml.SR.Get("CantCreateUnknownType", new object[] { parentType.GetQualifiedName() }); throw this.WithLineInfo(new XamlObjectWriterException(message)); } if (typeConverter == null) { throw this.WithLineInfo(new XamlObjectWriterException(System.Xaml.SR.Get("InitializationSyntaxWithoutTypeConverter", new object[] { parentType.GetQualifiedName() }))); } obj3 = this.Logic_CreateFromValue(ctx, typeConverter, currentInstance, null, parentType.Name); ctx.PopScope(); ctx.CurrentInstance = obj3; ctx.CurrentIsTypeConvertedObject = true; if (!(obj3 is NameFixupToken)) { if (parentType.IsCollection || parentType.IsDictionary) { ctx.CurrentCollection = obj3; } this.Logic_ApplyCurrentPreconstructionPropertyValues(ctx, true); } }
private object Logic_PushAndPopAProvideValueStackFrame(ObjectWriterContext ctx, XamlMember prop, MarkupExtension me, bool useIRME) { XamlMember currentProperty = ctx.CurrentProperty; ctx.CurrentProperty = prop; ctx.PushScope(); ctx.CurrentInstance = me; object obj2 = null; if (useIRME) { this.Logic_AssignProvidedValue(ctx); } else { obj2 = this.Runtime.CallProvideValue(me, ctx.ServiceProviderContext); } ctx.PopScope(); ctx.CurrentProperty = currentProperty; return obj2; }