public ParseResult(IAstNode rootNode, IdentifierCollection identifiers) { Require.NotNull(rootNode, "rootNode"); Require.NotNull(identifiers, "identifiers"); RootNode = rootNode; Identifiers = identifiers; }
private void TestCaseInsensitive(params string[] strings) { var idcol = new IdentifierCollection(strings).AsCaseInsensitiveCollection(); Assert.Equal(strings.Length, idcol.Count); Assert.Equal(true, Enumerable.SequenceEqual(strings.OrderBy(x => x), idcol.OrderBy(x => x))); Assert.Equal(idcol.GetEnumerator().GetType(), ((System.Collections.IEnumerable)idcol).GetEnumerator().GetType()); AssertContains(idcol, strings); AssertContains(idcol, strings.Select(s => s.ToUpper())); AssertNotContains(idcol, "x"); var copy = new string[strings.Length]; idcol.CopyTo(copy, 0); Assert.Equal(true, Enumerable.SequenceEqual(strings.OrderBy(x => x), copy.OrderBy(x => x))); }
public CacheKey(IdentifierCollection identifiers, bool ignoreCase, IBindingContext bindingContext, BoundExpressionOptions options) { Options = options; OwnerType = bindingContext.OwnerType; var imports = bindingContext.Imports; Imports = new Import[imports == null ? 0 : imports.Count]; if (Imports.Length > 0) imports.CopyTo(Imports, 0); IdentifierTypes = new Type[identifiers.Count]; for (int i = 0; i < identifiers.Count; i++) { IdentifierTypes[i] = bindingContext.GetVariableType( identifiers[i].Name, ignoreCase ); } }
protected CollectionBase(IdentifierCollection identifierCollection) { IdentifierCollection = identifierCollection; }
internal override IElement CreateElement(IElementFactory elementFactory, IElement parent, IRule rule, IdentifierCollection ruleIds) { Collection <RuleElement> collection = new Collection <RuleElement>(); CalcCount(null); Optimize(collection); foreach (RuleElement item in collection) { base.Items.Add(item); } string text = ruleIds.CreateNewIdentifier("root"); elementFactory.Grammar.Root = text; elementFactory.Grammar.TagFormat = SrgsTagFormat.KeyValuePairs; IRule rule2 = elementFactory.Grammar.CreateRule(text, RulePublic.False, RuleDynamic.NotSet, false); foreach (GrammarBuilderBase item2 in base.Items) { if (item2 is RuleElement) { item2.CreateElement(elementFactory, rule2, rule2, ruleIds); } } foreach (GrammarBuilderBase item3 in base.Items) { if (!(item3 is RuleElement)) { IElement element = item3.CreateElement(elementFactory, rule2, rule2, ruleIds); if (element != null) { element.PostParse(rule2); elementFactory.AddElement(rule2, element); } } } rule2.PostParse(elementFactory.Grammar); elementFactory.Grammar.PostParse(null); return(null); }
internal override IElement CreateElement(IElementFactory elementFactory, IElement parent, IRule rule, IdentifierCollection ruleIds) { Collection <RuleElement> newRules = new(); CalcCount(null); Optimize(newRules); foreach (GrammarBuilderBase baseRule in newRules) { Items.Add(baseRule); } // The id of the root rule string rootId = ruleIds.CreateNewIdentifier("root"); // Set the grammar's root rule elementFactory.Grammar.Root = rootId; elementFactory.Grammar.TagFormat = System.Speech.Recognition.SrgsGrammar.SrgsTagFormat.KeyValuePairs; // Create the root rule IRule root = elementFactory.Grammar.CreateRule(rootId, RulePublic.False, RuleDynamic.NotSet, false); // Create all the rules foreach (GrammarBuilderBase item in Items) { if (item is RuleElement) { item.CreateElement(elementFactory, root, root, ruleIds); } } // Create an item which represents the grammar foreach (GrammarBuilderBase item in Items) { if (!(item is RuleElement)) { IElement element = item.CreateElement(elementFactory, root, root, ruleIds); if (element != null) { element.PostParse(root); elementFactory.AddElement(root, element); } } } // Post parse the root rule root.PostParse(elementFactory.Grammar); elementFactory.Grammar.PostParse(null); return(null); }
public AbstractCollectionPersister(Mapping.Collection collection, ISessionFactoryImplementor factory) { this.factory = factory; dialect = factory.Dialect; //sqlExceptionConverter = factory.SQLExceptionConverter; collectionType = collection.CollectionType; role = collection.Role; ownerClass = collection.OwnerClass; Alias alias = new Alias("__"); sqlOrderByString = collection.OrderBy; hasOrder = sqlOrderByString != null; sqlOrderByStringTemplate = hasOrder ? Template.RenderOrderByStringTemplate(sqlOrderByString, dialect) : null; sqlWhereString = collection.Where; hasWhere = sqlWhereString != null; sqlWhereStringTemplate = hasWhere ? Template.RenderWhereStringTemplate(sqlWhereString, dialect) : null; hasOrphanDelete = collection.OrphanDelete; batchSize = collection.BatchSize; cache = collection.Cache; keyType = collection.Key.Type; int keySpan = collection.Key.ColumnSpan; keyColumnNames = new string[keySpan]; string[] keyAliases = new string[keySpan]; int k = 0; foreach (Column col in collection.Key.ColumnCollection) { keyColumnNames[k] = col.GetQuotedName(dialect); keyAliases[k] = col.Alias(dialect); k++; } keyColumnAliases = alias.ToAliasStrings(keyAliases, dialect); //unquotedKeyColumnNames = StringHelper.Unquote( keyColumnAliases ); ISet distinctColumns = new HashedSet(); CheckColumnDuplication(distinctColumns, collection.Key.ColumnCollection); //isSet = collection.IsSet; //isSorted = collection.IsSorted; primitiveArray = collection.IsPrimitiveArray; array = collection.IsArray; IValue element = collection.Element; int elementSpan = element.ColumnSpan; ICollection iter = element.ColumnCollection; Table table = collection.CollectionTable; enableJoinedFetch = element.OuterJoinFetchSetting; elementType = element.Type; if (!collection.IsOneToMany) { CheckColumnDuplication(distinctColumns, element.ColumnCollection); } if (elementType.IsEntityType) { elementPersister = factory.GetPersister((( EntityType )elementType).AssociatedClass); } else { elementPersister = null; } qualifiedTableName = table.GetQualifiedName(dialect, factory.DefaultSchema); string[] aliases = new string[elementSpan]; elementColumnNames = new string[elementSpan]; int j = 0; foreach (Column col in iter) { elementColumnNames[j] = col.GetQuotedName(dialect); aliases[j] = col.Alias(dialect); j++; } elementColumnAliases = alias.ToAliasStrings(aliases, dialect); IType selectColumns; string[] selectType; hasIndex = collection.IsIndexed; if (hasIndex) { IndexedCollection indexedCollection = ( IndexedCollection )collection; indexType = indexedCollection.Index.Type; int indexSpan = indexedCollection.Index.ColumnSpan; indexColumnNames = new string[indexSpan]; string[] indexAliases = new string[indexSpan]; int i = 0; foreach (Column indexCol in indexedCollection.Index.ColumnCollection) { indexAliases[i] = indexCol.Alias(dialect); indexColumnNames[i] = indexCol.GetQuotedName(dialect); i++; } selectType = indexColumnNames; selectColumns = indexType; indexColumnAliases = alias.ToAliasStrings(indexAliases, dialect); CheckColumnDuplication(distinctColumns, indexedCollection.Index.ColumnCollection); } else { indexType = null; indexColumnNames = null; indexColumnAliases = null; selectType = elementColumnNames; selectColumns = elementType; } hasIdentifier = collection.IsIdentified; if (hasIdentifier) { if (collection.IsOneToMany) { throw new MappingException("one-to-many collections with identifiers are not supported."); } IdentifierCollection idColl = ( IdentifierCollection )collection; identifierType = idColl.Identifier.Type; Column col = null; foreach (Column column in idColl.Identifier.ColumnCollection) { col = column; break; } identifierColumnName = col.GetQuotedName(dialect); selectType = new string[] { identifierColumnName }; selectColumns = identifierType; identifierColumnAlias = alias.ToAliasString(col.Alias(dialect), dialect); unquotedIdentifierColumnName = identifierColumnAlias; identifierGenerator = idColl.Identifier.CreateIdentifierGenerator(dialect); CheckColumnDuplication(distinctColumns, idColl.Identifier.ColumnCollection); } else { identifierType = null; identifierColumnName = null; identifierColumnAlias = null; unquotedIdentifierColumnName = null; identifierGenerator = null; } rowSelectColumnNames = selectType; rowSelectType = selectColumns; sqlDeleteString = GenerateDeleteString(); sqlInsertRowString = GenerateInsertRowString(); sqlUpdateRowString = GenerateUpdateRowString(); sqlDeleteRowString = GenerateDeleteRowString(); isLazy = collection.IsLazy; isInverse = collection.IsInverse; if (collection.IsArray) { elementClass = (( Array )collection).ElementClass; } else { // for non-arrays, we don't need to know the element class elementClass = null; } initializer = CreateCollectionInitializer(factory); if (elementType.IsComponentType) { elementPropertyMapping = new CompositeElementPropertyMapping(elementColumnNames, ( IAbstractComponentType )elementType, factory); } else if (!elementType.IsEntityType) { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } else { IClassPersister persister = factory.GetPersister((( EntityType )elementType).AssociatedClass); // Not all classpersisters implement IPropertyMapping! if (persister is IPropertyMapping) { elementPropertyMapping = ( IPropertyMapping )persister; } else { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } } }
private Session FromIdentifiers(IdentifierCollection identifiers) { return(_sessions.FirstOrDefault(p => p.Player.Identifiers.All(identifiers.Contains))); }