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 1927984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:55:29+00:00 2026-05-17T06:55:29+00:00

Basically I would like to do something like this at the top of my

  • 0

Basically I would like to do something like this at the top of my class (I know this doesn’t work as it isn’t a constant)….

[XmlStorage(IsSingleStorageFile = false, IsSubordinate = true,
StorageLocation = "posts" + GetBlogId()]

Where GetBlogId() would be a static utility method.

I’m building an xml storage framework for a blogging engine I am writing (partly a learning excercise, partly as I want to give something back to the open source) and I thought that the tidiest way to determine the storage location would be to use custom attributes since I would be to use a datacontractserializer anyway.

My only problem at present is determining the location for subordinate type whose location would be determined by the id of their parent. e.g Post < Blog.

My storage path would be something like this…

posts\blogid\postid.xml

Where the blog id would be determined by parsing the url and returning the associated blog. This would allow me to host multiple blogs in one installation whilst keeping post storage files separate to reduce memory overheads when loading posts.

Is this a straight no or is there a better way for me to do what I am attempting?

Edit:

Following John answer I tried this….

 private static string GetSubordinatePath(Type type)
    {
        if (typeof(ISubordinate).IsAssignableFrom(type))
        {
            object instance = Activator.CreateInstance(type);
            return (instance as ISubordinate).ParentGuid.ToString();
        }
        else
        {
            // TODO: Localize this.
            throw new ArgumentException(
            String.Format(
            CultureInfo.CurrentCulture,
            "The specified type '{0}' does not impliment the ISubordinate interface. Please edit the source appropriately to enable storage.",
            type.GetType().Name));
        }
    }

Which would be called from the class reading the custom attribute.

This works nicely..

  • 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-17T06:55:30+00:00Added an answer on May 17, 2026 at 6:55 am

    It’s a straight no for attributes… the values are constants baked into the metadata.

    One option you could use would be to have some sort of templating built into whatever uses the attributes… so you could have a storage location of posts\{GetBlogId()} and call the method at execution time. It’s not exactly elegant though… you might want to consider using an interface instead.

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

Sidebar

Related Questions

Basically I would like to do something like this: $(#whatever).css(bottom, -=40); $(#whatever).css(top, +=40); I
I would just like your feedback on something. Basically I have a value called
Would it be possible to do something like the following in c#? Basically TParent
Basically I would like to store the address of a pointer in a buffer.
Basically I would like to tell MSTest to execute a bit of code before
Having another tough one here guys, basically I would like to check if a
I would like to basically get all the events that i get invited to
I would like to create a custom data type which basically behaves like an
I would like to set a variable in bash called test_var Basically, I want
I would like to add a preprocessor to HTML pages. Basically, I have a

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.