Beispiel #1
0
 public Y Evaluate(X x)
 {
     for (var i = 0; i < Next; i++)
     {
         var predicate = Predicates[i];
         if (predicate(x))
         {
             return(Evaluators[predicate](x));
         }
     }
     return(fail <Y>(PredicateUnsatisfied(true)));
 }
        public void GraphicsMixedStandardShaderQualityIsReported(bool isMixed)
        {
            var buildGroup         = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
            var savedTier1settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier1);
            var savedTier2settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier2);
            var savedTier3settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier3);

            var tier1settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier1);
            var tier2settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier2);
            var tier3settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier3);

            tier1settings.standardShaderQuality = ShaderQuality.High;
            tier2settings.standardShaderQuality = ShaderQuality.High;
            tier3settings.standardShaderQuality = isMixed ? ShaderQuality.Low : ShaderQuality.High;

            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier1, tier1settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier2, tier2settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier3, tier3settings);

            Assert.AreEqual(isMixed, Evaluators.GraphicsMixedStandardShaderQuality());

            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier1, savedTier1settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier2, savedTier2settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier3, savedTier3settings);
        }
Beispiel #3
0
        public void Submit(IEvaluatorRequest request)
        {
            LOGGER.Log(Level.Info, "Submitting request for {0} evaluators and {1} MB memory and  {2} core to rack {3} and runtime {4}.", request.Number, request.MemoryMegaBytes, request.VirtualCore, request.Rack, request.RuntimeName);
            lock (Evaluators)
            {
                for (var i = 0; i < request.Number; i++)
                {
                    if (!string.IsNullOrWhiteSpace(request.RuntimeName))
                    {
                        if (runtimes.runtimeNames != null && !runtimes.runtimeNames.Contains(request.RuntimeName))
                        {
                            throw new ArgumentException(string.Format("Requested runtime {0} is not in the defined runtimes list {1}", request.RuntimeName, string.Join(",", runtimes.runtimeNames)));
                        }
                    }

                    var descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore, request.RuntimeName, request.Rack);
                    var key        = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", request.EvaluatorBatchId, BatchIdxSeparator, i);
                    try
                    {
                        Evaluators.Add(key, descriptor);
                    }
                    catch (ArgumentException e)
                    {
                        Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER);
                        Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER);
                    }
                }
            }

            Clr2Java.Submit(request);
        }
        public void GraphicsUsingRenderingPathIsReported(RenderingPath renderingPath)
        {
            var buildGroup         = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
            var savedTier1settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier1);
            var savedTier2settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier2);
            var savedTier3settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier3);

            var tier1settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier1);
            var tier2settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier2);
            var tier3settings = EditorGraphicsSettings.GetTierSettings(buildGroup, GraphicsTier.Tier3);

            tier1settings.renderingPath = renderingPath;
            tier2settings.renderingPath = renderingPath;
            tier3settings.renderingPath = renderingPath;

            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier1, tier1settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier2, tier2settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier3, tier3settings);

            if (renderingPath == RenderingPath.Forward)
            {
                Assert.AreEqual(true, Evaluators.GraphicsUsingForwardRendering());
                Assert.AreEqual(false, Evaluators.GraphicsUsingDeferredRendering());
            }
            else
            {
                Assert.AreEqual(false, Evaluators.GraphicsUsingForwardRendering());
                Assert.AreEqual(true, Evaluators.GraphicsUsingDeferredRendering());
            }

            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier1, savedTier1settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier2, savedTier2settings);
            EditorGraphicsSettings.SetTierSettings(buildGroup, GraphicsTier.Tier3, savedTier3settings);
        }
