Example #1
0
        public static Class1 CreateTestInstance()
        {
            Class2 c2c = new Class2() { Foo = "foo C", Bar = null }; // automatic serialization
            Class3 c3 = new Class3() { OneString = "lowercase", SharedClass2Res = c2c }; // manual reader/writer serialization
            Class2 c2a = new Class2() { Foo = "foo A", Bar = c3 }; // automatic serialization
            Class2 c2b = new Class2() { Foo = "foo B", Bar = c3 }; // automatic serialization

            Class1 c1 = new Class1(); // automatic serialization
            c1.SimpleString = "This is indeed a string";
            c1.privateField = "A private field"; // but serialized!
            c1.IgnoredString = "An ignored one"; // ignored
            c1.AnotherString = "Another string"; // <BasicString>..
            c1.StringList = new List<string>(new string[] {"a", "b", "c"}); // <ListOfStrings><StringItem>..
            c1.Class2Resource = c2a; // embedded
            c1.SharedClass2Resource = c2a; // shared
            c1.SharedClass2ResourceAgain = c2a; // shared
            c1.SharedClass2ResourceAnother = c2c; // shared
            c1.Class2List = new List<Class2>(new Class2[] { c2a, c2b });
            c1.SharedClass2List = new SharedResourceList<Class2>(new Class2[] { c2a, c2c });
            c1.SharedClass3Resource = c3;
            c1.OptionalNumber = 42;
            c1.AssetName = "c1"; // SerialDataBase

            return c1;
        }
Example #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load<SpriteFont>("SpriteFont1");

            // c1
            string assetName = "c1";
            c1 = Content.Load<Class1>(assetName);
            if (c1 != null)
                c1.AssetName = assetName;

            // text
            text = "Couldn't deserialize .XNB file with custom type!";
            if (c1 != null)
                text = c1.GetDebugInfo();
        }