public IDataContextBuilder AddChild(IDataScopeRules dataScopeRules) { var child = new DataContextBuilder( _dataContextFactory, _idManager, _dataCatalog, dataScopeRules) { _parent = this }; #if DETAILED_TRACE Trace.WriteLine("Data context builder #" + Id + " is the parent of #" + child.Id); #endif if (_children == null) { _children = new[] { child } } ; else { _children = _children.Concat(new[] { child }).ToArray(); } return(child); }
private object GetUnscoped(Type type, bool isRequired) { var retry = false; while (true) { object result; if (TryGetProperty(type, out result)) { return(result); } if (_parent != null) { return(_parent.Get(type, null, isRequired)); } if (!isRequired) { return(null); } if (retry) { throw RetryFailedException(type); } DataContextBuilder.AddMissingData(_renderContext, _dataDependencyFactory.Create(type)); retry = true; } }
private void SetScoped(Type type, object value, string scopeName) { var dependency = _dataDependencyFactory.Create(type, scopeName); var isInScope = DataContextBuilder.IsInScope(dependency); if (isInScope || _parent == null) { SetProperty(type, scopeName, value); } else { _parent.Set(type, value, scopeName); } }
private object GetScoped(Type type, string scopeName, bool isRequired) { var retry = false; while (true) { object result; if (TryGetProperty(type, scopeName, out result)) { return(result); } var dependency = _dataDependencyFactory.Create(type, scopeName); var isInScope = DataContextBuilder.IsInScope(dependency); if (!isInScope) { if (_parent == null) { if (!isRequired) { return(null); } throw ScopeSearchFailedException(type, scopeName); } return(_parent.Get(type, scopeName, isRequired)); } if (!isRequired) { return(null); } if (retry) { throw RetryFailedException(type); } DataContextBuilder.AddMissingData(_renderContext, dependency); retry = true; } }