Esempio n. 1
0
        BaseBuildSettingEntry CreateBuildSettingEntry(string settingName)
        {
            BaseBuildSettingEntry newEntry;
            BaseBuildSetting      refSetting;

            if (_reference.BuildSetting(settingName, out refSetting))
            {
                if (refSetting is BoolBuildSetting)
                {
                    var boolSetting = refSetting as BoolBuildSetting;
                    newEntry = new BoolBuildSettingEntry(settingName, boolSetting.Value);
                }
                else if (refSetting is ArrayBuildSetting || refSetting is StringListBuildSetting)
                {
                    newEntry = new CollectionBuildSettingEntry(settingName);
                }
                else if (refSetting is EnumBuildSetting)
                {
                    newEntry = new EnumBuildSettingEntry(settingName);
                }
                else if (refSetting is StringBuildSetting)
                {
                    var stringSetting = refSetting as StringBuildSetting;
                    newEntry = new StringBuildSettingEntry(settingName, stringSetting.Value);
                }
                else
                {
                    throw new System.NotImplementedException("EgoXproject: Developer has forgotten to implement check for new build setting type.");
                }
            }
            else
            {
                newEntry = new CustomStringBuildSettingEntry(settingName);
            }

            return(newEntry);
        }
Esempio n. 2
0
        public void Merge(BuildSettingsChanges other)
        {
            foreach (var otherEntry in other._buildSettings)
            {
                var entry = _buildSettings.Find(o => o.Name == otherEntry.Name);

                //new entry, so add
                if (entry == null)
                {
                    if (otherEntry is BoolBuildSettingEntry)
                    {
                        _buildSettings.Add(new BoolBuildSettingEntry(otherEntry as BoolBuildSettingEntry));
                    }
                    else if (otherEntry is EnumBuildSettingEntry)
                    {
                        _buildSettings.Add(new EnumBuildSettingEntry(otherEntry as EnumBuildSettingEntry));
                    }
                    else if (otherEntry is CollectionBuildSettingEntry)
                    {
                        var otherArray = otherEntry as CollectionBuildSettingEntry;

                        if (otherArray.Values.Count <= 0)
                        {
                            continue;
                        }

                        var array = new CollectionBuildSettingEntry(otherArray);

                        if (array.Values.Count <= 0)
                        {
                            continue;
                        }

                        _buildSettings.Add(array);
                    }
                    else if (otherEntry is CustomStringBuildSettingEntry)
                    {
                        var otherStr = otherEntry as CustomStringBuildSettingEntry;

                        if (string.IsNullOrEmpty(otherStr.Value.Trim()))
                        {
                            continue;
                        }

                        if (string.IsNullOrEmpty(otherStr.Name.Trim()))
                        {
                            continue;
                        }

                        var str = new CustomStringBuildSettingEntry(otherStr);
                        _buildSettings.Add(str);
                    }
                    else if (otherEntry is StringBuildSettingEntry)
                    {
                        var otherStr = otherEntry as StringBuildSettingEntry;

                        if (string.IsNullOrEmpty(otherStr.Value.Trim()))
                        {
                            continue;
                        }

                        var str = new StringBuildSettingEntry(otherStr);
                        _buildSettings.Add(str);
                    }
                }
                //existing entry, so selective merge
                else
                {
                    if (otherEntry is CollectionBuildSettingEntry)
                    {
                        var a = entry as CollectionBuildSettingEntry;
                        var b = otherEntry as CollectionBuildSettingEntry;

                        foreach (var otherValue in b.Values)
                        {
                            if (string.IsNullOrEmpty(otherValue))
                            {
                                continue;
                            }

                            if (!a.Values.Contains(otherValue))
                            {
                                a.Values.Add(otherValue);
                            }
                        }
                    }
                    else if (otherEntry is CustomStringBuildSettingEntry)
                    {
                        if (string.IsNullOrEmpty(entry.Name.Trim()))
                        {
                            continue;
                        }

                        var a = entry as CustomStringBuildSettingEntry;

                        if (string.IsNullOrEmpty(a.Value.Trim()))
                        {
                            var b = otherEntry as CustomStringBuildSettingEntry;
                            a.Value = b.Value;
                        }
                    }
                    else if (otherEntry is StringBuildSettingEntry && entry is StringBuildSettingEntry)
                    {
                        var a = entry as StringBuildSettingEntry;

                        if (string.IsNullOrEmpty(a.Value.Trim()))
                        {
                            var b = otherEntry as StringBuildSettingEntry;
                            a.Value = b.Value;
                        }
                    }
                }
            }
        }