Esempio n. 1
0
        void _doc_MapDeleted(IMap map)
        {
            if (map == null)
            {
                return;
            }

            bool found = false;

            foreach (IEditLayer editLayer in ListOperations <IEditLayer> .Clone(_editLayers))
            {
                if (editLayer.FeatureLayer == null)
                {
                    _editLayers.Remove(editLayer);
                    found = true;
                }
                if (map[editLayer.FeatureLayer] != null)
                {
                    _editLayers.Remove(editLayer);
                    found = true;
                }
            }

            if (found &&
                OnEditLayerCollectionChanged != null)
            {
                OnEditLayerCollectionChanged(this);
            }
        }
Esempio n. 2
0
        void _doc_LayerRemoved(IMap sender, ILayer layer)
        {
            if (sender == null || layer == null || _doc == null)
            {
                return;
            }

            bool found = false;

            foreach (IEditLayer editLayer in ListOperations <IEditLayer> .Clone(_editLayers))
            {
                if (editLayer.FeatureLayer == null)
                {
                    _editLayers.Remove(editLayer);
                    found = true;
                }
                else if (editLayer.FeatureLayer == layer)
                {
                    _editLayers.Remove(editLayer);
                    found = true;
                }
            }

            if (found &&
                OnEditLayerCollectionChanged != null)
            {
                OnEditLayerCollectionChanged(this);
            }
        }
    public List <Room> GenerateOptions(Dictionary <Door, DirectionState> dictionaryDirections)
    {
        List <Room> disponibleRooms = new List <Room>();

        //disponibleRooms.Add(new Room(RoomTypeBacktracking.A)); // no tengo esta pieza
        disponibleRooms.Add(new Room(RoomType.B));
        disponibleRooms.Add(new Room(RoomType.C));
        disponibleRooms.Add(new Room(RoomType.D));
        disponibleRooms.Add(new Room(RoomType.E));
        disponibleRooms.Add(new Room(RoomType.F));
        disponibleRooms.Add(new Room(RoomType.G));
        disponibleRooms.Add(new Room(RoomType.H));
        disponibleRooms.Add(new Room(RoomType.I));

        /*
         * //Estas las generaremos al final
         * disponibleRooms.Add(new Room(RoomTypeBacktracking.J));
         * disponibleRooms.Add(new Room(RoomTypeBacktracking.K));
         * disponibleRooms.Add(new Room(RoomTypeBacktracking.L));
         * disponibleRooms.Add(new Room(RoomTypeBacktracking.M));
         */

        disponibleRooms.Add(new Room(RoomType.N));
        disponibleRooms.Add(new Room(RoomType.O));

        List <Room> compatibles = new List <Room>();

        //bucle añadiendo a compatibles todas las que tengan Up false
        compatibles = Filter(dictionaryDirections, disponibleRooms);

        //Randomize list
        ListOperations.Shuffle <Room>(compatibles);

        return(compatibles);
    }
