コード例 #1
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());
        }
コード例 #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());
        }
コード例 #3
0
        public virtual T[] Find(Identifier identifier)
        {
            if (identifier == null)
            {
                throw ExceptionBuilder.ArgumentNull("identifier");
            }

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

            foreach (T binding in this)
            {
                if (identifier.Matches(binding.Name))
                {
                    result.Add(binding);
                }
            }

            return(result.ToArray());
        }
コード例 #4
0
        public override FunctionBinding[] Find(Identifier identifier)
        {
            if (identifier == null)
            {
                throw ExceptionBuilder.ArgumentNull("identifier");
            }

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

            foreach (string exitingsFunctionName in _functionTable.Keys)
            {
                if (identifier.Matches(exitingsFunctionName))
                {
                    List <FunctionBinding> functions = _functionTable[exitingsFunctionName];
                    result.AddRange(functions);
                }
            }

            return(result.ToArray());
        }
コード例 #5
0
ファイル: MetadataContext.cs プロジェクト: chenzuo/nquery
		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();
		}
コード例 #6
0
ファイル: MetadataContext.cs プロジェクト: chenzuo/nquery
		/// <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();
		}