Example #1
0
 /// <summary>
 /// Creates a new <see cref="Node"/> instance.
 /// </summary>
 /// <param name="context">Context this node belongs to.</param>
 /// <param name="policy">The node policy.</param>
 public Node(ObjectXPathContext context, INodePolicy policy)
 {
     _context         = context;
     _nodePolicy      = policy;
     _nodeType        = XPathNodeType.All;
     _nodeState       = NodeState.ObjectNotKnown;
     _attributesCount = -1;
     _elementsCount   = -1;
 }
Example #2
0
 private void CheckAndSwitchPolicy()
 {
     if (_nodePolicy != null)
     {
         var newPolicy = _nodePolicy.GetNewPolicy(this);
         if (newPolicy != null)
         {
             _nodePolicy = newPolicy;
         }
     }
 }
Example #3
0
        /// <summary>
        /// Creates a node policy for given object instance.
        /// </summary>
        /// <param name="obj">An object to create node policy for.</param>
        /// <returns>An object implementing <see cref="INodePolicy"/> interface
        /// which should be used to map this object to the tree node.</returns>
        public INodePolicy GetNodePolicy(object obj)
        {
            INodePolicy policy = _nodePolicyFactory.GetPolicy(obj.GetType());

            if (NodePolicyGet != null)
            {
                NodePolicyGetEventArgs e = new NodePolicyGetEventArgs(obj, policy);
                NodePolicyGet(this, e);
                if (e.Policy != null)
                {
                    policy = e.Policy;
                }
            }
            return(policy);
        }
Example #4
0
 /// <summary>
 /// Creates a new <see cref="Node"/> instance.
 /// </summary>
 /// <param name="context">Context this node belongs to.</param>
 /// <param name="policy">The node policy.</param>
 public Node(ObjectXPathContext context, INodePolicy policy)
 {
     _context    = context;
     _nodePolicy = policy;
     // _parent = null;
     //_index = 0;
     //_name = null;
     //_namespace = null;
     _nodeType = XPathNodeType.All;
     //_targetObject = null;
     _nodeState = NodeState.ObjectNotKnown;
     //_targetObjectType = null;
     //_isTransparent = false;
     //_knowTransparent = false;
     //_value = null;
     _attributesCount = -1;
     _elementsCount   = -1;
 }
Example #5
0
		/// <summary>
		/// Creates a new <see cref="Node"/> instance.
		/// </summary>
		/// <param name="context">Context this node belongs to.</param>
		/// <param name="policy">The node policy.</param>
		public Node( ObjectXPathContext context, INodePolicy policy )
		{
			_context = context;
			_nodePolicy = policy;
			// _parent = null;
			//_index = 0;
			//_name = null;
			//_namespace = null;
			_nodeType = XPathNodeType.All;
			//_targetObject = null;
			_nodeState = NodeState.ObjectNotKnown;
			//_targetObjectType = null;
			//_isTransparent = false;
			//_knowTransparent = false;
			//_value = null;
			_attributesCount = -1;
			_elementsCount = -1;
		}
Example #6
0
        /// <summary>
        /// See <see cref="INodePolicy.GetNewPolicy"/> for details.
        /// </summary>
        public override INodePolicy GetNewPolicy(Node node)
        {
            INodePolicy result = null;

            // Check if we have to switch the policy
            if (node.State == NodeState.ObjectKnown)
            {
                if (node.Object != null)
                {
                    if (!node.ObjectType.IsSimpleType && node.Member.ConverterType == null)
                    {
                        // Create policy for a node that is not of simple type and
                        // without explicitly set converter
                        result = node.Context.GetNodePolicy(node.Object);
                        string s = node.Name;
                        s = node.Namespace;
                    }
                    else
                    {
                        // This is a node with simple content
                        result = TextNodePolicy.GetPolicy();
                    }
                }
                else
                {
                    // The value of this member is null
                    result = NullValueNodePolicy.GetPolicy();
                }
            }
            else if (node.State == NodeState.Exception)
            {
                // This is a node with exception
                result = ExceptionNodePolicy.GetPolicy();
            }
            return(result);
        }
Example #7
0
 /// <summary>
 /// Creates a new <see cref="NodePolicyGetEventArgs"/> instance.
 /// </summary>
 /// <param name="obj">Object the policy is being created for.</param>
 /// <param name="policy">Proposed policy.</param>
 public NodePolicyGetEventArgs(object obj, INodePolicy policy)
 {
     _obj    = obj;
     _policy = policy;
 }
Example #8
0
        private string _value; // Empty if null

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new <see cref="Node"/> instance.
        /// </summary>
        /// <param name="context">Context this node belongs to.</param>
        /// <param name="policy">The node policy.</param>
        public Node( ObjectXPathContext context, INodePolicy policy )
        {
            _context = context;
            _nodePolicy = policy;
            _nodeType = XPathNodeType.All;
            _nodeState = NodeState.ObjectNotKnown;
            _attributesCount = -1;
            _elementsCount = -1;
        }
Example #9
0
 private void CheckAndSwitchPolicy()
 {
     if( _nodePolicy != null )
     {
         var newPolicy = _nodePolicy.GetNewPolicy( this );
         if( newPolicy != null )
             _nodePolicy = newPolicy;
     }
 }
		/// <summary>
		/// Creates a new <see cref="NodePolicyGetEventArgs"/> instance.
		/// </summary>
		/// <param name="obj">Object the policy is being created for.</param>
		/// <param name="policy">Proposed policy.</param>
		public NodePolicyGetEventArgs( object obj, INodePolicy policy )
		{
			_obj = obj;
			_policy = policy;
		}