Esempio n. 4
0
        public void ConvertTree_ValidTree_ConvertsToCircularLinkedList()
        {
            // arrange
            BinaryTreeNode root = new BinaryTreeNode("0-root");
            root.Left = new BinaryTreeNode("1-left");
            root.Right = new BinaryTreeNode("1-right");
            root.Left.Left = new BinaryTreeNode("2-left-left");
            root.Left.Right = new BinaryTreeNode("2-left-right");
            root.Right.Left = new BinaryTreeNode("2-right-left");
            root.Right.Right = new BinaryTreeNode("2-right-right");
            root.Right.Right.Left = new BinaryTreeNode("3-right-right-left");
            root.Right.Right.Left.Right = new BinaryTreeNode("4-right-right-left-right");
            ListOperations ops = new ListOperations();

            // act
            ListOperations.LinkedListNode actual = ops.ConvertTree(root);

            // assert
            Assert.AreEqual(root.Value, actual.Value);
            Assert.AreEqual(root.Left.Value, actual.Next.Value);
            Assert.AreEqual(root.Right.Value, actual.Next.Next.Value);
            Assert.AreEqual(root.Left.Left.Value, actual.Next.Next.Next.Value);
            Assert.AreEqual(root.Left.Right.Value, actual.Next.Next.Next.Next.Value);
            Assert.AreEqual(root.Right.Left.Value, actual.Next.Next.Next.Next.Next.Value);
            Assert.AreEqual(root.Right.Right.Value, actual.Next.Next.Next.Next.Next.Next.Value);
            Assert.AreEqual(root.Right.Right.Left.Value, actual.Next.Next.Next.Next.Next.Next.Next.Value);
            Assert.AreEqual(root.Right.Right.Left.Right.Value, actual.Next.Next.Next.Next.Next.Next.Next.Next.Value);
            Assert.AreEqual(actual, actual.Next.Next.Next.Next.Next.Next.Next.Next.Next);
        }
 //init
 public TemporaryStorage()
 {
     _reflectionInvoker     = new ReflectionInvoker();
     _listOperations        = new ListOperations();
     _runningTasks          = new List <Task>();
     _entitiesAwaitingFlush = new Dictionary <Type, IList>();
 }
        public void List_Align_ThreeLists_AllMismatch()
        {
            List <ICanAlign> l1 = new List <ICanAlign>();
            List <ICanAlign> l2 = new List <ICanAlign>();
            List <ICanAlign> l3 = new List <ICanAlign>();

            l1.Add(new RootDetail("X3"));
            l1.Add(new RootDetail("X4"));

            l2.Add(new RootDetail("X2"));
            l2.Add(new RootDetail("X5"));

            l3.Add(new RootDetail("X1"));
            l3.Add(new RootDetail("X6"));

            ListOperations.AlignListsNoParent(l1, l2, l3);
            ListOperations.CheckAlignment(l1, l2);
            ListOperations.CheckAlignment(l3, l2);
            ListOperations.CheckAlignment(l1, l3);

            Assert.AreEqual(Status.Missing, l1[0].Status);
            Assert.AreEqual(Status.Missing, l2[0].Status);
            Assert.AreEqual("X1", l3[0].Name);

            Assert.AreEqual("X4", l1[3].Name);
            Assert.AreEqual(Status.Missing, l2[3].Status);
            Assert.AreEqual(Status.Missing, l3[3].Status);
        }
Esempio n. 7
0
        public void Test_Reverse_Sort()
        {
            string    input = RandomString((int)Math.Pow(10, 8));
            Stopwatch sw    = new Stopwatch();

            Debug.WriteLine("test begin");
            sw.Start();
            string test = ListOperations.Reverse(input);

            sw.Stop();
            var testDuration = sw.Elapsed;

            Debug.WriteLine("test end");
            Debug.WriteLine(sw.Elapsed.Ticks);
            Debug.WriteLine("control begin");
            sw.Reset();
            sw.Start();
            string control = Control(input);

            sw.Stop();
            var controlDuration = sw.Elapsed;

            Debug.WriteLine("control end");
            Debug.WriteLine(sw.Elapsed.Ticks);
            Assert.AreEqual(test, control);
            if (testDuration > controlDuration)
            {
                Debug.WriteLine("Control Wins");
            }
            else
            {
                Debug.WriteLine("Test Wins");
            }
        }
Esempio n. 8
0
 public void CloseAllConnections(IDataset dataset)
 {
     lock (_thisLock)
     {
         foreach (SdeConnection sdeConnection in _freeConnections)
         {
             if (dataset == null || sdeConnection.Dataset == dataset)
             {
                 if (sdeConnection.SeConnection.handle != IntPtr.Zero)
                 {
                     CloseConnection(sdeConnection);
                 }
             }
         }
         foreach (SdeConnection sdeConnection in ListOperations <SdeConnection> .Clone(_usedConnections))
         {
             if (dataset == null || sdeConnection.Dataset == dataset)
             {
                 CloseConnection(sdeConnection);
                 _usedConnections.Remove(sdeConnection);
                 _freeConnections.Add(sdeConnection);
             }
         }
     }
 }
Esempio n. 9
0
        private ClassDetail ExtractNestedClass(string assembly, string className, string interfaceName)
        {
            ClassDetail cd = ExtractClass(assembly, className);

            Assert.AreEqual(Status.Present, cd.Status);
            return(ListOperations.FindOrReturnMissing(cd.FilterChildren <ClassDetail>(), interfaceName));
        }
