コード例 #1
0
        /// <summary>
        /// Determines whether a left-hand-side associative XML object is equal to any right-hand-side object using value semantics (instead of reference semantics).
        /// </summary>
        /// <param name="leftAssociativeXmlObject"> The left-hand-side associative XML object to test. </param>
        /// <param name="rightObject"> The right-hand-side object to test. </param>
        /// <returns> A value indicating whether the two objects equate using value semantics. </returns>
        public static bool CommonEquals(IAssociativeXmlObject leftAssociativeXmlObject, object rightObject)
        {
            object            thisValue, thatValue;
            PropertyConstruct propertyConstruct;

            if ((object)leftAssociativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(leftAssociativeXmlObject));
            }

            thisValue = leftAssociativeXmlObject.GetAssociativeObjectValue(NullTemplatingContext.Instance);

            if ((object)rightObject == null)
            {
                return((object)thisValue == null);
            }

            if ((propertyConstruct = rightObject as PropertyConstruct) != null)
            {
                thatValue = propertyConstruct.GetAssociativeObjectValue(NullTemplatingContext.Instance);
            }
            else
            {
                thatValue = rightObject;
            }

            return(SolderFascadeAccessor.DataTypeFascade.ObjectsEqualValueSemantics(thisValue, thatValue));
        }
コード例 #2
0
        /// <summary>
        /// Gets a string representation for an associative XML object value.
        /// </summary>
        /// <param name="associativeXmlObject"> The associative XML object used to get a string representation. </param>
        /// <returns> The string representation of the associative XML object's value. </returns>
        public static string CommonToString(IAssociativeXmlObject associativeXmlObject)
        {
            object value;

            if ((object)associativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(associativeXmlObject));
            }

            value = associativeXmlObject.GetAssociativeObjectValue(NullTemplatingContext.Instance);

            if ((object)value == null)
            {
                return(null);
            }

            return(value.SafeToString());
        }
コード例 #3
0
		private static void EnumSchema(IAssociativeXmlObject parentAssociativeXmlObject, XmlSchemaObjectCollection currentXmlSchemaObjectCollection)
		{
			XmlSchemaElement xmlSchemaElement;
			XmlSchemaComplexType xmlSchemaComplexType;
			XmlSchemaSequence xmlSchemaSequence;
			XmlSchemaSimpleType xmlSchemaSimpleType;
			ArrayConstruct arrayConstruct00, arrayConstruct01;
			ObjectConstruct objectConstruct00, objectConstruct01;
			PropertyConstruct propertyConstruct00, propertyConstruct01;

			if ((object)parentAssociativeXmlObject == null)
				throw new ArgumentNullException("parentAssociativeXmlObject");

			if ((object)currentXmlSchemaObjectCollection == null)
				throw new ArgumentNullException("currentXmlSchemaObjectCollection");

			arrayConstruct00 = new ArrayConstruct();
			arrayConstruct00.Name = "XmlSchemaElements";
			parentAssociativeXmlObject.Items.Add(arrayConstruct00);

			foreach (XmlSchemaObject xmlSchemaObject in currentXmlSchemaObjectCollection)
			{
				objectConstruct00 = new ObjectConstruct();
				arrayConstruct00.Items.Add(objectConstruct00);

				xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;

				if ((object)xmlSchemaElement != null)
				{
					if (DataTypeFascade.Instance.IsNullOrWhiteSpace(xmlSchemaElement.Name) &&
						!DataTypeFascade.Instance.IsNullOrWhiteSpace(xmlSchemaElement.RefName.Name))
					{
						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementIsRef";
						propertyConstruct00.RawValue = true;
						objectConstruct00.Items.Add(propertyConstruct00);

						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementLocalName";
						propertyConstruct00.RawValue = xmlSchemaElement.RefName.Name;
						objectConstruct00.Items.Add(propertyConstruct00);

						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementNamespace";
						propertyConstruct00.RawValue = xmlSchemaElement.RefName.Namespace;
						objectConstruct00.Items.Add(propertyConstruct00);

						continue;
					}
					else
					{
						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementIsRef";
						propertyConstruct00.RawValue = false;
						objectConstruct00.Items.Add(propertyConstruct00);

						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementLocalName";
						propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Name;
						objectConstruct00.Items.Add(propertyConstruct00);

						propertyConstruct00 = new PropertyConstruct();
						propertyConstruct00.Name = "XmlSchemaElementNamespace";
						propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Namespace;
						objectConstruct00.Items.Add(propertyConstruct00);

						xmlSchemaComplexType = xmlSchemaElement.ElementSchemaType as XmlSchemaComplexType;
						xmlSchemaSimpleType = xmlSchemaElement.ElementSchemaType as XmlSchemaSimpleType;

						if ((object)xmlSchemaSimpleType != null)
						{
							propertyConstruct00 = new PropertyConstruct();
							propertyConstruct00.Name = "XmlSchemaElementSimpleType";
							propertyConstruct00.RawValue = xmlSchemaSimpleType.Datatype.TypeCode;
							objectConstruct00.Items.Add(propertyConstruct00);
						}
						else if ((object)xmlSchemaComplexType != null)
						{
							arrayConstruct01 = new ArrayConstruct();
							arrayConstruct01.Name = "XmlSchemaAttributes";
							objectConstruct00.Items.Add(arrayConstruct01);

							if ((object)xmlSchemaComplexType.Attributes != null)
							{
								foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes)
								{
									objectConstruct01 = new ObjectConstruct();
									arrayConstruct01.Items.Add(objectConstruct01);

									propertyConstruct01 = new PropertyConstruct();
									propertyConstruct01.Name = "XmlSchemaElementLocalName";
									propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Name;
									objectConstruct01.Items.Add(propertyConstruct01);

									propertyConstruct01 = new PropertyConstruct();
									propertyConstruct01.Name = "XmlSchemaElementNamespace";
									propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Namespace;
									objectConstruct01.Items.Add(propertyConstruct01);

									propertyConstruct01 = new PropertyConstruct();
									propertyConstruct01.Name = "XmlSchemaElementNamespace";
									propertyConstruct01.RawValue = xmlSchemaAttribute.AttributeSchemaType.TypeCode;
									objectConstruct01.Items.Add(propertyConstruct01);
								}
							}

							xmlSchemaSequence = xmlSchemaComplexType.ContentTypeParticle as XmlSchemaSequence;

							if ((object)xmlSchemaSequence != null)
								EnumSchema(objectConstruct00, xmlSchemaSequence.Items);
						}
					}
				}
			}
		}
        private static void WriteSqlQuery(IEnumerable <SqlQuery> sqlQueries, IAssociativeXmlObject parentAssociativeXmlObject, Type connectionType, string connectionString, bool getSchemaOnly)
        {
            ArrayConstruct    arrayConstruct;
            ObjectConstruct   objectConstruct;
            PropertyConstruct propertyConstructA, propertyConstructB;
            Tokenizer         tokenizer;

            IEnumerable <IDictionary <string, object> > records;
            string commandText_;
            int    count = 0;

            if ((object)sqlQueries == null)
            {
                throw new ArgumentNullException(nameof(sqlQueries));
            }

            if ((object)parentAssociativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(parentAssociativeXmlObject));
            }

            if ((object)connectionType == null)
            {
                throw new ArgumentNullException(nameof(connectionType));
            }

            if ((object)connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(connectionString))
            {
                throw new ArgumentOutOfRangeException(nameof(connectionString));
            }

            tokenizer = new Tokenizer(true);

            foreach (SqlQuery sqlQuery in sqlQueries.OrderBy(c => c.Key).ThenBy(c => c.Order))
            {
                arrayConstruct      = new ArrayConstruct();
                arrayConstruct.Name = sqlQuery.Key;
                parentAssociativeXmlObject.Items.Add(arrayConstruct);

                commandText_ = tokenizer.ExpandTokens(sqlQuery.Text, new DynamicWildcardTokenReplacementStrategy(new object[] { parentAssociativeXmlObject }));

                // one hell of a polyfill ;)
                Func <CommandType, string, IEnumerable <DbParameter>, Action <long>, IEnumerable <__Record> > executeRecordsCallback =
                    (CommandType commandType, string commandText, IEnumerable <DbParameter> dbParameters, Action <long> resultCallback) =>
                {
                    const bool           _schemaOnly       = false;
                    Type                 _connectionType   = connectionType;
                    string               _connectionString = connectionString;
                    const bool           _transactional    = false;
                    const IsolationLevel _isolationLevel   = IsolationLevel.Unspecified;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.ExecuteRecords(_schemaOnly, _connectionType, _connectionString, _transactional, _isolationLevel, commandType, commandText, dbParameters, resultCallback));
                };

                Func <CommandType, string, IEnumerable <DbParameter>, Action <long>, IEnumerable <__Record> > executeSchemaRecordsCallback =
                    (CommandType commandType, string commandText, IEnumerable <DbParameter> dbParameters, Action <long> resultCallback) =>
                {
                    const bool           _schemaOnly       = true;
                    Type                 _connectionType   = connectionType;
                    string               _connectionString = connectionString;
                    const bool           _transactional    = false;
                    const IsolationLevel _isolationLevel   = IsolationLevel.Unspecified;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.ExecuteRecords(_schemaOnly, _connectionType, _connectionString, _transactional, _isolationLevel, commandType, commandText, dbParameters, resultCallback));
                };

                Func <string, ParameterDirection, DbType, int, byte, byte, bool, string, object, DbParameter> createParameterCallback =
                    (string sourceColumn, ParameterDirection parameterDirection, DbType parameterDbType, int parameterSize, byte parameterPrecision, byte parameterScale, bool parameterNullable, string parameterName, object parameterValue) =>
                {
                    Type _connectionType = connectionType;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(_connectionType, sourceColumn, parameterDirection, parameterDbType, parameterSize, parameterPrecision, parameterScale, parameterNullable, parameterName, parameterValue));
                };

                var unitOfWork = new
                {
                    ExecuteRecords       = executeRecordsCallback,
                    ExecuteSchemaRecords = executeSchemaRecordsCallback,
                    CreateParameter      = createParameterCallback
                };

                // using (null)
                {
                    if (getSchemaOnly)
                    {
                        records = unitOfWork.ExecuteRecords(sqlQuery.Type, commandText_, new DbParameter[] { }, null);
                    }
                    else
                    {
                        records = unitOfWork.ExecuteSchemaRecords(sqlQuery.Type, commandText_, new DbParameter[] { }, null);
                    }

                    records = records.ToArray();                     // force eager load
                }

                propertyConstructA      = new PropertyConstruct();
                propertyConstructA.Name = "RowCount";
                arrayConstruct.Items.Add(propertyConstructA);

                if ((object)records != null)
                {
                    foreach (IDictionary <string, object> record in records)
                    {
                        objectConstruct = new ObjectConstruct();
                        arrayConstruct.Items.Add(objectConstruct);

                        if ((object)record != null)
                        {
                            foreach (KeyValuePair <string, object> keyValuePair in record)
                            {
                                propertyConstructB          = new PropertyConstruct();
                                propertyConstructB.Name     = keyValuePair.Key;
                                propertyConstructB.RawValue = keyValuePair.Value;

                                objectConstruct.Items.Add(propertyConstructB);
                            }
                        }

                        // correlated
                        WriteSqlQuery(sqlQuery.SubQueries, objectConstruct, connectionType, connectionString, getSchemaOnly);

                        count++;
                    }

                    propertyConstructA.RawValue = count;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets a string represnetation for an associative XML object value.
        /// </summary>
        /// <param name="associativeXmlObject"> The associative XML object used to get a string representation. </param>
        /// <returns> The string representation of the associative XML object's value. </returns>
        public static string CommonToString(IAssociativeXmlObject associativeXmlObject)
        {
            object value;

            if ((object)associativeXmlObject == null)
                throw new ArgumentNullException("associativeXmlObject");

            value = associativeXmlObject.GetAssociativeObjectValue();

            if ((object)value == null)
                return null;

            return value.SafeToString();
        }
コード例 #6
0
		private static void WriteSqlQuery(IEnumerable<SqlQuery> sqlQueries, IAssociativeXmlObject parentAssociativeXmlObject, Type connectionType, string connectionString, bool getSchemaOnly)
		{
			ArrayConstruct arrayConstruct;
			ObjectConstruct objectConstruct;
			PropertyConstruct propertyConstructA, propertyConstructB;
			Tokenizer tokenizer;

			IEnumerable<IDictionary<string, object>> records;
			string commandText;
			int count = 0;

			if ((object)sqlQueries == null)
				throw new ArgumentNullException(nameof(sqlQueries));

			if ((object)parentAssociativeXmlObject == null)
				throw new ArgumentNullException(nameof(parentAssociativeXmlObject));

			if ((object)connectionType == null)
				throw new ArgumentNullException(nameof(connectionType));

			if ((object)connectionString == null)
				throw new ArgumentNullException(nameof(connectionString));

			if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(connectionString))
				throw new ArgumentOutOfRangeException(nameof(connectionString));

			tokenizer = new Tokenizer(true);

			foreach (SqlQuery sqlQuery in sqlQueries.OrderBy(c => c.Key).ThenBy(c => c.Order))
			{
				arrayConstruct = new ArrayConstruct();
				arrayConstruct.Name = sqlQuery.Key;
				parentAssociativeXmlObject.Items.Add(arrayConstruct);

				commandText = tokenizer.ExpandTokens(sqlQuery.Text, new DynamicWildcardTokenReplacementStrategy(new object[] { parentAssociativeXmlObject }));

				records = DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.ExecuteRecords(getSchemaOnly, connectionType, connectionString, false, IsolationLevel.Unspecified, sqlQuery.Type, commandText, null);

				propertyConstructA = new PropertyConstruct();
				propertyConstructA.Name = "RowCount";
				arrayConstruct.Items.Add(propertyConstructA);

				if ((object)records != null)
				{
					foreach (IDictionary<string, object> record in records)
					{
						objectConstruct = new ObjectConstruct();
						arrayConstruct.Items.Add(objectConstruct);

						if ((object)record != null)
						{
							foreach (KeyValuePair<string, object> keyValuePair in record)
							{
								propertyConstructB = new PropertyConstruct();
								propertyConstructB.Name = keyValuePair.Key;
								propertyConstructB.RawValue = keyValuePair.Value;

								objectConstruct.Items.Add(propertyConstructB);
							}
						}

						// correlated
						WriteSqlQuery(sqlQuery.SubQueries, objectConstruct, connectionType, connectionString, getSchemaOnly);

						count++;
					}

					propertyConstructA.RawValue = count;
				}
			}
		}
コード例 #7
0
        /// <summary>
        /// Determines whether a left-hand-side associative XML object is equal to any right-hand-side object using value semantics (instead of reference semantics).
        /// </summary>
        /// <param name="leftAssociativeXmlObject"> The left-hand-side associative XML object to test. </param>
        /// <param name="rightObject"> The right-hand-side object to test. </param>
        /// <returns> A value indicating whether the two objects equate using value semantics. </returns>
        public static bool CommonEquals(IAssociativeXmlObject leftAssociativeXmlObject, object rightObject)
        {
            object thisValue, thatValue;
            PropertyConstruct propertyConstruct;

            if ((object)leftAssociativeXmlObject == null)
                throw new ArgumentNullException("leftAssociativeXmlObject");

            thisValue = leftAssociativeXmlObject.GetAssociativeObjectValue();

            if ((object)rightObject == null)
                return (object)thisValue == null;

            if ((propertyConstruct = rightObject as PropertyConstruct) != null)
                thatValue = propertyConstruct.GetAssociativeObjectValue();
            else
                thatValue = rightObject;

            return DataType.ObjectsEqualValueSemantics(thisValue, thatValue);
        }
コード例 #8
0
        /// <summary>
        /// Determines the hash code for an associative XML object.
        /// </summary>
        /// <param name="associativeXmlObject"> The associative XML object used to get a hash code. </param>
        /// <returns> The hash code of the associative XML object's value. </returns>
        public static int CommonGetHashCode(IAssociativeXmlObject associativeXmlObject)
        {
            object value;

            if ((object)associativeXmlObject == null)
                throw new ArgumentNullException("associativeXmlObject");

            value = associativeXmlObject.GetAssociativeObjectValue();

            if ((object)value == null)
                return 0;

            return value.GetHashCode();
        }
コード例 #9
0
ファイル: PropertyConstruct.cs プロジェクト: textmetal/main
		/// <summary>
		/// Determines whether a left-hand-side associative XML object is equal to any right-hand-side object using value semantics (instead of reference semantics).
		/// </summary>
		/// <param name="leftAssociativeXmlObject"> The left-hand-side associative XML object to test. </param>
		/// <param name="rightObject"> The right-hand-side object to test. </param>
		/// <returns> A value indicating whether the two objects equate using value semantics. </returns>
		public static bool CommonEquals(IAssociativeXmlObject leftAssociativeXmlObject, object rightObject)
		{
			object thisValue, thatValue;
			PropertyConstruct propertyConstruct;

			if ((object)leftAssociativeXmlObject == null)
				throw new ArgumentNullException(nameof(leftAssociativeXmlObject));

			thisValue = leftAssociativeXmlObject.GetAssociativeObjectValue(NullTemplatingContext.Instance);

			if ((object)rightObject == null)
				return (object)thisValue == null;

			if ((propertyConstruct = rightObject as PropertyConstruct) != null)
				thatValue = propertyConstruct.GetAssociativeObjectValue(NullTemplatingContext.Instance);
			else
				thatValue = rightObject;

			return SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.ObjectsEqualValueSemantics(thisValue, thatValue);
		}
コード例 #10
0
ファイル: PropertyConstruct.cs プロジェクト: textmetal/main
		/// <summary>
		/// Gets a string representation for an associative XML object value.
		/// </summary>
		/// <param name="associativeXmlObject"> The associative XML object used to get a string representation. </param>
		/// <returns> The string representation of the associative XML object's value. </returns>
		public static string CommonToString(IAssociativeXmlObject associativeXmlObject)
		{
			object value;

			if ((object)associativeXmlObject == null)
				throw new ArgumentNullException(nameof(associativeXmlObject));

			value = associativeXmlObject.GetAssociativeObjectValue(NullTemplatingContext.Instance);

			if ((object)value == null)
				return null;

			return value.SafeToString();
		}
コード例 #11
0
ファイル: PropertyConstruct.cs プロジェクト: textmetal/main
		/// <summary>
		/// Determines the hash code for an associative XML object.
		/// </summary>
		/// <param name="associativeXmlObject"> The associative XML object used to get a hash code. </param>
		/// <returns> The hash code of the associative XML object's value. </returns>
		public static int CommonGetHashCode(IAssociativeXmlObject associativeXmlObject)
		{
			object value;

			if ((object)associativeXmlObject == null)
				throw new ArgumentNullException(nameof(associativeXmlObject));

			value = associativeXmlObject.GetAssociativeObjectValue(NullTemplatingContext.Instance);

			if ((object)value == null)
				return 0;

			return value.GetHashCode();
		}
