public void GivenChildWithPreviousName_LatestNameIsRegisteredInParent() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection<Instruction> { x.StartObject<DummyClass>(), x.StartMember<DummyClass>(d => d.Child), x.StartObject<ChildClass>(), x.StartMember<ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var childClass = result.Find("OuterName"); Assert.NotNull(childClass); }
public void MultinameRegistrationGivesSameObjectTwoSubsequentNames() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection<Instruction> { x.StartObject<DummyClass>(), x.StartMember<DummyClass>(d => d.Child), x.StartObject<ChildClass>(), x.StartMember<ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var child = (DummyObject)result.Child; Assert.Equal("InnerName", child.NamesHistory[0]); Assert.Equal("OuterName", child.NamesHistory[1]); }
public void StringToDateConversion() { var mapping = new ColumnPropertyMapping<TestUser, DateTime>("CreatedAt", model => model.CreatedAt, ctx => ctx.ToDateTime()); var user = new TestUser(); var context = new ValueContext<TestUser> { ColumnValue = "2009-11-01", Entity = user }; var value = mapping.ConvertValue(context); Assert.Equal(new DateTime(2009,11,01), value); }
private ObjectAssembler CreateSut() { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary <string, object>()); return(new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, new Settings { InstanceLifeCycleListener = new TestListener() })); }
public override void ExitValue([NotNull] ValueContext context) { if (context.Int() != null) { if (int.TryParse(context.Int().GetText(), out int data)) { context.Value = (RawRsfInt)data; } else { Script.Warning.Add($"Warning [RS1001]: Non-integer value for integer argument. (Line {context.Int().Symbol.Line}, Position {context.Int().Symbol.Column + 1})"); } } else if (context.Float() != null) { if (float.TryParse(context.Float().GetText(), out float data)) { context.Value = (RawRsfFloat)data; } else { Script.Warning.Add($"Warning [RS1002]: Non-float value for float argument. (Line {context.Float().Symbol.Line}, Position {context.Float().Symbol.Column + 1})"); } } else if (context.Word() != null) { string data = context.Word().GetText(); if ((data.StartsWith('"') || data.StartsWith('\'')) && (data.EndsWith('"') || data.EndsWith('\''))) { Script.Warning.Add($"Warning [RS1003]: Plain string value for word-string argument. (Line {context.Float().Symbol.Line}, Position {context.Float().Symbol.Column + 1})"); } else { context.Value = (RawRsfWord)data; } } else if (context.plainString() != null) { string data = context.Word().GetText(); if ((data.StartsWith('"') || data.StartsWith('\'')) && (data.EndsWith('"') || data.EndsWith('\''))) { if (data.StartsWith('\'')) { data = data.Trim('\''); } else if (data.StartsWith('"')) { data = data.Trim('"'); } context.Value = (RawRsfPlainString)data; } else { Script.Warning.Add($"Warning [RS1004]: Word string value for plain-string argument. (Line {context.Float().Symbol.Line}, Position {context.Float().Symbol.Column + 1})"); } } }
public ValueRepository(ValueContext context) { _context = context; Add(new ValueItem { Value = "Item1" }); }
protected override void Dispose(bool disposing) { if (disposing && context != null) { context.Dispose(); context = null; } base.Dispose(disposing); }
public IObjectAssembler CreateAssembler(Settings settings) { var mapping = new DeferredLoaderMapping(); mapping.Map<DataTemplate>(template => template.Content, new DummyDeferredLoader()); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext, settings.ParsingContext); var objectAssembler = new ObjectAssembler(runtimeTypeSource, valueConnectionContext, settings); return new TemplateHostingObjectAssembler(objectAssembler, mapping); }
public void GetExpressionGetsAnExpresssionWhichReturnsFalseForADifferentManifestValueAndNoItem([ManifestModel] ManifestValue value, [ManifestModel] ManifestValue otherValue, object identity, object actualValue) { var context = new ValueContext(identity, actualValue, value); var sut = new ValueContextIsMatchForItem(otherValue); Assert.That(sut.Matches(context), Is.False); }
public void GetExpressionGetsAnExpresssionWhichReturnsFalseForAManifestValueAndADifferentItemWithoutIdentity([ManifestModel] ManifestValue value, ObjectWithIdentity item, ObjectWithIdentity otherItem) { value.IdentityAccessor = null; var context = new ValueContext(null, item, value); var sut = new ValueContextIsMatchForItem(value, otherItem); Assert.That(sut.Matches(context), Is.False); }
public void AutoToStringConversion() { var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name); var user = new TestUser(); var ctx = new ValueContext<TestUser> {ColumnValue = 22, Entity = user}; var value = mapping.ConvertValue(ctx); Assert.Equal("22", value); mapping.SetValue(user, value); }
public void CalculateItem(PriceItem item, ICalculationContext context) { ValueContext valueContext = context as ValueContext; if (valueContext == null) { throw new InvalidCastException("The supplied ICalculationContext is not of type ValueContext"); } DoCalculation(item, valueContext); }
public IObjectAssembler CreateAssembler(Settings settings) { var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.Content, new DummyDeferredLoader()); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext, settings.ParsingContext); var objectAssembler = new ObjectAssembler(runtimeTypeSource, valueConnectionContext, settings); return(new TemplateHostingObjectAssembler(objectAssembler, mapping)); }
public IObjectAssembler CreateSutForLoadingSpecificInstance(object instance) { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext); var settings = new Settings { RootInstance = instance }; var assembler = new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, settings); return(assembler); }
public void CalculateItems(List <PriceItem> items, ICalculationContext context) { ValueContext valueContext = context as ValueContext; if (valueContext == null) { throw new InvalidCastException("The supplied ICalculationContext is not of type ValueContext"); } Parallel.ForEach(items, (currentItem => { DoCalculation(currentItem, valueContext); })); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 8, RULE_value); try { State = 51; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case WORD: EnterOuterAlt(_localctx, 1); { State = 44; _localctx.content = Match(WORD); } break; case SINGLE_QUOTE: EnterOuterAlt(_localctx, 2); { State = 45; Match(SINGLE_QUOTE); State = 46; _localctx.content = Match(WORD); State = 47; Match(SINGLE_QUOTE); } break; case DOUBLE_QUOTE: EnterOuterAlt(_localctx, 3); { State = 48; Match(DOUBLE_QUOTE); State = 49; _localctx.content = Match(WORD); State = 50; Match(DOUBLE_QUOTE); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ObjectAssembler(IRuntimeTypeSource typeSource, ITopDownValueContext topDownValueContext, Settings settings = null) { TypeSource = typeSource; var mapping = new DeferredLoaderMapping(); mapping.Map<DataTemplate>(template => template.AlternateTemplateContent, new DeferredLoader()); var parsingDictionary = GetDictionary(settings); var valueConnectionContext = new ValueContext(typeSource, topDownValueContext, parsingDictionary); objectAssembler = new TemplateHostingObjectAssembler( new OmniXaml.ObjectAssembler.ObjectAssembler( typeSource, valueConnectionContext, settings), mapping); }
private bool ShouldCount(object value, ValueContext context) { switch (context) { case ValueContext.EnteredDirectly: return(value == null || value is decimal || ConvertUtil.TryParseObjectToDecimal(value, out double parsedValue)); case ValueContext.FromCellRange: case ValueContext.FromArray: return(!(value is bool) && this.IsNumeric(value)); default: return(false); } }
public ObjectAssembler(IRuntimeTypeSource typeSource, ITopDownValueContext topDownValueContext, Settings settings = null) { TypeSource = typeSource; var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.AlternateTemplateContent, new DeferredLoader()); var parsingDictionary = GetDictionary(settings); var valueConnectionContext = new ValueContext(typeSource, topDownValueContext, parsingDictionary); objectAssembler = new TemplateHostingObjectAssembler( new OmniXaml.ObjectAssembler.ObjectAssembler( typeSource, valueConnectionContext, settings), mapping); }
public PerspexObjectAssembler( IRuntimeTypeSource typeSource, ITopDownValueContext topDownValueContext, Settings settings = null) { var mapping = new DeferredLoaderMapping(); mapping.Map <ControlTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <DataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <FocusAdornerTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <TreeDataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <ItemsPanelTemplate>(x => x.Content, new TemplateLoader()); var valueContext = new ValueContext(typeSource, topDownValueContext); assembler = new ObjectAssembler(typeSource, valueContext, settings); objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 6, RULE_value); try { State = 25; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case ELEMENT: _localctx = new ELEMENTContext(_localctx); EnterOuterAlt(_localctx, 1); { State = 23; Match(ELEMENT); } break; case STRING: _localctx = new STRINGContext(_localctx); EnterOuterAlt(_localctx, 2); { State = 24; Match(STRING); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 12, RULE_value); try { State = 64; switch (TokenStream.La(1)) { case BOOLEAN: case NUMBER: case STRING: _localctx = new ConstantValueContext(_localctx); EnterOuterAlt(_localctx, 1); { State = 62; ((ConstantValueContext)_localctx).Value = constant(); } break; case CURLY_BRACE_OPEN: case SQUARE_BRACE_OPEN: _localctx = new LiteralValueContext(_localctx); EnterOuterAlt(_localctx, 2); { State = 63; ((LiteralValueContext)_localctx).Value = literal(); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ValueContext value() { ValueContext _localctx = new ValueContext(_ctx, State); EnterRule(_localctx, 12, RULE_value); try { EnterOuterAlt(_localctx, 1); { State = 80; Match(Value); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ValuesController(ValueContext context) { _context = context; if (_context.Persons.Count() == 0) { _context.Persons.Add(new Person { Name = "Foo", Surname = "Dummy", Address = new Address() { City = "Las Vegas", Street = "Mainstreet", Type = AddressType.Business, ZIP = "98765" }, Communication = new Communication() { Type = CommunicationType.Email, Value = "*****@*****.**" } }); _context.SaveChanges(); } }
public ValueContext value() { ValueContext _localctx = new ValueContext(_ctx, State); EnterRule(_localctx, 8, RULE_value); try { EnterOuterAlt(_localctx, 1); { State = 45; Match(T__3); State = 46; Match(WHITESPACE); State = 47; _localctx.val = Match(NUMBER); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ValuesController(ValueContext dbContext) { _dbContext = dbContext; }
private IObjectAssembler CreateSutForLoadingSpecificInstance(object instance) { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary<string, object>()); var settings = new Settings {RootInstance = instance}; var assembler = new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, settings); return assembler; }
public StringValueContext(ValueContext context) { CopyFrom(context); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 40, RULE_value); try { EnterOuterAlt(_localctx, 1); { State = 155; Match(Number); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }
public ValuesController(ValueContext dataContext) { _dataContext = dataContext; }
public ValueContext value() { ValueContext _localctx = new ValueContext(_ctx, State); EnterRule(_localctx, 28, RULE_value); try { State = 286; switch (_input.La(1)) { case INTEGER: EnterOuterAlt(_localctx, 1); { State = 274; _localctx._INTEGER = Match(INTEGER); try{ _localctx.retValue = new ValueExpression(int.Parse((_localctx._INTEGER!=null?_localctx._INTEGER.Text:null)), ValueType.Integer);} catch { _localctx.retValue = new ValueExpression(long.Parse((_localctx._INTEGER!=null?_localctx._INTEGER.Text:null)), ValueType.Integer); } } break; case FLOAT: EnterOuterAlt(_localctx, 2); { State = 276; _localctx._FLOAT = Match(FLOAT); _localctx.retValue = new ValueExpression(double.Parse((_localctx._FLOAT!=null?_localctx._FLOAT.Text:null), NumberStyles.Float, numberFormatInfo), ValueType.Float); } break; case STRING: EnterOuterAlt(_localctx, 3); { State = 278; _localctx._STRING = Match(STRING); _localctx.retValue = new ValueExpression(extractString((_localctx._STRING!=null?_localctx._STRING.Text:null)), ValueType.String); } break; case DATETIME: EnterOuterAlt(_localctx, 4); { State = 280; _localctx._DATETIME = Match(DATETIME); _localctx.retValue = new ValueExpression(DateTime.Parse((_localctx._DATETIME!=null?_localctx._DATETIME.Text:null).Substring(1, (_localctx._DATETIME!=null?_localctx._DATETIME.Text:null).Length - 2)), ValueType.DateTime); } break; case TRUE: EnterOuterAlt(_localctx, 5); { State = 282; Match(TRUE); _localctx.retValue = new ValueExpression(true, ValueType.Boolean); } break; case FALSE: EnterOuterAlt(_localctx, 6); { State = 284; Match(FALSE); _localctx.retValue = new ValueExpression(false, ValueType.Boolean); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }
public ValueRepository() { this.db = new ValueContext(); }
public BooleanValueContext(ValueContext context) { CopyFrom(context); }
public ValuesController() { context = new ValueContext(); //ConfigurationManager.ConnectionStrings["valueContext"].ConnectionString }
private ObjectAssembler CreateSut() { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary<string, object>()); return new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, new Settings {InstanceLifeCycleListener = new TestListener()}); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 8, RULE_value); int _la; try { EnterOuterAlt(_localctx, 1); { State = 78; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case PLAINCHAR: { State = 75; Match(PLAINCHAR); } break; case ESCAPE: { State = 76; Match(ESCAPE); State = 77; _la = TokenStream.LA(1); if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ESCAPE) | (1L << SPACE) | (1L << PAIR_SEPERATOR) | (1L << PLAINCHAR))) != 0))) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } } break; default: throw new NoViableAltException(this); } State = 86; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ESCAPE) | (1L << SPACE) | (1L << PLAINCHAR))) != 0)) { { State = 84; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case PLAINCHAR: { State = 80; Match(PLAINCHAR); } break; case SPACE: { State = 81; Match(SPACE); } break; case ESCAPE: { State = 82; Match(ESCAPE); State = 83; _la = TokenStream.LA(1); if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ESCAPE) | (1L << SPACE) | (1L << PAIR_SEPERATOR) | (1L << PLAINCHAR))) != 0))) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } } break; default: throw new NoViableAltException(this); } } State = 88; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 8, RULE_value); try { State = 97; switch (TokenStream.La(1)) { case LeftBrace: EnterOuterAlt(_localctx, 1); { State = 94; @object(); } break; case LeftBracket: EnterOuterAlt(_localctx, 2); { State = 95; array(); } break; case LeftParen: case Plus: case PlusPlus: case Minus: case MinusMinus: case Star: case And: case Not: case Tilde: case Identifier: case Constant: case StringLiteral: EnterOuterAlt(_localctx, 3); { State = 96; expression(); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 28, RULE_value); int _la; try { EnterOuterAlt(_localctx, 1); { State = 915; ErrorHandler.Sync(this); _la = TokenStream.La(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LINE_FOLD) | (1L << WSP) | (1L << A) | (1L << B) | (1L << C) | (1L << D) | (1L << E) | (1L << F) | (1L << G) | (1L << H) | (1L << I) | (1L << J) | (1L << K) | (1L << L) | (1L << M) | (1L << N) | (1L << O) | (1L << P) | (1L << Q) | (1L << R) | (1L << S) | (1L << T) | (1L << U) | (1L << V) | (1L << W) | (1L << X) | (1L << Y) | (1L << Z) | (1L << EXCLAMATION) | (1L << DQUOTE) | (1L << HASH) | (1L << DOLLAR) | (1L << X25) | (1L << AMP) | (1L << X27) | (1L << X28) | (1L << X29) | (1L << X2A) | (1L << PLUS) | (1L << COMMA) | (1L << MINUS) | (1L << DOT) | (1L << FSLASH) | (1L << D0) | (1L << D1) | (1L << D2) | (1L << D3) | (1L << D4) | (1L << D5) | (1L << D6) | (1L << D7) | (1L << D8) | (1L << D9) | (1L << COL) | (1L << SCOL) | (1L << X3C) | (1L << ASSIGN) | (1L << X3E) | (1L << X3F) | (1L << X40))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (X5B - 64)) | (1L << (BSLASH - 64)) | (1L << (X5D - 64)) | (1L << (CARET - 64)) | (1L << (USCORE - 64)) | (1L << (X60 - 64)) | (1L << (X7B - 64)) | (1L << (X7C - 64)) | (1L << (X7D - 64)) | (1L << (X7E - 64)) | (1L << (NON_US_ASCII - 64)))) != 0)) { { { State = 912; value_char(); } } State = 917; ErrorHandler.Sync(this); _la = TokenStream.La(1); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }
public ArrayValueContext(ValueContext context) { CopyFrom(context); }
public IntegerValueContext(ValueContext context) { CopyFrom(context); }
private void DoCalculation(PriceItem item, ValueContext valueContext) { item.Price = item.Price + valueContext.Value; }
public ValueContext value() { ValueContext _localctx = new ValueContext(Context, State); EnterRule(_localctx, 8, RULE_value); try { State = 52; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: _localctx = new ArrayValueContext(_localctx); EnterOuterAlt(_localctx, 1); { State = 46; array(); } break; case BOOLEAN: _localctx = new BooleanValueContext(_localctx); EnterOuterAlt(_localctx, 2); { State = 47; Match(BOOLEAN); } break; case INTEGER: _localctx = new IntegerValueContext(_localctx); EnterOuterAlt(_localctx, 3); { State = 48; Match(INTEGER); } break; case T__6: _localctx = new NullValueContext(_localctx); EnterOuterAlt(_localctx, 4); { State = 49; Match(T__6); } break; case T__3: _localctx = new ObjectValueContext(_localctx); EnterOuterAlt(_localctx, 5); { State = 50; oBjEcT(); } break; case STRING: _localctx = new StringValueContext(_localctx); EnterOuterAlt(_localctx, 6); { State = 51; Match(STRING); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }