Example #1
0
		/// <summary>
		/// Returns all properties matching the identifier.
		/// </summary>
		/// <param name="type">The type to search the properties in.</param>
		/// <param name="identifier">The identifier to match the properties.</param>
		public PropertyBinding[] FindProperty(Type type, Identifier identifier)
		{
			if (type == null)
				throw ExceptionBuilder.ArgumentNull("type");

			if (identifier == null)
				throw ExceptionBuilder.ArgumentNull("identifier");

			// Get property provider responsible for the given type.

			IPropertyProvider propertyProvider = _propertyProviders[type];

			if (propertyProvider == null)
				return new PropertyBinding[0];

			// Get properties from the provider.

			PropertyBinding[] properties;

			try
			{
				properties = propertyProvider.GetProperties(type);
			}
			catch (NQueryException)
			{
				throw;
			}
			catch (Exception ex)
			{
				throw ExceptionBuilder.IPropertyProviderGetPropertiesFailed(ex);
			}

			return FindProperty(properties, identifier);
		}
Example #2
0
		/// <summary>
		/// Returns all methods matching the identifier.
		/// </summary>
		/// <param name="type">The type to search the methods in.</param>
		/// <param name="identifier">The identifier to match the methods.</param>
		public MethodBinding[] FindMethod(Type type, Identifier identifier)
		{
			if (type == null)
				throw ExceptionBuilder.ArgumentNull("type");

			if (identifier == null)
				throw ExceptionBuilder.ArgumentNull("identifier");

			// Get method provider responsible for the given type.

			IMethodProvider methodProvider = _methodProviders[type];

			if (methodProvider == null)
				return new MethodBinding[0];

			// Get properties from the provider.

			MethodBinding[] methods;

			try
			{
				methods = methodProvider.GetMethods(type);
			}
			catch (NQueryException)
			{
				throw;
			}
			catch (Exception ex)
			{
				throw ExceptionBuilder.IMethodProviderGetMethodsFailed(ex);
			}

			// Return all methods that match the given name.

			List<MethodBinding> result = new List<MethodBinding>();

			foreach (MethodBinding methodBinding in methods)
			{
				if (identifier.Matches(methodBinding.Name))
					result.Add(methodBinding);
			}

			return result.ToArray();
		}
Example #3
0
 void IErrorReporter.AmbiguousConstant(SourceRange sourceRange, Identifier identifier, ConstantBinding[] candidates)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.AmbiguousConstant, identifier, FormattingHelpers.FormatBindingList(candidates));
     HandleError(sourceRange, ErrorId.AmbiguousConstant, message);
 }
Example #4
0
 void IErrorReporter.UndeclaredTable(SourceRange sourceRange, Identifier identifier)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.UndeclaredTable, identifier);
     HandleError(sourceRange, ErrorId.UndeclaredTable, message);
 }
Example #5
0
 void IErrorReporter.UndeclaredProperty(SourceRange sourceRange, Type type, Identifier identifier)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.UndeclaredProperty, FormattingHelpers.FormatType(type), identifier);
     HandleError(sourceRange, ErrorId.UndeclaredProperty, message);
 }
Example #6
0
 void IErrorReporter.UndeclaredMethod(SourceRange sourceRange, Type declaringType, Identifier identifier, Type[] parameterTypes)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.UndeclaredMethod, declaringType.Name, identifier, FormattingHelpers.FormatTypeList(parameterTypes));
     HandleError(sourceRange, ErrorId.UndeclaredMethod, message);
 }
Example #7
0
 void IErrorReporter.CteContainsGroupByHavingOrAggregate(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteContainsGroupByHavingOrAggregate, cteTableName.Text);
     HandleError(ErrorId.CteContainsGroupByHavingOrAggregate, message);
 }
Example #8
0
		/// <summary>
		/// Compares this instance of an identifier to another instance.
		/// </summary>
		/// <param name="identifier">Other identfier to compare to.</param>
		public bool Equals(Identifier identifier)
		{
			if (identifier == null)
				return false;

			return this == identifier;
		}
Example #9
0
 void IErrorReporter.DuplicateTableRefInFrom(Identifier identifier)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.DuplicateTableRefInFrom, identifier);
     HandleError(ErrorId.DuplicateTableRefInFrom, message);
 }
Example #10
0
 void IErrorReporter.CteHasTypeMismatchBetweenAnchorAndRecursivePart(Identifier columnName, Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteHasTypeMismatchBetweenAnchorAndRecursivePart, columnName.Text, cteTableName);
     HandleError(ErrorId.CteHasTypeMismatchBetweenAnchorAndRecursivePart, message);
 }
Example #11
0
 void IErrorReporter.CteHasMoreColumnsThanSpecified(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteHasMoreColumnsThanSpecified, cteTableName.Text);
     HandleError(ErrorId.CteHasMoreColumnsThanSpecified, message);
 }
Example #12
0
 void IErrorReporter.CteHasDuplicateTableName(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteHasDuplicateTableName, cteTableName.Text);
     HandleError(ErrorId.CteHasDuplicateTableName, message);
 }
