Esempio n. 1
0
        private object ReadComponent(XPathResult result, bool ifExists, IDictionaryAdapter dictionaryAdapter)
        {
            XPathNavigator source;

            if (result.GetNavigator(false, true, out source) == false || (source == null && ifExists))
            {
                return(null);
            }

            XPathAdapter xpathAdapter;
            var          elementType = result.Type;

            if (source != null)
            {
                if (result.XmlMeta != null)
                {
                    elementType = result.XmlMeta.Type;
                }
                else
                {
                    var xmlType = Context.GetXmlType(source);
                    elementType = dictionaryAdapter.GetXmlSubclass(xmlType, elementType) ?? elementType;
                }
                xpathAdapter = new XPathAdapter(source, this);
            }
            else
            {
                Func <XPathNavigator> createSource = () => result.GetNavigator(true);
                xpathAdapter = new XPathAdapter(createSource, this);
            }

            return(Create(dictionaryAdapter, elementType, null, xpathAdapter));
        }
Esempio n. 2
0
        private object ReadComponent(XPathResult result, bool ifExists, IDictionaryAdapter dictionaryAdapter)
        {
            XPathAdapter xpathAdapter;
            var          source = result.GetNavigator(false);

            if (source == null && ifExists)
            {
                return(null);
            }

            var elementType = result.Type;

            if (source != null)
            {
                if (result.XmlMeta != null)
                {
                    elementType = result.XmlMeta.Type;
                }
                else
                {
                    var xmlType = Context.GetXmlType(source);
                    elementType = dictionaryAdapter.GetXmlSubclass(xmlType, elementType) ?? elementType;
                }
                xpathAdapter = new XPathAdapter(source, this);
            }
            else
            {
                Func <XPathNavigator> createSource = () => result.GetNavigator(true);
                xpathAdapter = new XPathAdapter(createSource, this);
            }

            var component = Create(dictionaryAdapter, elementType, null, xpathAdapter);

            if (result.Property != null)
            {
                dictionaryAdapter.This.ExtendedProperties[result.Property.PropertyName] = component;
            }

            return(component);
        }
Esempio n. 3
0
		private object ReadComponent(XPathResult result, bool ifExists, IDictionaryAdapter dictionaryAdapter)
		{
			XPathNavigator source;
			if (result.Property != null)
				ifExists = ifExists || dictionaryAdapter.Meta.Type.IsAssignableFrom(result.Property.PropertyType);

			if (result.GetNavigator(false, true, out source) == false || (source == null && ifExists))
			{
				return null;
			}

			XPathAdapter xpathAdapter;
			var elementType = result.Type;

			if (source != null)
			{
				if (result.XmlMeta != null)
				{
					elementType = result.XmlMeta.Type;
				}
				else
				{
					var xmlType = GetEffectiveContext(dictionaryAdapter).GetXmlType(source);
					elementType = dictionaryAdapter.GetXmlSubclass(xmlType, elementType) ?? elementType;
				}
				xpathAdapter = new XPathAdapter(source, this);
			}
			else
			{
				Func<XPathNavigator> createSource = () => result.GetNavigator(true);
				xpathAdapter = new XPathAdapter(createSource, this);
			}

			return Create(dictionaryAdapter, elementType, null, xpathAdapter);
		}
Esempio n. 4
0
		private object ReadComponent(XPathResult result, bool ifExists, IDictionaryAdapter dictionaryAdapter)
		{
			XPathAdapter xpathAdapter;
			var source = result.GetNavigator(false);
			if (source == null && ifExists) return null;
		
			var elementType = result.Type;
			if (source != null)
			{
				if (result.XmlMeta != null)
				{
					elementType = result.XmlMeta.Type;
				}
				else
				{
					var xmlType = Context.GetXmlType(source);
					elementType = dictionaryAdapter.GetXmlSubclass(xmlType, elementType) ?? elementType;
				}
				xpathAdapter = new XPathAdapter(source, this);
			}
			else
			{
				Func<XPathNavigator> createSource = () => result.GetNavigator(true);
				xpathAdapter = new XPathAdapter(createSource, this);
			}

			var component = Create(dictionaryAdapter, elementType, null, xpathAdapter);

			if (result.Property != null)
				dictionaryAdapter.This.ExtendedProperties[result.Property.PropertyName] = component;

			return component;
		}
Esempio n. 5
0
		private object ReadComponent(XPathResult result, bool ifExists, IDictionaryAdapter dictionaryAdapter)
		{
			XPathAdapter adapter;
			Func<XPathNavigator> createSource = null;
			var source = result.GetNavigator(false);
			if (source == null && ifExists) return null;
		
			var elementType = result.Type;
			if (source != null)
			{
				if (result.XmlMeta != null)
				{
					elementType = result.XmlMeta.Type;
				}
				else
				{
					var xmlType = context.GetXmlType(source);
					elementType = dictionaryAdapter.GetXmlSubclass(xmlType, elementType) ?? elementType;
				}
				adapter = new XPathAdapter(source, this);
			}
			else
			{
				if (createSource == null)
				{
					createSource = () => result.GetNavigator(true);
				}
				adapter = new XPathAdapter(createSource, this);
			}

			var component = dictionaryAdapter.This.Factory.GetAdapter(elementType, new Hashtable(), 
				new DictionaryDescriptor().AddBehavior(XPathBehavior.Instance, adapter));

			if (result.Property != null)
			{
				dictionaryAdapter.This.ExtendedProperties[result.Property.PropertyName] = component;
			}

			return component;
		}