public void AddCollectionBuildSetting(string settingName, string[] values, MergeMethod mergeMethod)
        {
            if (string.IsNullOrEmpty(settingName) || values == null || values.Length <= 0)
            {
                return;
            }

            BaseBuildSetting baseSetting = null;

            XcodeBuildSettings.Instance().BuildSetting(settingName, out baseSetting);

            //its a custom array setting
            if (baseSetting == null)
            {
                baseSetting = new StringListBuildSetting(settingName, settingName, "User-Defined", false, false);
            }

            if (baseSetting is ArrayBuildSetting)
            {
                AddArrayBuildSetting(baseSetting as ArrayBuildSetting, values, mergeMethod);
            }
            else if (baseSetting is StringListBuildSetting)
            {
                AddStringListBuildSetting(baseSetting as StringListBuildSetting, values, mergeMethod);
            }
            else
            {
                Debug.LogError("EgoXproject: " + settingName + " is not a string list build setting");
            }
        }
Esempio n. 2
0
        public async Task <bool> MergePullRequest(PullRequest pullRequest, MergeMethod mergeMethod = MergeMethod.Merge)
        {
            try
            {
                HttpResponseMessage response = await _client.PutAsync(
                    $"repos/{pullRequest.Base.Repo.Owner.Login}/{pullRequest.Base.Repo.Name}/pulls/{pullRequest.Number}/merge",
                    new
                {
                    pullRequest.Head.Sha,
                    mergeMethod
                }.AsSnakeCaseJsonContent());

                if (response.IsSuccessStatusCode)
                {
                    _logger.LogInformation($"Successfully merged pull request #{pullRequest.Number}.");
                    return(true);
                }

                _logger.LogWarning($"Failed to merge pull request #{pullRequest.Number}. Reason: {response.ReasonPhrase}.");
                return(false);
            }
            catch (Exception exception)
            {
                _logger?.LogError(exception, $"Failed to merge pull request #{pullRequest.Number}.");
                return(false);
            }
        }
Esempio n. 3
0
        public DatabaseManager(IMemTable memTable, DiskTablesMerger diskTablesMerger, DirectoryInfo databaseDirectory, MergeMethod mergeMethod)
        {
            this.memTable          = memTable;
            this.diskTablesMerger  = diskTablesMerger;
            this.databaseDirectory = databaseDirectory;
            MergeMethod            = mergeMethod;

            ItemsTreshold = 10;
        }
        public void SetUp()
        {
            databaseDirectory = new DirectoryInfo("C:\\databaseLsm");
            diskTablesMerger  = Substitute.For <DiskTablesMerger>();
            memTable          = Substitute.For <IMemTable>();

            method          = MergeMethod.MergeByLevel;
            databaseManager = new DatabaseManager(memTable, diskTablesMerger, databaseDirectory, method);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.Write("Ammount of numbers> ");
            int[] ar = new int[IntInput(2)];


            Random randNum = new Random();

            for (int i = 0; i < ar.Length; i++)
            {
                ar[i] = randNum.Next(0, 100);
            }
            Console.Clear();
            Console.WriteLine("Before:");
            WriteArray(ar);
            MergeMethod.Sort(ar);
            Console.WriteLine("After:");
            WriteArray(ar);
            Console.ReadKey();
        }
Esempio n. 6
0
    static Dictionary <string, MergeMethod> FindMergeMethods(Compilation compilation, Action <Diagnostic> reportDiagnostic)
    {
        var mergeMethodByErrorTypeName = compilation.SyntaxTrees
                                         .SelectMany(t => FindMergeMethodsWalker.Get(t.GetRoot(), tree => compilation.GetSemanticModel(tree)))
                                         .Select(methodDeclaration =>
        {
            var semanticModel  = compilation.GetSemanticModel(methodDeclaration.SyntaxTree);
            var returnTypeName = semanticModel.GetFullTypeName(methodDeclaration.ReturnType);

            if (methodDeclaration.Modifiers.HasModifier(SyntaxKind.StaticKeyword))
            {
                if (methodDeclaration.ParameterList.Parameters.Count == 2 &&
                    methodDeclaration.ParameterList.Parameters.All(p => semanticModel.GetFullTypeName(p.Type !) == returnTypeName) &&
                    methodDeclaration.ParameterList.Parameters[0].Modifiers.HasModifier(SyntaxKind.ThisKeyword))
                {
                    return(MergeMethod.StaticMerge(methodDeclaration.Identifier.ToString(),
                                                   methodDeclaration.GetContainingNamespace(), returnTypeName));
                }
            }
            else if (methodDeclaration.ParameterList.Parameters.Count == 1 &&
                     methodDeclaration.Parent is ClassDeclarationSyntax c &&
                     //TODO: get correct name with visitor or from semantic model
                     $"{c.GetContainingNamespace()}.{c.Identifier}" == returnTypeName &&
                     methodDeclaration.ParameterList.Parameters.All(p => semanticModel.GetFullTypeName(p.Type !) == returnTypeName))
            {
                return(MergeMethod.ErrorTypeMember(methodDeclaration.Identifier.ToString(), returnTypeName));
            }

            reportDiagnostic(Diagnostics.InvalidMergeMethod(
                                 $"Method {methodDeclaration.Identifier}", methodDeclaration.GetLocation()));
            return(null);
        })
                                         .Where(m => m != null)
                                         .GroupBy(m => m !.FullErrorTypeName)
                                         .ToDictionary(g => g.Key, g =>
        {
            var methods = g.ToList();
            if (methods.Count > 1)
            {
                reportDiagnostic(Diagnostics.AmbiguousMergeMethods(methods.Select(m => m !.MethodName)));
            }
Esempio n. 7
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="elements">线段树锁维护的元素数组</param>
 /// <param name="left">维护的区间的左端点</param>
 /// <param name="right">维护的区间的右端点</param>
 /// <param name="mergeMethod">区间合并方法</param>
 /// <param name="addMethod">区间修改方法</param>
 /// <param name="mulMethod">区间修改累和方法</param>
 /// <param name="initVal">初始值(默认为T的初始值)</param>
 public SegmentTree(T[] elements, int left, int right,
                    MergeMethod mergeMethod, AddMethod addMethod, MultiplyMethod mulMethod, T initVal = default(T))
 {
     if (right < left)
     {
         throw new ArgumentOutOfRangeException("right", "区间right<left");
     }
     if (left < 0)
     {
         throw new ArgumentOutOfRangeException("left", "left越界");
     }
     if (right > elements.GetUpperBound(0))
     {
         throw new ArgumentOutOfRangeException("right", "right越界");
     }
     lazied   = false;
     _left    = left;
     _right   = right;
     merge    = mergeMethod;
     add      = addMethod;
     multiply = mulMethod;
     lazy     = initValue = initVal;
     build(elements);
 }
Esempio n. 8
0
        public CollectionBuildSettingEntry(PListDictionary dic)
            : base(dic)
        {
            //try to get array with new key
            var array = dic.ArrayValue(VALUE_KEY);

            //then try with old key
            if (array == null)
            {
                array = dic.ArrayValue(OLD_VALUE_KEY);
            }

            //get the values
            if (array != null)
            {
                Values = new List <string>();
                Values.AddRange(array.ToStringArray());
            }
            //if all failed see if it is a string (could be a custom string that is now known about.
            else
            {
                var strVal = dic.StringValue(VALUE_KEY);
                Values = StringUtils.StringListToList(strVal);
            }

            MergeMethod m;

            if (dic.EnumValue(MERGE_KEY, out m))
            {
                Merge = m;
            }
            else
            {
                Merge = MergeMethod.Append;
            }
        }
        void AddStringListBuildSetting(StringListBuildSetting stringListSetting, string[] values, MergeMethod mergeMethod)
        {
            var           settings   = BuildSettings;
            PBXProjString stringList = null;

            //TODO check conditionals, as will have to run for each conditional variant

            //handle appending
            if (mergeMethod == MergeMethod.Append)
            {
                stringList = settings.Element <PBXProjString>(stringListSetting.BuildSettingName);
            }

            //handles null case and replace case
            if (stringList == null)
            {
                stringList = new PBXProjString();
                settings[stringListSetting.BuildSettingName] = stringList;
            }

            //break down string list into list so it can be checked
            List <string> existingValues = StringUtils.StringListToList(stringList.Value);

            // handle settings that need inherit string being added
            if (stringListSetting.AddInherited)
            {
                if (existingValues.Where(o => o.Equals(INHERITED)).Count() <= 0)
                {
                    existingValues.Insert(0, INHERITED);
                }
            }

            foreach (var v in values)
            {
                if (existingValues.Where(o => o.Equals(v)).Count() <= 0)
                {
                    existingValues.Add(v);
                }
            }

            stringList.Value = StringUtils.ListToStringList(existingValues);
        }
Esempio n. 10
0
        void AddArrayBuildSetting(ArrayBuildSetting arraySetting, string[] values, MergeMethod mergeMethod)
        {
            var          settings = BuildSettings;
            PBXProjArray array    = null;

            //TODO check conditionals, as will have to run for each conditional variant

            //handle appending
            if (mergeMethod == MergeMethod.Append)
            {
                array = settings.Element <PBXProjArray>(arraySetting.BuildSettingName);

                //single entry may have been parsed as a string
                if (array == null)
                {
                    var str = settings.Element <PBXProjString>(arraySetting.BuildSettingName);

                    if (str != null)
                    {
                        array = new PBXProjArray();
                        array.Add(str.Value);
                        settings[arraySetting.BuildSettingName] = array;
                    }
                }
            }

            //handles null case and replace case
            if (array == null)
            {
                array = new PBXProjArray();
                settings[arraySetting.BuildSettingName] = array;
            }

            // handle settings that need inherit string being added
            if (arraySetting.AddInherited)
            {
                string inherited = INHERITED.EncloseInQuotes();

                if (array.Where(o => (o as PBXProjString).Value.Equals(inherited)).Count() <= 0)
                {
                    array.Add(inherited);
                }
            }

            foreach (var v in values)
            {
                string quoted;

                if (v.Contains(" ") && !v.StartsWith("\"", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    quoted = "\"" + v + "\"";
                }
                else
                {
                    quoted = v;
                }

                quoted = quoted.ToLiteralIfRequired();

                //only add if not present
                if (array.Where(o => (o as PBXProjString).Value.Equals(quoted)).Count() <= 0)
                {
                    array.Add(quoted);
                }
            }
        }
Esempio n. 11
0
        public static void SortMerge(MergeMethod JM, RecordWriter Output, FNodeSet Fields, Predicate Where, DataSet Data1, DataSet Data2, Key Equality1, Key Equality2,
            StaticRegister Memory1, StaticRegister Memory2)
        {

            switch (JM)
            {

                case MergeMethod.Cross:
                    CrossJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2);
                    break;
                case MergeMethod.Inner:
                    SortMergeInnerJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2);
                    break;
                case MergeMethod.Left:
                    SortMergeLeftJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, false);
                    break;
                case MergeMethod.Right:
                    SortMergeRightJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, false);
                    break;
                case MergeMethod.Full:
                    SortMergeLeftJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, false);
                    SortMergeRightJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiLeft:
                    SortMergeLeftJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiRight:
                    SortMergeRightJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiInner:
                    SortMergeLeftJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, true);
                    SortMergeRightJoin(Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2, true);
                    break;

            }
        }
Esempio n. 12
0
 /// <summary>
 ///   <para>This method will initiate a merge task handle merging of the conflicting assets.</para>
 /// </summary>
 /// <param name="assets">The list of conflicting assets to be merged.</param>
 /// <param name="method">How to merge the assets.</param>
 public static Task Merge(AssetList assets, MergeMethod method)
 {
     return(Provider.Internal_Merge(assets.ToArray(), method));
 }
 /// <summary>
 /// Loads the specified binary tag structure and merges its tags with the current property file using the specified merging method.
 /// </summary>
 /// <param name="path">The file path of the binary tag structure.</param>
 /// <param name="method">The method of merging.</param>
 public void MergeFrom(string path, MergeMethod method)
 {
     BinaryTagStructure structure = new BinaryTagStructure(path);
     structure.Load();
     this.Merge(structure, method);
 }
Esempio n. 14
0
        public static void HashTable(MergeMethod JM, RecordWriter Output, FNodeSet Fields, Predicate Where, DataSet Data1, DataSet Data2, Key Equality1, Key Equality2,
            StaticRegister Memory1, StaticRegister Memory2)
        {

            // Build temp hash tables //
            DataSet h1 = IndexBuilder.Build(Data1, Equality1, Data1.Directory);
            DataSet h2 = IndexBuilder.Build(Data2, Equality2, Data2.Directory);

            // Combine has tables //
            DataSet hash = BuildJoinHelper(h1, h2, JM);

            // Exit if the hash table has no records //
            if (hash.IsEmpty)
            {
                DataSetManager.DropData(h1);
                DataSetManager.DropData(h2);
                DataSetManager.DropData(hash);
                return;
            }

            // Sort the table by the first and second set ids, keys 0 and 2 //
            hash.Sort(new Key(0, 2));

            // Open a reader //
            RecordReader ac = hash.OpenReader();

            // Define logic //
            int sid1 = (int)ac.Read()[0].INT;
            int sid2 = (int)ac.Read()[2].INT;
            int rid1 = 0;
            int rid2 = 0;
            bool isnull1 = false;
            bool isnull2 = false;

            // Create the temp variables //
            RecordSet ts1 = Data1.PopAt(sid1);
            RecordSet ts2 = Data2.PopAt(sid2);

            // Main loop //
            while (!ac.EndOfData)
            {

                // Read the record id //
                Record dr = ac.ReadNext();
                sid1 = (int)dr[0].INT;
                rid1 = (int)dr[1].INT;
                sid2 = (int)dr[2].INT;
                rid2 = (int)dr[3].INT;
                isnull1 = dr[0].IsNull;
                isnull2 = dr[2].IsNull;

                // Check if we need to re-buffer a shard //
                if (ts1.ID != sid1 && !isnull1)
                    ts1 = Data1.PopAt(sid1);
                if (ts2.ID != sid2 && !isnull2)
                    ts2 = Data2.PopAt(sid2);

                // Create the output record - table one //
                if (!isnull1)
                    Memory1.Assign(ts1[rid1]);
                else
                    Memory1.Assign(ts1.Columns.NullRecord);

                // Create the output record - table two //
                if (!isnull2)
                    Memory2.Assign(ts2[rid2]);
                else
                    Memory2.Assign(ts2.Columns.NullRecord);

                // Write the output record //
                Record t = Fields.Evaluate();
                if (Where.Render())
                    Output.Insert(t);

            }

            // Drop tables //
            DataSetManager.DropData(h1);
            DataSetManager.DropData(h2);
            DataSetManager.DropData(hash);

        }