Esempio n. 10
0
        public bool RemoveMap(string mapName, string usr, string pwd)
        {
            if (IMS.acl != null && !IMS.acl.HasAccess(Identity.FromFormattedString(usr), pwd, "admin_removemap"))
            {
                return(false);
            }

            bool found = false;

            foreach (IMapService service in ListOperations <IMapService> .Clone(IMS.mapServices))
            {
                if (service.Name == mapName)
                {
                    IMS.mapServices.Remove(service);
                    found = true;
                }
            }

            foreach (IMap m in ListOperations <IMap> .Clone(IMS.mapDocument.Maps))
            {
                if (m.Name == mapName)
                {
                    _doc.RemoveMap(m);
                    found = true;
                }
            }
            IMS.RemoveConfig(mapName);

            return(found);
        }
Esempio n. 11
0
        async public void Content_DragDrop(System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
            }
            else
            {
                foreach (string format in e.Data.GetFormats())
                {
                    object ob = e.Data.GetData(format);
                    if (ob is IEnumerable <IExplorerObjectSerialization> )
                    {
                        ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                        List <IExplorerObject> exObjects = await exObjectManager.DeserializeExplorerObject((IEnumerable <IExplorerObjectSerialization>) ob);

                        if (exObjects == null)
                        {
                            return;
                        }

                        _dataset = await((IExplorerObject)this).GetInstanceAsync() as IFeatureDataset;

                        foreach (IExplorerObject exObject in ListOperations <IExplorerObject> .Clone(exObjects))
                        {
                            IFeatureClass fc = await exObject.GetInstanceAsync() as IFeatureClass;

                            if (fc == null)
                            {
                                continue;
                            }

                            if (fc.Dataset != null && fc.Dataset.ConnectionString.ToLower() == _dataset.ConnectionString.ToLower())
                            {
                                exObjects.Remove(exObject);
                            }
                        }
                        if (exObjects.Count == 0)
                        {
                            return;
                        }

                        FormFeatureclassCopy dlg = await FormFeatureclassCopy.Create(exObjects, _dataset);

                        if (dlg.ShowDialog() != DialogResult.OK)
                        {
                            continue;
                        }

                        foreach (FeatureClassListViewItem fcItem in dlg.FeatureClassItems)
                        {
                            await ImportDatasetObject(fcItem);
                        }
                        exObjectManager.Dispose(); // alle ExplorerObjects wieder löschen...
                    }
                }
            }
            await this.Refresh();
        }
Esempio n. 12
0
 public Task RemoveFirstFromList(string listName, int count)
 {
     for (int i = 0; i < count; i++)
     {
         ListOperations.RemoveItem(listName, 0);
     }
     return(Task.CompletedTask);
 }
Esempio n. 13
0
        protected MethodDetail ExtractOperator(string assemblyFile, string typeName, string OperatorName, DiffConfig config)
        {
            ClassDetail ci = ExtractClass(assemblyFile, typeName, config);

            MethodDetail value = ListOperations.FindOrReturnMissing(ci.FilterChildren <OperatorDetail>(), OperatorName);

            Log.Verbose("Extracted Operator : {0}", value);
            return(value);
        }
Esempio n. 14
0
        protected FieldDetail ExtractField(string assemblyFile, string typeName, string fieldName, DiffConfig config)
        {
            ClassDetail ci = ExtractClass(assemblyFile, typeName, config);

            FieldDetail value = ListOperations.FindOrReturnMissing(ci.FilterChildren <FieldDetail>(), fieldName);

            Log.Verbose("Extracted field : {0}", value);
            return(value);
        }
Esempio n. 15
0
        protected PropertyDetail ExtractProperty(string assemblyFile, string typeName, string propertyName, DiffConfig config)
        {
            ClassDetail ci = ExtractClass(assemblyFile, typeName, config);

            PropertyDetail value = ListOperations.FindOrReturnMissing(ci.FilterChildren <PropertyDetail>(), propertyName);

            Log.Verbose("Extracted property : {0}", value);
            return(value);
        }
Esempio n. 16
0
        protected T ExtractItem <T>(string assemblyFile, string name, DiffConfig config) where T : ICanAlign, new()
        {
            AssemblyDetail all = ExtractAll(assemblyFile, config);

            T t = ListOperations.FindOrReturnMissing(all.FilterChildren <T>(), name);

            Log.Verbose("Extracted Item {0} : {1}", t.GetType().Name, t.ToString());
            return(t);
        }
