static unsafe F createUnsafe(ref MyStruct s1, int x)
{
// почему нету такого типа
// const int _x =x;
F d = (ref MyStruct s) =>
{
//x же константа, и никуда не убежит
//s.x = _x; // есть ли способы?
// по факту сюда просто Il-команду Ldc.I4 n вставить надо
};
return (d);
}
public class UpdateCanvasListener
{
public Action Update { get; private set; }
public EventHandler< SKPaintSurfaceEventArgs> PaintHandler;
public UpdateCanvasListener(EventHandler<SKPaintSurfaceEventArgs> handler)
{
PaintHandler = handler;
}
}
class canvas{
public readonly static DependencyProperty SurfaceListenerProperty
= DependencyProperty.Register(nameof(SurfaceListener),
typeof(UpdateCanvasListener), typeof(FieldCanvas),
new PropertyMetadata(null, new PropertyChangedCallback(initSurfacePaintCommand)));
private static void initSurfacePaintCommand(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
FieldCanvas obj = (FieldCanvas)d;
var handlerOwner = e.NewValue as UpdateCanvasListener;
obj.PaintSurface += handlerOwner?.PaintHandler;
handlerOwner?.GetType().GetProperty("Update", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)?
.SetValue(handlerOwner, obj.InvalidateVisual };
}
}
Почему именно за 100 итераций? Для вычисления конечного значения итерации не нужны, и вы это понимаете, потому что сначала правильно пишите: