Пример #1
0
        private static void LoadComplexType(XmlSchemaComplexType complexType, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate, object parent, int ordinal, bool requirePrePostInit)
        {
            int num = ordinal;
            XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence)complexType.Particle;

            if (requirePrePostInit)
            {
                definitionDelegate(-1, null, null, null, null, false, xmlSchemaSequence.Items.Count, null);
            }
            foreach (XmlSchemaElement xmlSchemaElement in xmlSchemaSequence.Items)
            {
                string name = (xmlSchemaElement.Name != null) ? xmlSchemaElement.Name : xmlSchemaElement.QualifiedName.Name;
                string columnCaptionFromSchemaElement = FormattersHelpers.GetColumnCaptionFromSchemaElement(xmlSchemaElement);
                string @namespace = xmlSchemaElement.QualifiedName.Namespace;
                if (FormattersHelpers.IsNestedRowsetColumn(xmlSchemaElement))
                {
                    object obj = definitionDelegate(num, name, @namespace, columnCaptionFromSchemaElement, null, true, parent, null);
                    FormattersHelpers.ColumnDefinitionDelegate columnDefinitionDelegate = obj as FormattersHelpers.ColumnDefinitionDelegate;
                    if (columnDefinitionDelegate == null)
                    {
                        columnDefinitionDelegate = definitionDelegate;
                    }
                    else
                    {
                        obj = parent;
                    }
                    FormattersHelpers.LoadComplexType((XmlSchemaComplexType)xmlSchemaElement.ElementSchemaType, columnDefinitionDelegate, obj, 0, requirePrePostInit);
                }
                else
                {
                    Type   type             = null;
                    string strColumnXsdType = null;
                    FormattersHelpers.GetSchemaElementTypeAndName(xmlSchemaElement, out type, out strColumnXsdType);
                    definitionDelegate(num, name, @namespace, columnCaptionFromSchemaElement, type, false, parent, strColumnXsdType);
                }
                num++;
            }
            if (requirePrePostInit)
            {
                definitionDelegate(-2, null, null, null, null, false, xmlSchemaSequence.Items.Count, null);
            }
        }
Пример #2
0
 public static void LoadSchema(XmlReader xmlReader, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate, bool requirePrePostInit)
 {
     try
     {
         xmlReader.MoveToContent();
         XmlSchema xmlSchema;
         if (xmlReader is XmlaReader)
         {
             xmlSchema = ((XmlaReader)xmlReader).ReadSchema();
         }
         else
         {
             xmlSchema = XmlSchema.Read(xmlReader, null);
             xmlReader.ReadEndElement();
         }
         xmlReader.MoveToContent();
         XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
         xmlSchemaSet.Add(xmlSchema);
         xmlSchemaSet.Compile();
         foreach (XmlSchemaObject current in xmlSchema.Items)
         {
             if (current is XmlSchemaComplexType)
             {
                 XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType)current;
                 if (xmlSchemaComplexType.Name == FormattersHelpers.RowElement)
                 {
                     FormattersHelpers.LoadComplexType(xmlSchemaComplexType, definitionDelegate, null, 0, requirePrePostInit);
                     break;
                 }
             }
         }
     }
     catch (XmlSchemaException innerException)
     {
         throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
     }
 }
        private object ColumnDef(int ordinal, string name, string colNamespace, string caption, Type type, bool isNested, object parent, string strColumnXsdType)
        {
            if (ordinal == -1)
            {
                this.columnCount    = (int)parent;
                this.dtStore        = new DataTable();
                this.dtStore.Locale = CultureInfo.InvariantCulture;
                if (this.nestedDataReaders == null)
                {
                    this.nestedDataReaders = new XmlaDataReader[this.columnCount];
                }
                return(null);
            }
            if (ordinal == -2)
            {
                if (this.parentReader != null)
                {
                    this.dtStore.Columns.Add(string.Empty, this.currentRow.GetType());
                }
                return(null);
            }
            Type type2 = type;

            FormattersHelpers.ColumnDefinitionDelegate result = null;
            if (strColumnXsdType == "xmlDocument")
            {
                type2 = typeof(object);
            }
            if (isNested)
            {
                type2 = typeof(XmlaDataReader);
                this.nestedDataReaders[ordinal]              = new XmlaDataReader(this);
                this.nestedDataReaders[ordinal].rowElement   = name;
                this.nestedDataReaders[ordinal].rowNamespace = colNamespace;
                result = new FormattersHelpers.ColumnDefinitionDelegate(this.nestedDataReaders[ordinal].ColumnDef);
            }
            DataRow dataRow = this.schemaTable.NewRow();

            this.columnXmlNameLookup[name] = ordinal;
            this.columnNameLookup[caption] = ordinal;
            dataRow["ColumnName"]          = caption;
            dataRow["ColumnOrdinal"]       = ordinal;
            dataRow["ColumnSize"]          = 0;
            if (type2 == typeof(decimal))
            {
                dataRow["NumericPrecision"] = 19;
                dataRow["NumericScale"]     = 4;
            }
            else
            {
                dataRow["NumericPrecision"] = 0;
                dataRow["NumericScale"]     = 0;
            }
            dataRow["DataType"]        = type2;
            dataRow["ProviderType"]    = type2;
            dataRow["IsLong"]          = false;
            dataRow["AllowDBNull"]     = true;
            dataRow["IsReadOnly"]      = true;
            dataRow["IsRowVersion"]    = false;
            dataRow["IsUnique"]        = false;
            dataRow["IsKeyColumn"]     = false;
            dataRow["IsAutoIncrement"] = false;
            dataRow["BaseSchemaName"]  = null;
            dataRow["BaseCatalogName"] = null;
            dataRow["BaseTableName"]   = null;
            dataRow["BaseColumnName"]  = null;
            this.schemaTable.Rows.Add(dataRow);
            if (isNested)
            {
                this.dtStore.Columns.Add(name, this.currentRow.GetType());
            }
            else
            {
                DataColumn column = this.dtStore.Columns.Add(name, typeof(object));
                FormattersHelpers.SetColumnXsdTypeName(column, strColumnXsdType);
            }
            return(result);
        }
 private void LoadResponseSchema()
 {
     FormattersHelpers.ColumnDefinitionDelegate definitionDelegate = new FormattersHelpers.ColumnDefinitionDelegate(this.ColumnDef);
     FormattersHelpers.LoadSchema(this.xmlReader, definitionDelegate, true);
 }
Пример #5
0
 public static void LoadSchema(XmlReader xmlReader, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate)
 {
     FormattersHelpers.LoadSchema(xmlReader, definitionDelegate, false);
 }