/// <summary> /// Generates a index predefinition /// </summary> /// <param name="aIndex">The index definition by the gql</param> /// <returns>An IndexPredefinition</returns> private IndexPredefinition GenerateIndex(IndexDefinition aIndex, String myVertexType) { IndexPredefinition result; if (String.IsNullOrEmpty(aIndex.IndexName)) { result = new IndexPredefinition(myVertexType); } else { result = new IndexPredefinition(aIndex.IndexName, myVertexType); } result.SetVertexType(myVertexType); if (!String.IsNullOrEmpty(aIndex.IndexType)) { result.SetIndexType(aIndex.IndexType); } foreach (var aIndexProperty in aIndex.IndexAttributeDefinitions) { result.AddProperty(aIndexProperty.IndexAttribute.ContentString); } if (aIndex.Options != null) { foreach (var aIndexOption in aIndex.Options) { result.AddOption(aIndexOption.Key, aIndexOption.Value); } } return result; }
public void Init(ParsingContext context, ParseTreeNode parseNode) { if (parseNode.ChildNodes.Count < 1) { throw new ArgumentException("No index definitions found!"); } foreach (var child in parseNode.ChildNodes) { if (child.AstNode != null) { if (child.AstNode is IndexNameOptNode) { _IndexName = (child.AstNode as IndexNameOptNode).IndexName; } else if (child.AstNode is EditionOptNode) { _Edition = (child.AstNode as EditionOptNode).IndexEdition; } else if (child.AstNode is IndexTypeOptNode) { _IndexType = (child.AstNode as IndexTypeOptNode).IndexType; } else if (child.AstNode is IndexAttributeListNode) { _IndexAttributeDefinitions = (child.AstNode as IndexAttributeListNode).IndexAttributes; } else if (child.AstNode is OptionsNode) { _options = (child.AstNode as OptionsNode).Options; } } } #region Validation if (_IndexAttributeDefinitions.IsNullOrEmpty()) { throw new ArgumentException("No attributes given for index!"); } #endregion IndexDefinition = new IndexDefinition(_IndexName, _Edition, _IndexType, _IndexAttributeDefinitions, _options); }
/// <summary> /// Generates a index predefinition /// </summary> /// <param name="aIndex">The index definition by the gql</param> /// <returns>An IndexPredefinition</returns> private IndexPredefinition GenerateIndex(IndexDefinition aIndex) { IndexPredefinition result; if (String.IsNullOrEmpty(aIndex.IndexName)) { result = new IndexPredefinition(_TypeName); } else { result = new IndexPredefinition(aIndex.IndexName, _TypeName); } if (!String.IsNullOrEmpty(aIndex.IndexType)) { result.SetIndexType(aIndex.IndexType); } result.SetEdition(aIndex.Edition); //options for the index if (aIndex.Options != null) { foreach (var aKV in aIndex.Options) { result.AddOption(aKV.Key, aKV.Value); } } foreach (var aIndexProperty in aIndex.IndexAttributeDefinitions) { result.AddProperty(aIndexProperty.IndexAttribute.ContentString); } return result; }
/// <summary> /// Generates a index predefinition /// </summary> /// <param name="aIndex">The index definition by the gql</param> /// <returns>An IndexPredefinition</returns> private IndexPredefinition GenerateIndex(IndexDefinition aIndex) { IndexPredefinition result; if (String.IsNullOrEmpty(aIndex.IndexName)) { result = new IndexPredefinition(); } else { result = new IndexPredefinition(aIndex.IndexName); } if (!String.IsNullOrEmpty(aIndex.IndexType)) { result.SetIndexType(aIndex.IndexType); } result.SetEdition(aIndex.Edition); foreach (var aIndexProperty in aIndex.IndexAttributeDefinitions) { result.AddProperty(aIndexProperty.IndexAttribute.ContentString); } return result; }