public IStringBuilder Append(IStringBuilder builder)
        {
            if (builder == null)
                return this;

            _builder.Append(builder.ToString());
            return this;
        }
Ejemplo n.º 2
0
 public override void ToStringBuilder(IStringBuilder writer)
 {
     if (!string.IsNullOrEmpty(Comment))
     {
         writer.Append("/* ");
         writer.Append(Comment);
         writer.AppendLine(" */");
     }
 }
Ejemplo n.º 3
0
 public static IStringBuilder AppendLine(this IStringBuilder sb, int indent, string message)
 {
     if (indent > 0)
     {
         AppendTabSpaces(sb, indent);
     }
     sb.AppendLine(message);
     return(sb);
 }
Ejemplo n.º 4
0
 public void SetUp()
 {
     _stringBuilder = Substitute.For<IStringBuilder>();
     _stringBuilder.GenerateString().Returns("Claudia");
     
     _randomGenerator = Substitute.For<IRandomGenerator>();
     _expression = Substitute.For<IExpression>();
     _expression.ToStringBuilder().Returns(_stringBuilder);
 }
Ejemplo n.º 5
0
            public override string ToString()
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();

                sb.Append("isComplete=" + complete);
                sb.Append("\n");
                sb.Append("result=" + proofs);
                return(sb.ToString());
            }
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append('[');
            sb.Append(name);
            sb.Append("]");
            return(sb.ToString());
        }
Ejemplo n.º 7
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append(key)
            .Append("==")
            .Append(value);

            return(sb.ToString());
        }
Ejemplo n.º 8
0
        public static string ntimes(string s, int n)
        {
            IStringBuilder builder = TextFactory.CreateStringBuilder();

            for (int i = 0; i < n; ++i)
            {
                builder.Append(s);
            }
            return(builder.ToString());
        }
        public IStringBuilder Append(IStringBuilder builder)
        {
            if (builder == null)
            {
                return(this);
            }

            _builder.Append(builder.ToString());
            return(this);
        }
        /**
         * Template method controlling the search. It is based on iterative
         * deepening and tries to make to a good decision in limited time. Credit
         * goes to Behi Monsio who had the idea of ordering actions by utility in
         * subsequent depth-limited search runs.
         */

        public virtual A makeDecision(S state)
        {
            metrics = new Metrics();
            IStringBuilder logText = null;
            P player = game.GetPlayer(state);
            ICollection <A> results = orderActions(state, game.GetActions(state), player, 0);

            timer.start();
            currDepthLimit = 0;
            do
            {
                incrementDepthLimit();
                if (logEnabled)
                {
                    logText = TextFactory.CreateStringBuilder("depth " + currDepthLimit + ": ");
                }
                heuristicEvaluationUsed = false;
                ActionStore newResults = new ActionStore();
                foreach (A action in results)
                {
                    double value = minValue(game.GetResult(state, action), player, double.NegativeInfinity,
                                            double.PositiveInfinity, 1);
                    if (timer.timeOutOccurred())
                    {
                        break; // exit from action loop
                    }
                    newResults.add(action, value);
                    if (logEnabled)
                    {
                        logText.Append(action).Append("->").Append(value).Append(" ");
                    }
                }
                if (logEnabled)
                {
                    System.Console.WriteLine(logText);
                }
                if (newResults.size() > 0)
                {
                    results = newResults.actions;
                    if (!timer.timeOutOccurred())
                    {
                        if (hasSafeWinner(newResults.utilValues.Get(0)))
                        {
                            break; // exit from iterative deepening loop
                        }
                        else if (newResults.size() > 1 &&
                                 isSignificantlyBetter(newResults.utilValues.Get(0), newResults.utilValues.Get(1)))
                        {
                            break; // exit from iterative deepening loop
                        }
                    }
                }
            } while (!timer.timeOutOccurred() && heuristicEvaluationUsed);
            return(results.Get(0));
        }
Ejemplo n.º 11
0
        private static IStringBuilder IntersectStringBuilderWith(IStringBuilder toIntersectStringBuilder, IStringBuilder intersectionResult)
        {
            if (intersectionResult == null)
            {
                intersectionResult = toIntersectStringBuilder;
                return(intersectionResult);
            }

            intersectionResult = intersectionResult.IntersectWith(toIntersectStringBuilder);
            return(intersectionResult);
        }
