Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="proxy">XML proxy.</param>
        /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception>
        internal ProductionRequest(XsdNs.ProductionRequestType proxy)
        {
            SegmentRequirements = new List <SegmentRequirement>();

            try
            {
                // Read identifier
                if (proxy.ID != null)
                {
                    Identifier = new IdentifierType(proxy.ID);
                }

                // Read hierarchy scope
                if (proxy.HierarchyScope != null)
                {
                    HierarchyScopeObj = new HierarchyScope(proxy.HierarchyScope); // throws InvalidMessageException
                }

                // Read segment requirements
                if (proxy.SegmentRequirement != null)
                {
                    foreach (var segReq in proxy.SegmentRequirement)
                    {
                        SegmentRequirements.Add(new SegmentRequirement(segReq)); // throws InvalidMessageException
                    }
                }

                // Read scheduling parameters
                if (proxy.SchedulingParameters != null)
                {
                    try
                    {
                        // Expecting a data record in an XML node array
                        SchedulingParameters = (SXml.XmlNode[])proxy.SchedulingParameters;
                    }
                    catch (InvalidCastException e)
                    {
                        throw new XNeut.InvalidMessageException("Unexpected type of scheduling parameters", e);
                    }
                }
            }
            catch (NullReferenceException e)
            {
                var msg = string.Format("Failed to read ProductionRequest {0} - something required is missing", TryGetIdString());
                throw new XNeut.InvalidMessageException(msg, e);
            }
            catch (XNeut.InvalidMessageException e)
            {
                var msg = string.Format("Failed to read ProductionRequest {0}: {1}", TryGetIdString(), e.Message);
                throw new XNeut.InvalidMessageException(msg, e);
            }
        }
Exemple #2
0
        private XsdNs.ProductionRequestType[] BuildProductionRequestsForProxy(out ICollection <Type> extraTypes)
        {
            var extraTypesSet = new HashSet <Type>();
            var retval        = new XsdNs.ProductionRequestType[ProductionRequests.Count];

            for (int a = 0; a < ProductionRequests.Count; ++a)
            {
                retval[a] = ProductionRequests[a].ToXmlProxy(out ICollection <Type> extraTypesTemp);

                // Add any new extra types
                extraTypesSet.UnionWith(extraTypesTemp);
            }

            extraTypes = extraTypesSet;
            return(retval);
        }