本文整理汇总了C#中XamlType.GetAttachableMember方法的典型用法代码示例。如果您正苦于以下问题:C# XamlType.GetAttachableMember方法的具体用法?C# XamlType.GetAttachableMember怎么用?C# XamlType.GetAttachableMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XamlType
的用法示例。
在下文中一共展示了XamlType.GetAttachableMember方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadMemberElement
// member element, implicit member, children via content property, or value
IEnumerable<XamlXmlNodeInfo> ReadMemberElement (XamlType parentType, XamlType xt)
{
XamlMember xm = null;
var name = r.LocalName;
int idx = name.IndexOf ('.');
// FIXME: it skips strict type name check, as it could result in MarkupExtension mismatch (could be still checked, though)
if (idx >= 0/* && name.Substring (0, idx) == xt.Name*/) {
name = name.Substring (idx + 1);
xm = xt.GetMember (name);
} else {
xm = (XamlMember) FindStandardDirective (name, AllowedMemberLocations.MemberElement) ??
// not a standard directive? then try attachable
xt.GetAttachableMember (name) ??
// still not? then try ordinal member
xt.GetMember (name);
if (xm == null) {
// still not? could it be omitted as content property or items ?
if ((xm = GetExtraMember (xt)) != null) {
// Note that this does not involve r.Read()
foreach (var ni in ReadMember (xt, xm))
yield return ni;
yield break;
}
}
}
if (xm == null) {
// Current element could be for another member in the parent type (if exists)
if (parentType != null && parentType.GetMember (name) != null) {
// stop the iteration and signal the caller to not read current element as an object. (It resolves conflicts between "start object for current collection's item" and "start member for the next member in the parent object".
yield return Node (XamlNodeType.None, null);
yield break;
}
// ok, then create unknown member.
xm = new XamlMember (name, xt, false); // FIXME: not sure if isAttachable is always false.
}
if (!r.IsEmptyElement) {
r.Read ();
foreach (var ni in ReadMember (xt, xm))
yield return ni;
r.MoveToContent ();
r.ReadEndElement ();
}
else
r.Read ();
}
示例2: Read_AttachedProperty
protected void Read_AttachedProperty (XamlReader r)
{
var at = new XamlType (typeof (Attachable), r.SchemaContext);
Assert.IsTrue (r.Read (), "ns#1-1");
Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");
Assert.IsNotNull (r.Namespace, "ns#1-3");
Assert.AreEqual ("", r.Namespace.Prefix, "ns#1-4");
var assns = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
Assert.AreEqual (assns, r.Namespace.Namespace, "ns#1-5");
// t:AttachedWrapper
Assert.IsTrue (r.Read (), "so#1-1");
Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
var xt = new XamlType (typeof (AttachedWrapper), r.SchemaContext);
Assert.AreEqual (xt, r.Type, "so#1-3");
if (r is XamlXmlReader)
ReadBase (r);
ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "x", "x");
// m:Value
Assert.IsTrue (r.Read (), "sm#2-1");
Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#sm#2-2");
Assert.AreEqual (xt.GetMember ("Value"), r.Member, "sm#2-3");
// t:Attached
Assert.IsTrue (r.Read (), "so#2-1");
Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#so#2-2");
Assert.AreEqual (r.SchemaContext.GetXamlType (typeof (Attached)), r.Type, "so#2-3");
ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "y", "y");
Assert.IsTrue (r.Read (), "eo#2-1");
Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#eo#2-2");
// /m:Value
Assert.IsTrue (r.Read (), "em#2-1");
Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#em#2-2");
// /t:AttachedWrapper
Assert.IsTrue (r.Read (), "eo#1-1");
Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");
Assert.IsFalse (r.Read (), "end");
}
示例3: GetAttachableMember
public XamlMember GetAttachableMember(XamlType xamlType, string name)
{
return xamlType.GetAttachableMember(name);
}
示例4: XamlDomMember
// XamlDomObject.GetMemberNode() needs to take a XamlType and string for supporting unknown attached members.
// This constructor is here to match that.
public XamlDomMember(XamlType declaringType, string attachedMember, params XamlDomItem[] items)
{
if (declaringType == null)
{
throw new ArgumentNullException("declaringType");
}
if (attachedMember == null)
{
throw new ArgumentNullException("attachedMember");
}
foreach (var itemNode in items)
{
Items.Add(itemNode);
}
var member = declaringType.GetAttachableMember(attachedMember);
if (member == null)
{
throw new NotImplementedException("Unknown members are not implemented");
}
_member = member;
Resolve();
}
示例5: GetXamlAttachableProperty
public XamlMember GetXamlAttachableProperty(XamlType xamlType, string propertyName)
{
if (xamlType.IsUnknown)
{
return null;
}
XamlMember attachableMember = xamlType.GetAttachableMember(propertyName);
if (!this.IsVisible(attachableMember, null))
{
return null;
}
return attachableMember;
}