Example #13
0
 void IErrorReporter.CteDoesNotHaveUnionAll(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteDoesNotHaveUnionAll, cteTableName.Text);
     HandleError(ErrorId.CteDoesNotHaveUnionAll, message);
 }
Example #14
0
 void IErrorReporter.CteContainsUnion(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteContainsUnion, cteTableName.Text);
     HandleError(ErrorId.CteContainsUnion, message);
 }
Example #15
0
 void IErrorReporter.CteContainsRecursiveReferenceInSubquery(Identifier cteTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CteContainsRecursiveReferenceInSubquery, cteTableName.Text);
     HandleError(ErrorId.CteContainsRecursiveReferenceInSubquery, message);
 }
Example #16
0
 void IErrorReporter.NoColumnAliasSpecified(SourceRange sourceRange, int columnIndex, Identifier derivedTableName)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.NoColumnAliasSpecified, columnIndex + 1, derivedTableName.ToSource());
     HandleError(sourceRange, ErrorId.NoColumnAliasSpecified, message);
 }
Example #17
0
		public PropertyBinding[] FindProperty(IList<PropertyBinding> properties, Identifier identifier)
		{
			if (properties == null)
				throw ExceptionBuilder.ArgumentNull("properties");

			if (identifier == null)
				throw ExceptionBuilder.ArgumentNull("identifier");

			// Return all properties that match the given name.

			List<PropertyBinding> candidateList = new List<PropertyBinding>();

			foreach (PropertyBinding propertyBinding in properties)
			{
				if (identifier.Matches(propertyBinding.Name))
					candidateList.Add(propertyBinding);
			}

			return candidateList.ToArray();
		}
Example #18
0
 void IErrorReporter.UndeclaredColumn(SourceRange sourceRange, TableRefBinding tableRefBinding, Identifier identifier)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.UndeclaredColumn, tableRefBinding.Name, identifier);
     HandleError(sourceRange, ErrorId.UndeclaredColumn, message);
 }
Example #19
0
		/// <summary>
		/// Checks whether this identifier matches the given identifier.
		/// To match <paramref name="identifier" /> the following must be true:
		/// <ul>
		///		<li>The value of <see cref="Verbatim"/> of this instance and <paramref name="identifier" /> must be equal.</li>
		///		<li>If <see cref="Verbatim"/> is <see langword="true"/> the value of <see cref="Text"/> of this instance and <paramref name="identifier" /> must be equal (compared case-sensitive).</li>
		///		<li>If <see cref="Verbatim"/> is <see langword="false"/> the value of <see cref="Text"/> of this instance and <paramref name="identifier" /> must be equal (compared case-insensitive).</li>
		/// </ul>
		/// </summary>
		/// <param name="identifier">The identifier to match against</param>
		public bool Matches(Identifier identifier)
		{
			// Identifier a1 = new Identifier("Name", true);
			// Identifier a2 = new Identifier("NAME", true);
			//
			// Identifier b1 = new Identifier("Name", false);
			// Identifier b2 = new Identifier("NAME", false);
			//
			// a1 and a2 are verbatim identifiers, b1 and b2 are a non-verbatim identifiers.
			//
			// -- Every identifier matches itself
			//
			// a1.Matches(a1)  == true
			// a2.Matches(a2)  == true
			// b1.Matches(b1)  == true
			// b2.Matches(b2)  == true
			//
			// -- Verbatim idenfiers are compared case sensitive
			//
			// a1.Matches(a2)  == false
			// a2.Matches(a1)  == false
			//
			// -- Non verbatim identifiers are compared case insensitive
			//
			// b1.Matches(b2)  == true
			// b2.Matches(b1)  == true
			//
			// -- A verbatim identifier compared with a non-verbatim identifier will never produce a match
			//
			// a1.Matches(b1)  == false
			// a2.Matches(b2)  == false
			//
			// -- A non-verbatim identifier and a verbatim identifier are compared case insensitive
			//
			// b1.Matches(a1)  == true
			// b1.Matches(a2)  == true
			// b2.Matches(a1)  == true
			// b2.Matches(a2)  == true

			if (identifier == null)
				return false;

			if (identifier == this)
				return true;

			if (Verbatim && !identifier.Verbatim)
			{
				// They will not match

				return false;
			}

			if (Verbatim && identifier.Verbatim)
			{
				// Both are verbatim, compare the string by chars.

				return Text == identifier.Text;
			}

			// The left identifier is not verbatim, compare the names case insensitive.

			return String.Compare(Text, identifier.Text, StringComparison.OrdinalIgnoreCase) == 0;
		}
Example #20
0
 void IErrorReporter.AmbiguousReference(SourceRange sourceRange, Identifier identifier, Binding[] candidates)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.AmbiguousReference, identifier, FormattingHelpers.FormatBindingListWithCategory(candidates));
     HandleError(sourceRange, ErrorId.AmbiguousReference, message);
 }