Esempio n. 17
0
        protected EventDetail ExtractEvent(string assemblyFile, string typeName, string eventName, DiffConfig config)
        {
            ClassDetail ci = ExtractClass(assemblyFile, typeName, config);

            EventDetail value = ListOperations.FindOrReturnMissing(ci.FilterChildren <EventDetail>(), eventName);

            Log.Verbose("Extracted event : {0}", value);
            return(value);
        }
Esempio n. 18
0
        protected virtual void CompareChildren(ICanCompare from, bool suppressBreakingChanges)
        {
            ListOperations.CheckAlignment(from.Children, _children);

            for (int i = 0; i < from.Children.Count; i++)
            {
                ((RootDetail)_children[i]).PerformCompareInternal((ICanCompare)from.Children[i], suppressBreakingChanges || this.SuppressBreakingChangesInChildren);
            }
        }
Esempio n. 19
0
        public void Class_Nested_TwiceClassExtraction()
        {
            ClassDetail ci = ExtractNestedClass(Subjects.One, "ParentClass", "NestedProtectedClass");

            Assert.AreEqual(Status.Present, ci.Status);
            ClassDetail gc = ListOperations.FindOrReturnMissing <ClassDetail>(ci.FilterChildren <ClassDetail>(), "NestedGrandchildClass");

            Assert.AreEqual(Status.Present, gc.Status);
        }
Esempio n. 20
0
        public List <long> CollectNIDs(IGeometry geometry)
        {
            if (geometry is IEnvelope)
            {
                // Schnelle Suche für Envelope (GetMap)
                return(CollectNIDs(geometry as IEnvelope));
            }
            // sonst ausführliche Suche

            //
            //  Envelopes der Geometrie Teile bestimmen
            //
            List <IEnvelope> envelops = gView.Framework.SpatialAlgorithms.Algorithm.PartEnvelops(geometry);

            List <long> ids = new List <long>();

            //if (_nodeNumbers.BinarySearch(0) > -1) ids.Add(0);

            //
            //  IDs für die Envelopes suchen
            //
            foreach (IEnvelope envelope in envelops)
            {
                if (envelops == null)
                {
                    continue;
                }

                NodeNumbers nn = new NodeNumbers(_nodeNumbers);
                Collect(0, 0, envelope, _bounds, nn, ids, true);
                ids.Sort();
            }

            //
            //  IDs wieder entfernen, die sich nicht mit der Geometrie schneiden
            //
            foreach (long id in ListOperations <long> .Clone(ids))
            {
                IEnvelope bound = this[id];
                if (!SpatialAlgorithms.Algorithm.IntersectBox(geometry, bound))
                {
                    ids.Remove(id);
                }
            }

            if (ids.Count == 0)
            {
                ids.Add(0);
            }
            else if (ids.IndexOf(0) == -1 && _nodeNumbers.BinarySearch(0) > -1)
            {
                ids.Add(0);
            }

            return(ids);
        }
Esempio n. 21
0
 public void Remove(string name, string path)
 {
     foreach (Favorite fav in ListOperations <Favorite> .Clone(this))
     {
         if (fav.Name == name && fav.Path == path)
         {
             this.Remove(fav);
         }
     }
 }
Esempio n. 22
0
 public void ShowOperation(ListOperations operation)
 {
     OperationControllers.ForEach(obj =>
     {
         if (obj.OperationType.Equals(operation))
         {
             obj.gameObject.SetActive(true);
         }
     });
 }
Esempio n. 23
0
 public void Remove(IFeatureLayer layer)
 {
     foreach (ISnapLayer sLayer in ListOperations <ISnapLayer> .Clone(_snapLayers))
     {
         if (sLayer.FeatureLayer == layer)
         {
             _snapLayers.Remove(sLayer);
         }
     }
 }
Esempio n. 24
0
            public void Order()
            {
                this.Sort();
                List <double> scales = ListOperations <double> .Swap((List <double>) this);

                this.Clear();
                foreach (double s in scales)
                {
                    this.Add(s);
                }
            }
