Exemple #1
0
        private static void ProcessAttribute_Feature(PackageDataModel targetModel,
                                                     XmlAttributeCollection attributeCollection)
        {
            if (attributeCollection == null)
            {
                return;
            }

            string featureName    = string.Empty;
            bool   featureRequire = false;

            foreach (XmlAttribute currentAttribute in attributeCollection)
            {
                if (currentAttribute.Name.Equals(KEY_ATTRIBUTE_NAME))
                {
                    featureName = currentAttribute.Value;
                }
                if (currentAttribute.Name.Equals(KEY_ATTRIBUTE_FEATURE_REQUIRED))
                {
                    bool.TryParse(currentAttribute.Value, out featureRequire);
                }
                if (currentAttribute.Name.Equals(KEY_ATTRIBUTE_OPENGLVERSION))
                {
                    targetModel.OpenGLVersion = StringConstant.FieldHead_OpenGL +
                                                OtherUtil.OpenGLVersionParse(currentAttribute.Value);
                    Console.WriteLine("Node OpenGL: " + targetModel.OpenGLVersion);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(featureName))
            {
                Console.WriteLine("Node Feature: " + featureName + " " + featureRequire);
                if (featureRequire)
                {
                    targetModel.Feature_Require.Add(featureName);
                }
                else
                {
                    targetModel.Feature_NotRequire.Add(featureName);
                }
            }
        }
        public static void ReadBadging(PackageDataModel targetModel, string badgingResult)
        {
            if (targetModel == null)
            {
                targetModel = new PackageDataModel();
            }

            string[] textLines = badgingResult.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string line in textLines)
            {
                (string, string)splitResult = SplitKeyValue(line);
                string key   = splitResult.Item1.Trim();
                string value = splitResult.Item2.Trim('\'', ' ');

                //Console.WriteLine("key=" + key);
                //Console.WriteLine("value=" + value);

                if (key.StartsWith(KEY_APPICON))
                {
                    if (string.IsNullOrEmpty(targetModel.MaxIconZipEntry))
                    {
                        targetModel.MaxIconZipEntry = value;
                    }
                    else if (targetModel.MaxIconZipEntry.Count(x => x.Equals('x')) < value.Count(x => x.Equals('x')))
                    {
                        targetModel.MaxIconZipEntry = value;
                    }
                }
                if (key.StartsWith(KEY_APPLABEL))
                {
                    if (key.Equals(KEY_APPLABEL))
                    {
                        targetModel.AppNameLangDict.Add(StringConstant.LangCode_Key_Default, value);
                    }
                    else if (targetModel.AppNameLangDict.ContainsKey(StringConstant.LangCode_Key_Default) &&
                             !value.Equals(targetModel.AppNameLangDict[StringConstant.LangCode_Key_Default]))
                    {
                        targetModel.AppNameLangDict.Add(key.Substring(KEY_APPLABEL.Length + 1), value);
                    }
                }

                switch (key)
                {
                case KEY_PACKAGEGROUP:
                    Dictionary <string, string> packageDict = SplitSubDict(value);
                    targetModel.PackageName   = packageDict[SUBKEY_NAME];
                    targetModel.VersionCode   = packageDict[SUBKEY_VERSIONCODE];
                    targetModel.VersionString = packageDict[SUBKEY_VERSIONNAME];
                    break;

                case KEY_MINSDK:
                    targetModel.MinSDKCode = value;
                    break;

                case KEY_TARGETSDK:
                    targetModel.MaxSDKCode = value;
                    break;

                case KEY_APP:
                    Dictionary <string, string> labelDict = SplitSubDict(value);
                    targetModel.AppName = labelDict[SUBKEY_LABEL];
                    break;

                case KEY_SCREENSIZE:
                    targetModel.ScreenSize.AddRange(SplitSubArray(value));
                    break;

                case KEY_DENSITY:
                    targetModel.Densities.AddRange(SplitSubArray(value));
                    break;

                case KEY_DENSITY_ANY:
                    if (value.Equals(true.ToString().ToLower()))
                    {
                        targetModel.Densities.Add("any");
                    }
                    break;

                case KEY_PERMISSION:
                    Dictionary <string, string> permissionDict = SplitSubDict(value);
                    targetModel.Permissions.Add(permissionDict[SUBKEY_NAME]);
                    break;

                case KEY_FEATURE_REQUIRED:
                    Dictionary <string, string> featureDict = SplitSubDict(value);
                    targetModel.Feature_Require.Add(featureDict[SUBKEY_NAME]);
                    break;

                case KEY_FEATURE_NOTREQUIRED:
                    Dictionary <string, string> featureNRDict = SplitSubDict(value);
                    targetModel.Feature_NotRequire.Add(featureNRDict[SUBKEY_NAME]);
                    break;

                case KEY_GLES:
                    targetModel.OpenGLVersion = StringConstant.FieldHead_OpenGL + OtherUtil.OpenGLVersionParse(value);
                    break;

                case KEY_NATIVE_CODE:
                    targetModel.Architecture.AddRange(SplitSubArray(value));
                    break;

                default:
                    //Console.WriteLine("Key not processed, key=" + key);
                    break;
                }
            }
        }