예제 #1
0
        public void CanBuildWithOverridableActions()
        {
            var folder = TestData.Get(@"TestData\OverridableActions");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(baseFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));
                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\MsiPackage\test.txt")));

                var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir"));
                var section      = intermediate.Sections.Single();

                var actions = section.Tuples.OfType <WixActionTuple>().Where(wat => wat.Action.StartsWith("Set")).ToList();
                Assert.Equal(2, actions.Count);
                //Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
                //Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
            }
        }
        public void CanSetBootstrapperApplicationDllDpiAwareness()
        {
            var folder = TestData.Get(@"TestData\BootstrapperApplication");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var wixlibPath         = Path.Combine(intermediateFolder, @"test.wixlib");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "DpiAwareness.wxs"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", wixlibPath,
                });

                result.AssertSuccess();

                var intermediate = Intermediate.Load(wixlibPath);
                var allSymbols   = intermediate.Sections.SelectMany(s => s.Symbols);
                var baDllSymbol  = allSymbols.OfType <WixBootstrapperApplicationDllSymbol>()
                                   .SingleOrDefault();
                Assert.NotNull(baDllSymbol);

                Assert.Equal(WixBootstrapperApplicationDpiAwarenessType.GdiScaled, baDllSymbol.DpiAwareness);
            }
        }
예제 #3
0
        public void CanBuildManualUpgrade()
        {
            var folder = TestData.Get(@"TestData\ManualUpgrade");

            using (var fs = new DisposableFileSystem())
            {
                var intermediateFolder = fs.GetFolder();

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(intermediateFolder, @"bin\test.msi")
                }, out var messages);

                Assert.Equal(0, result);

                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi")));
                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\test.txt")));

                var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wir"));
                var section      = intermediate.Sections.Single();

                var wixFile = section.Tuples.OfType <WixFileTuple>().Single();
                Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
                Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
            }
        }
예제 #4
0
        public double[] ReadScaled(uint AIChannelNumber, Int64 AIStartBurst, Int64 AINumberOfBursts, bool AIHalveAmplitude)
        {
            if (AIChannelNumber >= ChannelCount)
            {
                return(null);
            }
            Array Intermediate;

            if (Is16Bit)
            {
                Intermediate = new Int16[AINumberOfBursts, ChannelCount];
            }
            else
            {
                Intermediate = new int[AINumberOfBursts, ChannelCount];
            }
            ReadRaw(AIStartBurst, AINumberOfBursts, ref Intermediate);
            List <double> retVal = new List <double>();

            for (int iKanal = 0; iKanal < ChannelCount; iKanal++)
            {
                for (int iWert = 0; iWert < AINumberOfBursts; iWert++)
                {
                    object o     = Intermediate.GetValue(iWert, iKanal);
                    double val   = Convert.ToDouble(o);
                    double slope = Slope[iKanal];
                    if (AIHalveAmplitude)
                    {
                        slope /= 2.0;
                    }
                    retVal.Add(val * slope + YOffset[iKanal]);
                }
            }
            return(retVal.ToArray());
        }
        public void ProtectedLinksAcrossFragmentsButNotFiles()
        {
            XDocument doc1 = XDocument.Parse("<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'><Product Id='*' Language='1033' Manufacturer='WixTests' Name='ProtectedLinksAcrossFragments' Version='1.0.0' UpgradeCode='12345678-1234-1234-1234-1234567890AB'><DirectoryRef Id='ProtectedDirectory'/></Product>" +
                                             "<Fragment><Directory Id='TARGETDIR' Name='SourceDir'><Directory Id='protected ProtectedDirectory' Name='protected'/></Directory></Fragment></Wix>");
            XDocument      doc2     = XDocument.Parse("<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'><Fragment><DirectoryRef Id='TARGETDIR'><Directory Id='protected ProtectedDirectory' Name='conflict'/></DirectoryRef></Fragment></Wix>");
            XDocument      src1     = new Preprocessor().Process(doc1.CreateReader(), new Dictionary <string, string>());
            XDocument      src2     = new Preprocessor().Process(doc2.CreateReader(), new Dictionary <string, string>());
            Compiler       compiler = new Compiler();
            Linker         linker   = new Linker();
            List <Section> sections = new List <Section>();

            Intermediate intermediate = compiler.Compile(src1);

            sections.AddRange(intermediate.Sections);

            intermediate = compiler.Compile(src2);
            sections.AddRange(intermediate.Sections);

            Output output = linker.Link(sections, OutputType.Product);

            var directoryRows = output.Sections.SelectMany(sec => sec.Tables).Where(t => t.Name.Equals("Directory")).SelectMany(t => t.Rows).OrderBy(r => r[0]).ToArray();

            Assert.Equal(2, directoryRows.Length);

            Assert.Equal("ProtectedDirectory", directoryRows[0][0]);
            Assert.Equal(AccessModifier.Protected, directoryRows[0].Access);

            Assert.Equal("TARGETDIR", directoryRows[1][0]);
            Assert.Equal(AccessModifier.Public, directoryRows[1].Access);
        }
예제 #6
0
        public void CanCanonicalizeName()
        {
            var folder = TestData.Get(@"TestData\Payload");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var wixlibPath         = Path.Combine(intermediateFolder, @"test.wixlib");

                var result = WixRunner.Execute(warningsAsErrors: false, new[]
                {
                    "build",
                    Path.Combine(folder, "CanonicalizeName.wxs"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", wixlibPath,
                });

                result.AssertSuccess();

                Assert.Single(result.Messages, m => m.Id == (int)WarningMessages.Ids.PathCanonicalized);

                var intermediate  = Intermediate.Load(wixlibPath);
                var allSymbols    = intermediate.Sections.SelectMany(s => s.Symbols);
                var payloadSymbol = allSymbols.OfType <WixBundlePayloadSymbol>()
                                    .SingleOrDefault();
                Assert.NotNull(payloadSymbol);

                var fields = payloadSymbol.Fields.Select(field => field?.Type == IntermediateFieldType.Bool
                                                        ? field.AsNullableNumber()?.ToString()
                                                        : field?.AsString())
                             .ToList();
                Assert.Equal(@"c\d.exe", fields[(int)WixBundlePayloadSymbolFields.Name]);
            }
        }
예제 #7
0
 public static Intermediate.Operand DereferenceLabel(Intermediate.Label l)
 {
     return new Intermediate.Operand{
         label = l,
         semantics = Intermediate.OperandSemantics.Dereference | Intermediate.OperandSemantics.Label
     };
 }
예제 #8
0
        /// <summary>
        /// Join
        /// </summary>
        /// <param name="project"></param>
        /// <param name="testrun"></param>
        /// <param name="category"></param>
        /// <param name="entity"></param>
        /// <param name="valueIndex"></param>
        /// <param name="historyCount"></param>
        /// <param name="workload"></param>
        public void JoinIntermediateValues(string project, string testrun, string category, string entity, int valueIndex, int historyCount, string workload)
        {
            Log.WriteLine(string.Format("join intermediate values entity={0}...", entity));
            JoinController joinController = new JoinController();

            this.intermediate = joinController.JoinIntermediateValues(project, testrun, category, entity, valueIndex, historyCount, workload);
        }
        public void CanBuildCopyFile()
        {
            var folder = TestData.Get(@"TestData");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var msiPath            = Path.Combine(baseFolder, @"bin\test.msi");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "CopyFile", "CopyFile.wxs"),
                    Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
                    Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
                    "-bindpath", Path.Combine(folder, "SingleFile", "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", msiPath
                });

                result.AssertSuccess();

                var intermediate   = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
                var section        = intermediate.Sections.Single();
                var copyFileSymbol = section.Symbols.OfType <MoveFileSymbol>().Single();
                Assert.Equal("MoveText", copyFileSymbol.Id.Id);
                Assert.True(copyFileSymbol.Delete);
                Assert.Equal("OtherFolder", copyFileSymbol.DestFolder);
            }
        }
