windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

How to iterate only over properties that don’t belong to base class

Asked By: Anonymous

I have the following generic class:

public class TestGenericRenderer<TXamarinView, TNativeView>
    : ViewRenderer<TXamarinView, TNativeView>

    where TXamarinView : Xamarin.Forms.VisualElement
    where TNativeView : System.Windows.FrameworkElement
    protected override void OnElementChanged(ElementChangedEventArgs<TXamarinView> e)

        if (Control == null)
            var xamarinType = e.NewElement.GetType();
            var nativeView = Activator.CreateInstance(typeof(TNativeView));
            var nativeProps = nativeView.GetType().GetProperties();
            foreach (var prop in xamarinType.GetProperties())
                var corrProp = nativeProps.FirstOrDefault(x => x.Name == prop.Name);
                if (corrProp != null)
                        corrProp.SetValue(nativeView, prop.GetValue(e.NewElement));
                    catch { }

When iterating through the properties of xamarinType, I want to only get the properties that weren’t declared in classes it inherits, otherwise there will be type mismatches (and therefore it only works thanks to the try-catch hack)

How can I skip these properties?


Answered By: Anonymous

Use the BindingFlags.DeclaredOnly flag to get only properties declared by the target type:

    BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno