예제 #1
0
        ///// <summary>
        ///// Dictionary where values are derived
        ///// from the prefedined dictionary value type
        ///// </summary>
        //[DataMember, ProtoMember(21)]
        //public ComplexObjectPolymorphicDictionary ComplexObjectDictionary { get; set; }

        ///// <summary>
        ///// Multidimensional array of generic object with polymorphic attribute
        ///// </summary>
        //[DataMember, ProtoMember(24)]
        //public GenericObject<ComplexObject>[,] MultiArrayOfGenericObjectWithPolymorphicArgument { get; set; }

        ///// <summary>
        ///// Array of objects where every item can be of other type
        ///// It is serialized as SingleDimensionalArrayProperty
        ///// </summary>
        //[DataMember, ProtoMember(25)]
        //public object[] SingleArrayOfObjects { get; set; }


        public static ComplexContainer[] CreateContainerArray(int itemCount)
        {
            var result = new List <ComplexContainer>();

            for (int i = 0; i < itemCount; i++)
            {
                result.Add(ComplexContainer.CreateFakeRoot());
            }
            return(result.ToArray());
        }
예제 #2
0
        public static ComplexContainer CreateFakeRoot()
        {
            var root = new ComplexContainer();

            root.SimpleSByte     = -33;
            root.SimpleInt       = 42;
            root.SimpleSingle    = -352;
            root.SimpleDouble    = 42.42;
            root.SimpleDateTime  = new DateTime(2004, 5, 5);
            root.SimpleTimeSpan  = new TimeSpan(5, 4, 3);
            root.SimpleEnum      = EnSimpleEnum.Three;
            root.FlagsEnum       = FlagEnum.Alfa | FlagEnum.Beta;
            root.SimpleDecimal   = Convert.ToDecimal(17.123);
            root.SimpleString    = "sth";
            root.EmptyString     = string.Empty;
            root.AdvancedStruct1 = new AdvancedStruct()
            {
                DateTime = new DateTime(2010, 4, 10), SimpleText = "nix"
            };

            //root.SingleArray = new[] { "ala", "ma", null, "kota" };
            //root.DoubleArray = new[,] { { "k1", "k2" }, { "b1", "b2" }, { "z1", "z2" } };

            root.PolymorphicSingleArray = new ComplexObject[] { new ComplexObject()
                                                                {
                                                                    SimpleInt = 999
                                                                } };

            root.GenericList = new List <string> {
                "item1", "item2", "item3"
            };
            root.GenericDictionary = new Dictionary <int, string>();
            root.GenericDictionary.Add(5, null);
            root.GenericDictionary.Add(10, "ten");
            root.GenericDictionary.Add(20, "twenty");

            root.GenericDictionaryOfPolymorphicValues = new Dictionary <int, ComplexObject>();
            root.GenericDictionaryOfPolymorphicValues.Add(2012, new ComplexObject()
            {
                SimpleInt = 2012000
            });

            root.ComplexObject1 = new ComplexObject {
                SimpleInt = 33
            };
            root.ComplexObjectCollection1 = new ComplexObjectPolymorphicCollection {
                new ComplexObject {
                    SimpleInt = 11
                }, new ComplexObject {
                    SimpleInt = 12
                }
            };
            //root.ComplexObjectDictionary = new ComplexObjectPolymorphicDictionary();
            //root.ComplexObjectDictionary.Add(100, new ComplexObject { SimpleInt = 101 });
            //root.ComplexObjectDictionary.Add(200, new ComplexObject { SimpleInt = 202 });
            //root.ComplexObjectDictionary.Add(300, null);

            root.GenericListOfComplexObjects = new List <ComplexObject> {
                new ComplexObject {
                    SimpleInt = 303
                }
            };
            root.GenericObjectOfComplexObject = new GenericObject <ComplexObject>(new ComplexObject {
                SimpleInt = 12345
            });

            //root.MultiArrayOfGenericObjectWithPolymorphicArgument = new GenericObject<ComplexObject>[1, 1];
            //root.MultiArrayOfGenericObjectWithPolymorphicArgument[0, 0] = new GenericObject<ComplexObject>() { Data = new ComplexObject() { SimpleInt = 1357 } };

            ////it contains objects of different types and a nested array
            //root.SingleArrayOfObjects = new object[] { 42, "nothing to say", false, BusinessObjects.SimpleEnum.Three, null, new object[] { 42, "nothing to say", false, BusinessObjects.SimpleEnum.Three, null } };

            return(root);
        }