示例#1
0
        /// <inheritdoc/>
        public async Task <UnpackObjectResult> UnpackObject(ExtractArchiveEntryResult extractArchiveEntryResult)
        {
            var result = new UnpackObjectResult
            {
                LogLevel = LogLevel.Info
            };

            try
            {
                var json   = Encoding.UTF8.GetString(extractArchiveEntryResult.Data);
                var ribbon = JsonConvert.DeserializeObject <RibbonTab>(json);

                result.InstallableObject = new InstallableObject
                {
                    Content = ribbon,
                    Target  = extractArchiveEntryResult.Location,
                    Mode    = extractArchiveEntryResult.Mode
                };

                result.Message = $"Unpacked RibbonTab at {extractArchiveEntryResult.Location}.";
            }
            catch (Exception ex)
            {
                result.Message   = $"Failed to unpack RibbonTab at {extractArchiveEntryResult.Location}.";
                result.LogLevel  = LogLevel.Error;
                result.Exception = ex;
            }
            return(result);
        }
        /// <inheritdoc/>
        public async Task <UnpackObjectResult> UnpackObject(ExtractArchiveEntryResult extractArchiveEntryResult)
        {
            var result = new UnpackObjectResult
            {
                LogLevel = LogLevel.Info
            };

            try
            {
                var json    = Encoding.UTF8.GetString(extractArchiveEntryResult.Data);
                var jObject = JObject.Parse(json);

                var configuration = jObject["Configuration"];
                jObject.Remove("Configuration");

                var content = jObject.ToObject <EplReport>();
                content.Configuration = DeserializeConfiguration(content.Type, configuration);

                result.InstallableObject = new InstallableObject
                {
                    Content = content,
                    Target  = extractArchiveEntryResult.Location,
                    Mode    = extractArchiveEntryResult.Mode
                };
                result.Message = $"Unpacked EplReport at {extractArchiveEntryResult.Location}.";
            }
            catch (Exception ex)
            {
                result.Message   = $"Failed to unpack EplReport at {extractArchiveEntryResult.Location}.";
                result.LogLevel  = LogLevel.Error;
                result.Exception = ex;
            }
            return(result);
        }
        /// <inheritdoc/>
#pragma warning disable 1998
        public async Task <UnpackObjectResult> UnpackObject(ExtractArchiveEntryResult extractArchiveEntryResult)
#pragma warning restore 1998
        {
            var result = new UnpackObjectResult
            {
                LogLevel = LogLevel.Info
            };

            try
            {
                var json    = Encoding.UTF8.GetString(extractArchiveEntryResult.Data);
                var jObject = JObject.Parse(json);

                // Separate settings and rest of json
                var settingsJson = jObject["Configuration"]?.ToString();
                jObject.Remove("Configuration");

                // Separately deserialize settings and rest of json
                var deserializedApplication = jObject.ToObject <Application>();

                if (deserializedApplication == null)
                {
                    throw new NullReferenceException("Deserialized application is null");
                }


                deserializedApplication.Configuration =
                    DeserializeSettings(deserializedApplication.Type, settingsJson);

                result.InstallableObject = new InstallableObject
                {
                    Content = deserializedApplication,
                    Target  = extractArchiveEntryResult.Location,
                    Mode    = extractArchiveEntryResult.Mode
                };


                result.Message = $"Unpacked Application at {extractArchiveEntryResult.Location}.";
            }
            catch (Exception ex)
            {
                result.Message   = $"Failed to unpack Application at {extractArchiveEntryResult.Location}.";
                result.LogLevel  = LogLevel.Error;
                result.Exception = ex;
            }
            return(result);
        }
        /// <inheritdoc/>
        public async Task <UnpackObjectResult> UnpackObject(ExtractArchiveEntryResult extractArchiveEntryResult)
        {
            var result = new UnpackObjectResult
            {
                LogLevel = LogLevel.Info
            };

            try
            {
                var json    = Encoding.UTF8.GetString(extractArchiveEntryResult.Data);
                var jObject = JObject.Parse(json);

                // Seperate settings and rest of json
                var configuration = jObject["configuration"];
                jObject.Remove("configuration");

                // Seperately deserialize settings and rest of json
                var deserialiedStackContextArea = jObject.ToObject <StackContextArea>();
                deserialiedStackContextArea.Configuration = DeserializedConfiguration(deserialiedStackContextArea.Type, configuration);

                result.InstallableObject = new InstallableObject
                {
                    Content = deserialiedStackContextArea,
                    Target  = extractArchiveEntryResult.Location,
                    Mode    = extractArchiveEntryResult.Mode
                };
                result.Message = $"Unpacked StackContextArea at {extractArchiveEntryResult.Location}.";
            }
            catch (Exception ex)
            {
                result.Message   = $"Failed to unpack StackContextArea at {extractArchiveEntryResult.Location}.";
                result.LogLevel  = LogLevel.Error;
                result.Exception = ex;
            }
            return(result);
        }