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

  • SEARCH
  • Home
  • 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 6999485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:32:51+00:00 2026-05-27T20:32:51+00:00

I got the following code that generate a DLL (sample exemple) : public class

  • 0

I got the following code that generate a DLL (sample exemple) :

public class PluginClass
{
    private string _MyString;
    public string MyString
    {
        get { return _MyString; }
        set
        {
            _MyString = value;
            RaisePropertyChanged("MyString");
        }
    }

    public int MyInt;

    public SpeedGenerator SpeedGenerator1 = new SpeedGenerator();

    public GaugeValueGenerator GaugeValueGenerator1
    {
        get;
        set;
    }

    public PluginClass()
    {
        GaugeValueGenerator1 = new GaugeValueGenerator();
    }
}

As you can see I got 4 fields/properties.

1 primitive field (primitive is int/string/bool/etcetc…) : MyInt
1 primitive property : MyString
1 object field : SpeedGenerator1
1 object property : GaugeValueGenerator1

When Im parsing my DLL I got to do some code that is in the function : WriteProperty

var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
var props = type.GetProperties();

foreach (FieldInfo field in fields)
{
    WriteProperty(field.FieldType, field.Name, XXX);
}

foreach (PropertyInfo prop in props)
{
    WriteProperty(prop.PropertyType, prop.Name, XXX);
}

My question is on XXX that is a boolean that indicate if my field/property is “primitive”. So it must be set to false if it is an object.
I fell like I tried quite everything but I can’t resolve it…
Any help will be very appreciate !

(My idea was to call

var props = propertyType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

and consider that it should be empty for simple/primitive types ! But no… for example on String, this return the properties Chars (char[]) and Length (int)…)

(nb : Of course I don’t wanna do a string operation on field/property.Name/FullName… something like

if ((propertyType.FullName).Contains("System."))

would be very very sucky… and inaccurate)

  • 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-27T20:32:52+00:00Added an answer on May 27, 2026 at 8:32 pm

    Why not use IsPrimitive of the Type class?

    XXX = field.FiledType.IsPrimitive
    

    EDIT: You will have to treat string as a special case as IsPrimitive will not return true.

    EDIT 2: The problem you are having is that you are trying to marry two primitve definitions wich don’t match. Being that the case I can only see two options:

    1. Make both definitions match which obviously you can’t do changing the CLR type system and probably can’t do either changing the framework you are using.

    2. Make some hack that “marries” both definitions. I see no other way around hardcoding the specific exceptions that don’t match one of the two definitions of primitve types.

    • 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 :
Let's say that I got the following class and enum: public class MyModel {
I've got the following code that I am trying to use to access a
I've got the following bit of code (that another developer wrote) that I need
I have the following code and got myself confused: I have a query that
I've got the following bit of code that generates a list I'm trying to
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: char buffer[2047]; int charsRead; do { if(fscanf(file, %2047[^\n]%n%*c, buffer,
I got the following code inside an NSTimer selector: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2.0];

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.