These are chat archives for AvaloniaUI/Avalonia

21st
Jan 2016
Ivan Kochurkin
@KvanTTT
Jan 21 2016 09:56
Hello! I want to implement new shapes as Polygon and Polyline (as I already did it for Perspex/Perspex#393). They use PointCollection. What is the best way to implement this Collection? Is it possible to use just enough List<Point>?
Steven Kirk
@grokys
Jan 21 2016 11:11
yeah, i think so. i thought for a second that PointCollection in WPF implemented INotifyCollectionChanged but it doesn't seem to
so I think List<Point> is the closest
perhaps make the property an IList<Point> so that arrays can be assigned to it too?
Ivan Kochurkin
@KvanTTT
Jan 21 2016 11:16
@grokys, yes, good idea.
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:38
hi, does someone know is it possible to convert System.Array to List<?> using reflection?
I mean that I have no possibility to set type explicitly, but I have a type I want convert to
Steven Kirk
@grokys
Jan 21 2016 11:40
array.ToList()?
also Array implements IList<T>
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:40
its not generic Array and it has no such method
I created array through this method: Array.CreateInstance
Steven Kirk
@grokys
Jan 21 2016 11:42
can't you just cast it to the correct type? e.g. (int[])Array.CreateInstance(typeof(int), 0)?
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:43
No, because I want to be that method common and it could create instance of any type.
I just create Array from type and everything is ok, until I need to assign it to typed array
Steven Kirk
@grokys
Jan 21 2016 11:44
ok, so your type is decided at runtime?
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:44
yes
Steven Kirk
@grokys
Jan 21 2016 11:44
you'll need to use reflection all the way then unfortunately
as you said
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:45
but how exactly? I didnt found example yet.
and one interesting thing. For example I have int[] and my System.Array of type int[]
but CLR does not allow ne to copy Syste,.Array to int[] without explicit convertion
why?
in debugger I see that created from Array.CreateInstance(typeof(int), 0) array has correct type, but I cannot use it - I have no access to the elements as I created an array of objects and not array of ints
Steven Kirk
@grokys
Jan 21 2016 11:49
because at compile time you just have an untyped Array
one way might be to use dynamic?
otherwise you'll need to use reflection to cast the array
but i don't understand how you expect it to work if you don't know the concrete type
what is the signature of the method receiving the array for example?
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:51
I know concrete type as I store it in Type variable
Steven Kirk
@grokys
Jan 21 2016 11:51
that's not a compile-type type
that's a runtime type
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:51
the thing is that if I will use explicit typing I must create 10 different methods for the same action
and in this solution - only one method
Steven Kirk
@grokys
Jan 21 2016 11:52
what is the signature of the method?
Mohamed MEDIOUNI
@kika123
Jan 21 2016 11:52
And can Perspex have compatibility with WPF?
Steven Kirk
@grokys
Jan 21 2016 11:53
@kika123 how much compatibility?
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 11:54
method contains <T> and as far as I know I cannot set it in runtime. I need to set it explicit. So, I decide to use reflection with runtime typing
Mohamed MEDIOUNI
@kika123
Jan 21 2016 11:54
@grokys enough to run modern SharpDevelop for example(later than 3.2). Windows on ARM only has Windows Forms and WindowsBase, but not PresentationCore
Steven Kirk
@grokys
Jan 21 2016 12:03
@QuantumDeveloper you might have better luck if you posted a stackoverflow question with more details - it's a bit hard to understand your requirements here
@kika123 i don't know sharpdevelop well enough to say
but perspex isn't a reimplementation of WPF
it's similar in a lot of ways
but it doesn't implement the same API
tried that, it was depressing ;)
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 12:09
@grokys ok, I have a lot of structure types for my vertex buffers. And not to create switch or if/else statements for each type to get vertex buffer data with GetData<T>, I created GetData(Type t) method and use runtype array creation for holding vertex buffer array. But as far as I have a lot of different structs for using with that buffer, I want to have concrete type at the end. One way to use dynamic and If I assingn something like: MyVertex[] = GetData(Type t) it will work as expected, but if I have no explicit array and I make: `GetData(Type t) I will receive System.Array, which I must cast to explicit type to use elements inside it and here is the problem
seems there is no solution for that, right?
Steven Kirk
@grokys
Jan 21 2016 12:12
couldn't you make the method T[] GetData<T>()?
Denis Zaporozhets
@QuantumDeveloper
Jan 21 2016 12:13
I already have it, but in that case I need to make if/else to set correct type inside <T>
because it cannot be made at runtime
dynamically
Nikita Tsukanov
@kekekeks
Jan 21 2016 17:32
Don't play much with runtime services
You might lose iOS compatibility this way
Nikita Tsukanov
@kekekeks
Jan 21 2016 21:10
Guys
If we want to support .NET Core
we need to remove dependency on Splat
@grokys @SuperJMN
Splat uses bait&switch approach
So we can't run it in .NET core
at all
oh
nvm
they have NetCore45 dir in nuget package
Steven Kirk
@grokys
Jan 21 2016 21:15
Well RX doesn't have support for .net core yet afaik so we'll be waiting a while anyway
Nikita Tsukanov
@kekekeks
Jan 21 2016 21:51
Ehm
We are using stripped version compiled for Profile7
So our version does support .NET Core
Steven Kirk
@grokys
Jan 21 2016 22:01
I was assuming that this meant it wasn't supported:Reactive-Extensions/Rx.NET#148
Nikita Tsukanov
@kekekeks
Jan 21 2016 22:02
Yep, they also don't support desktop mono
so what
it only means that they are jerks
Oh, wait
its rx, not rxui
Rx itself has PCL lib
That actually does its job
.NET Core can load pcl
Steven Kirk
@grokys
Jan 21 2016 23:18
I don't know - that issue suggests to me that our doesn't work