private bool ResolveExtension(NestedArgument argument, Type targettype, out object obj) { if (GetExtension(argument.Scope.ToLower(), out Extension extension)) { obj = extension.Resolve(argument, GetSource, Parse, ResolveExtension, targettype); } else { obj = null; } return(obj != null); }
private void ResolveAttributes(InitializerObject instance, XAttribute attribute) { string propertyname = attribute.Name.LocalName; if (attribute.IsNamespaceDeclaration && !_assemblyKeys.ContainsKey(propertyname)) { if (NamespaceDeclaration.Resolve(propertyname, attribute.Value, out NamespaceDeclaration declaration)) { _assemblyKeys.Add(propertyname, declaration); } } else { int count = NestedArgument.ResolveNestedParenthesses(attribute.Value, '{', '}', out IEnumerable <NestedArgument> nestedargument); if (!instance.GetProperty(propertyname, out InitializerProperty property)) { _debug?.Pass(this, "initializer/instance/noproperty", (s) => string.Format(s, propertyname, instance, instance.GetType())); } else if (count > 1) { _debug?.Pass(this, "initializer/format/chained", (s) => string.Format(s, attribute.Value)); } else if (count == 1) { NestedArgument argument = nestedargument.First(); if (ResolveExtension(argument, property.Type, out object obj)) { if (obj is PropertyBinding binding) { property.Register(binding); } else if (obj != null) { property.SetValue(obj); } } else { _debug?.Pass(this, "initializer/extension/failed", (s) => string.Format(argument.Scope)); } } else if (count == 0 && SaveChangeType(property.Type, attribute.Value, out object obj)) { property.SetValue(obj); } } }