internal void RegisterParentDependency(DependencyParentInfo dependencyParentInfo) { if (pendingParents == null) { pendingParents = new List <DependencyParentInfo>(); } pendingParents.Add(dependencyParentInfo); }
private void ProcessPendingParent(DependencyParentInfo pendingParent) { var dependency = pendingParent.child; if (dependency == null) { AddDependency(parent: pendingParent.ParentValue, value: null); } else { var surrogateManager = _stateManager.surrogateManager; var parentAsIStateObject = pendingParent.ParentValue as IStateObject; if (parentAsIStateObject != null) { //Parent is an STATEOBJECT if (pendingParent.child.canBeAnOrphan) { _stateManager.AdoptionInformation.RegisterPossibleOrphan(parentAsIStateObject, (IStateObject)dependency.ResolvedValue); } surrogateManager.AddSurrogateReference(dependency.ResolvedSurrogate, parentAsIStateObject); //StateObject do not have dependencies } else { //Parent is a SURROGATE var parentAsSurrogate = pendingParent.ParentSurrogate ?? surrogateManager.GetSurrogateFor(pendingParent.ParentValue, generateIfNotFound: true); if (parentAsSurrogate == null) { throw new ArgumentException("A surrogate could not be gotten for value of type " + pendingParent.ParentValue.GetType().FullName); } if (dependency.IsStateObject) { if (dependency.canBeAnOrphan) { _stateManager.AdoptionInformation.RegisterPossibleOrphan(parent: parentAsSurrogate, obj: (IStateObject)dependency.ResolvedValue); } } else { if (!dependency.isEventsInfo) { surrogateManager.AddSurrogateReference(dependency.ResolvedSurrogate, parentAsSurrogate); } } AddDependency(parent: pendingParent.ParentValue, value: dependency.ResolvedValue); } } }