Esempio n. 25
0
        protected void Align(RootDetail t1, RootDetail t2)
        {
            List <List <ICanAlign> > lists = new List <List <ICanAlign> >();

            lists.Add(new List <ICanAlign>());
            lists.Add(new List <ICanAlign>());

            lists[0].Add(t1);
            lists[1].Add(t2);

            ListOperations.AlignListsNoParent(lists.ToArray());
        }
Esempio n. 26
0
        public async Task ShowList(string listName)
        {
            var list  = ListOperations.GetList(listName);
            var embed = new EmbedBuilder();

            embed.WithTitle(listName.First().ToString().ToUpper() + listName.Substring(1));
            for (int i = 0; i < list.Count; i++)
            {
                embed.AddField((i + 1).ToString() + ". " + list[i].Item1, list[i].Item2);
            }
            await Context.Channel.SendMessageAsync("", embed : embed);
        }
Esempio n. 27
0
        public async Task GetPosition(string listName, string item)
        {
            int pos = ListOperations.GetItemPosition(listName, item);

            if (pos == 0)
            {
                await Context.Channel.SendMessageAsync(Strings.GetString("WAITING_NO_ITEM"));
            }
            else
            {
                await Context.Channel.SendMessageAsync(pos.ToString());
            }
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            ListOperations list = new ListOperations();

            list.Add(4);
            list.Add(2);
            list.Add(10);
            list.Add(7);
            list.Add(34);
            list.Reverse();
            list.ForEach();
            list.Sort();
            list.ForEach();
        }
        public void List_Align_OneEmpty()
        {
            List <ICanAlign> l1 = new List <ICanAlign>();
            List <ICanAlign> l2 = new List <ICanAlign>();

            l2.Add(new RootDetail("X3"));
            l2.Add(new RootDetail("X2"));
            l2.Add(new RootDetail("X1"));

            ListOperations.AlignListsNoParent(l1, l2);
            ListOperations.CheckAlignment(l1, l2);

            Assert.AreEqual("X1", l2[0].Name);
            Assert.AreEqual(Status.Missing, l1[0].Status);
        }
Esempio n. 30
0
        public static List <ILayer> FindAdditionalWebServiceLayers(IWebServiceClass wsClass, List <ILayer> layers)
        {
            if (wsClass == null || layers == null)
            {
                return(layers);
            }

            List <ILayer> clonedLayers = ListOperations <ILayer> .Clone(layers);

            foreach (IWebServiceTheme theme in wsClass.Themes)
            {
                clonedLayers.Remove(theme);
            }

            return(clonedLayers);
        }
Esempio n. 31
0
 public void CloseAllConnections()
 {
     foreach (SdeConnection sdeConnection in _freeConnections)
     {
         if (sdeConnection.SeConnection.handle != 0)
         {
             CloseConnection(sdeConnection);
         }
     }
     foreach (SdeConnection sdeConnection in ListOperations <SdeConnection> .Clone(_usedConnections))
     {
         CloseConnection(sdeConnection);
         _usedConnections.Remove(sdeConnection);
         _freeConnections.Add(sdeConnection);
     }
 }
        /// <summary>
        /// Returns a new <see cref="DataClass"/> entity list.
        /// </summary>
        /// <param name="count">The number of items to be put in the list.</param>
        /// <param name="supportedOperations">The supported operations for the list.</param>
        /// <returns>The entity list.</returns>
        public static DataClassList GetDataClassList(int count, ListOperations supportedOperations)
        {
            DataClassList dataClassList = new DataClassList();

            for (int i = 0; i < count; i++)
            {
                DataClass dataClass = new DataClass()
                {
                    BoolProperty = (i % 2 == 0),
                    DateTimeProperty = new DateTime(2000 + i, 1 + (i % 12), 1 + (i % 28)),
                    IntProperty = i * 3,
                    IntPropertyWithoutAutoGenerateField = (i * 3) + 1,
                    NonGeneratedIntProperty = (i * 3) + 2,
                    StringProperty = "test string " + i.ToString(CultureInfo.CurrentCulture)
                };

                dataClass.AcceptChanges();
                dataClassList.Add(dataClass);
            }

            dataClassList.supportedOperations = supportedOperations;
            return dataClassList;
        }