Пример #1
0
        public T this[Type key]
        {
            get
            {
                if (key == null)
                {
                    throw ExceptionBuilder.ArgumentNull("key");
                }

                return(GetValue(key));
            }

            set
            {
                if (key == null)
                {
                    throw ExceptionBuilder.ArgumentNull("key");
                }

                if (value == null)
                {
                    throw ExceptionBuilder.ArgumentNull("value");
                }

                _typeDictionary[key] = value;
                OnChanged();
            }
        }
		public TableRelation Add(string parentTable, IList<string> parentColumns, string childTable, IList<string> childColumns)
		{
			if (parentTable == null)
				throw ExceptionBuilder.ArgumentNull("parentTable");

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

			if (parentColumns.Count == 0)
				throw ExceptionBuilder.ArgumentArrayMustNotBeEmpty("parentColumns");

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

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

			if (childColumns.Count == 0)
				throw ExceptionBuilder.ArgumentArrayMustNotBeEmpty("childColumns");

			TableBinding parentTableBinding = _dataContext.Tables[parentTable];
			TableBinding childTableBinding = _dataContext.Tables[childTable];

			if (parentTableBinding == null)
				throw ExceptionBuilder.ParentTableMustExistInDataContext("parentTable");

			if (childTableBinding == null)
				throw ExceptionBuilder.ChildTableMustExistInDataContext("childTable");

			return Add(parentTableBinding, parentColumns, childTableBinding, childColumns);
		}
Пример #3
0
        /// <summary>
        /// Detects whether a given text would not form a valid identifier and therefore must be parenthesized.
        /// </summary>
        /// <param name="text">The text of the identifier</param>
        public static bool MustBeParenthesized(string text)
        {
            if (text == null)
            {
                throw ExceptionBuilder.ArgumentNull("text");
            }

            if (text[0] != '_' && !Char.IsLetter(text[0]))
            {
                return(true);
            }

            for (int i = 1; i < text.Length; i++)
            {
                if (!Char.IsLetterOrDigit(text[i]) && text[i] != '_' && text[i] != '$')
                {
                    return(true);
                }
            }

            TokenInfo tokenInfo = TokenInfo.FromText(text);

            if (tokenInfo.IsKeyword || tokenInfo.IsQueryKeyword)
            {
                return(true);
            }

            return(false);
        }
Пример #4
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());
        }
		public void AddRange(DataRelationCollection dataRelations)
		{
			if (dataRelations == null)
				throw ExceptionBuilder.ArgumentNull("dataRelations");

			foreach (DataRelation dataRelation in dataRelations)
				Add(dataRelation);
		}
Пример #6
0
        public bool IsRegistered(Type key)
        {
            if (key == null)
            {
                throw ExceptionBuilder.ArgumentNull("key");
            }

            return(_typeDictionary.ContainsKey(key));
        }
        public CompilationFailedEventArgs(IList <CompilationError> errors)
        {
            if (errors == null)
            {
                throw ExceptionBuilder.ArgumentNull("errors");
            }

            _compilationErrors = new CompilationErrorCollection(errors);
        }
		protected override void SetItem(int index, TableRelation item)
		{
			if (item == null)
				throw ExceptionBuilder.ArgumentNull("item");

			BeforeInsert(item);
			base.SetItem(index, item);
			OnChange(EventArgs.Empty);
		}
Пример #9
0
        public void AddTablesAndRelations(DataSet dataSet)
        {
            if (dataSet == null)
            {
                throw ExceptionBuilder.ArgumentNull("dataSet");
            }

            _tables.AddRange(dataSet.Tables);
            _tableRelations.AddRange(dataSet.Relations);
        }
Пример #10
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw ExceptionBuilder.ArgumentNull("info");
            }

            info.AddValue("CompilationErrors", _compilationErrors, typeof(CompilationErrorCollection));
            base.GetObjectData(info, context);
        }
Пример #11
0
        internal CompilationException(string message, IList <CompilationError> errors)
            : base(message)
        {
            if (errors == null)
            {
                throw ExceptionBuilder.ArgumentNull("errors");
            }

            _compilationErrors = new CompilationErrorCollection(errors);
        }
