Пример #1
0
        bool Clear(ref PObject plist)
        {
            if (Type != null)
            {
                switch (Type.ToLowerInvariant())
                {
                case "string": plist = new PString(string.Empty); break;

                case "array": plist = new PArray(); break;

                case "dict": plist = new PDictionary(); break;

                case "bool": plist = new PBoolean(false); break;

                case "real": plist = new PReal(0); break;

                case "integer": plist = new PNumber(0); break;

                case "date": plist = new PDate(DateTime.Now); break;

                case "data": plist = new PData(new byte[1]); break;

                default:
                    Log.LogError(7045, null, $"Unrecognized Type: {Type}");
                    return(false);
                }
            }
            else
            {
                plist = PObject.Create(plist.Type);
            }

            return(true);
        }
Пример #2
0
        void LogErrorsFromOutput(string output)
        {
            try {
                if (string.IsNullOrEmpty(output))
                {
                    return;
                }

                var plist   = PObject.FromString(output) as PDictionary;
                var errors  = PObject.Create(PObjectType.Array) as PArray;
                var message = PObject.Create(PObjectType.String) as PString;

                if ((plist?.TryGetValue("product-errors", out errors) == true))
                {
                    foreach (var error in errors)
                    {
                        var dict = error as PDictionary;
                        if (dict?.TryGetValue("message", out message) == true)
                        {
                            Log.LogError(ToolName, null, null, null, 0, 0, 0, 0, "{0}", message.Value);
                        }
                    }
                }
            } catch (Exception ex) {
                Log.LogWarning($"Failed to parse altool output: {ex.Message}. \nOutput: {output}");
            }
        }