Ejemplo n.º 1
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private static IBHoMObject _ShallowClone(this IBHoMObject bhomObject, bool newGuid = false)
        {
            IBHoMObject clone = DeepClonerExtensions.ShallowClone(bhomObject);

            if (bhomObject.CustomData != null)
            {
                clone.CustomData = new Dictionary <string, object>(bhomObject.CustomData);
            }
            else
            {
                clone.CustomData = new Dictionary <string, object>();
            }

            if (bhomObject.Tags != null)
            {
                clone.Tags = new HashSet <string>(bhomObject.Tags);
            }
            else
            {
                clone.Tags = new HashSet <string>();
            }

            if (newGuid)
            {
                clone.BHoM_Guid = Guid.NewGuid();
            }

            return(clone);
        }
Ejemplo n.º 2
0
        private bool jaExisteSequencia(string conexaoAtual, List <List <string> > rotas, List <string> caminhoAtual)
        {
            if (rotas.Count == 0 || caminhoAtual.Count == 0)
            {
                return(false);
            }
            List <string> newList = caminhoAtual;

            newList.Add(conexaoAtual);

            foreach (List <string> path in rotas)
            {
                List <string> listCompare = new List <string>();
                listCompare = DeepClonerExtensions.DeepClone(path);
                listCompare.Add(conexaoAtual);

                if (listCompare.SequenceEqual(newList))
                {
                    return(true);
                }

                //foreach (string str in path)
                //{
                //    if (!str.Equals(conexaoAtual))
                //        return false;
                //}
            }
            return(false);
        }
Ejemplo n.º 3
0
        public void ProfileCloning()
        {
#if NET46
            var root = BenchmarkObjectNonISerializablerDictionary.GetNewInitialized();
            DesertOctopus.ObjectCloner.Clone(root);

            var c = Clone.ObjectGraph(root);
            var d = DeepClonerExtensions.DeepClone(root);

            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < 100000; i++)
            {
                DesertOctopus.ObjectCloner.Clone(root);
            }

            sw.Stop();
            _output.WriteLine(sw.Elapsed.ToString());
#endif
        }
Ejemplo n.º 4
0
 public static T DeepClone <T>(this T obj)
 {
     return(DeepClonerExtensions.DeepClone(obj));
 }
Ejemplo n.º 5
0
        /***************************************************/

        private static object _ShallowClone(this object obj)
        {
            return(DeepClonerExtensions.ShallowClone(obj));
        }
Ejemplo n.º 6
0
 public Invoice DeepClone() => DeepClonerExtensions.DeepClone(this);