예제 #10
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "Component":
                var componentId    = context["ComponentId"];
                var directoryId    = context["DirectoryId"];
                var componentWin64 = Boolean.Parse(context["Win64"]);

                switch (element.Name.LocalName)
                {
                case "Driver":
                    this.ParseDriverElement(intermediate, section, element, componentId, componentWin64);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
예제 #11
0
        public void CanBuildEnuWxl()
        {
            var folder = TestData.Get(@"TestData", "Language");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder = fs.GetFolder();

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", Path.Combine(baseFolder, "obj"),
                    "-o", Path.Combine(baseFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
                var section      = intermediate.Sections.Single();

                var propertySymbol = section.Symbols.OfType <PropertySymbol>().Single(p => p.Id.Id == "ProductLanguage");
                Assert.Equal("1033", propertySymbol.Value);

                var summaryPlatform = section.Symbols.OfType <SummaryInformationSymbol>().Single(s => s.PropertyId == SummaryInformationType.PlatformAndLanguage);
                Assert.Equal("Intel;1033", summaryPlatform.Value);

                var summaryCodepage = section.Symbols.OfType <SummaryInformationSymbol>().Single(s => s.PropertyId == SummaryInformationType.Codepage);
                Assert.Equal("1252", summaryCodepage.Value);
            }
        }
예제 #12
0
        public void CanParseCommandLineWithExtension()
        {
            var folder        = TestData.Get(@"TestData\ExampleExtension");
            var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);

            using (var fs = new DisposableFileSystem())
            {
                var intermediateFolder = fs.GetFolder();

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-ext", extensionPath,
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-example", "test",
                    "-o", Path.Combine(intermediateFolder, @"bin\extest.msi")
                }, out var messages);

                Assert.Equal(0, result);

                var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wir"));
                var section      = intermediate.Sections.Single();

                var property = section.Tuples.OfType <PropertyTuple>().Where(p => p.Id.Id == "ExampleProperty").Single();
                Assert.Equal("ExampleProperty", property.Property);
                Assert.Equal("test", property.Value);
            }
        }
예제 #13
0
        private void Button_ClickMediu(object sender, RoutedEventArgs e)
        {
            Intermediate window2 = new Intermediate();

            window2.Show();
            this.Hide();
        }
예제 #14
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "File":
                var fileId      = context["FileId"];
                var componentId = context["ComponentId"];

                switch (element.Name.LocalName)
                {
                case "FormatsFile":
                    this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId);
                    break;

                case "SnapIn":
                    this.ParseSnapInElement(intermediate, section, element, fileId, componentId);
                    break;

                case "TypesFile":
                    this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, componentId);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
예제 #15
0
        private Intermediate LibraryPhase(IEnumerable <Intermediate> intermediates, IEnumerable <Localization> localizations, bool bindFiles, IEnumerable <IBindPath> bindPaths, CancellationToken cancellationToken)
        {
            var context = this.ServiceProvider.GetService <ILibraryContext>();

            context.BindFiles         = bindFiles;
            context.BindPaths         = bindPaths;
            context.Extensions        = this.ExtensionManager.GetServices <ILibrarianExtension>();
            context.Localizations     = localizations;
            context.Intermediates     = intermediates;
            context.CancellationToken = cancellationToken;

            Intermediate library = null;

            try
            {
                var librarian = this.ServiceProvider.GetService <ILibrarian>();
                library = librarian.Combine(context);
            }
            catch (WixException e)
            {
                this.Messaging.Write(e.Error);
            }

            return(library);
        }
예제 #16
0
파일: MsiFixture.cs 프로젝트: sgtatham/Core
        public void CanBuild64bit()
        {
            var folder = TestData.Get(@"TestData\SingleFile");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-arch", "x64",
                    "-o", Path.Combine(baseFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
                var section      = intermediate.Sections.Single();

                var platformSummary = section.Symbols.OfType <SummaryInformationSymbol>().Single(s => s.PropertyId == SummaryInformationType.PlatformAndLanguage);
                Assert.Equal("x64;1033", platformSummary.Value);
            }
        }
예제 #17
0
파일: MsiFixture.cs 프로젝트: sgtatham/Core
        public void CanBuildSharedComponent()
        {
            var folder = TestData.Get(@"TestData\SingleFile");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-arch", "x64",
                    "-o", Path.Combine(baseFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
                var section      = intermediate.Sections.Single();

                // Only one component is shared.
                var sharedComponentSymbols = section.Symbols.OfType <ComponentSymbol>();
                Assert.Equal(1, sharedComponentSymbols.Sum(t => t.Shared ? 1 : 0));

                // And it is this one.
                var sharedComponentSymbol = sharedComponentSymbols.Single(t => t.Id.Id == "Shared.dll");
                Assert.True(sharedComponentSymbol.Shared);
            }
        }
예제 #18
0
        /// <summary>
        /// Parses a Condition element for Bundles.
        /// </summary>
        /// <param name="node">The element to parse.</param>
        private void ParseMbaPrereqInfoElement(Intermediate intermediate, IntermediateSection section, XElement node)
        {
            var    sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
            string packageId         = null;
            string licenseFile       = null;
            string licenseUrl        = null;

            foreach (var attrib in node.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "LicenseFile":
                        licenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "LicenseUrl":
                        licenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "PackageId":
                        packageId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(node, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
                }
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);

            if (null == packageId)
            {
                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "PackageId"));
            }

            if (null == licenseFile && null == licenseUrl ||
                null != licenseFile && null != licenseUrl)
            {
                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true));
            }

            if (!this.Messaging.EncounteredError)
            {
                section.AddSymbol(new WixMbaPrereqInformationSymbol(sourceLineNumbers)
                {
                    PackageId   = packageId,
                    LicenseFile = licenseFile,
                    LicenseUrl  = licenseUrl,
                });
                this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBundlePackage, packageId);
            }
        }
예제 #19
0
파일: MsiFixture.cs 프로젝트: sgtatham/Core
        public void CanBuildSingleFileCompressed()
        {
            var folder = TestData.Get(@"TestData\SingleFileCompressed");

            using (var fs = new DisposableFileSystem())
            {
                var intermediateFolder = fs.GetFolder();

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(intermediateFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi")));
                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\example.cab")));
                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));

                var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
                var section      = intermediate.Sections.Single();

                var fileSymbol = section.Symbols.OfType <FileSymbol>().Single();
                Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
                Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
            }
        }
예제 #20
0
        public override Vector4 Main(Intermediate d)
        {
            var data = (SampleInterData)d;

            lightPos    = Light.main.transform.position;
            lightColor  = Light.main.color.to_vector4().V3();
            viewPos     = Camera.main.transform.position;
            objectColor = new Vector3(0, 1, 1);

            objectColor = image.Value(data.UV.X, data.UV.Y, Vector3.One).to_vector4().V3();


            float ambientStrength = 0.1f;
            var   ambient         = ambientStrength * lightColor;

            // diffuse
            //var norm =new Vector3(0,1,0);
            var norm     = Vector3.Normalize(data.Normal);
            var lightDir = Vector3.Normalize(lightPos - data.FragPos); //Console.WriteLine(norm);
            var diff     = MathF.Max(Vector3.Dot(norm, lightDir), 0.0f);
            var diffuse  = diff * lightColor;

            // specular
            float specularStrength = 0.1f;
            var   viewDir          = Vector3.Normalize(viewPos - data.FragPos);
            var   reflectDir       = Vector3.Reflect(-lightDir, norm);
            float spec             = MathF.Pow(MathF.Max(Vector3.Dot(viewDir, reflectDir), 0f), 32);
            var   specular         = specularStrength * spec * lightColor;

            var result = (ambient + diffuse + specular) * objectColor;

            return(result.V4());
        }
예제 #21
0
        public void MustCompileBeforeLinking()
        {
            var intermediate1   = new Intermediate("TestIntermediate1", new[] { new IntermediateSection("test1", SectionType.Product, 65001) }, null);
            var intermediate2   = new Intermediate("TestIntermediate2", new[] { new IntermediateSection("test2", SectionType.Fragment, 65001) }, null);
            var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();

            var listener  = new TestMessageListener();
            var messaging = serviceProvider.GetService <IMessaging>();

            messaging.SetListener(listener);

            var creator = serviceProvider.GetService <ISymbolDefinitionCreator>();
            var context = serviceProvider.GetService <ILinkContext>();

            context.Extensions              = Enumerable.Empty <WixToolset.Extensibility.ILinkerExtension>();
            context.ExtensionData           = Enumerable.Empty <WixToolset.Extensibility.IExtensionData>();
            context.Intermediates           = new[] { intermediate1, intermediate2 };
            context.SymbolDefinitionCreator = creator;

            var linker = serviceProvider.GetService <ILinker>();

            linker.Link(context);

            Assert.Equal((int)ErrorMessages.Ids.IntermediatesMustBeCompiled, messaging.LastErrorNumber);
            Assert.Single(listener.Messages);
            Assert.EndsWith("TestIntermediate1, TestIntermediate2", listener.Messages[0].ToString());
        }
예제 #22
0
        /// <summary>
        /// Generate new threshold colorcode values for all intermediate rows
        /// </summary>
        /// <param name="greenColorcode"></param>
        /// <param name="yellowColorcode"></param>
        /// <param name="redColorcode"></param>
        public void GenerateThresholdValues(string greenColorcode, string yellowColorcode, string redColorcode, bool storeMetrics = false)
        {
            Log.WriteLine("generate threshold values...");
            // load threshold config from database
            Thresholds thresholds = new Thresholds(project);

            // generate color values
            Intermediate thValues = thresholds.GenerateThresholdValuesForTransactions(intermediate, greenColorcode, yellowColorcode, redColorcode);

            // merge threshold colortransactions with dataset
            Log.WriteLine(string.Format("adding {0} threshold entries...", thValues.Count));
            intermediate.Add(thValues);

            // count threshold violations (add in separate series) by transactionname patter + red color
            Log.WriteLine("aggregate threshold violations...");
            Intermediate thresholdViolations = thValues.AggregateCount(THRESHOLDVIOLATIONSKEY, @"\d\d_.*_c$", redColorcode); // only evaluate script transactions!

            // store these newly generated metrics back to the database
            if (storeMetrics)
            {
                thresholdViolations.SaveToDatabase(this.project, this.testrun, Category.Transaction, Entity.None);
            }

            Log.WriteLine("adding threshold violations: " + thresholdViolations.GetValue(THRESHOLDVIOLATIONSKEY));
            this.intermediate.Add(thresholdViolations);
        }
        private void ParseExampleSearchRefElement(Intermediate intermediate, IntermediateSection section, XElement element)
        {
            var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);

            foreach (var attrib in element.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "Id":
                        var refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, ExampleSymbolDefinitions.ExampleSearch, refId);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(element, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
                }
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
        }
