Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Exploring WinRT's ApplicationDataContainer

, 6 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Ever wondered what's inside your ApplicationDataContainer?

Introduction

Have you ever wondered what values are inside your ApplicationDataContainerExtensions?

This extension method will print it out for you like this:

Root
   + Values
      TotalCorrectQuestions = 67
      PreviousGameMode = ArcadeSession
      CampaignDifficulty = Easy
      UserGuid = 2af8a846-1560-4697-87eb-358e6eafb4f6
      TotalQuestions = 82
      LastUsedLanguage = Français
   + Containers
      AzureSessions
         + Values
            demo = demo
            demo_nl = 5
      English
         + Containers
            TenseProfiles
               + Values
                  PastParticiple = False
                  SimplePast = True
            VerbProfiles
               + Values
                  to send = False
                  to take = False

Code use

<yourcontainer>.PrintToDebug();

Code

public static class ApplicationDataContainerExtensions
{
    public static void PrintToDebug(this ApplicationDataContainer adc)
    {
        PrintToDebug(0, adc);
    }

    private static void PrintToDebug(int padding, ApplicationDataContainer adc)
    {
        Debug.WriteLine(new string(' ', padding) + (string.IsNullOrEmpty(adc.Name) ? "Root" : adc.Name));

        if (adc.Values.Count > 1)
        {
            Debug.WriteLine(new string(' ', padding + 3) + "+ Values");
            foreach (var item in adc.Values)
            {
                Debug.WriteLine(new string(' ', padding + 6) + item.Key + " = " + item.Value);
            }
        }

        if (adc.Containers.Count > 0)
        {
            Debug.WriteLine(new string(' ', padding + 3) + "+ Containers");
            foreach (var item in adc.Containers)
            {
                PrintToDebug(padding + 6, item.Value);
            }
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinmemberEdo Tzumer5-Jan-13 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 6 Jan 2013
Article Copyright 2013 by Wouter Van Ranst
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid