Ejemplo n.º 1
0
        /// <summary>
        /// Copy the given resource file into a given base folder.
        /// </summary>
        private void CopyResourceToFolder(string folder, string resourceFile, ResourceType resourceType)
        {
            var outputPath   = ResourceExtensions.GetNormalizedResourcePath(folder, resourceFile, resourceType);
            var outputFolder = Path.GetDirectoryName(outputPath);

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            // Collect last modification date
            var modified = File.GetLastWriteTime(resourceFile);

            if (modified > lastModified)
            {
                lastModified = modified;
            }

            // Copy the resource file
            File.Copy(resourceFile, outputPath, true);

            // Make sure file is not readonly.
            File.SetAttributes(outputPath, FileAttributes.Normal);

            // Post process
            ProcessResource(outputPath, resourceType);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Format a drawable resource id.
        /// </summary>
        internal static string FormatResourceId(string id, ResourceType defaultType)
        {
            ResourceId resId;

            if (ResourceId.TryParse(id, defaultType, out resId))
            {
                return(resId.ToString(ResourceIdFormat.AndroidXml));
            }
            throw new ArgumentException(string.Format("Unsupported resource id '{0}'", id));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Post process the given resource path.
        /// </summary>
        private void ProcessResource(string outputPath, ResourceType resourceType)
        {
            // Process contents if needed
            switch (resourceType)
            {
            case ResourceType.Layout:
                layoutProcessor.Process(outputPath, true);
                break;

            case ResourceType.Values:
                valuesResourceProcessor.Process(outputPath, true);
                break;
            }

            // Set the timestamp
            File.SetLastWriteTime(outputPath, DateTime.Now);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Format a drawable resource id.
 /// </summary>
 internal static string FormatResourceId(string id, ResourceType defaultType)
 {
     ResourceId resId;
     if (ResourceId.TryParse(id, defaultType, out resId))
         return resId.ToString(ResourceIdFormat.AndroidXml);
     throw new ArgumentException(string.Format("Unsupported resource id '{0}'", id));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Post process the given resource path.
        /// </summary>
        private void ProcessResource(string outputPath, ResourceType resourceType)
        {
            // Process contents if needed
            switch (resourceType)
            {
                case ResourceType.Layout:
                    layoutProcessor.Process(outputPath, true);
                    break;
                case ResourceType.Values:
                    valuesResourceProcessor.Process(outputPath, true);
                    break;
            }

            // Set the timestamp
            File.SetLastWriteTime(outputPath, DateTime.Now);            
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Copy the given resource file into a given base folder.
        /// </summary>
        private void CopyResourceToFolder(string folder, string resourceFile, ResourceType resourceType)
        {
            var outputPath = ResourceExtensions.GetNormalizedResourcePath(folder, resourceFile, resourceType);
            var outputFolder = Path.GetDirectoryName(outputPath);
            if (!Directory.Exists(outputFolder))
                Directory.CreateDirectory(outputFolder);

            // Collect last modification date
            var modified = File.GetLastWriteTime(resourceFile);
            if (modified > lastModified) lastModified = modified;

            // Copy the resource file
            File.Copy(resourceFile, outputPath, true);  

            // Make sure file is not readonly.
            File.SetAttributes(outputPath, FileAttributes.Normal);

            // Post process
            ProcessResource(outputPath, resourceType);
        }