예제 #24
0
        /// <summary>
        /// @Pre: A row of enemies is needed for the next level
        /// @Post: A level of enemies (basic, intermediate, or advanced) is added to the enemy list
        /// @Return: None.
        /// </summary>
        /// <param name="enemyType">Type of the enemy.</param>
        private void AddRowOfEnemy(Enemy.Type enemyType)
        {
            Enemy prevEnemy = Enemies.Count > 0 ? Enemies[Enemies.Count - 1][0] : null;
            float newPosY   = prevEnemy == null ? spacing.Y : prevEnemy.Position.Y + prevEnemy.Texture.Height + spacing.Y;

            Enemies.Add(new List <Enemy>());
            for (int x = 1; x <= ENEMIES_PER_ROW; x++)
            {
                Enemy enemy = null;

                switch (enemyType)
                {
                case Enemy.Type.Basic:
                    enemy = new Basic(new Vector2(((Game1.textureDictionary["basic"].Width + spacing.X) * x) - spacing.X + (Game1.textureDictionary["basic"].Width * (Enemies.Count % 2)), newPosY));
                    break;

                case Enemy.Type.Intermediate:
                    enemy = new Intermediate(new Vector2(((Game1.textureDictionary["intermediate"].Width + spacing.X) * x) - spacing.X + (Game1.textureDictionary["intermediate"].Width * (Enemies.Count % 2)), newPosY));
                    break;

                case Enemy.Type.Advanced:
                    enemy = new Advanced(new Vector2(((Game1.textureDictionary["advanced"].Width + spacing.X) * x) - spacing.X + (Game1.textureDictionary["advanced"].Width * (Enemies.Count % 2)), newPosY));
                    break;
                }

                Enemies[Enemies.Count - 1].Add(enemy);
            }
        }
        public void CreateProtectedDirectoryFromInlineSyntax()
        {
            XDocument doc = XDocument.Parse("<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'><Product Id='*' Language='1033' Manufacturer='WixTests' Name='CreateProtectedDirectoryFromInlineSyntax' Version='1.0.0' UpgradeCode='12345678-1234-1234-1234-1234567890AB'><DirectoryRef Id='BinFolder'/></Product>" +
                                            @"<Fragment><Directory Id='protected BinFolder' Name='TARGETDIR:\foo\bar\bin\' /></Fragment>" +
                                            "<Fragment><Directory Id='TARGETDIR' Name='SourceDir' /></Fragment></Wix>");
            XDocument src      = new Preprocessor().Process(doc.CreateReader(), new Dictionary <string, string>());
            Compiler  compiler = new Compiler();
            Linker    linker   = new Linker();

            Intermediate intermediate = compiler.Compile(src);
            Output       output       = linker.Link(intermediate.Sections, OutputType.Product);

            RowIndexedList <Row> directoryRows = new RowIndexedList <Row>(output.Sections.SelectMany(sec => sec.Tables).Where(t => t.Name.Equals("Directory")).SelectMany(d => d.Rows));

            Assert.Equal(4, directoryRows.Count);

            Row binFolder = directoryRows.Get("BinFolder");
            Row barFolder = directoryRows.Get((string)binFolder[1]);
            Row fooFolder = directoryRows.Get((string)barFolder[1]);
            Row targetDir = directoryRows.Get((string)fooFolder[1]);

            Assert.Equal(AccessModifier.Protected, binFolder.Access);
            Assert.Equal(AccessModifier.Private, barFolder.Access);
            Assert.Equal(AccessModifier.Private, fooFolder.Access);
            Assert.Equal(AccessModifier.Public, targetDir.Access);

            Assert.Equal("bin", binFolder[2]);
            Assert.Equal("bar", barFolder[2]);
            Assert.Equal("foo", fooFolder[2]);
            Assert.Equal("SourceDir", targetDir[2]);
        }
        public void ExplicitAccessModifiersValid()
        {
            XDocument doc = XDocument.Parse("<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'><Fragment><ComponentGroup Id='public PublicGroup' Directory='PrivateDirectory'>" +
                                            "<Component Id='internal InternalComponent'>" +
                                            "<File Id='protected ProtectedFile' Source='ignored'/></Component></ComponentGroup>" +
                                            "<DirectoryRef Id='TARGETDIR'><Directory Id='private PrivateDirectory'/></DirectoryRef></Fragment></Wix>");
            XDocument src      = new Preprocessor().Process(doc.CreateReader(), new Dictionary <string, string>());
            Compiler  compiler = new Compiler();

            Intermediate intermediate      = compiler.Compile(src);
            var          tables            = intermediate.Sections.SelectMany(sec => sec.Tables).ToDictionary(t => t.Name);
            var          componentGroupRow = tables["WixComponentGroup"].Rows.Single();

            Assert.Equal("PublicGroup", componentGroupRow[0].ToString());
            Assert.Equal(AccessModifier.Public, componentGroupRow.Access);

            var componentRow = tables["Component"].Rows.Single();

            Assert.Equal("InternalComponent", componentRow[0].ToString());
            Assert.Equal(AccessModifier.Internal, componentRow.Access);

            var fileRow = tables["File"].Rows.Single();

            Assert.Equal("ProtectedFile", fileRow[0].ToString());
            Assert.Equal(AccessModifier.Protected, fileRow.Access);

            var directoryRow = tables["Directory"].Rows.Single();

            Assert.Equal("PrivateDirectory", directoryRow[0].ToString());
            Assert.Equal(AccessModifier.Private, directoryRow.Access);
        }
