Exemplo n.º 1
0
        internal Stats.StatResult GetStatFunctionResult(Stats.StatFunction statFunction, DataGridCollectionView view)
        {
            if (!m_statFunctionValues.ContainsKey(statFunction))
            {
                this.CalculateStatFunctionValue(statFunction, view);
            }

            return(m_statFunctionValues[statFunction]);
        }
Exemplo n.º 2
0
        protected internal virtual bool IsEquivalent(StatFunction statFunction)
        {
            if (statFunction == null)
            {
                return(false);
            }

            return((this.GetType() == statFunction.GetType()) &&
                   (this.SourcePropertyName == statFunction.SourcePropertyName));
        }
Exemplo n.º 3
0
 internal static bool AreEquivalents(StatFunction statFunctionA, StatFunction statFunctionB)
 {
     if ((statFunctionA != null) && (statFunctionB != null))
     {
         return(statFunctionA.IsEquivalent(statFunctionB));
     }
     else
     {
         return((statFunctionA == null) && (statFunctionB == null));
     }
 }
Exemplo n.º 4
0
        private static StatResult RunStatFunction(
            StatFunction statFunction,
            Type[] dataTypes,
            object[] valuesX,
            object[] valuesY)
        {
            statFunction.InitializeAccumulationTypes(dataTypes);
            statFunction.StartCalculation();
            statFunction.Reset();

            try
            {
                if (statFunction.PrerequisiteFunctions != null && statFunction.PrerequisiteFunctions.Length > 0)
                {
                    StatResult[] preValues = new StatResult[statFunction.PrerequisiteFunctions.Length];

                    for (int i = 0; i < statFunction.PrerequisiteFunctions.Length; i++)
                    {
                        preValues[i] = StatFunction.RunStatFunction(statFunction.PrerequisiteFunctions[i], dataTypes, valuesX, valuesY);

                        if (preValues[i].Value is Exception)
                        {
                            throw ( Exception )preValues[i].Value;
                        }
                    }

                    statFunction.InitializePrerequisites(preValues);
                }

                if (statFunction.RequiresAccumulation)
                {
                    for (int i = 0; i < valuesX.Length; i++)
                    {
                        if (valuesY == null)
                        {
                            statFunction.Accumulate(new object[] { valuesX[i] });
                        }
                        else
                        {
                            statFunction.Accumulate(new object[] { valuesX[i], valuesY[i] });
                        }
                    }
                }

                statFunction.EndCalculation();
                return(statFunction.GetResult());
            }
            catch (Exception ex)
            {
                return(new StatResult(ex));
            }
        }
Exemplo n.º 5
0
        protected internal virtual bool IsEquivalent(StatFunction statFunction)
        {
            if (object.ReferenceEquals(statFunction, null))
            {
                return(false);
            }

            if (object.ReferenceEquals(statFunction, this))
            {
                return(true);
            }

            return((this.GetType() == statFunction.GetType()) &&
                   (this.SourcePropertyName == statFunction.SourcePropertyName));
        }
Exemplo n.º 6
0
        internal object GetStatFunctionValue(string propertyName)
        {
            DataGridCollectionView view = this.GetCollectionView();

            Debug.Assert(view != null);

            if (view == null)
            {
                return(null);
            }

            Stats.StatFunction statFunction = view.StatFunctions[propertyName];

            Debug.Assert(view != null);

            if (statFunction == null)
            {
                return(null);
            }

            return(this.GetStatFunctionResult(statFunction, view).Value);
        }
Exemplo n.º 7
0
 private static StatResult RunStatFunction(StatFunction statFunction, Type[] dataTypes, params object[] values)
 {
     return(StatFunction.RunStatFunction(statFunction, dataTypes, values, null));
 }
Exemplo n.º 8
0
 protected internal virtual void InitializeFromInstance(StatFunction source)
 {
     this.SourcePropertyName = source.SourcePropertyName;
 }
Exemplo n.º 9
0
 internal static bool AreEquivalents( StatFunction statFunctionA, StatFunction statFunctionB )
 {
   if( ( statFunctionA != null ) && ( statFunctionB != null ) )
   {
     return statFunctionA.IsEquivalent( statFunctionB );
   }
   else
   {
     return ( statFunctionA == null ) && ( statFunctionB == null );
   }
 }
Exemplo n.º 10
0
    protected internal virtual bool IsEquivalent( StatFunction statFunction )
    {
      if( statFunction == null )
        return false;

      return ( this.GetType() == statFunction.GetType() ) &&
             ( this.SourcePropertyName == statFunction.SourcePropertyName );
    }
Exemplo n.º 11
0
 protected internal virtual void InitializeFromInstance( StatFunction source )
 {
   this.SourcePropertyName = source.SourcePropertyName;
 }
Exemplo n.º 12
0
 private void CalculateStatFunctionValue(Stats.StatFunction statFunction, DataGridCollectionView view)
 {
     m_statFunctionValues[statFunction] = new Stats.StatResult(
         new InvalidOperationException(Log.NotToolkitStr("Statistical functions"))
         );
 }
    private static StatResult RunStatFunction( 
      StatFunction statFunction, 
      Type[] dataTypes, 
      object[] valuesX, 
      object[] valuesY )
    {
      statFunction.InitializeAccumulationTypes( dataTypes );
      statFunction.StartCalculation();
      statFunction.Reset();

      try
      {
        if( statFunction.PrerequisiteFunctions != null && statFunction.PrerequisiteFunctions.Length > 0 )
        {
          StatResult[] preValues = new StatResult[ statFunction.PrerequisiteFunctions.Length ];

          for( int i = 0; i < statFunction.PrerequisiteFunctions.Length; i++ )
          {
            preValues[ i ] = StatFunction.RunStatFunction( statFunction.PrerequisiteFunctions[ i ], dataTypes, valuesX, valuesY );

            if( preValues[ i ].Value is Exception )
              throw ( Exception )preValues[ i ].Value;
          }

          statFunction.InitializePrerequisites( preValues );
        }

        if( statFunction.RequiresAccumulation )
        {
          for( int i = 0; i < valuesX.Length; i++ )
          {
            if( valuesY == null )
            {
              statFunction.Accumulate( new object[] { valuesX[ i ] } );
            }
            else
            {
              statFunction.Accumulate( new object[] { valuesX[ i ], valuesY[ i ] } );
            }
          }
        }

        statFunction.EndCalculation();
        return statFunction.GetResult();
      }
      catch( Exception ex )
      {
        return new StatResult( ex );
      }
    }
 private static StatResult RunStatFunction( StatFunction statFunction, Type[] dataTypes, params object[] values )
 {
   return StatFunction.RunStatFunction( statFunction, dataTypes, values, null );
 }
    protected internal virtual bool IsEquivalent( StatFunction statFunction )
    {
      if( object.ReferenceEquals( statFunction, null ) )
        return false;

      if( object.ReferenceEquals( statFunction, this ) )
        return true;

      return ( this.GetType() == statFunction.GetType() ) &&
             ( this.SourcePropertyName == statFunction.SourcePropertyName );
    }