Skip to content
Snippets Groups Projects
Select Git revision
  • 510b4f23a9958a16cfd8c3b9ee8a6272d25ca5c3
  • master default
  • JS-based-scroll-rendering
  • Paul_Marius_Level
  • Paul_Marius_2
  • Paul_Marius
  • Andi_Mark
  • be-UnityWebView
  • gitignoreFrameitServer
  • ZimmerBSc
  • Bugfix_StageLoading
  • stages
  • MAZIFAU_Experimental
  • tsc/coneworld
  • tsc/fact-interaction
  • marcel
  • MaZiFAU_TopSort
  • mergeHelper
  • zwischenSpeichern
  • tempAndrToMaster
  • SebBranch
  • 3.0
  • v2.1
  • v2.0
  • v1.0
25 results

FactOrganizer.cs.meta

Blame
  • FunctionFact.cs 11.21 KiB
    using System;
    using System.Collections.Generic;
    using UnityEngine;
    using Newtonsoft.Json;
    using static SOMDocManager;
    using System.Linq.Expressions;
    using System.Linq;
    using MoreLinq;
    using MoreLinq.Extensions;
    
    /// <summary>
    /// Represents a function taking Parameters (<typeparam name="T0">) and Returning <typeparam name="TResult">
    /// </summary>
    public class FunctionFact<T0, TResult> : FactWrappedCRTP<FunctionFact<T0, TResult>>
    {
        /// \copydoc Fact.s_type
        [JsonProperty]
        protected new string s_type = "FunctionFact<" + typeof(T0) + ", " + typeof(TResult) + ">";
    
        public SOMDoc Function_SOMDoc;
    
        //TODO: doc
        [JsonIgnore]
        public LambdaExpression Function_expression;
    
        [JsonIgnore]
        public Func<T0, TResult> Function;
    
        //TODO
        public (T0 t_0, T0 t_n) Domain = (default, default);
    
        /// <summary> \copydoc Fact.Fact </summary>
        public FunctionFact() : base() { }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="Function_MMT">sets <see cref="Function_SOMDoc"/> and contains the Abstract Syntax Tree</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public FunctionFact(SOMDoc Function_MMT, (T0, T0) domain, FactOrganizer organizer) : base(organizer)
            => init(Function_MMT, domain);
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
        /// <param name="function_expression">sets <see cref="Function_expression"/> and contains the Abstract Syntax Tree</param>
        /// <param name="uri">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public FunctionFact(SOMDoc Function_SOMDoc, (T0, T0) domain, string uri, FactOrganizer organizer) : base(organizer)
        {
            this.Function_SOMDoc = Function_SOMDoc;
            this.Domain = domain;
    
            this.Function_expression = Function_SOMDoc.GetReducedLambdaExpression();
            ////TODO: catch
            //string debug_tostring = Function_expression.ToString();
            //dynamic debug_function = Function_expression.Compile();
            this.Function = this.Function_expression.Compile() as Func<T0, TResult>;
    
            this._URI = uri;
            _ = this.Label;
    
            RecalculateTransform();
        }
    
        /// <summary>
        /// Initiates <see cref="Function_SOMDoc"/>, <see cref="Function_expression"/>, <see cref="Function"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
        /// </summary>
        /// <param name="Function_SOMDoc">sets <see cref="Function_SOMDoc"/> and contains the Abstract Syntax Tree</param>
        private void init(SOMDoc Function_SOMDoc, (T0, T0) domain)