<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChamberLib
{
    public class Overrides
    {
        public Overrides(
            Overrides prototype=null,
            LightingData? lighting=null,
            IMaterial material=null,
            float? alpha=null,
            IShaderProgram shaderProgram=null,
            IShaderStage vertexShader=null,
            IShaderStage fragmentShader=null,
            ShaderUniforms uniforms=null)
        {
            this.Prototype = prototype;
            this.Lighting = lighting;
            this.Material = material;
            this.Alpha = alpha;
            this.ShaderProgram = shaderProgram;
            this.VertexShader = vertexShader;
            this.FragmentShader = fragmentShader;
            this.Uniforms = uniforms ?? new ShaderUniforms();
        }

        public readonly Overrides Prototype;

        public LightingData? Lighting;

        public IMaterial Material;
        public float? Alpha;

        public IShaderProgram ShaderProgram;
        public IShaderStage VertexShader;
        public IShaderStage FragmentShader;
        public ShaderUniforms Uniforms;
    }

    public static class OverridesHelper
    {
        public static LightingData? GetLighting(this Overrides overrides, LightingData? defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.Lighting ?? defaultValue;
        }

        public static IMaterial GetMaterial(this Overrides overrides, IMaterial defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.Material ?? defaultValue;
        }
        public static float GetAlpha(this Overrides overrides, float defaultValue)
        {
            if (overrides == null) return defaultValue;
            if (overrides.Alpha.HasValue) return overrides.Alpha.Value;
            if (overrides.Material == null) return defaultValue;
            return overrides.Material.Alpha;
        }

        public static IShaderProgram GetShaderProgram(this Overrides overrides, IShaderProgram defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.ShaderProgram ?? defaultValue;
        }
        public static IShaderStage GetVertexShader(this Overrides overrides, IShaderStage defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.VertexShader ?? defaultValue;
        }
        public static IShaderStage GetFragmentShader(this Overrides overrides, IShaderStage defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.FragmentShader ?? defaultValue;
        }
        public static ShaderUniforms GetUniforms(this Overrides overrides, ShaderUniforms defaultValue=null)
        {
            if (overrides == null) return defaultValue;
            return overrides.Uniforms ?? defaultValue;
        }
    }
}<commit_msg>Extract GetXXX_ instance methods.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChamberLib
{
    public class Overrides
    {
        public Overrides(
            Overrides prototype=null,
            LightingData? lighting=null,
            IMaterial material=null,
            float? alpha=null,
            IShaderProgram shaderProgram=null,
            IShaderStage vertexShader=null,
            IShaderStage fragmentShader=null,
            ShaderUniforms uniforms=null)
        {
            this.Prototype = prototype;
            this.Lighting = lighting;
            this.Material = material;
            this.Alpha = alpha;
            this.ShaderProgram = shaderProgram;
            this.VertexShader = vertexShader;
            this.FragmentShader = fragmentShader;
            this.Uniforms = uniforms ?? new ShaderUniforms();
        }

        public readonly Overrides Prototype;

        public LightingData? Lighting;
        public LightingData? GetLighting_(LightingData? defaultValue)
        {
            return this.Lighting ?? defaultValue;
        }

        public IMaterial Material;
        public IMaterial GetMaterial_(IMaterial defaultValue)
        {
            return this.Material ?? defaultValue;
        }
        public float? Alpha;
        public float GetAlpha_(float defaultValue)
        {
            if (this.Alpha.HasValue) return this.Alpha.Value;
            if (this.Material == null) return defaultValue;
            return this.Material.Alpha;
        }

        public IShaderProgram ShaderProgram;
        public IShaderProgram GetShaderProgram_(IShaderProgram defaultValue)
        {
            return this.ShaderProgram ?? defaultValue;
        }

        public IShaderStage VertexShader;
        public IShaderStage GetVertexShader_(IShaderStage defaultValue)
        {
            return this.VertexShader ?? defaultValue;
        }

        public IShaderStage FragmentShader;
        public IShaderStage GetFragmentShader_(IShaderStage defaultValue)
        {
            return this.FragmentShader ?? defaultValue;
        }

        public ShaderUniforms Uniforms;
        public ShaderUniforms GetUniforms_(ShaderUniforms defaultValue = null)
        {
            return this.Uniforms ?? defaultValue;
        }
    }

    public static class OverridesHelper
    {
        public static LightingData? GetLighting(this Overrides overrides, LightingData? defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetLighting_(defaultValue);
        }

        public static IMaterial GetMaterial(this Overrides overrides, IMaterial defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetMaterial_(defaultValue);
        }
        public static float GetAlpha(this Overrides overrides, float defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetAlpha_(defaultValue);
        }

        public static IShaderProgram GetShaderProgram(this Overrides overrides, IShaderProgram defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetShaderProgram_(defaultValue);
        }
        public static IShaderStage GetVertexShader(this Overrides overrides, IShaderStage defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetVertexShader_(defaultValue);
        }
        public static IShaderStage GetFragmentShader(this Overrides overrides, IShaderStage defaultValue)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetFragmentShader_(defaultValue);
        }
        public static ShaderUniforms GetUniforms(this Overrides overrides, ShaderUniforms defaultValue=null)
        {
            if (overrides == null) return defaultValue;
            return overrides.GetUniforms_(defaultValue);
        }
    }
}
{'fraction_non_alphanumeric': 0.06192821956368754, 'fraction_numerical': 0.0, 'mean_word_length': 2.2256014525646846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2518591', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1708, 'n_words': 442}