Beispiel #5
0
        public Symbol Evaluate(Symbol symbol)
        {
            if (symbol is Expression expression && expression.Count > 0)
            {
                Expression.Builder builder = new Expression.Builder(expression);
                for (int i = 0; i < builder.Count; i++)
                {
                    if (builder.Arguments[i] is Expression)
                    {
                        builder.Arguments[i] = Evaluate(builder[i]);
                    }
                }

                if (Evaluators.TryGetValue(builder[0], out var evaluator))
                {
                    symbol = evaluator.Evaluate(builder.Build(), this);
                }
            }

            History.Insert(0, symbol);

            for (int i = 0; i < Math.Min(History.Count, 10); i++)
            {
                Variable[Atom.OfHistory(i)] = History[i];
            }

            return(symbol);
        }
Beispiel #6
0
 public static void Exit()
 {
     Self.SendChat(ChatColors.Blue + "C# Interactive Mode disabled");
     Server.SettingsProvider.Set(Self.Username + ".repl.enabled", false);
     Evaluators.Remove(Self.Username);
     Self = null;
 }
Beispiel #7
0
 public StringEvaluators(IDataReader dataReader)
 {
     Palindrome = new PalindromeEvaluator(dataReader);
     Consonants = new ConsonantsEvaluator(dataReader);
     Evaluators.Add(Palindrome);
     Evaluators.Add(Consonants);
 }
        private bool _PerformComparison(string query, object target, string operation)
        {
            var evaluator = string.IsNullOrEmpty(operation)
                                                                ? Evaluators.FirstOrDefault()
                                                                : Evaluators.FirstOrDefault(e => e.Operation == operation);

            if (evaluator == null)
            {
                return(false);
            }

            if (target is bool b)
            {
                return(bool.TryParse(query, out var boolQuery) && evaluator.Match(boolQuery, b));
            }

            if (target is sbyte || target is byte || target is char ||
                target is short || target is ushort ||
                target is int || target is uint ||
                target is long || target is ulong ||
                target is float || target is double ||
                target is decimal)
            {
                return(double.TryParse(query, out var doubleQuery) && evaluator.Match(doubleQuery, Convert.ToDouble(target)));
            }

            return(evaluator.Match(query, target?.ToString(), IsCaseSensitive));
        }
        public override bool AllowsScopes(IEnumerable <string> scopes)
        {
            if (!Evaluators.Any())
            {
                return(true);
            }

            return(Evaluators.Any(permission => permission.AllowsScopes(scopes)));
        }
        public void  SplashScreenIsEnabledAndCanBeDisabled(bool splashScreenEnabled)
        {
            var prevSplashScreenEnabled = PlayerSettings.SplashScreen.show;

            PlayerSettings.SplashScreen.show = splashScreenEnabled;

            Assert.AreEqual(splashScreenEnabled, Evaluators.PlayerSettingsSplashScreenIsEnabledAndCanBeDisabled());

            PlayerSettings.SplashScreen.show = prevSplashScreenEnabled;
        }
Beispiel #11
0
        /// <summary>
        ///   Adds the specified <see cref="T:Crystal.IEvaluator"/> to this <see cref="T:Crystal.CompositeEvaluator"/>
        ///   if the new evaluator has a domain that does not overlap the domains of definition of the
        ///   <see cref="T:Crystal.IEvaluator"/> already added to this <see cref="T:Crystal.CompositeEvaluator"/>.
        /// </summary>
        /// <param name="ev">Ev.</param>
        public void Add(IEvaluator ev)
        {
            if (DoesNotOverlapWithAnyEvaluator(ev))
            {
                Evaluators.Add(ev);
            }

            Evaluators.Sort((e1, e2) => e1.XInterval.CompareTo(e2.XInterval));
            UpdateXyPoints();
        }
Beispiel #12
0
 public bool RunEvaluators()
 {
     if (!BuilderStateMachine.TypeIsChecked)
     {
         DataContext.ASTHandlerExceptions.Add(new QLError("previous step not completed successfuly"));
         return(false);
     }
     BuilderStateMachine.IsEvaluated = RunHandlerLevel(Evaluators.ToArray());
     return(BuilderStateMachine.IsEvaluated);
 }