예제 #27
0
        private void Compile(Compiler compiler, string name, Wix wix)
        {
            // Load the wix document into an XML document.

            XmlDocument xmlDocument = new XmlDocument();

            using (MemoryStream writerStream = new MemoryStream())
            {
                using (XmlTextWriter xmlWriter = new XmlTextWriter(writerStream, Encoding.Unicode))
                {
                    wix.OutputXml(xmlWriter);
                }

                using (MemoryStream readerStream = new MemoryStream(writerStream.GetBuffer()))
                {
                    xmlDocument.Load(readerStream);
                }
            }

            // Compile it.

            Intermediate intermediate = compiler.Compile(xmlDocument);

            // Save the intermediate.

            string path = Path.Combine(m_buildFolder, name + File.Wixobj.Extension);

            intermediate.Save(path);
        }
예제 #28
0
        private Output Link(Localizer localizer, WixVariableResolver wixVariableResolver)
        {
            // Create a linker.

            Linker linker = new Linker();

            linker.Message            += HandleMessage;
            linker.Localizer           = localizer;
            linker.WixVariableResolver = wixVariableResolver;

            // Load each intermediate for each document.

            SectionCollection sections = new SectionCollection();

            foreach (KeyValuePair <string, Wix> pair in m_wixDocuments)
            {
                string       path         = Path.Combine(m_buildFolder, pair.Key + File.Wixobj.Extension);
                Intermediate intermediate = Intermediate.Load(path, linker.TableDefinitions, false, false);
                sections.AddRange(intermediate.Sections);
            }

            // Link.

            ArrayList transforms = new ArrayList();

            return(linker.Link(sections, transforms));
        }
