Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entities"></param>
 /// <returns></returns>
 private IEnumerable <Inference <TEntity> > InferenceEntities(IEnumerable <TEntity> entities)
 {
     foreach (TEntity entity in entities)
     {
         InferenceInternal <TEntity> inferenceResultInternal = this.GetBruteInferenceCollection(entity);
         yield return(inferenceResultInternal.InternalToPublicConversion());
     }
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="inferenceInternal"></param>
 /// <returns>Inference</returns>
 internal static Inference <TEntity> InternalToPublicConversion <TEntity>(this InferenceInternal <TEntity> inferenceInternal)
     where TEntity : class, new()
 {
     return(new Inference <TEntity>()
     {
         Data = inferenceInternal.Data,
         ID = inferenceInternal.ID.ToString(),
         InferenceResult = inferenceInternal.InferenceResult,
         PropertiesNeedToChange = inferenceInternal.PropertiesNeedToChange,
         ErrorsQuantity = inferenceInternal.ErrorsQuantity
     });
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private InferenceInternal <TEntity> GetBruteInferenceCollection(TEntity entity)
        {
            InferenceInternal <TEntity> result = new InferenceInternal <TEntity>()
            {
                RatingsReport          = new List <bool>(),
                PropertiesNeedToChange = new List <string>(),
                Data = entity
            };
            IntermediateInferenceItemInternal minErrors = GetBruteInferenceCollectionIntermediate(entity).OrderBy(x => x.ErrorsQuantity).FirstOrDefault();

            result.RatingsReport          = minErrors.RatingsReport;
            result.PropertiesNeedToChange = minErrors.PropertiesNeedToChange;
            return(result);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="type"></param>
        /// <param name="entityItem"></param>
        /// <returns></returns>
        public static string GetInference(Expression <Func <TEntity, bool> > expression, ResponseType type, TEntity entityItem)
        {
            string result = null;
            InferenceInternal <TEntity> InferenceResultInternal = (new FuzzyLogic <TEntity>(expression)).GetBruteInferenceCollection(entityItem);
            Inference <TEntity>         inferenceResult         = InferenceResultInternal.InternalToPublicConversion();

            switch (type)
            {
            case ResponseType.Xml:
                result = inferenceResult.XmlSerialize();
                break;

            case ResponseType.Json:
                result = inferenceResult.JsonSerialize();
                break;
            }
            return(result);
        }