Beispiel #13
0
        void HandleChatMessage(object sender, ChatMessageEventArgs e)
        {
            if (!Evaluators.ContainsKey(e.Origin.Username))
            {
                return;
            }
            e.Handled = true;
            object result;
            bool   result_set;

            if (ReplContext.LongExpression && e.RawMessage != ">>>")
            {
                ReplContext.WorkingExpression += e.RawMessage;
                e.Origin.SendChat(ChatColors.Yellow + e.RawMessage);
                return;
            }
            if (e.RawMessage == "<<<")
            {
                ReplContext.LongExpression    = true;
                ReplContext.WorkingExpression = string.Empty;
                return;
            }
            if (e.RawMessage.EndsWith("\\"))
            {
                ReplContext.WorkingExpression += e.RawMessage.Remove(e.RawMessage.Length - 1);
                return;
            }
            if (!ReplContext.LongExpression)
            {
                ReplContext.WorkingExpression += e.RawMessage;
            }
            else
            {
                ReplContext.LongExpression = false;
            }
            try
            {
                Evaluators[e.Origin.Username].Evaluate(ReplContext.WorkingExpression, out result, out result_set);
                if (result_set)
                {
                    e.Origin.SendChat(result.ToString());
                }
            }
            catch (Exception)
            {
                // ...will be sent to the user by Mono.CSharp...
            }
            ReplContext.WorkingExpression = string.Empty;
        }
        public static string Replace(this string obj, string matchString, string formatString, bool ignoreCase)
        {
            Regex regex;

            if (ignoreCase)
            {
                regex = new Regex(matchString, RegexOptions.IgnoreCase);
            }
            else
            {
                regex = new Regex(matchString);
            }
            var evaluator = new MatchEvaluator(match => Evaluators.Wrap(match, obj, formatString));

            return(regex.Replace(obj, evaluator));
        }
Beispiel #15
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.graphdb.traversal.Traverser traverser(org.neo4j.graphdb.Node start, final org.neo4j.graphdb.Node end, org.neo4j.graphalgo.impl.util.PathInterest<double> interest)
        private Traverser Traverser(Node start, Node end, PathInterest <double> interest)
        {
            PathExpander  dijkstraExpander;
            PathEvaluator dijkstraEvaluator;

            if (_stateInUse)
            {
                dijkstraExpander  = _expander;
                dijkstraEvaluator = Evaluators.includeWhereEndNodeIs(end);
            }
            else
            {
                MutableDouble shortestSoFar = new MutableDouble(double.MaxValue);
                dijkstraExpander  = new DijkstraPathExpander(_expander, shortestSoFar, _epsilon, interest.StopAfterLowestCost());
                dijkstraEvaluator = new DijkstraEvaluator(shortestSoFar, end, _costEvaluator);
            }
            _lastTraverser = (new MonoDirectionalTraversalDescription()).uniqueness(Uniqueness.NODE_PATH).expand(dijkstraExpander, _stateFactory).order(new DijkstraSelectorFactory(interest, _costEvaluator)).evaluator(dijkstraEvaluator).traverse(start);
            return(_lastTraverser);
        }
