Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:13:27+00:00 2026-05-26T14:13:27+00:00

I got the following code to generate a DLL : public class QtObject :

  • 0

I got the following code to generate a DLL :

public class QtObject : DependencyObject
{
    public int speedSimu
    {
        get { return (int)GetValue(speedSimuProperty); }
        set { SetValue(speedSimuProperty, value); }
    }
    public static readonly DependencyProperty speedSimuProperty =
        DependencyProperty.Register("speedSimu", typeof(int), typeof(QtObject), new PropertyMetadata(0));

    public int rpmSimu
    {
        get { return (int)GetValue(rpmSimuProperty); }
        set { SetValue(rpmSimuProperty, value); }
    }
    public static readonly DependencyProperty rpmSimuProperty =
        DependencyProperty.Register("rpmSimu", typeof(int), typeof(QtObject), new PropertyMetadata(0));

    public int nbSimu;
}

public class Timer : DependencyObject
{
    public string description
    {
        get { return (string)GetValue(descriptionProperty); }
        set { SetValue(descriptionProperty, value); }
    }
    public static readonly DependencyProperty descriptionProperty =
        DependencyProperty.Register("description", typeof(string), typeof(Timer), new PropertyMetadata("This is a time"));

    public bool isActive
    {
        get { return (bool)GetValue(isActiveProperty); }
        set { SetValue(isActiveProperty, value); }
    }
    public static readonly DependencyProperty isActiveProperty =
        DependencyProperty.Register("isActive", typeof(bool), typeof(Timer), new PropertyMetadata(true));
}

public class AnotherClass
    {
        //blaaa
    }

I now would like to ONLY get DependencyObject/Properties. (ie without property “nbSimu” and without object “AnotherClass”)

Here is the code I have :

var library = Assembly.LoadFrom(libraryPath);
IEnumerable<Type> types = library.GetTypes();
var libs = types.Where(t => true);

foreach (Type type in libs)
{
    foreach (PropertyInfo property in type.GetProperties())
    {
        //TODO
   }
}

On the 3rd line I tried :

var libs = types.Where(t => t.BaseType == typeof(DependencyObject));

It doesn’t say any error, but doesn’t filter anything…

And about filtering the DependencyProperties, I just got no idead about how to do it…

Thanks in advance for any help on it, on both problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:13:27+00:00Added an answer on May 26, 2026 at 2:13 pm

    It works on my comp.

    public class A : DependencyObject
        {
          public string Name { get; set; }
    
          public int speedSimu
          {
            get { return (int)GetValue(speedSimuProperty); }
            set { SetValue(speedSimuProperty, value); }
          }
          public static readonly DependencyProperty speedSimuProperty =
              DependencyProperty.Register("speedSimu", typeof(int), typeof(A), new PropertyMetadata(0));
    
          public int rpmSimu
          {
            get { return (int)GetValue(rpmSimuProperty); }
            set { SetValue(rpmSimuProperty, value); }
          }
          public static readonly DependencyProperty rpmSimuProperty =
              DependencyProperty.Register("rpmSimu", typeof(int), typeof(A), new PropertyMetadata(0));
    
        }
    
        public class B : A
        {
          public int Age { get; set; }
        }
    
        private static void Main(string[] args)
        {
          var assembly = Assembly.GetExecutingAssembly();
          var types = assembly.GetTypes();
    
          var filterTypes = types.Where(t => typeof (DependencyObject).IsAssignableFrom(t)).ToList(); // A and B
    
          Func<string, string> mapFieldToProperty =
            field => field.EndsWith("Property") ? field.Remove(field.IndexOf("Property")) : field;
    
    
          foreach (var type in filterTypes)
          {
            var depFields =
              type.GetFields(BindingFlags.Public | BindingFlags.Static).Where(
                f => typeof (DependencyProperty).IsAssignableFrom(f.FieldType)).ToList(); // speedSimuProperty and rpmSimuProperty
            var depPropertyNames = depFields.ToLookup(f => mapFieldToProperty(f.Name)); 
    
            var depProperties =
              type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(
                prop => depPropertyNames.Contains(prop.Name)).ToList(); // speedSimu and rpmSimu
    
            foreach (var property in depProperties)
            {
              // TODO
            }
    
          }
          return;
        }
    

    What about second problem.. you should keep to naming convention of your properties/fields

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the following code that generates a DLL : public class MyObject :
I got the following code: char buffer[2047]; int charsRead; do { if(fscanf(file, %2047[^\n]%n%*c, buffer,
Let's say that I got the following class and enum: public class MyModel {
I got following code in an XHTML-document and every browser saysit is malformed :(
Ive got the following code which I hacked together from website examples. It works
I got the following code inside an NSTimer selector: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2.0];
I've got the following code to end a process, but I still receive an
I have got the following code from here to read an Excel file using
I've got the following code that I am trying to use to access a
i've got the following code which runs a bat file. the bat file then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.