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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:54:18+00:00 2026-06-18T06:54:18+00:00

Can anyone point me to some full code samples of how to integrate the

  • 0

Can anyone point me to some full code samples of how to integrate the Glue framework into a project? I am attempting to use it a bit like AutoMapper in that I would hope to be able to register a bunch of conversions to Glue, then arbitrarily hand it two objects for it to figure out from there. The website gives a good idea of how to make individual mappings, but not how to integrate those into the project at large.

It would all be abstracted away, of course, so one could do a manual mapping if Glue became too slow or the mapping framework needed to change, but as it stands right now the main use-case I see is creating a lot of Glue.Converter.IConverter objects and having the IoC container of your choice inject them to wherever they are needed. This sounds fine, but our project will require dozens upon dozens of these zero-calorie objects if this is the procedure we use.

  • 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-06-18T06:54:19+00:00Added an answer on June 18, 2026 at 6:54 am

    This required a hell of a lot of finagling, but I took care of it.

    Using the TypeSwitch code to allow me to do some switching on type, I initially wrote out this code:

        public Mapping<Address, DatabaseAddress> DatabaseAddress { get; }
        public Mapping<T1, T2> GetMapping<T1, T2>()
        {
            Mapping<T1, T2> retMapping = null;
            TypeSwitch.Do(
                typeof (T1),
                TypeSwitch.Case<Address>(() =>
                    TypeSwitch.Do(
                        typeof (T2),
                        TypeSwitch.Case<DatabaseAddress>(() => retMapping = AddressToDatabaseAddressMapping)
                ));
    
            return returnedMapping;
        }
    

    retMapping = AddressToDatabaseAddressMapping was causing a compiler error because you can’t automatically assign Mapping<Address,DatabaseAddress> to Mapping<T1,T2>. Even if, heuristically, they are the same thing here, they’re not LOGICALLY the same thing.

    Turns out, you can effectively make C# operate as a dynamic language by leveraging the object type, though.

        public Mapping<Address, DatabaseAddress> DatabaseAddress { get; }
        public Mapping<T1, T2> GetMapping<T1, T2>()
        {
            object retMapping = null;
            TypeSwitch.Do(
                typeof (T1),
                TypeSwitch.Case<Address>(() =>
                    TypeSwitch.Do(
                        typeof (T2),
                        TypeSwitch.Case<DatabaseAddress>(() => retMapping = AddressToDatabaseAddress),
                ));
    
            var returnedMapping = (Mapping<T1, T2>) retMapping;
    
            return returnedMapping;
        }
    

    This is a little more verbose than it needs to be to show my point, but it’s interesting to note that at run-time, AddressToDatabaseAddress will maintain its identity even though its static type doesn’t imply it needs to. And since, heuristically, Mapping<T1, T2> IS Mapping<Address, DatabaseAddress>, it will assign itself properly at runtime and work perfectly.

    It is important to note that I had to add something onto TypeSwitch to make typeof(T1) and typeof(T2) work properly, however. The way it’s written by default, object source that is passed in is System.Type, which is not the behavior you want! However, adding an overload of:

        public static void Do(Type source, params CaseInfo[] cases)
        {
            foreach (var entry in cases.Where(entry => entry.IsDefault || entry.Target.IsAssignableFrom(source)))
            {
                entry.Action(source);
                break;
            }
        }
    

    Will make it behave as intended. Since the System.Type overload is more specific than the System.Object overload, the framework will prefer to use it. Makes TypeSwitch a little more sane for a common use-case, if someone prefers to throw in the type directly.

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

Sidebar

Related Questions

Can anyone point me to some documentation about how I can use an Iso
Can anyone point me towards some good documentation / code examples on how best
Can anyone point to some code that deals with the security of files access
This is what I have in mind: Can anyone point out some relevant resources?
Can anyone recommend a tutorial or point me in the direction of some easily
Can any one explain difference between position and anchor point in cocos-2D with some
Can Anyone point Me in the direction of how to tell when, for example,
Can anyone point me at an example of a customized Google Chrome Frame install
Can anyone point me toward a Go library that will give me the ability
can anyone point to a site or describe how I can go about designing

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.