コード例 #1
0
        /// <summary>
        /// Given the set of parameters that are set to the factory, and the set of parameters coming from the task invocation that we're searching for
        /// a matching record to, determine whether the parameters match this record.
        /// </summary>
        private static bool TaskIdentityParametersMatchFactory(IDictionary <string, string> factoryIdentityParameters, IDictionary <string, string> taskIdentityParameters)
        {
            if (taskIdentityParameters == null || taskIdentityParameters.Count == 0 || factoryIdentityParameters == null || factoryIdentityParameters.Count == 0)
            {
                // either the task or the using task doesn't care about anything, in which case we match by default.
                return(true);
            }

            string taskRuntime           = null;
            string taskArchitecture      = null;
            string usingTaskRuntime      = null;
            string usingTaskArchitecture = null;

            taskIdentityParameters.TryGetValue(XMakeAttributes.runtime, out taskRuntime);
            factoryIdentityParameters.TryGetValue(XMakeAttributes.runtime, out usingTaskRuntime);

            if (XMakeAttributes.RuntimeValuesMatch(taskRuntime, usingTaskRuntime))
            {
                taskIdentityParameters.TryGetValue(XMakeAttributes.architecture, out taskArchitecture);
                factoryIdentityParameters.TryGetValue(XMakeAttributes.architecture, out usingTaskArchitecture);

                if (XMakeAttributes.ArchitectureValuesMatch(taskArchitecture, usingTaskArchitecture))
                {
                    // both match
                    return(true);
                }
            }

            // one or more does not match, so we don't match.
            return(false);
        }
コード例 #2
0
        public void TestArchitectureValuesMatch()
        {
            string currentArchitecture    = EnvironmentUtilities.Is64BitProcess ? XMakeAttributes.MSBuildArchitectureValues.x64 : XMakeAttributes.MSBuildArchitectureValues.x86;
            string notCurrentArchitecture = EnvironmentUtilities.Is64BitProcess ? XMakeAttributes.MSBuildArchitectureValues.x86 : XMakeAttributes.MSBuildArchitectureValues.x64;

            Assert.True(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.any, XMakeAttributes.MSBuildArchitectureValues.currentArchitecture));
            Assert.True(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.any, XMakeAttributes.MSBuildArchitectureValues.x64));
            Assert.True(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.x86, XMakeAttributes.MSBuildArchitectureValues.any));
            Assert.True(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.currentArchitecture, currentArchitecture));

            Assert.False(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.currentArchitecture, notCurrentArchitecture));
            Assert.False(XMakeAttributes.ArchitectureValuesMatch(XMakeAttributes.MSBuildArchitectureValues.x64, XMakeAttributes.MSBuildArchitectureValues.x86));
        }