/// <summary>
        /// Execute the task with delegate handlers.
        /// </summary>
        /// <param name="createFileStream">CreateFileStream delegate</param>
        /// <returns>True if task succeeded.</returns>
        internal bool Execute
        (
            CreateFileStream createFileStream
        )
        {
            _manifestResourceNames = new TaskItem[ResourceFiles.Length];
            _resourceFilesWithManifestResourceNames = new TaskItem[ResourceFiles.Length];

            bool success = true;
            int  i       = 0;

            // If Rootnamespace was null, then it wasn't set from the project resourceFile.
            // Empty namespaces are allowed.
            if (RootNamespace != null)
            {
                Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.RootNamespace", _rootNamespace);
            }
            else
            {
                Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.NoRootNamespace");
            }


            foreach (ITaskItem resourceFile in ResourceFiles)
            {
                try
                {
                    string fileName      = resourceFile.ItemSpec;
                    string dependentUpon = (string)resourceFile.GetMetadata(ItemMetadataNames.dependentUpon);

                    // Pre-log some information.
                    bool isDependentOnSourceFile = (dependentUpon != null) && (dependentUpon.Length > 0) && IsSourceFile(dependentUpon);

                    if (isDependentOnSourceFile)
                    {
                        Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUpon", fileName, dependentUpon);
                    }
                    else
                    {
                        Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUponNothing", fileName);
                    }

                    // Create the manifest name.
                    Stream binaryStream = null;
                    string manifestName;

                    if (isDependentOnSourceFile)
                    {
                        string pathToDependent = Path.Combine(Path.GetDirectoryName(fileName), dependentUpon);
                        binaryStream = createFileStream(pathToDependent, FileMode.Open, FileAccess.Read);
                    }

                    // Put the task item into a dictionary so we can access it from a derrived class quickly.
                    itemSpecToTaskitem[resourceFile.ItemSpec] = resourceFile;

                    // This "using" statement ensures that the "binaryStream" will be disposed once
                    // we're done with it.
                    using (binaryStream)
                    {
                        manifestName = CreateManifestName
                                       (
                            fileName,
                            resourceFile.GetMetadata(ItemMetadataNames.targetPath),
                            RootNamespace,
                            isDependentOnSourceFile ? dependentUpon : null,
                            binaryStream
                                       );
                    }

                    // Emit an item with our manifest name.
                    _manifestResourceNames[i]          = new TaskItem(resourceFile);
                    _manifestResourceNames[i].ItemSpec = manifestName;

                    // Emit a new item preserving the itemSpec of the resourceFile, but with new metadata for manifest resource name
                    _resourceFilesWithManifestResourceNames[i] = new TaskItem(resourceFile);
                    _resourceFilesWithManifestResourceNames[i].SetMetadata("ManifestResourceName", manifestName);

                    // Add a LogicalName metadata to Non-Resx resources
                    // LogicalName isn't used for Resx resources because the ManifestResourceName metadata determines the filename of the
                    // .resources file which then is used as the embedded resource manifest name
                    if (String.IsNullOrEmpty(_resourceFilesWithManifestResourceNames[i].GetMetadata("LogicalName")) &&
                        String.Equals(_resourceFilesWithManifestResourceNames[i].GetMetadata("Type"), "Non-Resx", StringComparison.OrdinalIgnoreCase))
                    {
                        _resourceFilesWithManifestResourceNames[i].SetMetadata("LogicalName", manifestName);
                    }

                    // Post-logging
                    Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.AssignedName", fileName, manifestName);
                }
                catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception.
                {
                    if (ExceptionHandling.NotExpectedException(e))
                    {
                        throw;
                    }
                    Log.LogErrorWithCodeFromResources("CreateManifestResourceName.Error", resourceFile.ItemSpec, e.Message);
                    success = false;
                }

                ++i;
            }

            return(success);
        }
        /// <summary>
        /// Execute the task with delegate handlers.
        /// </summary>
        /// <param name="createFileStream">CreateFileStream delegate</param>
        /// <returns>True if task succeeded.</returns>
        internal bool Execute
        (
            CreateFileStream createFileStream
        )
        {
            _manifestResourceNames = new TaskItem[ResourceFiles.Length];
            _resourceFilesWithManifestResourceNames = new TaskItem[ResourceFiles.Length];

            bool success = true;
            int i = 0;

            // If Rootnamespace was null, then it wasn't set from the project resourceFile.
            // Empty namespaces are allowed.
            if (RootNamespace != null)
            {
                Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.RootNamespace", _rootNamespace);
            }
            else
            {
                Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.NoRootNamespace");
            }


            foreach (ITaskItem resourceFile in ResourceFiles)
            {
                try
                {
                    string fileName = resourceFile.ItemSpec;
                    string dependentUpon = (string)resourceFile.GetMetadata(ItemMetadataNames.dependentUpon);

                    // Pre-log some information.
                    bool isDependentOnSourceFile = (dependentUpon != null) && (dependentUpon.Length > 0) && IsSourceFile(dependentUpon);

                    if (isDependentOnSourceFile)
                    {
                        Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUpon", fileName, dependentUpon);
                    }
                    else
                    {
                        Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUponNothing", fileName);
                    }

                    // Create the manifest name.
                    Stream binaryStream = null;
                    string manifestName;

                    if (isDependentOnSourceFile)
                    {
                        string pathToDependent = Path.Combine(Path.GetDirectoryName(fileName), dependentUpon);
                        binaryStream = createFileStream(pathToDependent, FileMode.Open, FileAccess.Read);
                    }

                    // Put the task item into a dictionary so we can access it from a derived class quickly.
                    itemSpecToTaskitem[resourceFile.ItemSpec] = resourceFile;

                    // This "using" statement ensures that the "binaryStream" will be disposed once
                    // we're done with it.
                    using (binaryStream)
                    {
                        manifestName = CreateManifestName
                            (
                                fileName,
                                resourceFile.GetMetadata(ItemMetadataNames.targetPath),
                                RootNamespace,
                                isDependentOnSourceFile ? dependentUpon : null,
                                binaryStream
                            );
                    }

                    // Emit an item with our manifest name.
                    _manifestResourceNames[i] = new TaskItem(resourceFile);
                    _manifestResourceNames[i].ItemSpec = manifestName;

                    // Emit a new item preserving the itemSpec of the resourceFile, but with new metadata for manifest resource name
                    _resourceFilesWithManifestResourceNames[i] = new TaskItem(resourceFile);
                    _resourceFilesWithManifestResourceNames[i].SetMetadata("ManifestResourceName", manifestName);

                    // Add a LogicalName metadata to Non-Resx resources
                    // LogicalName isn't used for Resx resources because the ManifestResourceName metadata determines the filename of the 
                    // .resources file which then is used as the embedded resource manifest name                    
                    if (String.IsNullOrEmpty(_resourceFilesWithManifestResourceNames[i].GetMetadata("LogicalName")) &&
                        String.Equals(_resourceFilesWithManifestResourceNames[i].GetMetadata("Type"), "Non-Resx", StringComparison.OrdinalIgnoreCase))
                    {
                        _resourceFilesWithManifestResourceNames[i].SetMetadata("LogicalName", manifestName);
                    }

                    // Post-logging
                    Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.AssignedName", fileName, manifestName);
                }
                catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception.
                {
                    if (ExceptionHandling.NotExpectedException(e))
                        throw;
                    Log.LogErrorWithCodeFromResources("CreateManifestResourceName.Error", resourceFile.ItemSpec, e.Message);
                    success = false;
                }

                ++i;
            }

            return success;
        }
        internal bool Execute(CreateFileStream createFileStream)
        {
            this.manifestResourceNames = new TaskItem[this.ResourceFiles.Length];
            this.resourceFilesWithManifestResourceNames = new TaskItem[this.ResourceFiles.Length];
            bool flag  = true;
            int  index = 0;

            if (this.RootNamespace != null)
            {
                base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.RootNamespace", new object[] { this.rootNamespace });
            }
            else
            {
                base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.NoRootNamespace", new object[0]);
            }
            foreach (ITaskItem item in this.ResourceFiles)
            {
                try
                {
                    string str3;
                    string itemSpec = item.ItemSpec;
                    string metadata = item.GetMetadata("DependentUpon");
                    bool   flag2    = ((metadata != null) && (metadata.Length > 0)) && this.IsSourceFile(metadata);
                    if (flag2)
                    {
                        base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUpon", new object[] { itemSpec, metadata });
                    }
                    else
                    {
                        base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUponNothing", new object[] { itemSpec });
                    }
                    Stream binaryStream = null;
                    if (flag2)
                    {
                        string path = Path.Combine(Path.GetDirectoryName(itemSpec), metadata);
                        binaryStream = createFileStream(path, FileMode.Open, FileAccess.Read);
                    }
                    using (binaryStream)
                    {
                        str3 = this.CreateManifestName(itemSpec, item.GetMetadata("TargetPath"), this.RootNamespace, flag2 ? metadata : null, binaryStream);
                    }
                    this.manifestResourceNames[index]                  = new TaskItem(item);
                    this.manifestResourceNames[index].ItemSpec         = str3;
                    this.resourceFilesWithManifestResourceNames[index] = new TaskItem(item);
                    this.resourceFilesWithManifestResourceNames[index].SetMetadata("ManifestResourceName", str3);
                    if (string.IsNullOrEmpty(this.resourceFilesWithManifestResourceNames[index].GetMetadata("LogicalName")) && string.Equals(this.resourceFilesWithManifestResourceNames[index].GetMetadata("Type"), "Non-Resx", StringComparison.OrdinalIgnoreCase))
                    {
                        this.resourceFilesWithManifestResourceNames[index].SetMetadata("LogicalName", str3);
                    }
                    base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.AssignedName", new object[] { itemSpec, str3 });
                }
                catch (Exception exception)
                {
                    if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
                    {
                        throw;
                    }
                    base.Log.LogErrorWithCodeFromResources("CreateManifestResourceName.Error", new object[] { item.ItemSpec, exception.Message });
                    flag = false;
                }
                index++;
            }
            return(flag);
        }
 internal bool Execute(CreateFileStream createFileStream)
 {
     this.manifestResourceNames = new TaskItem[this.ResourceFiles.Length];
     this.resourceFilesWithManifestResourceNames = new TaskItem[this.ResourceFiles.Length];
     bool flag = true;
     int index = 0;
     if (this.RootNamespace != null)
     {
         base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.RootNamespace", new object[] { this.rootNamespace });
     }
     else
     {
         base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.NoRootNamespace", new object[0]);
     }
     foreach (ITaskItem item in this.ResourceFiles)
     {
         try
         {
             string str3;
             string itemSpec = item.ItemSpec;
             string metadata = item.GetMetadata("DependentUpon");
             bool flag2 = ((metadata != null) && (metadata.Length > 0)) && this.IsSourceFile(metadata);
             if (flag2)
             {
                 base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUpon", new object[] { itemSpec, metadata });
             }
             else
             {
                 base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.DependsUponNothing", new object[] { itemSpec });
             }
             Stream binaryStream = null;
             if (flag2)
             {
                 string path = Path.Combine(Path.GetDirectoryName(itemSpec), metadata);
                 binaryStream = createFileStream(path, FileMode.Open, FileAccess.Read);
             }
             using (binaryStream)
             {
                 str3 = this.CreateManifestName(itemSpec, item.GetMetadata("TargetPath"), this.RootNamespace, flag2 ? metadata : null, binaryStream);
             }
             this.manifestResourceNames[index] = new TaskItem(item);
             this.manifestResourceNames[index].ItemSpec = str3;
             this.resourceFilesWithManifestResourceNames[index] = new TaskItem(item);
             this.resourceFilesWithManifestResourceNames[index].SetMetadata("ManifestResourceName", str3);
             if (string.IsNullOrEmpty(this.resourceFilesWithManifestResourceNames[index].GetMetadata("LogicalName")) && string.Equals(this.resourceFilesWithManifestResourceNames[index].GetMetadata("Type"), "Non-Resx", StringComparison.OrdinalIgnoreCase))
             {
                 this.resourceFilesWithManifestResourceNames[index].SetMetadata("LogicalName", str3);
             }
             base.Log.LogMessageFromResources(MessageImportance.Low, "CreateManifestResourceName.AssignedName", new object[] { itemSpec, str3 });
         }
         catch (Exception exception)
         {
             if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
             {
                 throw;
             }
             base.Log.LogErrorWithCodeFromResources("CreateManifestResourceName.Error", new object[] { item.ItemSpec, exception.Message });
             flag = false;
         }
         index++;
     }
     return flag;
 }