예제 #1
0
        internal static ManifestProcessingResult Process(string Path)
        {
            var Manifest       = FileService.ReadAsString(Path);
            var VisualElements = VisualElementsManifest.ManifestService.Parse(Manifest);

            var ManifestData     = StringFormatter.Serialize(Manifest);
            var ManifestFileName = PathService.GetFileName(Path);

            var Components = new Dictionary <ManifestComponentType, ManifestComponentData>
            {
                [ManifestComponentType.Manifest] = new ManifestComponentData(ManifestData, ManifestFileName)
            };

            if (VisualElements.IsSquare70x70LogoAndSquare150x150LogoSet())
            {
                var Square70x70LogoPath   = PathService.CombinePath(PathService.GetDirectoryPath(Path), VisualElements.GetSetSquare70x70Logo());
                var Square150x150LogoPath = PathService.CombinePath(PathService.GetDirectoryPath(Path), VisualElements.GetSetSquare150x150Logo());

                var Square70x70LogoData       = FileService.ReadAsBytes(Square70x70LogoPath);
                var Square150x150LogoData     = FileService.ReadAsBytes(Square150x150LogoPath);
                var Square70x70LogoFileName   = VisualElements.GetSetSquare70x70Logo();
                var Square150x150LogoFileName = VisualElements.GetSetSquare150x150Logo();

                Components[ManifestComponentType.Square70x70Logo]   = new ManifestComponentData(Square70x70LogoData, Square70x70LogoFileName);
                Components[ManifestComponentType.Square150x150Logo] = new ManifestComponentData(Square150x150LogoData, Square150x150LogoFileName);
            }

            return(new ManifestProcessingResult(Components));
        }
예제 #2
0
        internal static bool CanBeProcessed(string Path)
        {
            var Manifest = FileService.ReadAsString(Path);

            // if is not valid - stop
            if (VisualElementsManifest.ManifestService.Validate(Manifest) == false)
            {
                return(false);
            }


            var VisualElements = VisualElementsManifest.ManifestService.Parse(Manifest);

            // if is basic version (without images) - ok
            if (VisualElements.IsSquare70x70LogoAndSquare150x150LogoSet() == false)
            {
                return(true);
            }


            var Square70x70LogoPath   = PathService.CombinePath(PathService.GetDirectoryPath(Path), VisualElements.GetSetSquare70x70Logo());
            var Square150x150LogoPath = PathService.CombinePath(PathService.GetDirectoryPath(Path), VisualElements.GetSetSquare150x150Logo());

            // images exists for sure?
            return(FileService.Exists(Square70x70LogoPath) && FileService.Exists(Square150x150LogoPath));
        }
예제 #3
0
        internal static ManifestCompilationResult Compile(string AppName, int BackgroundColor, bool LightForegroundText, bool ShowNameOnSquare150x150Logo, byte[] Square70x70LogoData, byte[] Square150x150LogoData, string Square70x70LogoName, string Square150x150LogoName, string OptionalSquare70x70LogoFormat = null, string OptionalSquare150x150LogoFormat = null, string OptionalSquare70x70LogoDirectoryPath = null, string OptionalSquare150x150LogoDirectoryPath = null)
        {
            var Square70x70LogoFormat   = OptionalSquare70x70LogoFormat ?? ImageService.GetFormat(Square70x70LogoData);
            var Square150x150LogoFormat = OptionalSquare150x150LogoFormat ?? ImageService.GetFormat(Square150x150LogoData);

            var Square70x70LogoDirectoryPath   = OptionalSquare70x70LogoDirectoryPath ?? string.Empty;
            var Square150x150LogoDirectoryPath = OptionalSquare150x150LogoDirectoryPath ?? string.Empty;

            var Square70x70LogoFullName   = PathService.CombineName(Square70x70LogoName, Square70x70LogoFormat);
            var Square150x150LogoFullName = PathService.CombineName(Square150x150LogoName, Square150x150LogoFormat);

            var Square70x70LogoPath   = PathService.CombinePath(Square70x70LogoDirectoryPath, Square70x70LogoFullName);
            var Square150x150LogoPath = PathService.CombinePath(Square150x150LogoDirectoryPath, Square150x150LogoFullName);

            var VisualElements = new VisualElements();

            VisualElements.SetBackgroundColorOn(BackgroundColor);
            VisualElements.SetForegroundTextOn(LightForegroundText);
            VisualElements.SetShowNameOnSquare150x150LogoOn(ShowNameOnSquare150x150Logo);
            VisualElements.SetSquare70x70LogoOn(Square70x70LogoPath);
            VisualElements.SetSquare150x150LogoOn(Square150x150LogoPath);
            var Manifest = VisualElementsManifest.ManifestService.Create(VisualElements);

            var ManifestData     = StringFormatter.Serialize(Manifest);
            var ManifestFileName = ManifestNameBuilder.Build(AppName);

            var Components = new Dictionary <ManifestComponentType, ManifestComponentData>()
            {
                { ManifestComponentType.Manifest, new ManifestComponentData(ManifestData, ManifestFileName) },
                { ManifestComponentType.Square70x70Logo, new ManifestComponentData(Square70x70LogoData, Square70x70LogoPath) },
                { ManifestComponentType.Square150x150Logo, new ManifestComponentData(Square150x150LogoData, Square150x150LogoPath) },
            };

            return(new ManifestCompilationResult(Components));
        }
