public CachedHash(HashFunc hashFunc, FailureBehavior failureBehavior = FailureBehavior.AssertFailures, CachabilityTestFunc cachabilityTest = null) { this._hashCache = new Dictionary <HashedObjectType, ValueType>(); this._hashFunc = hashFunc; this._failureBehavior = failureBehavior; this._cachabilityTest = cachabilityTest; }
/// <summary> /// Internal evaluation method of absolute fusionPath /// </summary> /// <param name="fusionPath"></param> /// <param name="behaviorIfPathNotFound"></param> /// <param name="contextObject">The object which will be "this" in Eel expressions, if any</param> /// <returns></returns> protected object EvaluateInternal(string fusionPath, FailureBehavior behaviorIfPathNotFound, AbstractFusionObject contextObject = null) { var needToPopContext = false; var needToPopApply = false; lastEvaluationStatus = EvaluationStatus.Executed; var fusionConfiguration = GetConfigurationForPath(fusionPath); var cacheContext = runtimeContentCache.Enter(new Cache.FusionObjectCacheConfiguration(), fusionPath); var currentProperties = GetCurrentApplyValues(); if (currentProperties.ContainsKey(fusionPath)) { if (!EvaluateIfCondition(fusionConfiguration, fusionPath, contextObject)) { return(null); } return(EvaluateProcessors(currentProperties[fusionPath].Value, fusionConfiguration, fusionPath, contextObject)); } if (!CanRenderWithConfiguration(fusionConfiguration)) { FinalizePathEvaluation(cacheContext); ThrowExceptionForUnrenderablePathIfNeeded(fusionPath, fusionConfiguration, behaviorIfPathNotFound); lastEvaluationStatus = EvaluationStatus.Skipped; return(null); } object output = null; try { if (HasExpressionOrValue(fusionConfiguration)) { return(EvaluateExpressionOrValueInternal(fusionPath, fusionConfiguration, cacheContext, contextObject)); } needToPopApply = PrepareApplyValuesForFusionPath(fusionPath, fusionConfiguration); var fusionObject = InstantiateFusionObject(fusionPath, fusionConfiguration); needToPopContext = PrepareContextForFusionObject(fusionObject, fusionPath, fusionConfiguration, cacheContext); output = EvaluateObjectOrRetrieveFromCache(fusionObject, fusionPath, fusionConfiguration, cacheContext); } catch (Exception e) { FinalizePathEvaluation(cacheContext, needToPopContext, needToPopApply); // todo error handling Console.WriteLine(e.Message); // Console.WriteLine(e.StackTrace); // throw e; } FinalizePathEvaluation(cacheContext, needToPopContext, needToPopApply); return(output); }
private void ThrowExceptionForUnrenderablePathIfNeeded(string fusionPath, FusionAst fusionConfiguration, FailureBehavior behaviorIfPathNotFound) { // System.Console.WriteLine("Could not render at path " + fusionPath); if (!string.IsNullOrEmpty(fusionConfiguration.ObjectType)) { var objectType = fusionConfiguration.ObjectType; throw new FusionException($"The fusion object at path \"{fusionPath}\" could not be rendered:\n\t\tThe fusion object `{objectType}` is not completely defined (missing property `@class`). Most likely you didn't inherit from a basic object."); } if (behaviorIfPathNotFound == FailureBehavior.Exception) { throw new FusionException($"No fusion object found in path \"{fusionPath}\"\n\t\tPlease make sure to define one in your Fusion configuration."); } }