Beispiel #16
0
 public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
 {
     Server = server;
     if (parameters.Length != 0)
     {
         user.SendChat(ChatColors.Red + "Invalid parameters. Use /help repl for more information.");
         return;
     }
     if (ReplContext.Self != null)
     {
         user.SendChat(ChatColors.Red + ReplContext.Self.Username + " is currently in REPL mode. Only one user may be in REPL mode at a time.");
         // TODO: Upgrade Mono.CSharp to Mono 3.0 and support several REPLs at once
         return;
     }
     server.ChatMessage -= HandleChatMessage;
     server.ChatMessage += HandleChatMessage;
     server.MinecraftServer.PlayerLoggedOut += (s, e) =>
     {
         if (Evaluators.ContainsKey(e.Username))
         {
             Evaluators.Remove(e.Username);
         }
         ReplContext.Self = null;
     };
     Evaluators[user.Username] = new Evaluator(new CompilerContext(new CompilerSettings(), new MinecraftReportPrinter(user)));
     Evaluators[user.Username].ReferenceAssembly(typeof(Server).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(MinecraftServer).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(Craft.Net.Networking.IPacket).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(World).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(IServer).Assembly);
     Evaluators[user.Username].InteractiveBaseClass = typeof(ReplContext);
     Evaluators[user.Username].Run("using Craft.Net");
     Evaluators[user.Username].Run("using Craft.Net.Data");
     Evaluators[user.Username].Run("using Craft.Net.Data.Blocks");
     Evaluators[user.Username].Run("using Craft.Net.Data.Items");
     Evaluators[user.Username].Run("using Craft.Net.Server");
     Evaluators[user.Username].Run("using PartyCraft");
     ReplContext.Self   = user;
     ReplContext.Server = server;
     user.SendChat(ChatColors.Blue + "Entering C# Interactive Mode");
     user.SendChat(ChatColors.Blue + "Use `Exit()` to exit REPL mode.");
 }
Beispiel #17
0
 protected void PATCH(string json)
 {
     UserCheck();
     if (MethodAllowed(RESTarMethods.PATCH))
     {
         try
         {
             Evaluators.PATCH(RESTarData, json, Request);
             Success = true;
         }
         catch (AbortedUpdaterException e)
         {
             SetMessage(e.InnerException?.Message ?? e.Message, e.ErrorCode, error);
         }
     }
     else
     {
         SetMessage($"You are not allowed to update the '{Resource}' resource", NotAuthorized, error);
     }
 }
Beispiel #18
0
 protected void DELETE(object item)
 {
     UserCheck();
     if (MethodAllowed(RESTarMethods.DELETE))
     {
         try
         {
             Evaluators.DELETE(item, Request);
             Success = true;
         }
         catch (AbortedDeleterException e)
         {
             SetMessage(e.InnerException?.Message ?? e.Message, e.ErrorCode, error);
         }
     }
     else
     {
         SetMessage($"You are not allowed to delete from the '{Resource}' resource", NotAuthorized, error);
     }
 }
Beispiel #19
0
        public void Submit(IEvaluatorRequest request)
        {
            LOGGER.Log(Level.Info, "Submitting request for {0} evaluators and {1} MB memory and  {2} core to rack {3}.", request.Number, request.MemoryMegaBytes, request.VirtualCore, request.Rack);

            lock (Evaluators)
            {
                for (var i = 0; i < request.Number; i++)
                {
                    var descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore, request.Rack);
                    var key        = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", request.EvaluatorBatchId, BatchIdxSeparator, i);
                    try
                    {
                        Evaluators.Add(key, descriptor);
                    }
                    catch (ArgumentException e)
                    {
                        Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER);
                        Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER);
                    }
                }
            }

            Clr2Java.Submit(request);
        }
Beispiel #20
0
 public IEnumerator GetEnumerator()
 => Evaluators.GetEnumerator();
Beispiel #21
0
 public void Add(Func <X, bool> predicate, Func <X, Y> whenTrue)
 {
     Evaluators.Add(predicate, whenTrue);
     Predicates[Next++] = predicate;
 }
Beispiel #22
0
 public AttributeSelections(Runtime rt)
 {
     Algorithms = new Algorithms(rt);
     Evaluators = new Evaluators(rt);
 }
