internal View GetChild(Selector selector, bool createImplicity=true)
{
if(selector == null || selector.IsEmpty ) {
return this;
}
if (string.IsNullOrEmpty(selector.Name) && selector.Parameter != null) {
selector = new Selector("*",selector.Parameter,selector.SourceLocation,selector.AfterTheParameter);
}
selector = ResolveAlias(selector);
if(selector.IsGlobal) {
return RootView.GetChild(selector.DeGlobaled, createImplicity);
}
if (selector.AfterTheParameter.Is()) {
return GetChild(selector.WithoutAfterTheParameter, createImplicity).GetChild(selector.AfterSelector, createImplicity);
}
if(selector.IsCompound) {
var name = selector.Prefix.Name;
return HasChild(name) ? GetProperty(name, createImplicity).GetChild(selector.Suffix, createImplicity) : (createImplicity ? CreatePlaceholderView(name).GetChild(selector.Suffix, createImplicity) : null);
}
if (selector.IsSpecialCase) {
// this ensures a special case where a selector is resolving, but it has an empty auto-condition in it.
// this should make sure that '*[].foo' is the same thing as 'foo'
return GetChild(selector.AfterSelector, createImplicity);
}
if (selector.HasParameter) {
return HasChild(selector.Name) ? GetProperty(selector.Name, createImplicity).GetElement(selector.Parameter) : (createImplicity ? CreatePlaceholderView(selector.Name).GetElement(selector.Parameter) : null);
}
return GetProperty(selector.Name, createImplicity);
}