Пример #12
0
        public void Unregister(Type key)
        {
            if (key == null)
            {
                throw ExceptionBuilder.ArgumentNull("key");
            }

            _typeDictionary.Remove(key);
            OnChanged();
        }
Пример #13
0
        private Identifier([SuppressMessage("Microsoft.Globalization", "CA1303")] string text, IdentifierFlags flags)
        {
            if (text == null)
            {
                throw ExceptionBuilder.ArgumentNull("text");
            }

            _text  = text;
            _flags = flags;
        }
Пример #14
0
        protected override void InsertItem(int index, T item)
        {
            if (item == null)
            {
                throw ExceptionBuilder.ArgumentNull("item");
            }

            BeforeInsert(item);
            base.InsertItem(index, item);
            OnChange(EventArgs.Empty);
        }
Пример #15
0
        public CompilationError(SourceRange sourceRange, ErrorId id, string text)
        {
            if (text == null)
            {
                throw ExceptionBuilder.ArgumentNull("text");
            }

            _sourceRange = sourceRange;
            _id          = id;
            _text        = text;
        }
Пример #16
0
        public void RemoveFromContainer(object container)
        {
            if (container == null)
            {
                throw ExceptionBuilder.ArgumentNull("container");
            }

            IEnumerable <ReflectionFunctionBinding> containerBindings = CreateBindingsFromContainer(container);

            RemoveFromContainer(containerBindings);
        }
Пример #17
0
        /// <summary>
        /// Writes this execution plan to the given text writer.
        /// </summary>
        /// <param name="textWriter">The <see cref="TextWriter"/> to write to.</param>
        /// <param name="indent">The number of spaces used to indent the node levels.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="textWriter"/> is <see langword="null"/>.</exception>
        public void WriteTo(TextWriter textWriter, int indent)
        {
            if (textWriter == null)
            {
                throw ExceptionBuilder.ArgumentNull("textWriter");
            }

            IndentedTextWriter indentedTextWriter = new IndentedTextWriter(textWriter, new string(' ', indent));

            WriteTo(indentedTextWriter, _root);
        }
Пример #18
0
        /// <summary>
        /// Loads an execution plan from an XML document.
        /// </summary>
        /// <param name="navigable">An XPath navigable object to load the execution plan from</param>
        public static ShowPlan FromXml(IXPathNavigable navigable)
        {
            if (navigable == null)
            {
                throw ExceptionBuilder.ArgumentNull("navigable");
            }

            XPathNavigator  navigator = navigable.CreateNavigator();
            ShowPlanElement root      = ReadPlanElement(navigator.SelectSingleNode("executionPlan/element"));

            return(new ShowPlan(root));
        }
Пример #19
0
        public TableBinding Add(DataTable dataTable)
        {
            if (dataTable == null)
            {
                throw ExceptionBuilder.ArgumentNull("dataTable");
            }

            DataTableBinding tableBinding = new DataTableBinding(dataTable);

            Add(tableBinding);
            return(tableBinding);
        }
Пример #20
0
        public void AddRange(DataTableCollection dataTables)
        {
            if (dataTables == null)
            {
                throw ExceptionBuilder.ArgumentNull("dataTables");
            }

            foreach (DataTable dataTable in dataTables)
            {
                Add(dataTable);
            }
        }
Пример #21
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());
        }
Пример #22
0
        protected Evaluatable(string text, DataContext dataContext)
        {
            if (text == null)
            {
                throw ExceptionBuilder.ArgumentNull("text");
            }

            _scope = new Scope();
            _scope.Parameters.Changed += parameters_Changed;

            _text       = text;
            DataContext = dataContext;
        }
Пример #23
0
        /// <summary>
        /// Gets all the attribute fields in the collection for the current record.
        /// </summary>
        /// <param name="values">An array of <see cref="T:System.Object" /> to copy the attribute fields into.</param>
        /// <returns>
        /// The number of instances of <see cref="T:System.Object" /> in the array.
        /// </returns>
        public int GetValues(object[] values)
        {
            if (values == null)
            {
                throw ExceptionBuilder.ArgumentNull("values");
            }

            int upperBound = (values.Length < _resultIterator.RowBuffer.Length) ? values.Length : _resultIterator.RowBuffer.Length;

            Array.Copy(_resultIterator.RowBuffer, values, upperBound);

            return(upperBound);
        }
Пример #24
0
        public void Remove(string name)
        {
            if (name == null)
            {
                throw ExceptionBuilder.ArgumentNull("name");
            }

            T bindingToRemove = this[name];

            if (bindingToRemove != null)
            {
                Remove(bindingToRemove);
            }
        }
Пример #25
0
        public void AddFromContainer(object container)
        {
            if (container == null)
            {
                throw ExceptionBuilder.ArgumentNull("container");
            }

            IEnumerable <ReflectionFunctionBinding> bindings = CreateBindingsFromContainer(container);

            foreach (ReflectionFunctionBinding binding in bindings)
            {
                Add(binding);
            }
        }
Пример #26
0
		public IList<TableRelation> GetRelations(TableBinding table)
		{
			if (table == null)
				throw ExceptionBuilder.ArgumentNull("table");

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

			foreach (TableRelation tableRelation in this)
			{
				if (tableRelation.ParentTable == table || tableRelation.ChildTable == table)
					result.Add(tableRelation);
			}

			return result;
		}
Пример #27
0
		public TableRelation Add(DataRelation dataRelation)
		{
			if (dataRelation == null)
				throw ExceptionBuilder.ArgumentNull("dataRelation");

			string[] parentColumns = new string[dataRelation.ParentColumns.Length];
			for (int i = 0; i < parentColumns.Length; i++)
				parentColumns[i] = dataRelation.ParentColumns[i].ColumnName;

			string[] childColumns = new string[dataRelation.ChildColumns.Length];
			for (int i = 0; i < childColumns.Length; i++)
				childColumns[i] = dataRelation.ChildColumns[i].ColumnName;

			return Add(dataRelation.ParentTable.TableName, parentColumns, dataRelation.ChildTable.TableName, childColumns);
		}
Пример #28
0
        protected override void SetItem(int index, T item)
        {
            if (item == null)
            {
                throw ExceptionBuilder.ArgumentNull("item");
            }

            T removedItem = this[index];

            BeforeInsert(item);
            base.SetItem(index, item);
            AfterRemove(removedItem);

            OnChange(EventArgs.Empty);
        }
Пример #29
0
        public FunctionBinding Add(string functionName, Delegate functionDelegate)
        {
            if (functionName == null)
            {
                throw ExceptionBuilder.ArgumentNull("functionName");
            }

            if (functionDelegate == null)
            {
                throw ExceptionBuilder.ArgumentNull("functionDelegate");
            }

            // Check return type

            if (functionDelegate.Method.ReturnType == typeof(void))
            {
                throw ExceptionBuilder.FunctionMustNotBeVoid(functionDelegate);
            }

            // Check parameters

            ParameterInfo[] parameters = functionDelegate.Method.GetParameters();

            foreach (ParameterInfo param in parameters)
            {
                if (param.IsOut || param.ParameterType.IsByRef)
                {
                    throw ExceptionBuilder.FunctionMustNotHaveRefOrOutParams(functionDelegate, param);
                }

                if (param.IsOptional)
                {
                    throw ExceptionBuilder.FunctionMustNotHaveOptionalParams(functionDelegate, param);
                }

                if (param.ParameterType.IsArray)
                {
                    throw ExceptionBuilder.FunctionMustNotHaveArrayParams(functionDelegate, param);
                }
            }

            // Ok, everything seems to be fine.

            ReflectionFunctionBinding reflectionFunctionBinding = new ReflectionFunctionBinding(functionName, functionDelegate.Method, functionDelegate.Target, false);

            Add(reflectionFunctionBinding);
            return(reflectionFunctionBinding);
        }
Пример #30
0
        public TableBinding Add <T>(IEnumerable <T> enumerable, string tableName)
        {
            if (enumerable == null)
            {
                throw ExceptionBuilder.ArgumentNull("enumerable");
            }

            if (tableName == null)
            {
                throw ExceptionBuilder.ArgumentNull("tableName");
            }

            Type elementType = typeof(T);

            return(Add(enumerable, elementType, tableName));
        }