예제 #29
0
        public void CanSaveAndLoadIntermediate()
        {
            var sln = new SourceLineNumber("test.wxs", 1);

            var section = new IntermediateSection("test", SectionType.Product, 65001);

            section.Tuples.Add(new ComponentTuple(sln, new Identifier("TestComponent", AccessModifier.Public))
            {
                ComponentId = new Guid(1, 0, 0, new byte[8]).ToString("B"),
                Directory_  = "TestFolder",
                Attributes  = 2,
            });

            var intermediate = new Intermediate("TestIntermediate", new[] { section }, null, null);

            var path = Path.GetTempFileName();

            intermediate.Save(path);

            var loaded = Intermediate.Load(path);

            var tuple = (ComponentTuple)loaded.Sections.Single().Tuples.Single();

            Assert.Equal("TestComponent", tuple.Id.Id);
            Assert.Equal(AccessModifier.Public, tuple.Id.Access);
            Assert.Equal("TestFolder", tuple.Directory_);
            Assert.Equal(2, tuple.Attributes);
        }
        public async Task <IActionResult> Edit(int id, [Bind("IntermediateId,LessonName")] Intermediate intermediate)
        {
            if (id != intermediate.IntermediateId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(intermediate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IntermediateExists(intermediate.IntermediateId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(intermediate));
        }
예제 #31
0
파일: Target.cs 프로젝트: Blecki/DCPUB
 public Intermediate.Operand GetOperand(TargetUsage usage,
     Intermediate.OperandSemantics semantics = Intermediate.OperandSemantics.None, 
     ushort offset = 0)
 {
     if (target == Targets.Stack)
     {
         switch (usage)
         {
             case TargetUsage.Peek: return CompilableNode.Operand("PEEK", semantics, offset);
             case TargetUsage.Push: return CompilableNode.Operand("PUSH", semantics, offset);
             case TargetUsage.Pop: return CompilableNode.Operand("POP", semantics, offset);
         }
     }
     else if (target == Targets.Discard)
         throw new InternalError("Unable to get operand from target with semantic 'discard'.");
     else if (target == Targets.Raw)
         return new Intermediate.Operand
         {
             register = (Intermediate.OperandRegister)virtualId,
             semantics = semantics,
             constant = offset
         };
     else
         return CompilableNode.Virtual(virtualId, semantics, offset);
     throw new InternalError("Unknown error while getting operand from target.");
 }
예제 #32
0
        private WixOutput CreateWixout(List <ITrackedFile> trackedFiles, Intermediate intermediate, string manifestPath, string baDataPath, string bextDataPath)
        {
            WixOutput wixout;

            if (String.IsNullOrEmpty(this.OutputPdbPath))
            {
                wixout = WixOutput.Create();
            }
            else
            {
                var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final);
                trackedFiles.Add(trackPdb);

                wixout = WixOutput.Create(trackPdb.Path);
            }

            intermediate.Save(wixout);

            wixout.ImportDataStream(BurnConstants.BurnManifestWixOutputStreamName, manifestPath);
            wixout.ImportDataStream(BurnConstants.BootstrapperApplicationDataWixOutputStreamName, baDataPath);
            wixout.ImportDataStream(BurnConstants.BundleExtensionDataWixOutputStreamName, bextDataPath);

            wixout.Reopen();

            return(wixout);
        }
예제 #33
0
 public static Intermediate.Operand Operand(String r,
     Intermediate.OperandSemantics semantics = Intermediate.OperandSemantics.None,
     ushort offset = 0)
 {
     Intermediate.OperandRegister opReg;
     if (!Enum.TryParse(r, out opReg))
         throw new InternalError("Unmappable operand register: " + r);
     return new Intermediate.Operand { register = opReg, semantics = semantics, constant = offset };
 }
예제 #34
0
        /*************************
         *  CONSTRUCTOR(S)
         *************************/
        /*
         * ManualAgent constructor sets a passed instance of an intermediate class as the source of everything the agent will
         * know of the maze/graph it is traversing and the destination for all of the agent's movement instructions.
         */
        public ManualAgent(Intermediate intermediate)
        {
            //System.Console.WriteLine("\nIn ManualAgent()");

            this._intermediate = intermediate;

            _graphBuilder = new GraphBuilder();

            //System.Console.WriteLine("Leaving ManualAgent()");
        }
예제 #35
0
        /*************************
         *  CONSTRUCTOR(S)
         *************************/
        /*
         * AutonomousAgent constructor sets a passed instance of an intermediate class as the source of everything the agent will
         * know of the maze/graph it is traversing and the destination for all of the agent's movement instructions.
         */
        public AutonomousAgent(Intermediate intermediate)
        {
            //System.Console.WriteLine("\nIn AutonomousAgent()");

            this._intermediate = intermediate;

            _graphBuilder = new GraphBuilder();

            _pathFromStartToCurrentPosition = new List<string>();

            //System.Console.WriteLine("Leaving AutonomousAgent()");
        }
예제 #36
0
        public static Intermediate.Operand Virtual(int id, 
            Intermediate.OperandSemantics semantics = Intermediate.OperandSemantics.None,
            ushort offset = 0)
        {
            if ((semantics & Intermediate.OperandSemantics.Offset) == Intermediate.OperandSemantics.Offset &&
                offset == 0)
                semantics &= ~Intermediate.OperandSemantics.Offset;

            return new Intermediate.Operand
            {
                register = Intermediate.OperandRegister.VIRTUAL,
                virtual_register = (ushort)id,
                semantics = semantics,
                constant = offset
            };
        }
예제 #37
0
        Intermediate.IRNode AssignableNode.EmitAssignment(CompileContext context, Model.Scope scope, Intermediate.Operand from, Intermediate.Instructions opcode)
        {
            var r = new TransientNode();

            if (member == null)
            {
                context.ReportError(this, "Member was not resolved");
                return r;
            }

            var target = Target.Register(context.AllocateRegister());
            r.AddChild(Child(0).Emit(context, scope, target));
            r.AddInstruction(opcode, target.GetOperand(TargetUsage.Peek,
                Intermediate.OperandSemantics.Dereference | Intermediate.OperandSemantics.Offset, (ushort)member.offset),
                from);
            return r;
        }
예제 #38
0
파일: Node.cs 프로젝트: Blecki/DCPUB
 public void AddLabel(Intermediate.Label label)
 {
     AddChild(new LabelNode { label = label });
 }
예제 #39
0
 public static Intermediate.Operand Label(Intermediate.Label value)
 {
     return new Intermediate.Operand { semantics = Intermediate.OperandSemantics.Label, label = value };
 }