示例#1
0
        /*
         * Adjust Clone to simply copy the object instance
         *
         *
         */
        public IBinaryDataList Merge(IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool newList, out ErrorResultTO errors)
        {
            IBinaryDataList mergeResult = newList ? Clone(depth, out errors, false) : this;

            // do the merge ;)
            ((BinaryDataList)mergeResult).MergeIntoInstance(right, mergeType, depth, out errors);

            return(mergeResult);
        }
示例#2
0
 /// <summary>
 /// Conditionals the merge.
 /// </summary>
 /// <param name="conditions">The conditions.</param>
 /// <param name="destinationDatalistID">The destination datalist ID.</param>
 /// <param name="sourceDatalistID">The source datalist ID.</param>
 /// <param name="datalistMergeFrequency">The datalist merge frequency.</param>
 /// <param name="datalistMergeType">Type of the datalist merge.</param>
 /// <param name="datalistMergeDepth">The datalist merge depth.</param>
 public void ConditionalMerge(DataListMergeFrequency conditions,
                              Guid destinationDatalistID, Guid sourceDatalistID, DataListMergeFrequency datalistMergeFrequency,
                              enDataListMergeTypes datalistMergeType, enTranslationDepth datalistMergeDepth)
 {
     _svrCompiler.ConditionalMerge(null, conditions, destinationDatalistID, sourceDatalistID, datalistMergeFrequency, datalistMergeType, datalistMergeDepth);
 }
示例#3
0
 /// <summary>
 /// Merges the specified left.
 /// </summary>
 /// <param name="left">The left.</param>
 /// <param name="right">The right.</param>
 /// <param name="mergeType">Type of the merge.</param>
 /// <param name="depth">The depth.</param>
 /// <param name="createNewList">if set to <c>true</c> [create new list].</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public IBinaryDataList Merge(IBinaryDataList left, IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool createNewList, out ErrorResultTO errors)
 {
     return(left.Merge(right, mergeType, depth, createNewList, out errors));
 }
示例#4
0
 /// <summary>
 /// Merges the specified left ID with the right ID
 /// </summary>
 /// <param name="leftID">The left ID.</param>
 /// <param name="rightID">The right ID.</param>
 /// <param name="mergeType">Type of the merge.</param>
 /// <param name="depth"></param>
 /// <param name="createNewList"></param>
 /// <param name="errors"></param>
 /// <returns></returns>
 public Guid Merge(Guid leftID, Guid rightID, enDataListMergeTypes mergeType, enTranslationDepth depth, bool createNewList, out ErrorResultTO errors)
 {
     return(_svrCompiler.Merge(null, leftID, rightID, mergeType, depth, createNewList, out errors));
 }
        /// <summary>
        /// Merges the into instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        private void MergeIntoInstance(IBinaryDataList obj, enDataListMergeTypes typeOf, enTranslationDepth depth, out ErrorResultTO errorResult)
        {

            errorResult = new ErrorResultTO();
            BinaryDataList toClone = (BinaryDataList)obj;
            if(obj.ParentUID != UID)
            {
                ParentUID = toClone.ParentUID;
            }
            IList<string> lamdaErrors = new List<string>();
            IList<string> errorList = new List<string>();
            IList<string> unionKeyHits = new List<string>();

            // clone the dictionary
            IList<string> tmp = _templateDict.Keys.ToList();  // must be this way since we modify the collection...
            foreach(string e in tmp)
            {
                string error;
                IBinaryDataListEntry cloned;

                if(typeOf == enDataListMergeTypes.Union)
                {
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry fetchTmp;
                    if(toClone._templateDict.TryGetValue(e, out fetchTmp))
                    {
                        unionKeyHits.Add(e);
                        cloned = fetchTmp.Clone(depth, UID, out error);
                        if(error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }

                        // We need to ensure that the intellisense dictionary is populated with this key ;)

                    }
                }
                else if(typeOf == enDataListMergeTypes.Intersection)
                {
                    IBinaryDataListEntry toFetch;
                    if(toClone.TryGetEntry(e, out toFetch, out error))
                    {
                        cloned = toClone._templateDict[e].Clone(depth, UID, out error);
                        if(error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }
                    }
                    else
                    {
                        lamdaErrors.Add("Missing DataList item [ " + e + " ] ");
                    }
                }

                // compile error list ?!
                foreach(string err in lamdaErrors)
                {
                    errorList.Add(err);
                }
                lamdaErrors.Clear();
            }


            // now process key misses for union
            if(typeOf == enDataListMergeTypes.Union)
            {
                //toClone._templateDict.Keys
                foreach(string k in (toClone._templateDict.Keys.ToArray().Except(unionKeyHits)))
                {
                    string error;
                    IBinaryDataListEntry cloned = toClone._templateDict[k].Clone(depth, UID, out error);
                    if(error != string.Empty)
                    {
                        lamdaErrors.Add(error);
                    }
                    else
                    {
                        DepthMerge(depth, cloned, k, out lamdaErrors);
                    }
                }
            }

            // now build the silly composite object since lamba is an daft construct
            // how about proper exception handling MS?!
            foreach(string err in errorList)
            {
                errorResult.AddError(err);
            }
        }
        /*
         * Adjust Clone to simply copy the object instance
         * 
         * 
         */
        public IBinaryDataList Merge(IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool newList, out ErrorResultTO errors)
        {
            IBinaryDataList mergeResult = newList ? Clone(depth, out errors, false) : this;

            // do the merge ;)
            ((BinaryDataList)mergeResult).MergeIntoInstance(right, mergeType, depth, out errors);

            return mergeResult;
        }
