Ejemplo n.º 1
0
        /// <summary>
        /// Clones a <see cref="JObject"/> preserving the line information
        /// </summary>
        /// <param name="objectToClone">The object to clone</param>
        /// <returns>A clone of the object with its line info</returns>
        internal static JObject CloneWithLineInfo(this JObject objectToClone)
        {
            var loadSettings = new JsonLoadSettings()
            {
                LineInfoHandling = JdtUtilities.GetLineInfoHandling()
            };

            using (var objectReader = objectToClone.CreateReader())
            {
                return(JObject.Load(objectReader, loadSettings));
            }
        }
        private void SetTransform(Stream transformStream)
        {
            this.loadSettings = new JsonLoadSettings()
            {
                CommentHandling  = CommentHandling.Ignore,
                LineInfoHandling = JdtUtilities.GetLineInfoHandling()
            };

            using (StreamReader transformStreamReader = new StreamReader(transformStream))
                using (JsonTextReader transformReader = new JsonTextReader(transformStreamReader))
                {
                    this.transformObject = JObject.Load(transformReader, this.loadSettings);
                }
        }