System.Data.DataSet.InferSchema C# (CSharp) Method

InferSchema() private method

private InferSchema ( XmlDocument xdoc, string excludedNamespaces, XmlReadMode mode ) : void
xdoc System.Xml.XmlDocument
excludedNamespaces string
mode XmlReadMode
return void
        internal void InferSchema(XmlDocument xdoc, string[] excludedNamespaces, XmlReadMode mode)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.InferSchema|INFO> {0}, mode={1}", ObjectID, mode);
            try
            {
                string ns = xdoc.DocumentElement.NamespaceURI;
                if (null == excludedNamespaces)
                {
                    excludedNamespaces = Array.Empty<string>();
                }
                XmlNodeReader xnr = new XmlIgnoreNamespaceReader(xdoc, excludedNamespaces);
                XmlSchemaInference infer = new XmlSchemaInference();

                infer.Occurrence = XmlSchemaInference.InferenceOption.Relaxed;

                infer.TypeInference = (mode == XmlReadMode.InferTypedSchema) ?
                    XmlSchemaInference.InferenceOption.Restricted :
                    XmlSchemaInference.InferenceOption.Relaxed;

                XmlSchemaSet schemaSet = infer.InferSchema(xnr);
                schemaSet.Compile();

                XSDSchema schema = new XSDSchema();
                schema.FromInference = true;

                try
                {
                    schema.LoadSchema(schemaSet, this);
                }
                finally
                {
                    schema.FromInference = false; // this is always false if you are not calling fron inference
                }
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }