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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:58:36+00:00 2026-05-24T12:58:36+00:00

I am using Sterling DB in a WP7 app and trying to implement a

  • 0

I am using Sterling DB in a WP7 app and trying to implement a custom serialiser for, hopefully, performance gains.

I’ll provide an example (excuse all formatting, trying to compress it to keep it small). Given a type that inherits List<string>:

public class TypedList : List<string>
{
    public Guid ObjectId { get; set; }

    public TypedList() {  }
    public TypedList(int count) : base(count) { }
}

And it’s serialiser:

public class TypedListSerializer : Wintellect.Sterling.Serialization.BaseSerializer
{
    public override bool CanSerialize(Type targetType)
    {
        return targetType.Equals(typeof(TypedList));   
    }

    public override object Deserialize(Type type, BinaryReader reader)
    {
        int count = reader.ReadInt32();
        var list = new TypedList(count);

        for (int i = 0; i < count; i++)
            list.Add(reader.ReadString());

        return list;
    }

    public override void Serialize(object target, BinaryWriter writer)
    {
        var list = (TypedList)target;
        writer.Write(list.Count);

        foreach (string s in list)
            writer.Write(s);
    }
}

I register the serialiser with the engine:

_engine = new SterlingEngine();
_engine.SterlingDatabase.RegisterSerializer<TypedListSerializer>();
_engine.Activate();

Assuming a table of TypedList types. Now when I try to save/load this type on the Sterling instance:

// _instance is a class that inherits BaseDatabaseInstance from the Sterling code.
_instance.Save<TypedList>(list);
_instance.Flush();
_instance.Load<TypedList>(g); // g is Guid.

It calls into CanSerialize, but the Type it is given is that of T from List<T>, the class I inherit from. If you change string to int, it tells me the type is an int.

Has anyone else had this problem? Is this a Sterling issue or one with type information on generics?

Update: as per Marc’s suggestion about inheritance, I amended my type to the following:

public class TypedList
{
    public Guid ObjectId { get; set; }
    public List<int> Items { get; set; }

    public TypedList() 
    {
        Items = new List<int>();
    }
}

What the serializer appears to be doing is checking the properties of TypedList instead of the type itself. I’m guessing this is now a fault with how I’m using Sterling. My table registration line looks like this:

protected override List<ITableDefinition> RegisterTables()
{
    return new List<ITableDefinition>
    {
        CreateTableDefinition<TypedList, Guid>(l => l.ObjectId)
    };
}
  • 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-24T12:58:36+00:00Added an answer on May 24, 2026 at 12:58 pm

    Just for what it’s worth – Sterling expects to be in full control of “top level” entities so it can build the keys, indexes, and other parts that it needs to function. That is why it never calls the custom serializer for the top-level entity (the one you define to have indexes and keys). The custom serializers are meant for properties off of those tables. The fix above is correct because it now sees the list as a property rather than the top level “item” it is trying to serialize.

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

Sidebar

Related Questions

Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using vs2008 .NET 3.5 SP1 I am trying to use an ActiveX dll in
As part of a larger web-app (using CakePHP), I'm putting together a simple blog
I've created an web authentication app using c# & asp.net and want to bounce
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
I have been writing a WP7 app and part of the functionality involves the
I'm trying to get Community.Csharp working with Windows Phone, I've tried using both the

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.