Exemplo n.º 1
0
        public static void MoveAssetsDirectory(Options options,
                                               DataInfo info)
        {
            string sourceDirectory      = GetSourceDirectory(options);
            string destinationDirectory = GetDestinationDirectory(options);

            try
            {
                if (options.IsTraceOn(Trace_Options.TraceInfo))
                {
                    Trace.TraceInformation("Moving Assets Source=" + sourceDirectory);
                    Trace.TraceInformation("              Dest  =" + destinationDirectory);
                }

                CommonIO.CreateDirectory(destinationDirectory, options);

                foreach (Asset TheAsset in info.Assets)
                {
                    if (TheAsset.AssetType == AssetType_Options.ImageAsset)
                    {
                        string sourceFile = options.BootstrapProjectPath + TheAsset.HtmlAsset;
                        string destFile   = destinationDirectory + TheAsset.RawAsset;
                        string sourcePath = Path.GetDirectoryName(sourceFile);
                        string destPath   = Path.GetDirectoryName(destFile) + @"\assets\img";

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                    else if (TheAsset.AssetType == AssetType_Options.HostAsset)
                    {
                        string sourcePath = options.BootstrapProjectPath + TheAsset.RawAsset;
                        string destPath   = options.BlazorProjectPath + "wwwroot\\" + options.PageName + "\\" + TheAsset.RawAsset;

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                    else if (TheAsset.AssetType == AssetType_Options.ScriptAsset)
                    {
                        string sourcePath = options.BootstrapProjectPath + TheAsset.RawAsset;
                        string destPath   = options.BlazorProjectPath + "wwwroot\\" + options.PageName + "\\" + TheAsset.RawAsset;

                        if (options.IsTraceOn(Trace_Options.TraceInfo))
                        {
                            Trace.TraceInformation("Copying Assets Source=" + sourcePath);
                            Trace.TraceInformation("               Dest  =" + destPath);
                        }

                        CommonIO.CopyDirectory(sourcePath, destPath, options);
                    }
                }
            }
            catch (IOException e)
            {
                if (options.IsTraceOn(Trace_Options.TraceExceptions))
                {
                    Trace.TraceError("IO Exception copying assets" + e.ToString());
                }
            }
        }