<commit_before>﻿using eScape.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Windows.UI.Xaml;

namespace eScapeLLC.UWP.Charts {
	#region IDataSourceRenderer
	/// <summary>
	/// Ability to render the items of a data source.
	/// preamble, foreach render, postamble.
	/// </summary>
	public interface IDataSourceRenderer {
		/// <summary>
		/// The name of the data source this renderer is bound to.
		/// </summary>
		String DataSourceName { get; }
		/// <summary>
		/// Return a state object that gets passed back on subsequent calls.
		/// Includes limit initialization.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <returns>NULL: do not participate; !NULL: The state.</returns>
		object Preamble(IChartRenderContext icrc);
		/// <summary>
		/// Render the current item.
		/// Includes limit updates.
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		/// <param name="index">Data index [0..N).</param>
		/// <param name="item">Current item.</param>
		void Render(object state, int index, object item);
		/// <summary>
		/// Apply axis and other linked component updates.
		/// Called after all items are processed, and before Postamble().
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		void RenderComplete(object state);
		/// <summary>
		/// Perform terminal actions.
		/// Axis limits were finalized (in RenderComplete) and MAY be use in layout calculations.
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		void Postamble(object state);
	}
	#endregion
	#region IProvideDataSourceRenderer
	/// <summary>
	/// Ability to provide an IDataSourceRenderer interface.
	/// </summary>
	public interface IProvideDataSourceRenderer {
		/// <summary>
		/// The renderer to use.
		/// MUST return a stable value.
		/// </summary>
		IDataSourceRenderer Renderer { get; }
	}
	#endregion
	#region IRequireDataSourceUpdates
	/// <summary>
	/// Interface to be notified of incremental <see cref="DataSource"/> updates.
	/// This is meant to be used with <see cref="System.Collections.ObjectModel.ObservableCollection{T}"/>.
	/// </summary>
	public interface IRequireDataSourceUpdates {
		/// <summary>
		/// The name of the <see cref="DataSource"/> that triggers incremental updates.
		/// </summary>
		String UpdateSourceName { get; }
		/// <summary>
		/// Remove series of items.
		/// Also responsible for adjsting extents due to removed values.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <param name="startAt">Starting index.</param>
		/// <param name="items">For reference.</param>
		void Remove(IChartRenderContext icrc, int startAt, IList items);
		/// <summary>
		/// Add series of items.
		/// Also responsible for adjsting extents due to new values.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <param name="startAt">Starting index.</param>
		/// <param name="items">For reference.</param>
		void Add(IChartRenderContext icrc, int startAt, IList items);
	}
	#endregion
	#region DataSourceRefreshRequestEventHandler
	/// <summary>
	/// Refresh delegate.
	/// </summary>
	/// <param name="ds">Originating component.</param>
	/// <param name="nccea">Collection changed args.</param>
	public delegate void DataSourceRefreshRequestEventHandler(DataSource ds, NotifyCollectionChangedEventArgs nccea);
	#endregion
	#region IDataSourceRenderContext
	/// <summary>
	/// Context for the DataSource.Render method.
	/// </summary>
	public interface IDataSourceRenderContext : IChartRenderContext {
	}
	#endregion
	#region DataSource
	/// <summary>
	/// Represents a source of data for one-or-more series.
	/// Primary purpose is to consolidate the data traversal for rendering this data.
	/// This is important when the data changes; only one notification is handled instead one per series.
	/// The <see cref="Items"/> property automatically tracks anything that implements <see cref="INotifyCollectionChanged"/>.
	/// Otherwise, owner must call <see cref="Refresh"/> at appropriate time, or alternatively, increment the <see cref="RefreshRequest"/> property.
	/// The latter is handier when you are doing collection updtaes from a View Model.
	/// </summary>
	public class DataSource : FrameworkElement {
		static LogTools.Flag _trace = LogTools.Add("DataSource", LogTools.Level.Error);
		#region data<commit_msg>Documentation update.<commit_after>﻿using eScape.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Windows.UI.Xaml;

namespace eScapeLLC.UWP.Charts {
	#region IDataSourceRenderer
	/// <summary>
	/// Ability to render the items of a data source.
	/// preamble, foreach render, postamble.
	/// </summary>
	public interface IDataSourceRenderer {
		/// <summary>
		/// The name of the data source this renderer is bound to.
		/// </summary>
		String DataSourceName { get; }
		/// <summary>
		/// Return a state object that gets passed back on subsequent calls.
		/// Includes limit initialization.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <returns>NULL: do not participate; !NULL: The state.</returns>
		object Preamble(IChartRenderContext icrc);
		/// <summary>
		/// Render the current item.
		/// Includes limit updates.
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		/// <param name="index">Data index [0..N).</param>
		/// <param name="item">Current item.</param>
		void Render(object state, int index, object item);
		/// <summary>
		/// Apply axis and other linked component updates.
		/// Called after all items are processed, and before Postamble().
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		void RenderComplete(object state);
		/// <summary>
		/// Perform terminal actions.
		/// Axis limits were finalized (in RenderComplete) and MAY be use in layout calculations.
		/// Not called if Preamble() returned NULL.
		/// </summary>
		/// <param name="state">Return from preamble().</param>
		void Postamble(object state);
	}
	#endregion
	#region IProvideDataSourceRenderer
	/// <summary>
	/// Ability to provide an IDataSourceRenderer interface.
	/// </summary>
	public interface IProvideDataSourceRenderer {
		/// <summary>
		/// The renderer to use.
		/// MUST return a stable value.
		/// </summary>
		IDataSourceRenderer Renderer { get; }
	}
	#endregion
	#region IRequireDataSourceUpdates
	/// <summary>
	/// Interface to be notified of incremental <see cref="DataSource"/> updates.
	/// This is meant to be used with <see cref="System.Collections.ObjectModel.ObservableCollection{T}"/>.
	/// </summary>
	public interface IRequireDataSourceUpdates {
		/// <summary>
		/// The name of the <see cref="DataSource"/> that triggers incremental updates.
		/// </summary>
		String UpdateSourceName { get; }
		/// <summary>
		/// Remove series of items.
		/// Also responsible for adjsting extents due to removed values.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <param name="startAt">Starting index.</param>
		/// <param name="items">For reference.</param>
		void Remove(IChartRenderContext icrc, int startAt, IList items);
		/// <summary>
		/// Add series of items.
		/// Also responsible for adjsting extents due to new values.
		/// </summary>
		/// <param name="icrc">Render context.</param>
		/// <param name="startAt">Starting index.</param>
		/// <param name="items">For reference.</param>
		void Add(IChartRenderContext icrc, int startAt, IList items);
	}
	#endregion
	#region DataSourceRefreshRequestEventHandler
	/// <summary>
	/// Refresh delegate.
	/// </summary>
	/// <param name="ds">Originating component.</param>
	/// <param name="nccea">Collection changed args.</param>
	public delegate void DataSourceRefreshRequestEventHandler(DataSource ds, NotifyCollectionChangedEventArgs nccea);
	#endregion
	#region IDataSourceRenderContext
	/// <summary>
	/// Context for the DataSource.Render method.
	/// </summary>
	public interface IDataSourceRenderContext : IChartRenderContext {
	}
	#endregion
	#region DataSource
	/// <summary>
	/// Represents a source of data for one-or-more series.
	/// Primary purpose is to consolidate the data traversal for rendering this data.
	/// This is important when the data changes; only one notification is handled instead one per series.
	/// <para/>
	/// The <see cref="Items"/> property automatically tracks anything that implements <see cref="INotifyCollectionChanged"/>.
	/// Otherwise, owner must call <see cref="Refresh"/> at appropriate time, or alternatively, increment the <see cref="RefreshRequest"/> property.
	/// The latter is handier when you are doing collection updtaes from a View Model.
	/// </summary>
	public class DataSource : FrameworkElement {
		static LogTools.Flag _trace = LogTools.Add("DataSource", LogTools.Level.Error);
		#region data
{'fraction_non_alphanumeric': 0.14077299945563418, 'fraction_numerical': 0.00021774632553075667, 'mean_word_length': 3.4121037463976944, 'pattern_counts': {'":': 0, '<': 138, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3141137', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2558, 'n_words': 867}