Ejemplo n.º 12
0
        public override string ToString()
        {
            IStringBuilder buf = TextFactory.CreateStringBuilder();

            foreach (DecisionListTest test in tests)
            {
                buf.Append(test.ToString() + " => " + testOutcomes.Get(test) + " ELSE \n");
            }
            buf.Append("END");
            return(buf.ToString());
        }
Ejemplo n.º 13
0
        protected override IStringBuilder ToSingleStringBuilder()
        {
            IStringBuilder builder = StringBuilder.Empty;

            foreach (var expression in _elementaryExpressions)
            {
                builder = builder.ConcatWith(expression.ToStringBuilder());
            }

            return(builder);
        }
        /**
         * Return string representation of this percept.
         *
         * @return a string representation of this percept.
         */
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append("[");
            sb.Append(getAgentLocation());
            sb.Append(", ");
            sb.Append(getLocationState());
            sb.Append("]");
            return(sb.ToString());
        }
Ejemplo n.º 15
0
        public void setUp()
        {
            aMap = new ExtendableMap();
            aMap.addBidirectionalLink("A", "B", 5.0);
            aMap.addBidirectionalLink("A", "C", 6.0);
            aMap.addBidirectionalLink("B", "C", 4.0);
            aMap.addBidirectionalLink("C", "D", 7.0);
            aMap.addUnidirectionalLink("B", "E", 14.0);

            envChanges = TextFactory.CreateStringBuilder();
        }
Ejemplo n.º 16
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            foreach (Sentence s in originalSentences)
            {
                sb.Append(s.ToString());
                sb.Append("\n");
            }
            return(sb.ToString());
        }
Ejemplo n.º 17
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append("[")
            .Append(left)
            .Append(" || ")
            .Append(right)
            .Append("]");

            return(sb.ToString());
        }
Ejemplo n.º 18
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append("if ")
            .Append(con)
            .Append(" then ")
            .Append(action)
            .Append(".");

            return(sb.ToString());
        }
Ejemplo n.º 19
0
 public override string ToString()
 {
     if (null == stringRep)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append("NOT(");
         sb.Append(negated.ToString());
         sb.Append(")");
         stringRep = sb.ToString();
     }
     return(stringRep);
 }
Ejemplo n.º 20
0
 public override string ToString()
 {
     if (null == toString)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(getDerivedName());
         sb.Append(" = ");
         sb.Append(sumsDomain.ToString());
         toString = sb.ToString();
     }
     return(toString);
 }
Ejemplo n.º 21
0
 public override string ToString()
 {
     if (null == stringRep)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(term1.ToString());
         sb.Append(" = ");
         sb.Append(term2.ToString());
         stringRep = sb.ToString();
     }
     return(stringRep);
 }
Ejemplo n.º 22
0
        public AssetManager(
            IRequestRouter requestRouter,
            IFrameworkConfiguration frameworkConfiguration,
            ICssWriterFactory cssWriterFactory,
            IJavascriptWriterFactory javascriptWriterFactory,
            IStringBuilderFactory stringBuilderFactory,
            IDictionaryFactory dictionaryFactory)
        {
            _frameworkConfiguration  = frameworkConfiguration;
            _cssWriterFactory        = cssWriterFactory;
            _javascriptWriterFactory = javascriptWriterFactory;
            _stringBuilderFactory    = stringBuilderFactory;

            _elementsAddedToWebsite = new HashSet <string>();
            _elementsAddedToModule  = dictionaryFactory.Create <string, HashSet <string> >();
            _elementsAddedToPage    = dictionaryFactory.Create <string, HashSet <string> >();

            _moduleStyles    = dictionaryFactory.Create <string, string>();
            _moduleFunctions = dictionaryFactory.Create <string, string>();
            _pageStyles      = dictionaryFactory.Create <string, string>();
            _pageFunctions   = dictionaryFactory.Create <string, string>();

            _websiteStylesBuilder    = stringBuilderFactory.Create();
            _websiteFunctionsBuilder = stringBuilderFactory.Create();

            _moduleStyleBuilders    = dictionaryFactory.Create <string, IStringBuilder>();
            _moduleFunctionBuilders = dictionaryFactory.Create <string, IStringBuilder>();
            _pageStyleBuilders      = dictionaryFactory.Create <string, IStringBuilder>();
            _pageFunctionBuilders   = dictionaryFactory.Create <string, IStringBuilder>();

            frameworkConfiguration.Subscribe(config =>
            {
                var rootPath = config.AssetRootPath;
                if (rootPath.EndsWith("/") && rootPath.Length > 1)
                {
                    rootPath = rootPath.Substring(0, rootPath.Length - 1);
                }
                _rootPath = new PathString(rootPath);

                var priorRegistration = _runableRegistration;

                _runableRegistration = requestRouter.Register(this,
                                                              new FilterAllFilters(
                                                                  new FilterByMethod(Method.Get),
                                                                  new FilterByPath(_rootPath.Value + "/**")), -10);

                if (priorRegistration != null)
                {
                    priorRegistration.Dispose();
                }
            });
        }
