public void Travel(IReadVisitor visitor, MultidimensionalArrayGraph graph) { ValueState state; state = visitor.TryVisit(_argsValue); if (state != ValueState.NotFound) { if (state == ValueState.Found) { ICollection <ICollection <int> > c = new List <ICollection <int> >(); while (visitor.TryVisit(VisitArgs.CollectionInCollection) == ValueState.Found) { ICollection <int> cv = new List <int>(); int?cvv; while (visitor.TryVisitValue(VisitArgs.CollectionItem, out cvv) && cvv.HasValue) { cv.Add(cvv.Value); } visitor.Leave(VisitArgs.CollectionInCollection); c.Add(cv); } graph.Value = ArrayProvider.To2DArray(c); visitor.Leave(_argsValue); } else { graph.Value = null; } } }
public void Travel(IReadVisitor visitor, TDictionary graph) { var valueArgs = VisitArgs.DictionaryValue; TValue TravelValue() { TValue value; if (_valueVisitor != null) { if (!_valueVisitor.TryVisitValue(visitor, valueArgs, out value)) { throw new InvalidGraphException("There were no corresponding value to the dictionary key."); } return(value); } if (visitor.TryVisit(valueArgs) != ValueState.Found) { throw new InvalidGraphException("There were no corresponding value to the dictionary key."); } value = (TValue)_instanceFactory.CreateInstance(_valueType); _valueTraveller.Travel(visitor, value); visitor.Leave(valueArgs); return(value); } var keyArgs = VisitArgs.DictionaryKey; if (_keyVisitor != null) { while (_keyVisitor.TryVisitValue(visitor, keyArgs, out var key)) { var value = TravelValue(); graph.Add(key, value); } return; } while (visitor.TryVisit(keyArgs) == ValueState.Found) { var key = (TKey)_instanceFactory.CreateInstance(_keyType); _keyTraveller.Travel(visitor, key); visitor.Leave(keyArgs); var value = TravelValue(); graph.Add(key, value); } }
public void Visit(object graph, IReadVisitor visitor) { var state = visitor.TryVisit(_args); if (state == ValueState.NotFound) return; if (state == ValueState.Null) { _property.Ref.SetValue(graph, null); visitor.Leave(_args); return; } var childGraph = Activator.CreateInstance(_property.Ref.PropertyType); _propertyType.Visit(childGraph, visitor); _property.Ref.SetValue(graph, childGraph); visitor.Leave(_args); }
public void Visit(object graph, IReadVisitor visitor) { var state = visitor.TryVisit(_args); if (state == ValueState.NotFound) { return; } if (state == ValueState.Null) { _property.Ref.SetValue(graph, null); visitor.Leave(_args); return; } var childGraph = Activator.CreateInstance(_property.Ref.PropertyType); _propertyType.Visit(childGraph, visitor); _property.Ref.SetValue(graph, childGraph); visitor.Leave(_args); }
public void Travel(IReadVisitor visitor, TCollection graph) { var itemArgs = VisitArgs.CollectionItem; if (_valueVisitor != null) { while (_valueVisitor.TryVisitValue(visitor, itemArgs, out var value)) { graph.Add(value); } return; } while (visitor.TryVisit(itemArgs) == ValueState.Found) { var element = (TElement)_instanceFactory.CreateInstance(_elementType); _elementTraveller.Travel(visitor, element); graph.Add(element); visitor.Leave(itemArgs); } }
public void Travel(IReadVisitor visitor, DataBlock graph) { Guid?v0; if (visitor.TryVisitValue(_argsId, out v0) && v0.HasValue) { graph.Id = v0.Value; } String v1; if (visitor.TryVisitValue(_argsString, out v1)) { graph.String = v1; } Int16?v2; if (visitor.TryVisitValue(_argsInt16, out v2) && v2.HasValue) { graph.Int16 = v2.Value; } Int32?v3; if (visitor.TryVisitValue(_argsInt32, out v3) && v3.HasValue) { graph.Int32 = v3.Value; } Int64?v4; if (visitor.TryVisitValue(_argsInt64, out v4) && v4.HasValue) { graph.Int64 = v4.Value; } UInt16?v5; if (visitor.TryVisitValue(_argsUInt16, out v5) && v5.HasValue) { graph.UInt16 = v5.Value; } UInt32?v6; if (visitor.TryVisitValue(_argsUInt32, out v6) && v6.HasValue) { graph.UInt32 = v6.Value; } UInt64?v7; if (visitor.TryVisitValue(_argsUInt64, out v7) && v7.HasValue) { graph.UInt64 = v7.Value; } Single?v8; if (visitor.TryVisitValue(_argsSingle, out v8) && v8.HasValue) { graph.Single = v8.Value; } Double?v9; if (visitor.TryVisitValue(_argsDouble, out v9) && v9.HasValue) { graph.Double = v9.Value; } TimeSpan?v10; if (visitor.TryVisitValue(_argsTimeSpan, out v10) && v10.HasValue) { graph.TimeSpan = v10.Value; } Decimal?v11; if (visitor.TryVisitValue(_argsDecimal, out v11) && v11.HasValue) { graph.Decimal = v11.Value; } DateTime?v12; if (visitor.TryVisitValue(_argsDateTime, out v12) && v12.HasValue) { graph.DateTime = v12.Value; } Byte?v13; if (visitor.TryVisitValue(_argsByte, out v13) && v13.HasValue) { graph.Byte = v13.Value; } Boolean?v14; if (visitor.TryVisitValue(_argsBoolean, out v14) && v14.HasValue) { graph.Boolean = v14.Value; } Byte[] v15; if (visitor.TryVisitValue(_argsBlob, out v15)) { graph.Blob = v15; } ValueState state; state = visitor.TryVisit(_argsMessages); if (state != ValueState.NotFound) { if (state == ValueState.Found) { var c = new List <string>(); string cv; while (visitor.TryVisitValue(VisitArgs.CollectionItem, out cv) && cv != null) { c.Add(cv); } graph.Messages = c; visitor.Leave(_argsMessages); } else { graph.Messages = null; } } state = visitor.TryVisit(_argsStamps); if (state != ValueState.NotFound) { if (state == ValueState.Found) { var c = new List <DateTime>(); DateTime?cv; while (visitor.TryVisitValue(VisitArgs.CollectionItem, out cv) && cv.HasValue) { c.Add(cv.Value); } graph.Stamps = c; visitor.Leave(_argsStamps); } else { graph.Stamps = null; } } state = visitor.TryVisit(_argsRelation); if (state != ValueState.NotFound) { if (state == ValueState.Found) { var c = new Relation(); _travellerRelation0.Travel(visitor, c); graph.Relation = c; visitor.Leave(_argsRelation); } else { graph.Relation = null; } } state = visitor.TryVisit(_argsDummyRelation); if (state != ValueState.NotFound) { if (state == ValueState.Found) { var c = new Relation(); _travellerRelation0.Travel(visitor, c); graph.DummyRelation = c; visitor.Leave(_argsDummyRelation); } else { graph.DummyRelation = null; } } state = visitor.TryVisit(_argsSecondaryRelations); if (state != ValueState.NotFound) { if (state == ValueState.Found) { var c = new List <Relation>(); while (visitor.TryVisit(VisitArgs.CollectionItem) == ValueState.Found) { var cv = new Relation(); _travellerRelation0.Travel(visitor, cv); visitor.Leave(VisitArgs.CollectionItem); c.Add(cv); } graph.SecondaryRelations = c; visitor.Leave(_argsSecondaryRelations); } else { graph.SecondaryRelations = null; } } state = visitor.TryVisit(_argsIndexedValues); if (state != ValueState.NotFound) { if (state == ValueState.Found) { IDictionary <string, int> c = new Dictionary <string, int>(); string ck; while (visitor.TryVisitValue(VisitArgs.DictionaryKey, out ck) && ck != null) { int?cv; if (visitor.TryVisitValue(VisitArgs.DictionaryValue, out cv) && cv.HasValue) { c.Add(ck, cv.Value); } else { throw InvalidGraphException.NoDictionaryValue("IndexedValues"); } } graph.IndexedValues = (Dictionary <string, int>)c; visitor.Leave(_argsIndexedValues); } else { graph.IndexedValues = null; } } state = visitor.TryVisit(_argsCategories); if (state != ValueState.NotFound) { if (state == ValueState.Found) { IDictionary <Identifier, Category> c = new Dictionary <Identifier, Category>(); while (visitor.TryVisit(VisitArgs.DictionaryKey) == ValueState.Found) { var ck = new Identifier(); _travellerIdentifier1.Travel(visitor, ck); visitor.Leave(VisitArgs.DictionaryKey); if (visitor.TryVisit(VisitArgs.DictionaryValue) == ValueState.Found) { var cv = new Category(); _travellerCategory2.Travel(visitor, cv); visitor.Leave(VisitArgs.DictionaryValue); c.Add(ck, cv); } else { throw InvalidGraphException.NoDictionaryValue("Categories"); } } graph.Categories = (Dictionary <Identifier, Category>)c; visitor.Leave(_argsCategories); } else { graph.IndexedValues = null; } } }