private static IEnumerable <MemberDefinition> GetMembers(XamlElement element, string elementTypeName, ITypeParser typeParser) { if (elementTypeName == "System.Windows.ResourceDictionary") { yield break; } XamlMember nameDirective = element.Directives.FirstOrDefault(directive => directive.Name == XamlLanguage.NameDirective); if (nameDirective != null) { yield return(new MemberDefinition((string)nameDirective.GetSingleValue(), elementTypeName)); } foreach (XamlElement child in element.Values.OfType <XamlElement>().Concat(element.Members.SelectMany(member => member.Values.OfType <XamlElement>()))) { string childTypeName = typeParser.ParseTypeName(child.Name); foreach (MemberDefinition member in GetMembers(child, childTypeName, typeParser)) { yield return(member); } } }
private void LoadStartupUri() { if (StartupUri == null) { return; } Uri uri = StartupUri.ResolveAbsoluteUri(BaseUri); XamlElement rootElement = XamlParser.Parse(Granular.Compatibility.String.FromByteArray(EmbeddedResourceLoader.LoadResourceData(uri)), uri); XamlMember classDirective = rootElement.Directives.FirstOrDefault(directive => directive.Name == XamlLanguage.ClassDirective); Window window = Activator.CreateInstance(Type.GetType(String.Format("{0}, {1}", classDirective.GetSingleValue(), GetType().Assembly.GetName().Name))) as Window; if (window != null) { window.Show(); } }
private static string GetClassFullName(XamlElement root) { XamlMember classDirective = root.Directives.FirstOrDefault(directive => directive.Name == XamlLanguage.ClassDirective); return(classDirective != null ? (string)classDirective.GetSingleValue() : String.Empty); }