示例#1
0
        public static RawDataSourceInfoBase GetDataSourceInfoFromBinding(DocumentCompositeNode bindingNode)
        {
            RawDataSourceInfoBase dataSourceInfoBase    = (RawDataSourceInfoBase)null;
            DocumentCompositeNode resourceReferenceNode = bindingNode.Properties[BindingSceneNode.SourceProperty] as DocumentCompositeNode;

            if (resourceReferenceNode == null)
            {
                dataSourceInfoBase = (RawDataSourceInfoBase)DataContextHelper.GetElementNameBinding(bindingNode);
            }
            if (dataSourceInfoBase == null)
            {
                string bindingPath = DataContextHelper.GetBindingPath(bindingNode);
                if (resourceReferenceNode != null && resourceReferenceNode.Type.IsResource)
                {
                    dataSourceInfoBase = DataContextHelper.GetDataSourceInfoFromResourceReference(resourceReferenceNode);
                    if (!dataSourceInfoBase.IsValid)
                    {
                        return(dataSourceInfoBase);
                    }
                    dataSourceInfoBase.AppendClrPath(bindingPath);
                }
                else
                {
                    dataSourceInfoBase = (RawDataSourceInfoBase) new RawDataSourceInfo((DocumentNode)resourceReferenceNode, bindingPath);
                }
            }
            string bindingXpath = DataContextHelper.GetBindingXPath(bindingNode);

            dataSourceInfoBase.XmlPath = XmlSchema.CombineXPaths(dataSourceInfoBase.XmlPath, bindingXpath);
            if (bindingNode.Properties[BindingSceneNode.RelativeSourceProperty] != null)
            {
                dataSourceInfoBase.SetInvalid();
            }
            return(dataSourceInfoBase);
        }
示例#2
0
 public static RawDataSourceInfoBase GetRawDataSourceInfo(DocumentNode dataSourceNode)
 {
     return(!dataSourceNode.Type.IsBinding ? (!dataSourceNode.Type.IsResource ? (RawDataSourceInfoBase) new RawDataSourceInfo(dataSourceNode, (string)null) : DataContextHelper.GetDataSourceInfoFromResourceReference((DocumentCompositeNode)dataSourceNode)) : DataContextHelper.GetDataSourceInfoFromBinding((DocumentCompositeNode)dataSourceNode));
 }