/// <inheritdoc /> public override void WriteAttachedEventSyntax(XPathNavigator reflection, SyntaxWriter writer) { if (reflection == null) { throw new ArgumentNullException(nameof(reflection)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } string eventName = (string)reflection.Evaluate(apiNameExpression); string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression); XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression); // xaml syntax block for attached event string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(containingTypeName + "." + eventName); writer.WriteString("=\""); WriteTypeReference(eventHandler, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); }
// A simple Property Element Usage block for a content property // syntax looks like: // <object> // <linkToType .../> // </object> private void PropertyContentElementUsageSimple(XPathNavigator propertyReflection, SyntaxWriter writer) { string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlContentElementUsageHeading); XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression); // start the syntax block writer.WriteStartSubBlock(xamlBlockId); // <object> writer.WriteString("<"); writer.WriteParameter("object"); writer.WriteString(">"); writer.WriteLine(); // <linkToType .../> writer.WriteString(" <"); WriteTypeReference(returnType, writer); writer.WriteString(" .../>"); writer.WriteLine(); // </object> writer.WriteString("</"); writer.WriteParameter("object"); writer.WriteString(">"); writer.WriteEndSubBlock(); }
private void WriteXamlBoilerplate(XamlBoilerplateID bpID, XPathNavigator typeReflection, SyntaxWriter writer) { string xamlBlockId = Enum.GetName(typeof(XamlBoilerplateID), bpID); if (xamlBlockId != null) { writer.WriteStartSubBlock(xamlBlockId); if (typeReflection != null) { WriteTypeReference(typeReflection, writer); } writer.WriteEndSubBlock(); } }
private void WriteXamlXmlnsUri(string assemblyName, string namespaceName, SyntaxWriter writer) { if (xamlAssemblies.TryGetValue(assemblyName, out Dictionary <string, List <string> > clrNamespaces)) { if (clrNamespaces.TryGetValue(namespaceName, out List <string> xmlnsUriList)) { foreach (string xmlnsUri in xmlnsUriList) { // start the syntax block writer.WriteStartSubBlock("xamlXmlnsUri"); writer.WriteString(xmlnsUri); writer.WriteEndSubBlock(); } } } }
// An Attribute Usage block private void PropertyAttributeUsage(XPathNavigator propertyReflection, SyntaxWriter writer) { string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); string propertyName = (string)propertyReflection.Evaluate(apiNameExpression); XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression); // start the syntax block writer.WriteStartSubBlock(xamlBlockId); // syntax looks like: // <object PropertyName="linkToType" .../> writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(propertyName); writer.WriteString("=\""); WriteTypeReference(returnType, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); }
/// <inheritdoc /> public override void WriteAttachedPropertySyntax(XPathNavigator reflection, SyntaxWriter writer) { if (reflection == null) { throw new ArgumentNullException(nameof(reflection)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } string propertyName = (string)reflection.Evaluate(apiNameExpression); string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression); bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression); XPathNavigator returnType = reflection.SelectSingleNode(apiReturnTypeExpression); if (!isSettable) { WriteXamlBoilerplate(XamlBoilerplateID.propertyXamlSyntax_readOnly, writer); } else { // xaml syntax block for attached property string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(containingTypeName + "." + propertyName); writer.WriteString("=\""); WriteTypeReference(returnType, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); } }
/// <inheritdoc /> public override void WriteAttachedEventSyntax(XPathNavigator reflection, SyntaxWriter writer) { string eventName = (string)reflection.Evaluate(apiNameExpression); string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression); XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression); // xaml syntax block for attached event string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(containingTypeName + "." + eventName); writer.WriteString("=\""); WriteTypeReference(eventHandler, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); }
/// <inheritdoc /> public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer) { string eventName = (string)reflection.Evaluate(apiNameExpression); string eventVisibility = (string)reflection.Evaluate(apiVisibilityExpression); bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractProcedureExpression); XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression); XPathNavigator containingType = reflection.SelectSingleNode(apiContainingTypeExpression); string containingTypeSubgroup = (string)containingType.Evaluate(apiSubgroupExpression); bool containingTypeIsAbstract = (bool)containingType.Evaluate(apiIsAbstractTypeExpression); bool containingTypeIsSealed = (bool)containingType.Evaluate(apiIsSealedTypeExpression); if(containingTypeSubgroup == "interface") { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_noXamlSyntaxForInterfaceMembers, writer); } else if(containingTypeIsAbstract && containingTypeIsSealed) { // the event's containing type is static if it's abstract and sealed // members of a static class cannot be used in XAML. WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer); } else if(IsExcludedSubClass(containingType)) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_parentIsExcludedSubClass, writer); } else if(!DoesParentSupportXaml(reflection)) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer); } else if(eventVisibility != "public") { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_notPublic, writer); } else if(isAbstract) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_abstract, writer); } else { // start the syntax block string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); // syntax looks like: // <object eventName="eventHandlerLink" .../> writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(eventName); writer.WriteString("=\""); WriteTypeReference(eventHandler, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); } }
// An Attribute Usage block private void PropertyAttributeUsage(XPathNavigator propertyReflection, SyntaxWriter writer) { string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); string propertyName = (string)propertyReflection.Evaluate(apiNameExpression); XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression); // start the syntax block writer.WriteStartSubBlock(xamlBlockId); // syntax looks like: // <object PropertyName="linkToType" .../> writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(propertyName); writer.WriteString("=\""); WriteTypeReference(returnType, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); }
// A grandiose Property Element Usage block // syntax looks like: // <object> // <object.PropertyName> // <linkToType .../> // </object.PropertyName> // </object> private void PropertyElementUsageGrande(XPathNavigator propertyReflection, SyntaxWriter writer) { string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlPropertyElementUsageHeading); string propertyName = (string)propertyReflection.Evaluate(apiNameExpression); XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression); // start the syntax block writer.WriteStartSubBlock(xamlBlockId); // <object> writer.WriteString("<"); writer.WriteParameter("object"); writer.WriteString(">"); writer.WriteLine(); // <object.PropertyName> writer.WriteString(" <"); writer.WriteParameter("object"); writer.WriteString("."); writer.WriteIdentifier(propertyName); writer.WriteString(">"); writer.WriteLine(); // <linkToType .../> writer.WriteString(" <"); WriteTypeReference(returnType, writer); writer.WriteString(" .../>"); writer.WriteLine(); // </object.PropertyName> writer.WriteString(" </"); writer.WriteParameter("object"); writer.WriteString("."); writer.WriteIdentifier(propertyName); writer.WriteString(">"); writer.WriteLine(); // </object> writer.WriteString("</"); writer.WriteParameter("object"); writer.WriteString(">"); writer.WriteEndSubBlock(); }
/// <inheritdoc /> public override void WriteAttachedPropertySyntax(XPathNavigator reflection, SyntaxWriter writer) { string propertyName = (string)reflection.Evaluate(apiNameExpression); string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression); bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression); XPathNavigator returnType = reflection.SelectSingleNode(apiReturnTypeExpression); if(!isSettable) { WriteXamlBoilerplate(XamlBoilerplateID.propertyXamlSyntax_readOnly, writer); } else { // xaml syntax block for attached property string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(containingTypeName + "." + propertyName); writer.WriteString("=\""); WriteTypeReference(returnType, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); } }
private void ObjectElementUsageForClassStruct(XPathNavigator reflection, SyntaxWriter writer) { string typeName = (string)reflection.Evaluate(apiNameExpression); bool isGeneric = (bool)reflection.Evaluate(apiIsGenericExpression); string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlObjectElementUsageHeading); string contentPropertyId = (string)reflection.Evaluate(contentPropertyIdExpression); if(String.IsNullOrEmpty(contentPropertyId)) contentPropertyId = (string)reflection.Evaluate(ancestorContentPropertyIdExpression); // start the syntax block writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); if(isGeneric) { writer.WriteIdentifier(typeName); // for generic types show the type arguments XPathNodeIterator templates = (XPathNodeIterator)reflection.Evaluate(apiTemplatesExpression); if(templates.Count > 0) { writer.WriteString(" x:TypeArguments=\""); while(templates.MoveNext()) { XPathNavigator template = templates.Current; string name = template.GetAttribute("name", String.Empty); writer.WriteString(name); if(templates.CurrentPosition < templates.Count) writer.WriteString(","); } writer.WriteString("\""); } } else { // for non-generic types just show the name writer.WriteIdentifier(typeName); } if(String.IsNullOrEmpty(contentPropertyId)) writer.WriteString(" .../>"); else { // close the start tag writer.WriteString(">"); // the inner xml of the Object Element syntax for a type with a content property // is a link to the content property writer.WriteLine(); writer.WriteString(" "); writer.WriteReferenceLink(contentPropertyId); writer.WriteLine(); // write the end tag writer.WriteString("</"); writer.WriteIdentifier(typeName); writer.WriteString(">"); } // end the sub block writer.WriteEndSubBlock(); }
private void WriteXamlBoilerplate(XamlBoilerplateID bpID, XPathNavigator typeReflection, SyntaxWriter writer) { string xamlBlockId = System.Enum.GetName(typeof(XamlBoilerplateID), bpID); if(xamlBlockId != null) { writer.WriteStartSubBlock(xamlBlockId); if(typeReflection != null) WriteTypeReference(typeReflection, writer); writer.WriteEndSubBlock(); } }
private void WriteXamlXmlnsUri(string assemblyName, string namespaceName, SyntaxWriter writer) { Dictionary<string, List<string>> clrNamespaces; if(xamlAssemblies.TryGetValue(assemblyName, out clrNamespaces)) { List<string> xmlnsUriList; if(clrNamespaces.TryGetValue(namespaceName, out xmlnsUriList)) { foreach(string xmlnsUri in xmlnsUriList) { // start the syntax block writer.WriteStartSubBlock("xamlXmlnsUri"); writer.WriteString(xmlnsUri); writer.WriteEndSubBlock(); } } } }
/// <inheritdoc /> public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer) { if (reflection == null) { throw new ArgumentNullException(nameof(reflection)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } string eventName = (string)reflection.Evaluate(apiNameExpression); string eventVisibility = (string)reflection.Evaluate(apiVisibilityExpression); bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractProcedureExpression); XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression); XPathNavigator containingType = reflection.SelectSingleNode(apiContainingTypeExpression); string containingTypeSubgroup = (string)containingType.Evaluate(apiSubgroupExpression); bool containingTypeIsAbstract = (bool)containingType.Evaluate(apiIsAbstractTypeExpression); bool containingTypeIsSealed = (bool)containingType.Evaluate(apiIsSealedTypeExpression); if (containingTypeSubgroup == "interface") { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_noXamlSyntaxForInterfaceMembers, writer); } else if (containingTypeIsAbstract && containingTypeIsSealed) { // the event's containing type is static if it's abstract and sealed // members of a static class cannot be used in XAML. WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer); } else if (IsExcludedSubClass(containingType)) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_parentIsExcludedSubClass, writer); } else if (!DoesParentSupportXaml(reflection)) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer); } else if (eventVisibility != "public") { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_notPublic, writer); } else if (isAbstract) { WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_abstract, writer); } else { // start the syntax block string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading); writer.WriteStartSubBlock(xamlBlockId); // syntax looks like: // <object eventName="eventHandlerLink" .../> writer.WriteString("<"); writer.WriteParameter("object "); writer.WriteIdentifier(eventName); writer.WriteString("=\""); WriteTypeReference(eventHandler, writer); writer.WriteString("\" .../>"); writer.WriteEndSubBlock(); } }
private void ObjectElementUsageForClassStruct(XPathNavigator reflection, SyntaxWriter writer) { string typeName = (string)reflection.Evaluate(apiNameExpression); bool isGeneric = (bool)reflection.Evaluate(apiIsGenericExpression); string xamlBlockId = Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlObjectElementUsageHeading); string contentPropertyId = (string)reflection.Evaluate(contentPropertyIdExpression); if (String.IsNullOrEmpty(contentPropertyId)) { contentPropertyId = (string)reflection.Evaluate(ancestorContentPropertyIdExpression); } // start the syntax block writer.WriteStartSubBlock(xamlBlockId); writer.WriteString("<"); if (isGeneric) { writer.WriteIdentifier(typeName); // for generic types show the type arguments XPathNodeIterator templates = (XPathNodeIterator)reflection.Evaluate(apiTemplatesExpression); if (templates.Count > 0) { writer.WriteString(" x:TypeArguments=\""); while (templates.MoveNext()) { XPathNavigator template = templates.Current; string name = template.GetAttribute("name", String.Empty); writer.WriteString(name); if (templates.CurrentPosition < templates.Count) { writer.WriteString(","); } } writer.WriteString("\""); } } else { // for non-generic types just show the name writer.WriteIdentifier(typeName); } if (String.IsNullOrEmpty(contentPropertyId)) { writer.WriteString(" .../>"); } else { // close the start tag writer.WriteString(">"); // the inner xml of the Object Element syntax for a type with a content property // is a link to the content property writer.WriteLine(); writer.WriteString(" "); writer.WriteReferenceLink(contentPropertyId); writer.WriteLine(); // write the end tag writer.WriteString("</"); writer.WriteIdentifier(typeName); writer.WriteString(">"); } // end the sub block writer.WriteEndSubBlock(); }