Esempio n. 15
0
 private static extern Task Internal_Merge(Asset[] assets, MergeMethod mergeMethod);
Esempio n. 16
0
 static public Task Merge(AssetList assets, MergeMethod method)
 {
     return(Internal_Merge(assets.ToArray()));
 }
Esempio n. 17
0
        private void OnGUI()
        {
            this.cancelled = false;
            GUILayout.Label("Conflicting files to resolve", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, base.position.height - 112f);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            bool flag = this.resolveList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.enabled = (this.assetList.Count > 0);
            GUILayout.Label("Resolve selection by:", new GUILayoutOption[0]);
            if (GUILayout.Button("using local version", new GUILayoutOption[0]))
            {
                AssetList selectedAssets = this.resolveList.SelectedAssets;
                Provider.Resolve(selectedAssets, ResolveMethod.UseMine).Wait();
                AssetDatabase.Refresh();
                base.Close();
            }
            if (GUILayout.Button("using incoming version", new GUILayoutOption[0]))
            {
                AssetList selectedAssets2 = this.resolveList.SelectedAssets;
                Provider.Resolve(selectedAssets2, ResolveMethod.UseTheirs).Wait();
                AssetDatabase.Refresh();
                base.Close();
            }
            MergeMethod mergeMethod = MergeMethod.MergeNone;

            if (GUILayout.Button("merging", new GUILayoutOption[0]))
            {
                mergeMethod = MergeMethod.MergeAll;
            }
            if (mergeMethod != MergeMethod.MergeNone)
            {
                Task task = Provider.Merge(this.resolveList.SelectedAssets, mergeMethod);
                task.Wait();
                if (task.success)
                {
                    task = Provider.Resolve(task.assetList, ResolveMethod.UseMerged);
                    task.Wait();
                    if (task.success)
                    {
                        task = Provider.Status(this.assetList);
                        task.Wait();
                        this.DoOpen(task.assetList);
                        if (task.success && this.assetList.Count == 0)
                        {
                            base.Close();
                        }
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Error resolving", "Error during resolve of files. Inspect log for details", "Close");
                        AssetDatabase.Refresh();
                    }
                }
                else
                {
                    EditorUtility.DisplayDialog("Error merging", "Error during merge of files. Inspect log for details", "Close");
                    AssetDatabase.Refresh();
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUI.enabled = true;
            if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
            {
                this.cancelled = true;
                base.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
            if (flag)
            {
                base.Repaint();
            }
        }
Esempio n. 18
0
 /// <summary>
 /// <para>This method will initiate a merge task handle merging of the conflicting assets.</para>
 /// </summary>
 /// <param name="assets">The list of conflicting assets to be merged.</param>
 /// <param name="method">How to merge the assets.</param>
 public static Task Merge(AssetList assets, MergeMethod method)
 {
     return Internal_Merge(assets.ToArray(), method);
 }
Esempio n. 19
0
 private static extern Task Internal_Merge(Asset[] assets, MergeMethod method);
Esempio n. 20
0
        // Main Join Functions //
        /// <summary>
        /// Allows the user to perform a join based on the equality predicate AND each predicate link via 'AND'
        /// </summary>
        /// <param name="Output"></param>
        /// <param name="JM"></param>
        /// <param name="JA"></param>
        /// <param name="T1"></param>
        /// <param name="J1"></param>
        /// <param name="T2"></param>
        /// <param name="J2"></param>
        /// <param name="CM"></param>
        public static void Join(MergeMethod JM, MergeAlgorithm JA, RecordWriter Output, FNodeSet Fields, Predicate Where, DataSet Data1, DataSet Data2, 
            Key Equality1, Key Equality2, StaticRegister Memory1, StaticRegister Memory2)
        {

            // Do some checks first //
            if (Where == null)
                Where = Predicate.TrueForAll;
            if (Equality1.Count != Equality2.Count)
                throw new Exception("Both join keys must have the same length");
            if (Equality1.Count == 0)
                JA = MergeAlgorithm.NestedLoop;

            // Nested loop; if the algorithm is nested loop and we have keys, we need to build a new where clause that has the equality predicates //
            FNodeResult nl_node = new FNodeResult(null, new AndMany());
            nl_node.AddChildNode(Where.Node.CloneOfMe());
            for (int i = 0; i < Equality1.Count; i++)
            {

                FNodeFieldRef left = new FNodeFieldRef(null, Equality1[i], Data1.Columns.ColumnAffinity(Equality1[i]), Data1.Columns.ColumnSize(Equality1[i]), Memory1);
                FNodeFieldRef right = new FNodeFieldRef(null, Equality2[i], Data2.Columns.ColumnAffinity(Equality2[i]), Data2.Columns.ColumnSize(Equality2[i]), Memory2);
                FNodeResult eq = new FNodeResult(null, new CellBoolEQ());
                eq.AddChildren(left, right);
                nl_node.AddChildNode(eq);

            }

            Predicate nl_where = (Equality1.Count == 0 ? Where : new Predicate(nl_node));

            // Switch //
            switch (JA)
            {
                case MergeAlgorithm.SortMerge:
                    SortMerge(JM, Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2);
                    break;
                case MergeAlgorithm.NestedLoop:
                    NestedLoop(JM, Output, Fields, nl_where, Data1, Data2, Memory1, Memory2);
                    break;
                default:
                    HashTable(JM, Output, Fields, Where, Data1, Data2, Equality1, Equality2, Memory1, Memory2);
                    break;
            }

        }
Esempio n. 21
0
        public bool Equals(DestinyHistoricalStatsDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     StatId == input.StatId ||
                     (StatId != null && StatId.Equals(input.StatId))
                     ) &&
                 (
                     Group == input.Group ||
                     (Group != null && Group.Equals(input.Group))
                 ) &&
                 (
                     PeriodTypes == input.PeriodTypes ||
                     (PeriodTypes != null && PeriodTypes.SequenceEqual(input.PeriodTypes))
                 ) &&
                 (
                     Modes == input.Modes ||
                     (Modes != null && Modes.SequenceEqual(input.Modes))
                 ) &&
                 (
                     Category == input.Category ||
                     (Category != null && Category.Equals(input.Category))
                 ) &&
                 (
                     StatName == input.StatName ||
                     (StatName != null && StatName.Equals(input.StatName))
                 ) &&
                 (
                     StatNameAbbr == input.StatNameAbbr ||
                     (StatNameAbbr != null && StatNameAbbr.Equals(input.StatNameAbbr))
                 ) &&
                 (
                     StatDescription == input.StatDescription ||
                     (StatDescription != null && StatDescription.Equals(input.StatDescription))
                 ) &&
                 (
                     UnitType == input.UnitType ||
                     (UnitType != null && UnitType.Equals(input.UnitType))
                 ) &&
                 (
                     IconImage == input.IconImage ||
                     (IconImage != null && IconImage.Equals(input.IconImage))
                 ) &&
                 (
                     MergeMethod == input.MergeMethod ||
                     (MergeMethod.Equals(input.MergeMethod))
                 ) &&
                 (
                     UnitLabel == input.UnitLabel ||
                     (UnitLabel != null && UnitLabel.Equals(input.UnitLabel))
                 ) &&
                 (
                     Weight == input.Weight ||
                     (Weight.Equals(input.Weight))
                 ) &&
                 (
                     MedalTierHash == input.MedalTierHash ||
                     (MedalTierHash.Equals(input.MedalTierHash))
                 ));
        }
Esempio n. 22
0
        public MergePlan(MergeMethod JM, MergeAlgorithm JA, RecordWriter Output, FNodeSet Fields, Predicate Where, DataSet Data1, DataSet Data2, 
            Key Equality1, Key Equality2, StaticRegister Memory1, StaticRegister Memory2)
            : base()
        {

            this._use_method = JM;
            this._use_algorithm = JA;
            this._output = Output;
            this._fields = Fields;
            this._where = Where;
            this._data1 = Data1;
            this._data2 = Data2;
            this._key1 = Equality1;
            this._key2 = Equality2;
            this._mem1 = Memory1;
            this._mem2 = Memory2;
            this.Name = "MERGE";

        }
Esempio n. 23
0
 /// <summary>
 /// <para>This method will initiate a merge task handle merging of the conflicting assets.</para>
 /// </summary>
 /// <param name="assets">The list of conflicting assets to be merged.</param>
 /// <param name="method">How to merge the assets.</param>
 public static Task Merge(AssetList assets, MergeMethod method) =>
 Internal_Merge(assets.ToArray(), method);
Esempio n. 24
0
            // ------------------------------------------------------------------------------------------------
            // Desc:    Look for a Material in a Material List
            // ------------------------------------------------------------------------------------------------
            // In:      string          targetPath      Path containing models
            //          List<Material>  sourceMat       Original Materials stripped from the models.
            //          string[]        sourceMatName   Original Material names.  Used to find the object's
            //                                            material in the primary material list.
            //          int[]           conMatPointer   Pointers linking the source material list to new materials
            //          string[]        conMatName      New Material names "shorter array with combined materials"
            //                                            used to rename the material.
            //          Material[]      conMat          Consolidated material array.  Already contains subsituted
            //                                            materials.
            //          bool            flagAddMeshCollider     Should a MeshCollider be added for each mesh
            //          bool            flagAddEmptyParent      Should an empty parent GameObject be created
            //          bool            flagPreserveModelHierarchy      Should prefab use same parent/child hierarchy as model
            //
            // Out:     Bool whether process was successful
            // ------------------------------------------------------------------------------------------------
            public bool CreatePrefabs(string targetPath, List <Material> sourceMat, List <string> sourceMatName,
                                      int[] conMatPointer, string[] conMatName, Material[] conMat,
                                      bool flagAddMeshCollider, bool flagAddEmptyParent, MergeMethod mergeMethod)
            {
                // Create a new "/Prefabs" folder, if one doesn't exist
                if (!AssetDatabase.IsValidFolder(targetPath + "/Prefabs"))
                {
                    AssetDatabase.CreateFolder(targetPath, "Prefabs");
                }

                AssetDatabase.SaveAssets();

                // Convert source Material name array to List for easy searching
                List <string> searchMatName = new List <string>(sourceMatName);

                // Loop through each source Material and give each a reference to the extracted or substituted Material
                for (int i = 0; i < sourceMat.Count; i++)
                {
                    sourceMat[i] = conMat[conMatPointer[i]];
                }

                // Get all models in the target folder
                GameObject[] model = GetModelsInFolder(targetPath);

                // Create new Prefab and Prefab child GameObjects
                GameObject finalGameObject = null;

                // Loop through each model
                for (int i = 0; i < model.Length; i++)
                {
                    // ------------------------------------------------------------
                    // Create new GameObject based on merge method chosen
                    // ------------------------------------------------------------

                    switch (mergeMethod)
                    {
                    // If merging children only, create a GameObject with a semi-preserved hierarchy, only merging meshes
                    //     in GameObjects that are at the end of the hierarchy and shared by the same parent GameObject
                    case MergeMethod.MergeChildren:
                        finalGameObject = CreateGameObjectWithMergedChildren(model[i].transform, searchMatName, sourceMat, model[i].name);
                        break;

                    // If not performing a merge, create a GameObject with a fully preserved hierarchy
                    case MergeMethod.DoNotMerge:
                        finalGameObject = CreateGameObjectWithPreservedHierarchy(model[i].transform, searchMatName, sourceMat, model[i].name);
                        break;

                    // If merging everything, create a GameObject with a single MeshFilter containing all Meshes combined
                    case MergeMethod.MergeAll:
                        finalGameObject = CreateGameObjectWithSingleMesh(model[i].transform, searchMatName, sourceMat);
                        break;
                    }

                    // ------------------------------------------------------------
                    // Add parent GameObject if requested and needed
                    // ------------------------------------------------------------

                    GameObject prefabGameObject;

                    // If adding an empty parent GameObject and the GameObject doesn't already have a an empty parent GameObject
                    if (flagAddEmptyParent && finalGameObject.GetComponent <MeshRenderer>())
                    {
                        // Create an empty parent with model's name and attach the gameobject as a child
                        prefabGameObject = new GameObject(model[i].name);
                        finalGameObject.transform.parent = prefabGameObject.transform;
                    }

                    // If not adding an empty parent GameObject or an empty parent GameObject already exists
                    else
                    {
                        // Create an empty parent with model's name
                        prefabGameObject = new GameObject(model[i].name);

                        // If the final GameObject has a MeshRenderer at its top level
                        if (finalGameObject.GetComponent <MeshRenderer>())
                        {
                            // Copy the MeshRender and MeshFilter to the Prefab
                            MeshRenderer meshRenderer = prefabGameObject.AddComponent <MeshRenderer>();
                            meshRenderer = finalGameObject.GetComponent <MeshRenderer>();

                            MeshFilter meshFilter = prefabGameObject.AddComponent <MeshFilter>();
                            meshFilter = finalGameObject.GetComponent <MeshFilter>();
                        }

                        // Move each child of the final GameObject to the Prefab manually, iterate through children in reverse since they will disappear
                        for (int j = finalGameObject.transform.childCount - 1; j > -1; j--)
                        {
                            finalGameObject.transform.GetChild(j).parent = prefabGameObject.transform;
                        }

                        // Delete the the empty final GameObject
                        GameObject.DestroyImmediate(finalGameObject);
                    }

                    // If user wants to add a MeshCollider to the Prefab
                    if (flagAddMeshCollider)
                    {
                        // Get all MeshRenderers in the Prefab
                        MeshRenderer[] meshRenderers = prefabGameObject.GetComponentsInChildren <MeshRenderer>();

                        // Add a MeshCollider to each GameObject with a MeshRenderer
                        foreach (MeshRenderer childMeshRenderer in meshRenderers)
                        {
                            childMeshRenderer.gameObject.AddComponent <MeshCollider>();
                        }
                    }

                    // ------------------------------------------------------------
                    // Save Prefab along with any Meshes it uses
                    // ------------------------------------------------------------

                    // Create a Prefab from the new GameObject, saving it as the model's name
                    GameObject prefab = PrefabUtility.SaveAsPrefabAsset(prefabGameObject, targetPath + "/Prefabs/" + model[i].name + ".prefab");

                    // Save all Meshes with the GameObject
                    AttachAllMeshesInGameObjectToPrefab(prefabGameObject.transform, prefab.transform, prefab);

                    // Delete the Prefab from the scene/Hierarchy
                    GameObject.DestroyImmediate(prefabGameObject);
                }

                // Save all changes
                AssetDatabase.SaveAssets();

                // Display a warning.  If the user clicks "Continue"
                if (EditorUtility.DisplayDialog("Prefab Creation Complete",
                                                "Successfully created " + model.Length + " prefabs!  They are located in the (" + targetPath + "/Prefabs"
                                                + ") folder.  The extracted Materials are located in (" + targetPath + "/Materials" + ") and the Prefab Meshes are located in ("
                                                + targetPath + "/Meshes).  The original models are no longer required for the prefabs.",
                                                "Got It!"))
                {
                }

                return(true);
            }
Esempio n. 25
0
        void OnGUI()
        {
            cancelled = false;
            GUILayout.Label("Conflicting files to resolve", EditorStyles.boldLabel);
            GUILayout.FlexibleSpace();

            // I would use GUIUtility.GetLastRect() here after the box but that seems to have wierd side effects.
            Rect r1 = new Rect(6, 40, position.width - 12, position.height - 112);  // 82

            GUILayout.BeginArea(r1);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndArea();

            bool repaint = resolveList.OnGUI(new Rect(r1.x + 2, r1.y + 2, r1.width - 4, r1.height - 4), true);

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUI.enabled = assetList.Count > 0;

            GUILayout.Label("Resolve selection by:");
            if (GUILayout.Button("using local version"))
            {
                SimpleMerge(ResolveMethod.UseMine);
            }

            if (GUILayout.Button("using incoming version"))
            {
                SimpleMerge(ResolveMethod.UseTheirs);
            }

            MergeMethod mergeMethod = MergeMethod.MergeNone;

            if (GUILayout.Button("merging"))
            {
                mergeMethod = MergeMethod.MergeAll;
            }

            if (mergeMethod != MergeMethod.MergeNone)
            {
                Task t = Provider.Merge(resolveList.SelectedAssets, mergeMethod);
                t.Wait();

                if (t.success)
                {
                    t = Provider.Resolve(t.assetList, ResolveMethod.UseMerged);
                    t.Wait();
                    if (t.success)
                    {
                        // Check that there are not more conflicts for the specified
                        // asset. This is possible in e.g. perforce where you handle
                        // one version conflict at a time.
                        t = Provider.Status(assetList);
                        t.Wait();

                        DoOpen(t.assetList);

                        if (t.success && assetList.Count == 0)
                        {
                            Close();
                        }

                        // The view will be updated with the new conflicts
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Error resolving", "Error during resolve of files. Inspect log for details", "Close");
                        AssetDatabase.Refresh();
                    }
                }
                else
                {
                    EditorUtility.DisplayDialog("Error merging", "Error during merge of files. Inspect log for details", "Close");
                    AssetDatabase.Refresh();
                }
            }

            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();
            GUILayout.Space(12);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUI.enabled = true;

            if (GUILayout.Button("Cancel"))
            {
                cancelled = true;
                Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(12);
            if (repaint)
            {
                Repaint();
            }
        }
Esempio n. 26
0
        public static void NestedLoop(MergeMethod JM, RecordWriter Output, FNodeSet Fields, Predicate Where, DataSet Data1, DataSet Data2,
            StaticRegister Memory1, StaticRegister Memory2)
        {

            switch (JM)
            {

                case MergeMethod.Cross:
                    CrossJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2);
                    break;
                case MergeMethod.Inner:
                    NestedLoopInnerJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2);
                    break;
                case MergeMethod.Left:
                    NestedLoopLeftJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, false);
                    break;
                case MergeMethod.Right:
                    NestedLoopRightJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, false);
                    break;
                case MergeMethod.Full:
                    NestedLoopLeftJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, false);
                    NestedLoopRightJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiLeft:
                    NestedLoopLeftJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiRight:
                    NestedLoopRightJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, true);
                    break;
                case MergeMethod.AntiInner:
                    NestedLoopLeftJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, true);
                    NestedLoopRightJoin(Output, Fields, Where, Data1, Data2, Memory1, Memory2, true);
                    break;

            }
        }
