Пример #1
0
                public void Emit(IXamlIlEmitter emitter)
                {
                    var so     = _parent._config.WellKnownTypes.Object;
                    var method = _parent._avaloniaObject
                                 .FindMethod(m => m.IsPublic && !m.IsStatic && m.Name == "SetValue"
                                             &&
                                             m.Parameters.Count == 3 &&
                                             m.Parameters[0].Equals(_parent._avaloniaPropertyType) &&
                                             m.Parameters[1].Equals(so) &&
                                             m.Parameters[2].IsEnum
                                             );

                    if (method == null)
                    {
                        throw new XamlIlTypeSystemException(
                                  "Unable to find SetValue(AvaloniaProperty, object, BindingPriority) on AvaloniaObject");
                    }
                    using (var loc = emitter.LocalsPool.GetLocal(_parent.PropertyType))
                        emitter
                        .Stloc(loc.Local)
                        .Ldsfld(_parent._field)
                        .Ldloc(loc.Local);

                    if (_parent.PropertyType.IsValueType)
                    {
                        emitter.Box(_parent.PropertyType);
                    }
                    emitter
                    .Ldc_I4(0)
                    .EmitCall(method);
                }