public void TryParse_MultiValue_MultiValueSet()
        {
            var subject = Qualified.TryParse("text/html;level=1;q=0.5");

            Assert.That(subject.Value, Is.EqualTo("text/html;level=1"));
            Assert.That(subject.Quality, Is.EqualTo(new Quality(.5f)));
        }
        public void TryParse_MultiValueDefaultQuality_MultiValueSet()
        {
            var subject = Qualified.TryParse("text/html;level=1");

            Assert.That(subject.Value, Is.EqualTo("text/html;level=1"));
            Assert.That(subject.Quality, Is.EqualTo(Quality.Default));
        }
		protected CreateIndexStatement(IndexName indexName, Qualified<SchemaName, TableName> tableName, IndexOptionGroup indexOptions) {
			Debug.Assert(indexName != null);
			Debug.Assert(tableName != null);
			this.indexName = indexName;
			this.tableName = tableName;
			this.indexOptions = indexOptions;
		}
        public void TryParse_SingleValue_SingleValueSet()
        {
            var subject = Qualified.TryParse("gzip;q=0.5");

            Assert.That(subject.Value, Is.EqualTo("gzip"));
            Assert.That(subject.Quality, Is.EqualTo(new Quality(.5f)));
        }
		public TableForeignKeyConstraint(ConstraintName constraintName, Sequence<ColumnName> columnNames, Qualified<SchemaName, TableName> refTableName, Optional<Sequence<ColumnName>> refColumnNames, Sequence<ForeignKeyAction> keyActions): base(constraintName) {
			Debug.Assert(refTableName != null);
			this.columnNames = columnNames.ToList();
			this.refTableName = refTableName;
			this.refColumnNames = refColumnNames.ToList();
			this.keyActions = keyActions.ToList();
		}
Ejemplo n.º 6
0
        private static Structure <Guid> CompileType(IUniverse universe, Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > @class)
        {
            switch (@class.Tag)
            {
            case Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Tags.Quantifier:
            {
                var quantifier = (Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Quantifier)@class;

                Term <Guid> dependency = Compile(quantifier.Dependency.TypeOf());

                var depUniverse = new Term <Guid> .Universe(quantifier.Dependency.Universe.Rank);

                var qualifiedDependency = new Qualified <Guid, Guid>(depUniverse, dependency, quantifier.Dependency.Term);

                return(new Structure <Guid> .Pair(qualifiedDependency, quantifier.Dependent(null)));
            }

            case Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Tags.Shift:
            {
                var shift = (Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Shift)@class;

                return(new Structure <Guid> .Continuation(shift.Content(null)));
            }

            default:
                throw new InvalidProgramException("Should never happen.");
            }
        }
		public CreateTypeFromStatement(Qualified<SchemaName, TypeName> typeName, TypeName systemTypeName, TypeConstraintToken constraint): base(typeName) {
			if (!systemTypeName.IsBuiltinType) {
				throw new ArgumentException("Derived types can only be created from system types", "systemTypeName");
			}
			this.systemTypeName = systemTypeName;
			this.constraint = constraint;
		}
        public void TryParse_NotQualifiedString_SingleValueSet()
        {
            var subject = Qualified.TryParse("not qualified");

            Assert.That(subject.Value, Is.EqualTo("not qualified"));
            Assert.That(subject.Quality, Is.EqualTo(Quality.Default));
        }
		public ExpressionColumnFunctionCalls(TableName tableName, ColumnName columnName, Sequence<NamedFunction> functions): base(functions.Item, functions.Next) {
			Debug.Assert(tableName != null);
			Debug.Assert(columnName != null);
			columnNameQualified = new Qualified<TableName, ColumnName>(tableName, columnName);
			Debug.Assert(!functions.Item.FunctionName.IsQualified);
			functions.Item.FunctionName.LockOverride();
		}
		public TypeNameNamedExtension(SqlIdentifier identifier, Qualified<SchemaName, XmlSchemaCollectionName> extension): base(identifier) {
			Debug.Assert(extension != null);
			this.extension = extension;
			isMax = !extension.IsQualified && string.Equals(extension.Name.Value, "MAX", StringComparison.OrdinalIgnoreCase);
			if (isMax) {
				this.extension.LockOverride();
			}
		}
Ejemplo n.º 11
0
        public void CompareTo_DoesNotTakeIntoAccountValueSemantics()
        {
            Qualified html = new Qualified("text/html", new Quality(.5f)),
                      text = new Qualified("text/*", new Quality(.5f));

            Assert.That(text.CompareTo(html), Is.EqualTo(0),
                        "if value semantics were used, html should be more important than any text");
        }