Esempio n. 27
0
 public CollectionBuildSettingEntry(CollectionBuildSettingEntry other)
     : base(other)
 {
     Values = new List <string>(other.Values);
     Merge  = other.Merge;
 }
        private void MergeCompound(TagCompound original, TagCompound compound, MergeMethod method)
        {
            if (method == MergeMethod.KeepSource)
            {
                foreach (TagCompound tag in compound.EnumerateCompounds())
                {
                    if (!original.ContainsTag(tag.Name))
                    {
                        // If the compound does not exist in the source structure, then simply add it.
                        original.AddCompound(tag);
                    }
                    else
                    {
                        // Otherwise, continue normal merging with that compound.
                        MergeCompound(compound, tag, method);
                    }
                }

                foreach (Tag tag in compound.EnumerateTags())
                {
                    // Adds the tag only if it does not exist in the source structure.
                    if (!original.ContainsTag(tag.Name))
                    {
                        original.AddTag(tag);
                    }
                }
            }
            else if (method == MergeMethod.Overwrite)
            {
                foreach (TagCompound tag in compound.EnumerateCompounds())
                {
                    if (!original.ContainsTag(tag.Name))
                    {
                        // If the compound does not exist in the source structure, then simply add it.
                        original.AddCompound(tag);
                    }
                    else
                    {
                        // Otherwise, continue normal merging with that compound.
                        MergeCompound(compound, tag, method);
                    }
                }

                foreach (Tag tag in compound.EnumerateTags())
                {
                    // If the tag already exists in the source structure, then remove it.
                    if (original.ContainsTag(tag.Name))
                    {
                        original.RemoveTag(tag.Name);
                    }

                    // Add the merged tag.
                    original.AddTag(tag);
                }
            }
            else if (method == MergeMethod.SourceOnly)
            {
                foreach (TagCompound tag in compound.EnumerateCompounds())
                {
                    if (original.ContainsTag(tag.Name))
                    {
                        MergeCompound(compound, tag, method);
                    }
                }

                foreach (Tag tag in compound.EnumerateTags())
                {
                    // Checks if the tag exists in the source structure.
                    if (original.ContainsTag(tag.Name))
                    {
                        Tag t = original.GetTag(tag.Name);

                        // Checks if there is a suitable conversion between the two tag types.
                        if (TagType.CanConvert(tag.Value, t.Type))
                        {
                            // Sets the value of the source tag to the converted value of the tag.
                            t.Value = TagType.ConvertTo(tag.Value, t.Type);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Merges the given structure with the current structure using the specified merging method.
 /// </summary>
 /// <param name="structure">The structure to merge.</param>
 /// <param name="method">The method of merging.</param>
 public void Merge(BinaryTagStructure structure, MergeMethod method)
 {
     MergeCompound(this, structure, method);
 }
Esempio n. 30
0
        // Hash Table - Collection Map //
        private static DataSet BuildJoinHelper(DataSet Data1, DataSet Data2, MergeMethod JM)
        {

            // Create the predicate fields //
            Key joiner = new Key();
            int T1Count = Data1.Columns.Count;
            for (int i = 2; i < T1Count; i++)
                joiner.Add(i);

            // Memory Registers //
            StaticRegister mem1 = new StaticRegister(null);
            StaticRegister mem2 = new StaticRegister(null);

            // Build the output fields //
            FNodeSet keeper = new FNodeSet();
            keeper.Add(new FNodeFieldRef(null, 0, CellAffinity.INT, 8, mem1));
            keeper.Add(new FNodeFieldRef(null, 1, CellAffinity.INT, 8, mem1));
            keeper.Add(new FNodeFieldRef(null, 0, CellAffinity.INT, 8, mem2));
            keeper.Add(new FNodeFieldRef(null, 1, CellAffinity.INT, 8, mem2));

            // Create the hashing variables //
            string dir = (Data1.Directory != null ? Data1.Directory : Data2.Directory);
            string name = Header.TempName();
            Schema s = new Schema("set_id1 int, row_id1 int, set_id2 int, row_id2 int");

            // Write the join result to the data set //
            DataSet hash = DataSet.CreateOfType(Data1, dir, name, s, Data1.MaxRecords);
            RecordWriter brw = hash.OpenWriter();
            MergeFunctions.SortMerge(JM, brw, keeper, Predicate.TrueForAll, Data1, Data2, joiner, joiner, mem1, mem2);
            brw.Close();

            // Return //
            return hash;

        }