Example #1
0
        public static void Unserialize(
                this XElement element
            ,   DataModelContext context
            ,   IUnserializeErrorReporter reporter
            ,   ref DataModelCollection<string> instance
            )
        {
            instance = new DataModelCollection<string> (context);

            if (element == null)
            {
                return;
            }

            foreach (var subElement in element.Elements (NodeName))
            {
                instance.Add (subElement.Value);
            }
        }
Example #2
0
        public static State UnserializeFromString(this string value)
        {
            if (value.IsNullOrWhiteSpace())
            {
                value = AppService.SampleData;
            }

            var doc = XDocument.Parse(value ?? "");

            var context = new DataModelContext
                              {
                                  IsSuppressingEvents = true
                              };

            State state = null;
            doc
                .Document
                .Elements(NodeName)
                .FirstOrDefault()
                .Unserialize(context, null, ref state)
                ;

            context.IsSuppressingEvents = false;

            return state;
        }
Example #3
0
        public static void Unserialize(
            this XElement element
            , DataModelContext context
            , IUnserializeErrorReporter reporter
            , ref bool instance
            )
        {
            if (element == null)
            {
                return;
            }

            instance = element.Value.Parse(SerializeCulture, false);
        }
Example #4
0
        public static void Unserialize(
            this XElement element
            , DataModelContext context
            , IUnserializeErrorReporter reporter
            , ref string instance
            )
        {
            if (element == null)
            {
                return;
            }

            instance = element.Value;
        }
Example #5
0
        State CreateEmptyState()
        {
            var context = new DataModelContext();
            var state = new State(context)
                            {
                                State_Lo            = 11.973429     ,
                                State_La            = 57.700324     ,
                                State_StationName   = "VALAND"      ,
                                State_ZoomLevel     = 18            ,
                            };

            var stations = CreateStations(state.Context, SampleData).ToArray();

            foreach (var station in stations)
            {
                state.State_Stations.Add(station);
            }

            return state;
        }
Example #6
0
        static IEnumerable<Station> CreateStations(
            DataModelContext context, 
            string xmlData
            )
        {
            var doc = XDocument.Parse(xmlData).Document;
            var markers = doc
                .Elements("carto")
                .Elements("markers")
                .Elements("marker")
                .ToArray();

            for (var index = 0; index < markers.Length; index++)
            {
                var marker = markers[index];
                var station = new Station(context)
                                  {
                                      Station_Name = marker.GetAttributeValue("name", "NoName"),
                                      Station_Number = marker.GetAttributeValue("number", "0").Parse(0),
                                      Station_Address = marker.GetAttributeValue("address", "NoAddress"),
                                      Station_FullAddress = marker.GetAttributeValue("fullAddress", "NoAddress"),
                                      Station_La = marker.GetAttributeValue("lat", "57.69").Parse(57.69),
                                      Station_Lo = marker.GetAttributeValue("lng", "11.95").Parse(11.95),
                                      Station_IsOpen = marker.GetAttributeValue("open", "0") == "1",
                                      Station_IsBonus = marker.GetAttributeValue("bonus", "0") == "1",
                                  };
                yield return station;
            }
        }
Example #7
0
 protected DataModelBase(DataModelContext context)
 {
     m_context = context;
 }