Ejemplo n.º 12
0
		public Parameter(ParameterName parameterName, Qualified<SchemaName, TypeName> parameterTypeName, Optional<Literal> defaultValue, Optional<UnreservedKeyword> readOnly) {
			Debug.Assert(parameterName != null);
			Debug.Assert(parameterTypeName != null);
			this.parameterName = parameterName;
			this.parameterTypeName = parameterTypeName;
			this.defaultValue = defaultValue;
			this.readOnly = readOnly.HasValue();
		}
		public CreateProcedureStatement(Qualified<SchemaName, ProcedureName> procedureName, Optional<Sequence<ProcedureParameter>> parameters, OptionToken option, ReplicationToken replication, StatementBlock body) {
			Debug.Assert(procedureName != null);
			Debug.Assert(body != null);
			this.procedureName = procedureName;
			this.option = option;
			this.replication = replication;
			this.parameters = parameters.ToList();
			this.body = body;
		}
Ejemplo n.º 14
0
        public void Ctor_SomeNulls_Skipped()
        {
            Qualified one = new Qualified("one", Quality.Default),
                      two = new Qualified("two", Quality.Default);

            var subject = new QualifiedCollection(new[] { one, null, two });

            Assert.That(subject, Is.EquivalentTo(new[] { one, two }));
        }
Ejemplo n.º 15
0
		public CreateViewStatement(Qualified<SchemaName, ViewName> viewName, Optional<Sequence<ColumnName>> columnNames, OptionToken viewOption, SelectStatement selectStatement, Optional<WithCheckOptionToken> withCheckOption) {
			Debug.Assert(viewName != null);
			Debug.Assert(selectStatement != null);
			this.viewName = viewName;
			this.viewOption = viewOption;
			this.columnNames = columnNames.ToList();
			this.selectStatement = selectStatement;
			this.withCheckOption = withCheckOption.HasValue();
		}
		public CreateFulltextIndexStatement(Qualified<SchemaName, TableName> tableName, Optional<Sequence<FulltextColumn>> columns, IndexName indexName, FulltextChangeTracking changeTracking) {
			Debug.Assert(tableName != null);
			Debug.Assert(indexName != null);
			Debug.Assert(changeTracking != null);
			this.tableName = tableName;
			this.columns = columns.ToList();
			this.indexName = indexName;
			this.changeTracking = changeTracking;
		}
Ejemplo n.º 17
0
        public void Ctor_OrderByQualityDescending()
        {
            Qualified pointThree = new Qualified("pointThree", new Quality(.3f)),
                      pointSeven = new Qualified("pointSeven", new Quality(.7f));

            var subject = new QualifiedCollection(new[] { pointThree, pointSeven });

            Assert.That(subject, Is.EqualTo(new[] { pointSeven, pointThree }));
        }
		public CreateColumnIndexStatement(Optional<UniqueToken> unique, ConstraintClusterToken clustered, IndexName indexName, Qualified<SchemaName, TableName> tableName, Sequence<IndexColumn> indexColumns, Sequence<ColumnName> columnNames, Predicate filter, IndexOptionGroup indexOptions)
				: base(indexName, tableName, indexOptions) {
			Debug.Assert(clustered != null);
			this.unique = unique.HasValue();
			this.clustered = clustered.Clustered;
			this.indexColumns = indexColumns.ToList();
			this.filter = filter;
			includeColumnNames = columnNames.ToList();
		}
		protected FulltextTableFunction(ReservedKeyword keyword, Qualified<SchemaName, TableName> tableName, Expression query, Literal language, IntegerLiteral top) {
			Debug.Assert(keyword != null);
			Debug.Assert(tableName != null);
			Debug.Assert(query != null);
			this.keyword = keyword;
			this.tableName = tableName;
			this.query = query;
			this.language = language;
			this.top = top;
		}
Ejemplo n.º 20
0
        //Extend CswNbtObjClass events here

        protected override void afterPopulateProps()
        {
            Qualified.SetOnBeforeRender(delegate(CswNbtNodeProp Prop)
            {
                if (null != ManufacturingSite.RelatedNodeId)
                {
                    CswNbtObjClassVendor ManufacturingSiteVendor = _CswNbtResources.Nodes[ManufacturingSite.RelatedNodeId];
                    Qualified.setReadOnly(ManufacturingSiteVendor.Internal.Checked != CswEnumTristate.True, true);
                }
            });
        }
Ejemplo n.º 21
0
        public void CompareTo_OnlyQualityTakenIntoAccount()
        {
            Qualified subject        = new Qualified("anything", new Quality(.5f)),
                      striclySmaller = new Qualified("smaller", new Quality(.3f)),
                      striclyLarger  = new Qualified("larger", new Quality(.7f)),
                      equal          = new Qualified("same", new Quality(.5f));

            Assert.That(subject, Is.GreaterThan(striclySmaller));
            Assert.That(subject, Is.LessThan(striclyLarger));
            Assert.That(subject, Is.LessThanOrEqualTo(equal));
            Assert.That(subject, Is.GreaterThanOrEqualTo(equal));
            Assert.That(subject.CompareTo(null), Is.GreaterThan(0));
        }
		public CreateTriggerStatement(Qualified<SchemaName, TriggerName> triggerName, Qualified<SchemaName, TableName> tableName, TriggerTypeToken triggerType, Sequence<DmlOperationToken> triggerOperations, ReplicationToken replication, Statement statement) {
			Debug.Assert(triggerName != null);
			Debug.Assert(triggerOperations != null);
			Debug.Assert(triggerType != null);
			Debug.Assert(tableName != null);
			Debug.Assert(statement != null);
			this.triggerName = triggerName;
			this.tableName = tableName;
			this.statement = statement;
			this.triggerOperations = triggerOperations.Select(token => token.Operation).ToList();
			this.replication = replication;
			type = triggerType;
		}
Ejemplo n.º 23
0
		public ExecuteStatement(VariableName resultVariableName, Qualified<SchemaName, ProcedureName> procedureName, Optional<Sequence<ExecuteParameter>> parameters, OptionToken option) {
			Debug.Assert(procedureName != null);
			this.resultVariableName = resultVariableName;
			this.procedureName = procedureName;
			this.parameters = parameters.ToList();
			this.option = option;
			if (!procedureName.IsQualified && procedureName.Name.Value.StartsWith("sp_", StringComparison.OrdinalIgnoreCase)) {
				procedureName.LockOverride();
				int[] parameterPositions;
				if (objectNameParameters.TryGetValue(procedureName.Name.Value, out parameterPositions)) {
					foreach (int parameterPosition in parameterPositions.Where(p => this.parameters.Count > p)) {
						ExecuteParameter<Literal> objectNameParameter = (ExecuteParameter<Literal>)this.parameters[parameterPosition];
						if ((objectNameParameter != null) && (objectNameParameter.Value is StringLiteral)) {
							this.parameters[parameterPosition] = new ExecuteParameterObjectName(objectNameParameter.ParameterName, ((StringLiteral)objectNameParameter.Value), objectNameParameter.Output);
						}
					}
				}
			}
		}
Ejemplo n.º 24
0
        private static Func <Term <Guid>, Term <Guid> > CompileDestructor(IUniverse universe, Class <Guid, Guid, ITerm <Guid, Guid> > @class, Func <Term <Guid>, Term <Guid> > focus, Continuation <Guid, Func <Term <Guid>, Term <Guid> > > continuation)
        {
            switch (universe.Polarity)
            {
            case Polarity.Forall:
            {
                return(arguments =>
                    {
                        var initialization = CompileNegativeDestructor(arguments, @class, continuation);

                        return focus(new Term <Guid> .Constructor(initialization));
                    });
            }

            case Polarity.Exists:
            {
                var qualifiedSelfType = universe.Qualify <Guid, Guid, ITerm <Guid, Guid> >(new Term <Guid, Guid>(new TermF <Guid, Guid, ITerm <Guid, Guid> > .Type(@class)));

                var compiledSelfType = Compile(qualifiedSelfType);

                var selfUniverse = new Term <Guid> .Universe(universe.Rank);

                return(arguments =>
                    {
                        var qualifiedSelf = new Qualified <Guid, Term <Guid> >(selfUniverse, compiledSelfType, focus(null));

                        var cont = CompilePositiveDestructor(arguments, @class, continuation);

                        return new Term <Guid> .Destructor(qualifiedSelf, cont);
                    });
            }

            case null:
            default:
                throw new ArgumentOutOfRangeException("polarity");
            }
        }
Ejemplo n.º 25
0
		public UpdateItem(Qualified<SqlName, ColumnName> columnName): this(columnName, null) {}
		public TypedColumnDefinition(Qualified<SchemaName, TypeName> columnType, Sequence<ColumnConstraint> constraints): base(constraints) {
			Debug.Assert(columnType != null);
			this.columnType = columnType;
		}
Ejemplo n.º 27
0
 protected bool Equals(Qualified other)
 {
     return(Equals(Qualification, other.Qualification) && Equals(Expression, other.Expression));
 }
Ejemplo n.º 28
0
		public DropTableStatement(Qualified<SchemaName, TableName> tableName) {
			Debug.Assert(tableName != null);
			this.tableName = tableName;
		}
Ejemplo n.º 29
0
		public SourceTableRowset(Qualified<SchemaName, TableName> tableName, RowsetAlias rowsetAlias, TableHintGroup tableHints): base(rowsetAlias) {
			Debug.Assert(tableName != null);
			this.tableName = tableName;
			this.tableHints = tableHints;
		}
Ejemplo n.º 30
0
        public void ToString_TokenizedConcatenation()
        {
            var subject = new Qualified("da", new Quality(.2f));

            Assert.That(subject.ToString(), Is.EqualTo("da;q=0.2"));
        }
		public CreateColumnIndexStatement(Optional<UniqueToken> unique, ConstraintClusterToken clustered, IndexName indexName, Qualified<SchemaName, TableName> tableName, Sequence<IndexColumn> indexColumns, Sequence<ColumnName> columnNames, IndexOptionGroup indexOptions)
				: this(unique, clustered, indexName, tableName, indexColumns, columnNames, null, indexOptions) {}
 public void CompareToSelf()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     Expect(x.CompareTo(x), EqualTo(0));
 }
Ejemplo n.º 33
0
 public void TryParse_Empty_Null(string empty)
 {
     Assert.That(Qualified.TryParse(empty), Is.Null);
 }
		public FulltextSingleTableFunction(ReservedKeyword keyword, Qualified<SchemaName, TableName> tableName, ColumnName column, Expression query, Optional<IntegerLiteral> top): this(keyword, tableName, column, query, null, top) {}
 public void CompareToEquivalent()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     IQualifiedName<SchemaName> y = new Qualified<SchemaName, TableName>(new SchemaName("DBO"), new TableName("ABC"));
     Expect(x.CompareTo(y), EqualTo(0));
 }
Ejemplo n.º 36
0
		protected UpdateItem(Qualified<SqlName, ColumnName> columnName, VariableName variableName) {
			Debug.Assert((columnName == null)^(variableName == null));
			this.columnName = columnName;
			this.variableName = variableName;
		}
Ejemplo n.º 37
0
		public FulltextColumn(ColumnName columnName, Optional<Qualified<SchemaName, TypeName>> typeColumn, Optional<Literal> language) {
			Debug.Assert(columnName != null);
			this.columnName = columnName;
			this.typeColumn = typeColumn;
			this.language = language;
		}
 public void CompareToSimilar()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     IQualifiedName<SchemaName> y = new Qualified<SchemaName, FunctionName>(new SchemaName("dbo"), new FunctionName("abc"));
     Expect(x.CompareTo(y), GreaterThan(0));
 }
 public void CompareToIdentical()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     IQualifiedName<SchemaName> y = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     Expect(x.CompareTo(y), EqualTo(0));
 }
 public void CompareToSmallerName()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("xyz"), new TableName("abc"));
     IQualifiedName<SchemaName> y = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     Expect(x.CompareTo(y), GreaterThan(0));
 }
		public FulltextSingleTableFunction(ReservedKeyword keyword, Qualified<SchemaName, TableName> tableName, ColumnName column, Expression query, Literal language, Optional<IntegerLiteral> top): base(keyword, tableName, query, language, top) {
			Debug.Assert(column != null);
			this.column = column;
		}
 public void CompareToLargerSchema()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     IQualifiedName<SchemaName> y = new Qualified<SchemaName, TableName>(new SchemaName("xyz"), new TableName("abc"));
     Expect(x.CompareTo(y), LessThan(0));
 }
		public AlterTableColumnPersistedStatement(Qualified<SchemaName, TableName> tableName, ColumnName columnName, DdlOperationToken ddlOperationToken): base(tableName, columnName, ddlOperationToken) {}
 public void CompareToNull()
 {
     IQualifiedName<SchemaName> x = new Qualified<SchemaName, TableName>(new SchemaName("dbo"), new TableName("abc"));
     Expect(x.CompareTo(null), GreaterThan(0));
 }