コード例 #1
0
        public void NewLayer_AddingANewLayer()
        {
            // The layer Dictionary
            var layerDictionary = new LayerDictionary();

            // The inital count should be 0
            Assert.IsTrue(layerDictionary.Count == 0);
            // Adding one layer
            layerDictionary.NewLayer("HelloWorld");
            // Now the count should be 1
            Assert.IsTrue(layerDictionary.Count == 1);
        }
コード例 #2
0
        public void ContainsLayer_ShouldContainTheLayerHelloWorld()
        {
            // The layer Dictionary
            var layerDictionary = new LayerDictionary();

            // The inital count should be 0
            Assert.IsTrue(layerDictionary.Count == 0);
            // Adding one layer
            layerDictionary.NewLayer("HelloWorld");
            // Now the count should be 1
            Assert.IsTrue(layerDictionary.Count == 1);
            // The layerDic should contain the layer HelloWorld
            Assert.IsTrue(layerDictionary.ContainsLayer("HelloWorld"));
            Assert.IsFalse(layerDictionary.ContainsLayer("ShouldNotContain"));
        }
コード例 #3
0
        public void GetLayer_ShouldGetHelloWorldLayer()
        {
            // The layer Dictionary
            var layerDictionary = new LayerDictionary();

            // The inital count should be 0
            Assert.IsTrue(layerDictionary.Count == 0);

            // Adding one layer
            layerDictionary.NewLayer("HelloWorld");

            // Now the count should be 1
            Assert.IsTrue(layerDictionary.Count == 1);

            // Get the layer HelloWorld
            var testGetLayer = layerDictionary.GetLayer("HelloWorld");

            Assert.IsTrue(testGetLayer.Name == "HelloWorld");
        }
コード例 #4
0
ファイル: DxfFile.cs プロジェクト: zixuan203344/Dxflib
        /// <summary>
        ///     Constructor that requires a path to a file.
        ///     This constructor will read the file and set up all of the required
        ///     tools for the DxfFile class
        /// </summary>
        /// <param name="pathToFile">An absolute or relative path to a dxf file</param>
        public DxfFile(string pathToFile)
        {
            // Initialize
            var fileReader = new DxfReader(pathToFile);

            Layers = new LayerDictionary();

            // Setup file
            PathToFile  = fileReader.PathToFile;
            FileName    = Path.GetFileName(PathToFile);
            DxfFileData = new TaggedDataList(fileReader.ReadFile());

            // The Main Parsing Calling Function
            var asciiParser = new AsciiParser(this);

            asciiParser.ParseFile();

            // Update the layer dictionary now that the Entities are all built
            Layers.UpdateDictionary(Entities.Values);
        }
コード例 #5
0
        public void UpdateDictionaryTest()
        {
            // The test Dictionary
            var testDictionary = new LayerDictionary();

            // TestLine 0
            var testLine0 = new Line(new LineBuffer
            {
                EntityType = typeof(Line),
                Handle     = "1A",
                LayerName  = "TestLayer",
                Thickness  = 0,
                X0         = 0,
                X1         = 0,
                Y0         = 1,
                Y1         = 2
            });

            // TestLine1
            var testLine1 = new Line(new LineBuffer
            {
                EntityType = typeof(Line),
                Handle     = "2A",
                LayerName  = "TestLayer",
                Thickness  = 0,
                X0         = 0,
                X1         = 0,
                Y0         = 1,
                Y1         = 2
            });

            // Place the entities into a list
            var entities = new List <Entity> {
                testLine0, testLine1
            };

            // Create the Dictionary
            testDictionary.UpdateDictionary(entities);

            // Update Dictionary should have created the layer test Layer
            Assert.IsTrue(testDictionary.ContainsLayer("TestLayer"));
            Assert.IsTrue(testDictionary.Count == 1);
            // Change the layer of the second line
            testLine1.LayerName = "NewLayer";

            // Assert that the new layer was created,
            // The second line is now a member of the new layer and
            // that is is not a member of the old layer
            Assert.IsTrue(testDictionary.ContainsLayer("NewLayer"));
            Assert.IsTrue(testDictionary.GetLayer("NewLayer").ContainsEntity(testLine1.Handle));
            Assert.IsFalse(testDictionary.GetLayer("TestLayer").ContainsEntity(testLine1.Handle));

            // Now let us move it back
            testLine1.LayerName = "TestLayer";

            // Assert that the layer was changed back to TestLayer
            // Assert that it is no longer a member of NewLayer
            // Assert that the count of Newlayer is 0
            Assert.IsTrue(testDictionary.GetLayer("TestLayer").ContainsEntity(testLine1.Handle));
            Assert.IsFalse(testDictionary.GetLayer("NewLayer").ContainsEntity(testLine1.Handle));
            Assert.IsTrue(testDictionary.GetLayer("NewLayer").Count == 0);
        }
コード例 #6
0
        public void GetLayer_LayerDoesNotExist_LayerDictionaryExceptionThrown()
        {
            var layerDictionary = new LayerDictionary();

            layerDictionary.GetLayer("ThisShouldFail");
        }
コード例 #7
0
 public NameRegistry(bool shadowing)
 {
     this.bag    = LayerDictionary.Create <ITemplateName, LocalInfo>(shadowing, EntityNameArityComparer.Instance);
     this.scopes = new Stack <IScope>();
 }
コード例 #8
0
 public VariableRegistry(bool shadowing)
 {
     this.bag = LayerDictionary.Create <IOwnedNode, ObjectData>(shadowing, ReferenceEqualityComparer <IOwnedNode> .Instance);
 }