Esempio n. 1
0
        public static Event[] ConvertEventClassifierTypeCollection(EventClassifierType[] remoteEvents)
        {
            Event[] localCopyOfEvents = new Event[remoteEvents.Length];

            for (int i = 0 ; i < localCopyOfEvents.Length ; i++)
            {
                localCopyOfEvents[i] = new Event();
                localCopyOfEvents[i].EventId = remoteEvents[i].Id;
                localCopyOfEvents[i].Name = remoteEvents[i].Name;
                localCopyOfEvents[i].DisplayOrder = remoteEvents[i].DisplayOrder;
                localCopyOfEvents[i].IsEnabledForMultiples = remoteEvents[i].IsEnabledForMultiples;

                // Is it possible to have an event
                //  with sub-events and collection of markets.
                if (remoteEvents[i].EventClassifiers != null)
                    localCopyOfEvents[i].Events = ConvertEventClassifierTypeCollection(remoteEvents[i].EventClassifiers);

                // Just in case it is possible don't use an else.
                if (remoteEvents[i].Markets != null)
                    localCopyOfEvents[i].Markets = MarketConverter.ConvertMarketTypeCollection(remoteEvents[i].Markets);
            }

            return localCopyOfEvents;
        }
Esempio n. 2
0
        private void AddEventsAndMarketsToThisNode(TreeNode nodeToAddTo, Event eventToExpand)
        {
            // Node text determined by:
            //  if event just display event name,
            //  if market include the string "Market: " before market name.

            // If there are any sub-events then add those.
            if (eventToExpand.Events != null)
                for (int i = 0; i < eventToExpand.Events.Length ; i++)
                {
                    // Create a new sub-event node.
                    TreeNode newEventNode = new TreeNode(eventToExpand.Events[i].Name);
                    newEventNode.Tag = eventToExpand.Events[i].EventId;

                    // Recursively add any sub-sub-events to our new sub-event.
                    AddEventsAndMarketsToThisNode(newEventNode, eventToExpand.Events[i]);

                    // Finally, add our new sub-event node to the original node.
                    nodeToAddTo.Nodes.Add(newEventNode);
                }

            // If there are any markets off our event node in question then add those.
            if (eventToExpand.Markets != null)
                for (int i = 0; i < eventToExpand.Markets.Length ; i++)
                {
                    TreeNode newMarketNode = new TreeNode("Market: " + eventToExpand.Markets[i].Name);
                    newMarketNode.Tag = eventToExpand.Markets[i].MarketId;
                    nodeToAddTo.Nodes.Add(newMarketNode);
                }
        }