예제 #4
0
 /// <include file=".Docs/.ManifestService.xml" path="docs/method[@name='CanBeProcessed(string, string)']/*"/>
 public static bool CanBeProcessed(string AppDirectory, string AppName)
 {
     return(Processer.CanBeProcessed(PathService.CombinePath(AppDirectory, ManifestNameBuilder.Build(AppName))));
 }
예제 #5
0
 /// <include file=".Docs/.ManifestService.xml" path="docs/method[@name='Process(string, string)']/*"/>
 public static ManifestProcessingResult Process(string AppDirectory, string AppName)
 {
     return(Processer.Process(PathService.CombinePath(AppDirectory, ManifestNameBuilder.Build(AppName))));
 }
예제 #6
0
        internal static ManifestDecompilationResult Decompile(ManifestComponents Components)
        {
            var VisualElements = VisualElementsManifest.ManifestService.Parse(StringFormatter.Deserialize(Components[ManifestComponentType.Manifest].Data));

            var AppName                        = Components[ManifestComponentType.Manifest].FileName.Split('.')[0];
            var BackgroundColor                = VisualElements.GetSetBackgroundColor();
            var LightForegroundText            = VisualElements.IsForegroundTextSetOnLight();
            var ShowNameOnSquare150x150Logo    = VisualElements.IsShowNameOnSquare150x150LogoSetOnOn();
            var Square70x70LogoData            = Components.ContainsKey(ManifestComponentType.Square70x70Logo) ? Components[ManifestComponentType.Square70x70Logo].Data : null;
            var Square150x150LogoData          = Components.ContainsKey(ManifestComponentType.Square150x150Logo) ? Components[ManifestComponentType.Square150x150Logo].Data : null;
            var Square70x70LogoName            = Components.ContainsKey(ManifestComponentType.Square70x70Logo) ? PathService.GetShortName(Components[ManifestComponentType.Square70x70Logo].FileName) : null;
            var Square150x150LogoName          = Components.ContainsKey(ManifestComponentType.Square150x150Logo) ? PathService.GetShortName(Components[ManifestComponentType.Square150x150Logo].FileName) : null;
            var Square70x70LogoFormat          = Components.ContainsKey(ManifestComponentType.Square70x70Logo) ? PathService.GetFileExtension(Components[ManifestComponentType.Square70x70Logo].FileName) : null;
            var Square150x150LogoFormat        = Components.ContainsKey(ManifestComponentType.Square150x150Logo) ? PathService.GetFileExtension(Components[ManifestComponentType.Square150x150Logo].FileName) : null;
            var Square70x70LogoDirectoryPath   = Components.ContainsKey(ManifestComponentType.Square70x70Logo) ? PathService.GetDirectoryPath(Components[ManifestComponentType.Square70x70Logo].FileName) : null;
            var Square150x150LogoDirectoryPath = Components.ContainsKey(ManifestComponentType.Square150x150Logo) ? PathService.GetDirectoryPath(Components[ManifestComponentType.Square150x150Logo].FileName) : null;

            return(new ManifestDecompilationResult(AppName, BackgroundColor, LightForegroundText, ShowNameOnSquare150x150Logo, Square70x70LogoData, Square150x150LogoData, Square70x70LogoName, Square150x150LogoName, Square70x70LogoFormat, Square150x150LogoFormat, Square70x70LogoDirectoryPath, Square150x150LogoDirectoryPath));
        }