Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public override BaseDoc Read(string DocData, bool DocRevStrict = false)
        {
            if (string.IsNullOrWhiteSpace(DocData))
            {
                return(null);
            }

            DocProcessingInstructions pi = ReadDocPI(DocData);

            string
                CollapsedElementsDocXml,
                DocTypeName = ReadDocTypeName(DocData),
                DocRev      = ReadDocRev(DocData);

            if (string.IsNullOrWhiteSpace(DocTypeName))
            {
                DocTypeName = pi.DocTypeName;
            }

            if (string.IsNullOrWhiteSpace(DocRev))
            {
                DocRev = pi.solutionVersion;
            }

            CollapsedElementsDocXml = CollapseDefaultValueElements(DocData, DocTypeName);

            BaseDoc dstBaseDoc = null;

            Type BaseDocType = Runtime.ActivateBaseDocType(
                DocTypeName,
                DocRevStrict
                    ? DocRev
                    : TemplateController.Instance.TopDocRev(DocTypeName));

            using (StringReader _StringReader = new StringReader(CollapsedElementsDocXml))
                using (XmlTextReader _XmlTextReader = new XmlTextReader(_StringReader))
                {
                    return(SetPI(
                               (BaseDoc) new XmlSerializer(BaseDocType).Deserialize(_XmlTextReader),
                               pi,
                               DocTypeName,
                               DocRev));
                }
        }