示例#7
0
        /// <summary>
        /// Merges the into instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        private void MergeIntoInstance(IBinaryDataList obj, enDataListMergeTypes typeOf, enTranslationDepth depth, out ErrorResultTO errorResult)
        {
            errorResult = new ErrorResultTO();
            BinaryDataList toClone = (BinaryDataList)obj;

            if (obj.ParentUID != UID)
            {
                ParentUID = toClone.ParentUID;
            }
            IList <string> lamdaErrors  = new List <string>();
            IList <string> errorList    = new List <string>();
            IList <string> unionKeyHits = new List <string>();

            // clone the dictionary
            IList <string> tmp = _templateDict.Keys.ToList();  // must be this way since we modify the collection...

            foreach (string e in tmp)
            {
                string error;
                IBinaryDataListEntry cloned;

                if (typeOf == enDataListMergeTypes.Union)
                {
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry fetchTmp;
                    if (toClone._templateDict.TryGetValue(e, out fetchTmp))
                    {
                        unionKeyHits.Add(e);
                        cloned = fetchTmp.Clone(depth, UID, out error);
                        if (error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }

                        // We need to ensure that the intellisense dictionary is populated with this key ;)
                    }
                }
                else if (typeOf == enDataListMergeTypes.Intersection)
                {
                    IBinaryDataListEntry toFetch;
                    if (toClone.TryGetEntry(e, out toFetch, out error))
                    {
                        cloned = toClone._templateDict[e].Clone(depth, UID, out error);
                        if (error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }
                    }
                    else
                    {
                        lamdaErrors.Add("Missing DataList item [ " + e + " ] ");
                    }
                }

                // compile error list ?!
                foreach (string err in lamdaErrors)
                {
                    errorList.Add(err);
                }
                lamdaErrors.Clear();
            }


            // now process key misses for union
            if (typeOf == enDataListMergeTypes.Union)
            {
                //toClone._templateDict.Keys
                foreach (string k in (toClone._templateDict.Keys.ToArray().Except(unionKeyHits)))
                {
                    string error;
                    IBinaryDataListEntry cloned = toClone._templateDict[k].Clone(depth, UID, out error);
                    if (error != string.Empty)
                    {
                        lamdaErrors.Add(error);
                    }
                    else
                    {
                        DepthMerge(depth, cloned, k, out lamdaErrors);
                    }
                }
            }

            // now build the silly composite object since lamba is an daft construct
            // how about proper exception handling MS?!
            foreach (string err in errorList)
            {
                errorResult.AddError(err);
            }
        }