PBXElementDict UpdatePropsAttribute()

in Facebook.Unity.Editor/iOS/PBX/Objects.cs [135:169]


        PBXElementDict UpdatePropsAttribute(PBXElementDict settings, bool value, string attributeName)
        {
            PBXElementArray attrs = null;
            if (value)
            {
                if (settings == null)
                    settings = m_Properties.CreateDict("settings");
            }
            if (settings != null && settings.Contains("ATTRIBUTES"))
                attrs = settings["ATTRIBUTES"].AsArray();

            if (value)
            {
                if (attrs == null)
                    attrs = settings.CreateArray("ATTRIBUTES");

                bool exists = attrs.values.Any(attr =>
                {
                    return attr is PBXElementString && attr.AsString() == attributeName;
                });

                if (!exists)
                    attrs.AddString(attributeName);
            }
            else
            {
                if (attrs != null)
                {
                    attrs.values.RemoveAll(el => (el is PBXElementString && el.AsString() == attributeName));
                    if (attrs.values.Count == 0)
                        settings.Remove("ATTRIBUTES");
                }
            }
            return settings;
        }