Click here to Skip to main content
12,692,778 members (36,770 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.3K views
1 bookmarked
Posted

Exploring WinRT's ApplicationDataContainer

, 6 Jan 2013 CPOL
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

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
Edo Tzumer5-Jan-13 22:31
memberEdo Tzumer5-Jan-13 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 6 Jan 2013
Article Copyright 2013 by Wouter Van Ranst
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid