/// <inheritdoc/> public Scene Read() { _root ??= this.Parse(); INodeConverter converter = NodeConverterBase.GetConverter(_root, this.OnNotification); return(converter.ConvertScene()); }
public ParzEngine(IEnumerable <string> separators, ITokenFactory tokenFactory, INodeConverter nodeConverter, Func <IEnumerable <string>, IEnumerable <ILeveledToken> > toLevelTokens = null) { _separators = separators; _tokenFactory = tokenFactory; _nodeConverter = nodeConverter; _toLevelTokens = toLevelTokens ?? ((t) => t.ToLevelTokens()); }
/// <summary>Creates a new instance of <see cref="OntologyAccessor"/>.</summary> internal OntologyAccessor(Entity entity, IOntology ontology, INodeConverter nodeConverter, IResultTransformerCatalog resultTransformers) { _tripleStore = entity.Context.Store; _entity = entity; _ontology = ontology; _resultTransformers = resultTransformers; _nodeConverter = nodeConverter; _context = entity.Context; }
protected void Property(string name, Uri predicate, Type returnType, INodeConverter converter) { var property = new Mock <IPropertyMapping>(); property.SetupGet(instance => instance.Name).Returns(name); property.SetupGet(instance => instance.Uri).Returns(predicate); property.SetupGet(instance => instance.ReturnType).Returns(returnType); property.SetupGet(instance => instance.Converter).Returns(converter); property.SetupGet(instance => instance.EntityMapping).Returns(this); _properties.Add(property.Object); }
protected void Collection(string name, Uri predicate, Type returnType, INodeConverter converter) { var collection = new Mock <ICollectionMapping>(); collection.SetupGet(instance => instance.Name).Returns(name); collection.SetupGet(instance => instance.Uri).Returns(predicate); collection.SetupGet(instance => instance.ReturnType).Returns(returnType); collection.SetupGet(instance => instance.Converter).Returns(converter); collection.SetupGet(instance => instance.ElementConverter).Returns(converter); collection.SetupGet(instance => instance.StoreAs).Returns(StoreAs.SimpleCollection); collection.SetupGet(instance => instance.EntityMapping).Returns(this); _properties.Add(collection.Object); }
public INode ToNode(IEnumerable <IToken> tokens, INodeConverter next) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } var intermediateOperators = new List <OperatorHelper>(); var currIndex = 0; var hasOperand = false; foreach (var curr in tokens) { if (curr.TokenType == ParzTokenType.Operator && hasOperand && curr.Level == 0) { // Add and reset the operand, this a new operator hasOperand = false; intermediateOperators.Add(new OperatorHelper { Index = currIndex, Priority = _operators[curr.Symbol], Symbol = curr.Symbol }); } if (curr.TokenType != ParzTokenType.Operator) { hasOperand = true; } currIndex++; } if (!intermediateOperators.Any()) { // There is no operator at this level! return(next.ToNode(tokens, next)); } // Need to check the lowest priority Operator var lowestPriorityOperator = intermediateOperators .Aggregate((prev, curr) => prev.Priority < curr.Priority ? prev : curr); var left = tokens.Take(lowestPriorityOperator.Index); var right = tokens.Skip(lowestPriorityOperator.Index + 1); return(new BinaryOperationNode(lowestPriorityOperator.Symbol, next.ToNode(left, next), next.ToNode(right, next))); }
public RazorNodeConverterProvider( IRazorDirectiveNodeFactory directiveNodeFactory, IRazorSectionNodeFactory sectionNodeFactory, IRazorCodeNodeFactory codeNodeFactory, IRazorTextNodeFactory textNodeFactory, IRazorCommentNodeFactory commentNodeFactory, IRazorExpressionNodeFactory expressionNodeFactory, IContentTagConverterConfiguration contentTagConverterConfig) { NodeConverters = new INodeConverter<IRazorNode>[] { new DirectiveConverter(directiveNodeFactory), new ContentTagConverter(this, sectionNodeFactory, contentTagConverterConfig), new CodeGroupConverter(this), new CodeBlockConverter(codeNodeFactory), new TextNodeConverter(textNodeFactory), new CommentNodeConverter(commentNodeFactory), new ExpressionBlockConverter(expressionNodeFactory) }; }
public INode ToNode(IEnumerable <IToken> tokens, INodeConverter next) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } if (next == null) { throw new ArgumentNullException(nameof(next)); } var first = tokens.First(); var operatorSymbol = first.Symbol; var node = next.ToNode(tokens.Skip(1), next); return(new UnaryOperationNode(operatorSymbol, node)); }
public RazorNodeConverterProvider(IRazorDirectiveNodeFactory directiveNodeFactory, IRazorSectionNodeFactory sectionNodeFactory, IRazorCodeNodeFactory codeNodeFactory, IRazorTextNodeFactory textNodeFactory, IRazorCommentNodeFactory commentNodeFactory, IRazorExpressionNodeFactory expressionNodeFactory, IContentTagConverterConfiguration contentTagConverterConfig) { NodeConverters = new INodeConverter <IRazorNode>[] { new DirectiveConverter(directiveNodeFactory, textNodeFactory), new ContentTagConverter(this, sectionNodeFactory, contentTagConverterConfig), new CodeGroupConverter(this), new CodeBlockConverter(codeNodeFactory), new TextNodeConverter(textNodeFactory), new CommentNodeConverter(commentNodeFactory), new ExpressionBlockConverter(expressionNodeFactory) }; }
public static INodeConverter GetConverter(FbxRootNode root, NotificationHandler onNotification) { INodeConverter converter = null; switch (root.Version) { case FbxVersion.v2000: case FbxVersion.v2001: case FbxVersion.v3000: case FbxVersion.v3001: case FbxVersion.v4000: case FbxVersion.v4001: case FbxVersion.v4050: case FbxVersion.v5000: case FbxVersion.v5800: throw new NotSupportedException($"Fbx version {root.Version} not supported"); case FbxVersion.v6000: case FbxVersion.v6100: throw new NotImplementedException($"Fbx version {root.Version} not implemented"); case FbxVersion.v7000: case FbxVersion.v7100: case FbxVersion.v7200: case FbxVersion.v7300: case FbxVersion.v7400: converter = new NodeConverter7400(root, onNotification); break; case FbxVersion.v7500: case FbxVersion.v7600: case FbxVersion.v7700: converter = new NodeConverter7400(root, onNotification); break; default: throw new Exception($"Unknown fbx version : {root.Version}"); } //TODO: check the versions differences to implement the missing converters return(converter); }
public static INode Treeify(this IEnumerable <IToken> tokens, INodeConverter converter) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } if (converter == null) { throw new ArgumentNullException(nameof(converter)); } if (!tokens.Any()) { throw new InvalidOperationException("Cannot treefy an empty expression!"); } return(converter.ToNode(tokens, converter)); }
public INode ToNode(IEnumerable <IToken> tokens, INodeConverter next) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } if (next == null) { throw new ArgumentNullException(nameof(next)); } // Find the location of the closing tag var idx = 1; var first = tokens.First(); foreach (var curr in tokens.Skip(1)) { if (curr.TokenType == ParzTokenType.Closer && curr.Level == first.Level) { break; } idx++; } // Check if it's the expression's end var count = tokens.Count(); if (idx != count - 1) { return(next.ToNode(tokens, next)); } // Trim the parentheses. Normalize the level // to avoid any inconsistencies. tokens = tokens .Skip(1) .Take(count - 2) .NormalizeLevel(); return(next.ToNode(tokens, next)); }
public CustomOverExpressionConverter(DefaultDocumentConverter documentConverter) : base(documentConverter) { originalOverExpressionConverter = new OverExpressionConverter(documentConverter); }
public INode ToNode(IEnumerable <IToken> token, INodeConverter next) { return(new ConstantNumberNode(decimal.Parse( _adapt(token.First().Symbol), _numberStyles, _formatProvider))); }
/// <summary>Creates instance of the <see cref="IBaseUriSelectionPolicy"/>.</summary> public AsEntityConverter() { _entityIdConverter = new EntityIdConverter(); }
/// <summary>Creates instance of the <see cref="IBaseUriSelectionPolicy"/>.</summary> /// <param name="baseUriSelectionPolicy">Base Uri selection policy.</param> public AsEntityConverter(IBaseUriSelectionPolicy baseUriSelectionPolicy) { _entityIdConverter = new EntityIdConverter(baseUriSelectionPolicy); }
public INode ToNode(IEnumerable <IToken> tokens, INodeConverter next) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } var first = tokens.First(); tokens = tokens.Skip(1); var second = tokens.First(); if (second.TokenType != ParzTokenType.Opener) { throw new InvalidOperationException( "Functions must be followed by parentheses!"); } var currentLevel = second.Level; var leftIdx = 0; var length = 0; tokens = tokens.Skip(1); var functionNodes = new List <IEnumerable <IToken> >(); foreach (var curr in tokens) { if (curr.TokenType == ParzTokenType.Closer && curr.Level == currentLevel) { break; } if (curr.TokenType == FuncTokenType.Separator && curr.Level == currentLevel) { var segment = tokens .Skip(leftIdx) .Take(length); functionNodes.Add(segment); // Need to skip the separator leftIdx += length + 1; length = 0; } else { length++; } } var lastSegment = tokens .Skip(leftIdx) .Take(length); // Funcions can be parameterless. if (tokens.Any()) { functionNodes.Add(lastSegment); } var arguments = functionNodes .Select(t => t.NormalizeLevel()) .Select(t => next.ToNode(t, next)); return(new FunctionNode(first.Symbol, arguments)); }
public INode ToNode(IEnumerable <IToken> token, INodeConverter next) { return(new VariableNode(token.First().Symbol)); }
public HtmlScraperConfigurationBuilder UseDefaultNodeConverter(INodeConverter nodeConverter) { SetProperty(x => x.DefaultNodeConverter, nodeConverter); return(this); }
private static DataNode GetNode(string name, object o, Dictionary <Type, Guid> derivedTypes, bool readOnly) { DataNode ret = null; if (o != null) { Type t = o.GetType(); if (o is DataNode) { ret = ((DataNode)o).CloneNode(); } else if (t.IsEnum) { ret = new EnumDataValue(name, (Enum)o); } else if (t.IsPrimitive) { ret = GetPrimitiveType(name, t, o); } else if (o is IPrimitiveValue) { object v = ((IPrimitiveValue)o).Value; ret = GetPrimitiveType(name, v.GetType(), v); } else if (t == typeof(DateTime)) { // Use a unix datetime, doesn't _really_ matter ret = new UnixDateTimeDataValue(name, false, (DateTime)o); } else if (t == typeof(string)) { ret = new StringDataValue(name, (string)o); } else if (t == typeof(BigInteger)) { ret = new BigIntegerDataValue(name, (BigInteger)o); } else if (t.IsArray) { if (t.GetElementType() == typeof(byte)) { byte[] newArr = (byte[])((byte[])o).Clone(); ret = new ByteArrayDataValue(name, (byte[])o); } else if (t.GetElementType() == typeof(char)) { ret = new StringDataValue(name, new string((char[])o)); } else { DataKey key = new DataKey(name); GetArrayType(key, t, o, derivedTypes, readOnly); ret = key; } } else if (t == typeof(IPAddress)) { ret = new IPAddressDataValue(name, (IPAddress)o); } else { INodeConverter converter = o as INodeConverter; if (converter != null) { ret = converter.ToNode(name); } else { DataKey key = new DataKey(name); GetComplexType(key, t, o, derivedTypes); ret = key; } } if (ret != null) { ret.Readonly = readOnly; } } return(ret); }
public INode ToNode(IEnumerable <IToken> token, INodeConverter next) { return(new LambdaExpressionNode(token.First().Symbol)); }
internal Entity(EntityId entityId, IEntityContext context, IFallbackNodeConverter fallbackNodeConverter, IResultTransformerCatalog transformerCatalog) : this(entityId, context) { _fallbackNodeConverter = fallbackNodeConverter; _transformerCatalog = transformerCatalog; }