コード例 #12
0
        private static void EnumSchema(IAssociativeXmlObject parentAssociativeXmlObject, XmlSchemaObjectCollection currentXmlSchemaObjectCollection)
        {
            XmlSchemaElement     xmlSchemaElement;
            XmlSchemaComplexType xmlSchemaComplexType;
            XmlSchemaSequence    xmlSchemaSequence;
            XmlSchemaSimpleType  xmlSchemaSimpleType;
            ArrayConstruct       arrayConstruct00, arrayConstruct01;
            ObjectConstruct      objectConstruct00, objectConstruct01;
            PropertyConstruct    propertyConstruct00, propertyConstruct01;

            if ((object)parentAssociativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(parentAssociativeXmlObject));
            }

            if ((object)currentXmlSchemaObjectCollection == null)
            {
                throw new ArgumentNullException(nameof(currentXmlSchemaObjectCollection));
            }

            arrayConstruct00      = new ArrayConstruct();
            arrayConstruct00.Name = "XmlSchemaElements";
            parentAssociativeXmlObject.Items.Add(arrayConstruct00);

            foreach (XmlSchemaObject xmlSchemaObject in currentXmlSchemaObjectCollection)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;

                if ((object)xmlSchemaElement != null)
                {
                    if (SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(xmlSchemaElement.Name) &&
                        !SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(xmlSchemaElement.RefName.Name))
                    {
                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = true;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        continue;
                    }
                    else
                    {
                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = false;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        xmlSchemaComplexType = xmlSchemaElement.ElementSchemaType as XmlSchemaComplexType;
                        xmlSchemaSimpleType  = xmlSchemaElement.ElementSchemaType as XmlSchemaSimpleType;

                        if ((object)xmlSchemaSimpleType != null)
                        {
                            propertyConstruct00          = new PropertyConstruct();
                            propertyConstruct00.Name     = "XmlSchemaElementSimpleType";
                            propertyConstruct00.RawValue = xmlSchemaSimpleType.Datatype.TypeCode;
                            objectConstruct00.Items.Add(propertyConstruct00);
                        }
                        else if ((object)xmlSchemaComplexType != null)
                        {
                            arrayConstruct01      = new ArrayConstruct();
                            arrayConstruct01.Name = "XmlSchemaAttributes";
                            objectConstruct00.Items.Add(arrayConstruct01);

                            if ((object)xmlSchemaComplexType.Attributes != null)
                            {
                                foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes)
                                {
                                    objectConstruct01 = new ObjectConstruct();
                                    arrayConstruct01.Items.Add(objectConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementLocalName";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Name;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Namespace;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.AttributeSchemaType.TypeCode;
                                    objectConstruct01.Items.Add(propertyConstruct01);
                                }
                            }

                            xmlSchemaSequence = xmlSchemaComplexType.ContentTypeParticle as XmlSchemaSequence;

                            if ((object)xmlSchemaSequence != null)
                            {
                                EnumSchema(objectConstruct00, xmlSchemaSequence.Items);
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
        private static void WriteSqlQuery(IEnumerable<SqlQuery> sqlQueries, IAssociativeXmlObject parentAssociativeXmlObject, Type connectionType, string connectionString, bool getSchemaOnly)
        {
            ArrayConstruct arrayConstruct;
            ObjectConstruct objectConstruct;
            PropertyConstruct propertyConstruct;
            Tokenizer tokenizer;

            IList<IDictionary<string, object>> objs;
            string commandText;
            int rcecordsAffected;

            if ((object)sqlQueries == null)
                throw new ArgumentNullException("sqlQueries");

            if ((object)parentAssociativeXmlObject == null)
                throw new ArgumentNullException("parentAssociativeXmlObject");

            if ((object)connectionType == null)
                throw new ArgumentNullException("connectionType");

            if ((object)connectionString == null)
                throw new ArgumentNullException("connectionString");

            if (DataType.IsWhiteSpace(connectionString))
                throw new ArgumentOutOfRangeException("connectionString");

            tokenizer = new Tokenizer(true);

            foreach (SqlQuery sqlQuery in sqlQueries.OrderBy(c => c.Key).ThenBy(c => c.Order))
            {
                arrayConstruct = new ArrayConstruct();
                arrayConstruct.Name = sqlQuery.Key;
                parentAssociativeXmlObject.Items.Add(arrayConstruct);

                commandText = tokenizer.ExpandTokens(sqlQuery.Text, new DynamicWildcardTokenReplacementStrategy(new object[] { parentAssociativeXmlObject }));

                using (IUnitOfWorkContext unitOfWorkContext = UnitOfWorkContext.Create(connectionType, connectionString, false))
                {
                    if (!getSchemaOnly)
                        objs = unitOfWorkContext.ExecuteDictionary(sqlQuery.Type, commandText, null, out rcecordsAffected);
                    else
                        objs = unitOfWorkContext.ExecuteSchema(sqlQuery.Type, commandText, null);
                }

                if ((object)objs != null)
                {
                    propertyConstruct = new PropertyConstruct();
                    propertyConstruct.Name = "RowCount";
                    propertyConstruct.RawValue = objs.Count;
                    arrayConstruct.Items.Add(propertyConstruct);

                    foreach (IDictionary<string, object> obj in objs)
                    {
                        objectConstruct = new ObjectConstruct();
                        arrayConstruct.Items.Add(objectConstruct);

                        if ((object)obj != null)
                        {
                            foreach (KeyValuePair<string, object> keyValuePair in obj)
                            {
                                propertyConstruct = new PropertyConstruct();
                                propertyConstruct.Name = keyValuePair.Key;
                                propertyConstruct.RawValue = keyValuePair.Value;

                                objectConstruct.Items.Add(propertyConstruct);
                            }
                        }

                        // correlated
                        WriteSqlQuery(sqlQuery.SubQueries, objectConstruct, connectionType, connectionString, getSchemaOnly);
                    }
                }
            }
        }