Exemplo n.º 1
0
        private void ExecuteForTaskItems(ITaskItem[] items, string targetOSVersion)
        {
            MergedDictionary mergedDictionary = MergedDictionary.CreateMergedDicionary();
            List <string>    files            = new List <string>();

            if (nextBaseFile != null)
            {
                files.Add(nextBaseFile);
            }
            if (items != null)
            {
                foreach (ITaskItem item in items)
                {
                    if (!string.IsNullOrEmpty(PagesFilteredBy) && !item.GetMetadata(PagesFilteredBy).Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        this.LogMessage(MessageImportance.Low, "Filtered item " + item.ItemSpec);
                        continue;
                    }

                    string file = item.ItemSpec;
                    if (File.Exists(file))
                    {
                        files.Add(file);
                    }
                    else
                    {
                        this.LogError("Can't find page file " + file);
                    }
                }
            }

            int apiVersion = StripNamespaces.universalApiContractVersionMapping[targetOSVersion];

            MergeAndGenerateXaml(mergedDictionary, files, targetOSVersion.ToLower(), apiVersion);
        }
        private void ExecuteForTaskItems(ITaskItem[] items, string targetOSVersion)
        {
            MergedDictionary mergedDictionary = MergedDictionary.CreateMergedDicionary();
            List <string>    files            = new List <string>();

            if (nextBaseFile != null)
            {
                files.Add(nextBaseFile);
            }
            if (items != null)
            {
                foreach (ITaskItem item in items)
                {
                    string file = item.ItemSpec;
                    if (File.Exists(file))
                    {
                        files.Add(file);
                    }
                    else
                    {
                        Log.LogError("Can't find page file " + file);
                    }
                }
            }

            int apiVersion = StripNamespaces.universalApiContractVersionMapping[targetOSVersion];

            MergeAndGenerateXaml(mergedDictionary, files, targetOSVersion.ToLower(), apiVersion);
        }
        public override bool Execute()
        {
            if (string.IsNullOrEmpty(ForOSVersion) || !StripNamespaces.universalApiContractVersionMapping.ContainsKey(ForOSVersion))
            {
                Log.LogError("Unknown OS version, and valid version is ", string.Join(",", StripNamespaces.universalApiContractVersionMapping.Keys));
            }

            MergedDictionary mergedDictionary = MergedDictionary.CreateMergedDicionary();

            foreach (ITaskItem item in Sources)
            {
                string file = item.ItemSpec;
                if (File.Exists(file))
                {
                    mergedDictionary.MergeContent(File.ReadAllText(file));
                }
                else
                {
                    Log.LogError("Error to look for file " + item.ItemSpec);
                }
            }

            int    apiVersion = StripNamespaces.universalApiContractVersionMapping[ForOSVersion];
            string content    = mergedDictionary.ToString();

            string prefixedName    = XamlFileGenerated.Substring(0, XamlFileGenerated.Length - 5) + ".prefixed.xaml";
            string strippedContent = StripNamespaces.StripNamespaceForAPIVersion(content, apiVersion);

            string[] filesWritten = new string[2];
            filesWritten[0] = Utils.RewriteFileIfNecessary(prefixedName, content);
            filesWritten[1] = Utils.RewriteFileIfNecessary(XamlFileGenerated, strippedContent);

            FilesWritten = filesWritten;

            return(!Log.HasLoggedErrors);
        }