Beispiel #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useTraverserInsideTraverser()
        public virtual void UseTraverserInsideTraverser()
        {
            /*
             * (a)-->(b)-->(c)
             *  |
             * \/
             * (d)-->(e)-->(f)
             *
             */

            CreateGraph("a FIRST d", "a TO b", "b TO c", "d TO e", "e TO f");

            using (Transaction tx = BeginTx())
            {
                TraversalDescription firstTraverser = GraphDb.traversalDescription().relationships(RelationshipType.withName("FIRST")).evaluator(Evaluators.toDepth(1));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Iterable<org.neo4j.graphdb.Path> firstResult = firstTraverser.traverse(getNodeWithName("a"));
                IEnumerable <Path> firstResult = firstTraverser.Traverse(GetNodeWithName("a"));

                IEnumerable <Node> startNodesForNestedTraversal = new IterableWrapperAnonymousInnerClass(this, firstResult);

                TraversalDescription nestedTraversal = GraphDb.traversalDescription().evaluator(Evaluators.atDepth(2));
                ExpectPaths(nestedTraversal.Traverse(startNodesForNestedTraversal), "a,b,c", "d,e,f");
                tx.Success();
            }
        }
Beispiel #24
0
 public void Setup()
 {
     Evaluators.ForEach(e => e.Setup());
     IsSetuped = true;
 }
 public override bool AllowsScopes(IEnumerable <string> scopes)
 {
     return(Evaluators.All(permissions => permissions.AllowsScopes(scopes)));
 }
 public Boolean HasComments()
 {
     return Evaluators.Where(e => !String.IsNullOrEmpty(e.Comment) || e.Values.Where(v => !String.IsNullOrEmpty(v.Comment)).Any()).Any() || Criteria.Where(c => c.Evaluations.Where(e => !String.IsNullOrEmpty(e.Criterion.Comment)).Any()).Any();
 }
Beispiel #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void traverseWithIterableForStartNodes()
        public virtual void TraverseWithIterableForStartNodes()
        {
            /*
             * (a)-->(b)-->(c)
             * (d)-->(e)-->(f)
             *
             */

            CreateGraph("a TO b", "b TO c", "d TO e", "e TO f");

            using (Transaction tx = BeginTx())
            {
                TraversalDescription basicTraverser = GraphDb.traversalDescription().evaluator(Evaluators.atDepth(2));

                ICollection <Node> startNodes = new List <Node>();
                startNodes.Add(GetNodeWithName("a"));
                startNodes.Add(GetNodeWithName("d"));

                IEnumerable <Node> iterableStartNodes = startNodes;

                ExpectPaths(basicTraverser.Traverse(iterableStartNodes), "a,b,c", "d,e,f");
                tx.Success();
            }
        }
Beispiel #28
0
 public void AddEvaluator(Evaluator evaluator)
 {
     Evaluators.Add(evaluator);
 }
Beispiel #29
0
 public virtual void Remove(Evaluators.Evaluator value)
 {
     List.Remove(value);
 }
Beispiel #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMaxDepthAndCustomPruneEvaluatorCombined()
        public virtual void TestMaxDepthAndCustomPruneEvaluatorCombined()
        {
            Evaluator lessThanThreeRels = path => count(path.endNode().getRelationships(Direction.OUTGOING).GetEnumerator()) < 3 ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;

            TraversalDescription description   = GraphDb.traversalDescription().evaluator(Evaluators.all()).evaluator(toDepth(1)).evaluator(lessThanThreeRels);
            ISet <string>        expectedNodes = new HashSet <string>(asList("a", "b", "c", "d", "e"));

            using (Transaction tx = BeginTx())
            {
                foreach (Path position in description.Traverse(Node("a")))
                {
                    string name = ( string )position.EndNode().getProperty("name");
                    assertTrue(name + " shouldn't have been returned", expectedNodes.remove(name));
                }
                tx.Success();
            }
            assertTrue(expectedNodes.Count == 0);
        }
Beispiel #31
0
 public virtual int Add(Evaluators.Evaluator value)
 {
     return List.Add(value);
 }
Beispiel #32
0
 public void RegisterEvaluator(IExecutableHandler handler)
 {
     Evaluators.Add(handler);
 }