Пример #1
0
 /// <summary>
 /// Returns whether the <paramref name="node"/> is a DScript 'public' decorator.
 /// </summary>
 public static bool IsScriptPublicDecorator(this IDecorator node)
 {
     return(node.Expression.As <IIdentifier>()?.OriginalKeywordKind == SyntaxKind.PublicKeyword);
 }
Пример #2
0
        private static bool TryCheckIsUnitTestDecorator(Logger logger, ISourceFile sourceFile, IDecorator decorator, out bool isUnitTestDecorator)
        {
            isUnitTestDecorator = false;
            var expression = decorator.Expression;

            ICallExpression callExpression = null;

            if (expression.Kind == SyntaxKind.CallExpression)
            {
                callExpression = (ICallExpression)expression;
                expression     = callExpression.Expression;
            }

            if (expression.Kind == SyntaxKind.PropertyAccessExpression)
            {
                var propertyAccess = (IPropertyAccessExpression)expression;
                expression = propertyAccess.Name;
            }

            if (expression.Kind == SyntaxKind.Identifier)
            {
                var identifier = (IIdentifier)expression;
                if (string.Equals(UnitTestName, identifier.Text, StringComparison.Ordinal))
                {
                    isUnitTestDecorator = true;
                }
                else if (string.Equals(UnitTestName, identifier.Text, StringComparison.OrdinalIgnoreCase))
                {
                    logger.LogError(sourceFile, decorator, C($"Decorator '{identifier.Text}' is using the wrong casing. Please use '{UnitTestName}'"));
                    return(false);
                }
            }

            // If this is a unit test and it came from a function call, perform some extra checks
            if (isUnitTestDecorator && callExpression != null)
            {
                if (callExpression.Arguments.Count > 0)
                {
                    logger.LogError(sourceFile, decorator, "UnitTest decorators are not allowed to have arguments");
                    return(false);
                }

                if (callExpression.TypeArguments != null && callExpression.TypeArguments.Count > 0)
                {
                    logger.LogError(sourceFile, decorator, "UnitTest decorators are not allowed to be generic");
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
 public static TReturn Decoration <TReturn, T>(IDecorator <TReturn, T> a, Func <TReturn, T> b)
 {
     return(a.RDecorate(b));
 }
Пример #4
0
 public Invoker(IServiceProvider serviceProvider = null, IDecorator decorator = null)
 {
     ServiceProvider = serviceProvider;
     Decorator       = decorator ?? new NullDecorator();
 }
Пример #5
0
 public ButtonC3PO(IDecorator actualButton)
 {
     this.ActualButton = actualButton;
 }
Пример #6
0
 private static bool IsObsolete(IDecorator decorator)
 {
     return(UnwrapIdentifier(decorator.Expression)?.Text == Names.ObsoleteAttributeName);
 }
Пример #7
0
 /// <summary>
 /// Convenience function that delegates to Decorate(Type, object).
 /// </summary>
 public static T Decorate <T>(this IDecorator decorator, T obj) where T : class
 {
     return((T)decorator.Decorate(typeof(T), obj));
 }
Пример #8
0
 public HelmetDecorator(IDecorator decorator) : base(decorator)
 {
     _def = def;
 }
Пример #9
0
 protected virtual void OnRasterize(ref UIOperationContext context, ref ImperativeRenderer renderer, DecorationSettings settings, IDecorator decorations)
 {
     decorations?.Rasterize(ref context, ref renderer, settings);
 }
Пример #10
0
        private void RasterizePass(
            ref UIOperationContext context,
            ref DecorationSettings settings, IDecorator decorations,
            bool compositing, ref RasterizePassSet passSet,
            ref ImperativeRenderer renderer, RasterizePasses pass
            )
        {
            UIOperationContext passContext;

            context.Clone(out passContext);
            passContext.Pass = pass;
            var hasNestedContext = (pass == RasterizePasses.Content) &&
                                   (ShouldClipContent || (HasChildren && CreateNestedContextForChildren));

            if (hasNestedContext)
            {
                UpdateVisibleRegion(ref passContext, ref settings.Box);
            }

            // FIXME: The memset for these actually burns a measurable amount of time
            ImperativeRenderer contentRenderer;
            RasterizePassSet   childrenPassSet;
            UIOperationContext contentContext;

            int previousStackDepth = passSet.StackDepth, newStackDepth = previousStackDepth;

            // For clipping we need to create a separate batch group that contains all the rasterization work
            //  for our children. At the start of it we'll generate the stencil mask that will be used for our
            //  rendering operation(s).
            if (hasNestedContext)
            {
                NestedContextPassSetup(
                    ref context, ref passSet, ref renderer, ref passContext,
                    out contentRenderer, out childrenPassSet, out contentContext,
                    previousStackDepth, ref newStackDepth
                    );
            }
            else
            {
                contentContext  = passContext;
                childrenPassSet = default;
                contentRenderer = default;
            }

            // TODO: all the copying of settings here burns CPU time

            if (HasPreRasterizeHandler && (pass == RasterizePasses.Content))
            {
                OnPreRasterize(ref contentContext, settings, decorations);
            }

            if (hasNestedContext)
            {
                OnRasterize(ref contentContext, ref contentRenderer, settings, decorations);
            }
            else
            {
                OnRasterize(ref contentContext, ref renderer, settings, decorations);
            }

            if ((pass == RasterizePasses.Content) && HasChildren)
            {
                if (hasNestedContext)
                {
                    OnRasterizeChildren(ref contentContext, ref childrenPassSet, settings);
                }
                else
                {
                    // FIXME: Save/restore layers?
                    OnRasterizeChildren(ref contentContext, ref passSet, settings);
                }
            }

            if (hasNestedContext)
            {
                // GROSS OPTIMIZATION HACK: Detect that any rendering operation(s) occurred inside the
                //  group and if so, set up the stencil mask so that they will be clipped.
                if (ShouldClipContent && !contentRenderer.Container.IsEmpty)
                {
                    NestedContextPassTeardown(
                        ref context, ref settings, decorations, ref passSet,
                        ref contentRenderer, ref contentContext, previousStackDepth
                        );
                }

                renderer.Layer += 1;
            }
        }
Пример #11
0
 protected virtual void OnPreRasterize(ref UIOperationContext context, DecorationSettings settings, IDecorator decorations)
 {
     UpdateAnimation(context.NowL);
 }
Пример #12
0
 protected virtual bool IsPassDisabled(RasterizePasses pass, IDecorator decorations)
 {
     // Best not to default this optimization on
     // return decorations.IsPassDisabled(pass);
     return(false);
 }
 public void AddDecorator(IDecorator decorator)
 {
     Decorators.Add(decorator);
 }
Пример #14
0
 private static void ShowCoffee(IDecorator coffee)
 {
     Console.WriteLine("Type : "+coffee.GetType().Name);
     Console.Write("Coffee Ingredients : " + coffee.CoffeeType());
     Console.WriteLine(String.Format("\nPrice in Rupees : {0}", coffee.getPrice().ToString()));
 }
Пример #15
0
 public static string GetMethodName(this IDecorator decorator)
 {
     return(decorator.Expression.Cast <ICallExpression>().Expression.Cast <IIdentifier>().Text);
 }
Пример #16
0
 public ChoclateCoffee(IDecorator iCoffee)
 {
     this.iCoffee = iCoffee;
     price = 1;
 }
Пример #17
0
 public ShieldDecorator(IDecorator decorator) : base(decorator)
 {
     _def = def;
 }
Пример #18
0
 public void Add(IDecorator combatAction)
 {
     actions.Enqueue(combatAction);
 }
Пример #19
0
 public DefaultDecorator(IDecorator decorator)
 {
     this.decorator = decorator;
 }
Пример #20
0
 public AbilityDecorator(IDecorator action)
 {
     this.action = action;
 }
Пример #21
0
 public B(IDecorator decorator)
 {
     this.decorator = decorator;
 }
Пример #22
0
 public static void Decoration <T>(IDecorator <T> a, Action <T> b)
 {
     a.Decorate(b);
 }
Пример #23
0
 public CountryDecorator(IDecorator decorator)
 {
     this._decorator = decorator;
 }
Пример #24
0
 /// <summary>
 /// Add decorators to be passed to serializing pattern converter
 /// </summary>
 /// <param name="value">one decorator</param>
 /// <remarks>
 /// This method will be most useful for XML configuration.
 /// </remarks>
 public virtual void AddDecorator(IDecorator value)
 {
     m_decorators.Add(value);
 }
 public AddOrnament(Figuren F, string T, IDecorator D)
 {
     text      = T;
     Fig       = F;
     decorator = D;
 }
Пример #26
0
 public MockDebugger(PathTable pathTable, LoggingContext loggingContext)
 {
     State     = new DebuggerState(pathTable, loggingContext, DScriptDebugerRenderer.Render, new DScriptExprEvaluator(loggingContext));
     Session   = new DebugSession(State, null, this);
     Decorator = new EvaluationDecorator(this, State, false);
 }
Пример #27
0
 public status ViaDecorator(IDecorator scope, V reason = null)
 => log?Lg.ViaScope(this, scope, reason) : this;
Пример #28
0
 private void R2D2_Click(object sender, RoutedEventArgs e)
 {
     droidButton = new ButtonR2D2(droidButton);
     Reinitialized();
 }
Пример #29
0
 public Load(List <Figuren> AF, Canvas C, IDecorator D)
 {
     AllFiguren = AF;
     MyCanvas   = C;
     decorator  = D;
 }
Пример #30
0
 public ArmorDecorator(IDecorator decorator) : base(decorator)
 {
     _def = def;
 }
Пример #31
0
        private Figuren LoadFig(string[] result)
        {
            int[]           position = new int[4];
            Regex           regex    = new Regex("");
            MatchCollection matches;
            int             groupsize       = 0;
            List <string[]> ornamentsloaded = new List <string[]>();
            List <Figuren>  templist        = new List <Figuren>();

            while (readline < result.Count())
            {
                regex   = new Regex("Groep:(\\d*)");
                matches = regex.Matches(result[readline]);
                foreach (Match M in matches)
                {
                    groupsize = Convert.ToInt16(M.Groups[1].ToString());
                    readline++;
                }
                while (result[readline].Contains("ornament"))
                {
                    regex   = new Regex("ornament\\s(\\w*)\\s(.*)");
                    matches = regex.Matches(result[readline]);
                    foreach (Match M in matches)
                    {
                        string   loc      = M.Groups[1].ToString();
                        string   or       = M.Groups[2].ToString();
                        string[] ornament = { loc, or };
                        ornamentsloaded.Add(ornament);
                        readline++;
                    }
                }
                regex = new Regex("(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)");

                if (result.Count() > readline + 1 && regex.IsMatch(result[readline + 1]))
                {
                    matches     = regex.Matches(result[readline + 1]);
                    position[0] = Convert.ToInt16(matches[0].Groups[1].Value);
                    position[1] = Convert.ToInt16(matches[0].Groups[2].Value);
                    position[2] = Convert.ToInt16(matches[0].Groups[3].Value);
                    position[3] = Convert.ToInt16(matches[0].Groups[4].Value);
                }

                switch (result[readline])
                {
                case "Rechthoek":

                    Rectangle newRectangle = new Rectangle()
                    {
                        Stroke          = Brushes.Green,
                        Fill            = Brushes.Red,
                        StrokeThickness = 4,
                        Width           = position[2] - position[0],
                        Height          = position[3] - position[1],
                    };
                    //MyCanvas.Children.Add(newRectangle);
                    Figuren RectangleFiguren = new Figuren(newRectangle, "Rechthoek", MyCanvas);
                    RectangleFiguren.SetPosition(position[0], position[1], position[2], position[3]);
                    templist = new List <Figuren>
                    {
                        RectangleFiguren
                    };
                    foreach (string[] str in ornamentsloaded)
                    {
                        switch (str[0])
                        {
                        case "Top":
                            decorator = new TopOrnamentDecorator();
                            break;

                        case "Bot":
                            decorator = new BotOrnamentDecorator();
                            break;

                        case "Left":
                            decorator = new LeftOrnamentDecorator();
                            break;

                        case "Right":
                            decorator = new RightOrnamentDecorator();
                            break;

                        default:
                            break;
                        }
                        commandinvoker.AddOrnament(ref templist, str[1], decorator);
                    }
                    commandinvoker.ExecuteCommands();

                    for (int c = 0; c < groupsize; c++)
                    {
                        readline += 2;
                        Figuren child          = LoadFig(result);
                        int     childgroupsize = 0;
                        if (child != null)
                        {
                            RectangleFiguren.Add(child);
                            childgroupsize = child.GetGroupSize();
                        }
                    }
                    AllFiguren.Add(RectangleFiguren);
                    return(RectangleFiguren);

                case "Ellipse":

                    Ellipse NewElipse = new Ellipse()
                    {
                        Stroke          = Brushes.Green,
                        Fill            = Brushes.Red,
                        StrokeThickness = 4,
                        Width           = position[2] - position[0],
                        Height          = position[3] - position[1],
                    };
                    //MyCanvas.Children.Add(NewElipse);
                    Figuren ElipseFiguren = new Figuren(NewElipse, "Ellipse", MyCanvas);
                    ElipseFiguren.SetPosition(position[0], position[1], position[2], position[3]);
                    templist = new List <Figuren>
                    {
                        ElipseFiguren
                    };
                    foreach (string[] str in ornamentsloaded)
                    {
                        switch (str[0])
                        {
                        case "Top":
                            decorator = new TopOrnamentDecorator();
                            break;

                        case "Bot":
                            decorator = new BotOrnamentDecorator();
                            break;

                        case "Left":
                            decorator = new LeftOrnamentDecorator();
                            break;

                        case "Right":
                            decorator = new RightOrnamentDecorator();
                            break;

                        default:
                            break;
                        }
                        commandinvoker.AddOrnament(ref templist, str[1], decorator);
                    }
                    commandinvoker.ExecuteCommands();

                    for (int c = 0; c < groupsize; c++)
                    {
                        readline += 2;
                        Figuren child          = LoadFig(result);
                        int     childgroupsize = 0;
                        if (child != null)
                        {
                            ElipseFiguren.Add(child);
                            childgroupsize = child.GetGroupSize();
                        }
                    }
                    AllFiguren.Add(ElipseFiguren);
                    return(ElipseFiguren);

                default:
                    readline++;
                    break;
                }
            }
            return(null);
        }
Пример #32
0
 public Coffee(IDecorator iCoffee)
 {
     this.iCoffee = iCoffee;
     price = 1.50;
 }
Пример #33
0
        private static IFrontEndController TryCreateFrontEndController(
            FrontEndFactory frontEndFactory,
            IDecorator <EvaluationResult> decorator,
            ICommandLineConfiguration configuration,
            SymbolTable symbolTable,
            LoggingContext loggingContext,
            PerformanceCollector collector,
            bool collectMemoryAsSoonAsPossible,
            IFrontEndStatistics statistics)
        {
            Contract.Requires(frontEndFactory != null && !frontEndFactory.IsSealed);

            var workspaceResolverFactory = new DScriptWorkspaceResolverFactory();

            // Statistic should be global for all front-ends, not per an instance.
            var frontEndStatistics = statistics ?? new FrontEndStatistics();

            var sharedModuleRegistry = new ModuleRegistry(symbolTable);

            // Note, that the following code is absolutely critical for detecting that front-end related objects
            // are freed successfully after evaluation.
            // ModuleRegistry was picked intentionally because it holds vast amount of front-end data.
            FrontEndControllerMemoryObserver.CaptureFrontEndReference(sharedModuleRegistry);

            frontEndFactory.SetConfigurationProcessor(
                new ConfigurationProcessor(
                    new FrontEndStatistics(), // Configuration processing is so lightweight that it won't affect overall perf statistics
                    logger: null));

            // TODO: Workspace resolvers and frontends are registered in separate factories. Consider
            // adding a main coordinator/registry
            RegisterKnownWorkspaceResolvers(
                symbolTable.StringTable,
                workspaceResolverFactory,
                frontEndStatistics);


            frontEndFactory.AddFrontEnd(new DScriptFrontEnd(
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new NugetFrontEnd(
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new DownloadFrontEnd());

#if !PLATFORM_OSX
            frontEndFactory.AddFrontEnd(new MsBuildFrontEnd());
            frontEndFactory.AddFrontEnd(new NinjaFrontEnd());
            frontEndFactory.AddFrontEnd(new CMakeFrontEnd());
#endif

            if (!frontEndFactory.TrySeal(loggingContext))
            {
                return(null);
            }

            return(new FrontEndHostController(
                       frontEndFactory,
                       workspaceResolverFactory,
                       evaluationScheduler: EvaluationScheduler.Default,
                       moduleRegistry: sharedModuleRegistry,
                       frontEndStatistics: frontEndStatistics,
                       logger: BuildXL.FrontEnd.Core.Tracing.Logger.CreateLogger(),
                       collector: collector,
                       collectMemoryAsSoonAsPossible: collectMemoryAsSoonAsPossible));
        }
Пример #34
0
 public CreamCoffee(IDecorator iCoffee)
 {
     this.iCoffee = iCoffee;
     price = 0.5;
 }
Пример #35
0
 public ProxyDecorator(IDecorator <TContext> decorator)
 {
     this._proxy = decorator;
 }