Ejemplo n.º 23
0
        public override string ToString()
        {
            if (null == toString)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append(getTermVariable().getName());
                sb.Append(" = ");
                sb.Append(value);

                toString = sb.ToString();
            }
            return(toString);
        }
Ejemplo n.º 24
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            for (int i = 0; i < radices.Length; ++i)
            {
                sb.Append("[");
                sb.Append(this.GetCurrentNumeralValue(i));
                sb.Append("]");
            }

            return(sb.ToString());
        }
Ejemplo n.º 25
0
        public override string ToString()
        {
            IStringBuilder buf = TextFactory.CreateStringBuilder();

            buf.Append("IF  ");
            foreach (string key in attrValues.GetKeys())
            {
                buf.Append(key + " = ");
                buf.Append(attrValues.Get(key) + " ");
            }
            buf.Append(" DECISION ");
            return(buf.ToString());
        }
Ejemplo n.º 26
0
        public override string ToString()
        {
            if (null == toString)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append("(NOT ");
                sb.Append(proposition.ToString());
                sb.Append(")");

                toString = sb.ToString();
            }
            return(toString);
        }
Ejemplo n.º 27
0
        public override string ToString()
        {
            IStringBuilder result = TextFactory.CreateStringBuilder();

            foreach (Pair <VAR, Domain <VAL> > pair in savedDomains)
            {
                result.Append(pair.GetFirst()).Append("=").Append(pair.getSecond()).Append(" ");
            }
            if (emptyDomainObserved)
            {
                result.Append("!");
            }
            return(result.ToString());
        }
Ejemplo n.º 28
0
        } // end getPageName()

        public static string loadFileText(string folderPath, FileInfo file)
        {
            IStringBuilder pageContent = TextFactory.CreateStringBuilder();

            using (StreamReader sr = new StreamReader(file.FullName))
            {
                while (!sr.EndOfStream)
                {
                    pageContent.Append(sr.ReadLine());
                }
            }

            return(pageContent.ToString());
        } // end loadFileText()
Ejemplo n.º 29
0
        public override string ToString()
        {
            IStringBuilder buffer = TextFactory.CreateStringBuilder();

            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 3; col++)
                {
                    buffer.Append(getValue(col, row)).Append(" ");
                }
                buffer.Append("\n");
            }
            return(buffer.ToString());
        }
Ejemplo n.º 30
0
 public override string ToString()
 {
     if (null == toString)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(getDerivedName());
         foreach (IRandomVariable rv in getScope())
         {
             sb.Append(" = ");
             sb.Append(rv);
         }
         toString = sb.ToString();
     }
     return(toString);
 }
Ejemplo n.º 31
0
        public override string ToString()
        {
            if (null == cachedStringRep)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                if (isNegativeLiteral())
                {
                    sb.Append(Connective.NOT.ToString());
                }
                sb.Append(getAtomicSentence().ToString());
                cachedStringRep = sb.ToString();
            }

            return(cachedStringRep);
        }