Beispiel #1
0
            private static void MergeObjIntoOther(EnumObject src, EnumObject dest, Dictionary <string, List <EnumObject> > memberMap)
            {
                foreach (var m in src.members)
                {
                    if (StringComparer.OrdinalIgnoreCase.Equals(m.name, "None"))
                    {
                        continue;
                    }

                    dest.AddIfNotSet(m.name, m.value);
                    if (!memberMap.TryGetValue(m.name, out var oList))
                    {
                        oList = new List <EnumObject>();
                        oList.Add(dest);
                    }
                    else
                    {
                        if (oList.Contains(src))
                        {
                            oList.Remove(src);
                        }

                        if (!oList.Contains(dest))
                        {
                            oList.Add(dest);
                        }
                    }
                }

                foreach (var u in src.uses)
                {
                    dest.AddUse(u);
                }
            }
Beispiel #2
0
            private bool MergeObjIntoOther(EnumObject src, EnumObject dest)
            {
                // If the dest is from C# code, make src point to dest. In effect,
                // it will give its uses to the C# version
                if (dest.FromCSharp)
                {
                    src.name = null;
                    src.members.Clear();
                    src.addUsesTo = dest.name;
                    return(true);
                }

                // Don't mess with an object that was declared to be finished in the json
                if (src.finished)
                {
                    return(false);
                }

                foreach (var m in src.members)
                {
                    if (StringComparer.OrdinalIgnoreCase.Equals(m.name, "None"))
                    {
                        continue;
                    }

                    dest.AddIfNotSet(m.name, m.value);
                    if (this.enumMemberNameToEnumObj.TryGetValue(m.name, out var memberOwner))
                    {
                        if (memberOwner != dest && memberOwner != src)
                        {
                            this.enumMemberNameToEnumObj[m.name] = dest;
                            this.MergeObjIntoOther(memberOwner, dest);
                        }
                    }

                    this.enumMemberNameToEnumObj[m.name] = dest;
                }

                foreach (var u in src.uses)
                {
                    dest.AddUse(u);
                }

                return(true);
            }