示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataVisitNodeBuilder"/> class.
        /// </summary>
        /// <param name="typeDescriptorFactory">The type descriptor factory.</param>
        /// <param name="rootInstance">The root instance of the object to visit.</param>
        /// <exception cref="System.ArgumentNullException">rootInstance</exception>
        private DataVisitNodeBuilder(ITypeDescriptorFactory typeDescriptorFactory, object rootInstance)
            : base(typeDescriptorFactory)
        {
            CustomVisitors.AddRange(AssetRegistry.GetDataVisitNodeBuilders());

            if (rootInstance == null)
            {
                throw new ArgumentNullException(nameof(rootInstance));
            }
            RootInstance = rootInstance;
            var objectDescriptor = typeDescriptorFactory.Find(rootInstance.GetType()) as ObjectDescriptor;

            if (objectDescriptor == null)
            {
                throw new ArgumentException(@"Expecting an object", nameof(rootInstance));
            }
            stackItems.Push(new DataVisitObject(rootInstance, objectDescriptor));
        }