public void ShouldResolveTypeAliasesInTypeShape_unresolved()
        {
            CompleteInNamespace(@"
                using I2 = X;
                using S2 = S;
                class S { }
                class C : S2, I2
                {
                    $
                }
            ");
            var actual   = ResultContext.TypeShape;
            var expected = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element = Names.Type("N.C, TestProject"),
                    Extends = new TypeHierarchy
                    {
                        Element = Names.Type("N.S, TestProject")
                    },
                    Implements =
                    {
                        new TypeHierarchy
                        {
                            Element = Names.UnknownType
                        }
                    }
                }
            };

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
 public ItemLayer(TypeShape type)
 {
     InitializeComponent();
     typeShape = type;
     if (type == TypeShape.Line)
     {
         objectBase = new LineObject();
     }
     else if (type == TypeShape.Rectangle)
     {
         objectBase = new RectangleObject();
     }
     else if (type == TypeShape.Ellipse)
     {
         objectBase = new EllipseObject();
     }
     else if (type == TypeShape.PolyLine)
     {
         objectBase = new PolyLineObject();
     }
     else if (type == TypeShape.PolyGon)
     {
         objectBase = new PolyGonObject();
     }
     else if (type == TypeShape.Text)
     {
         objectBase = new TextObject();
     }
 }
        public void RecursiveTypeDefinition()
        {
            CompleteInCSharpFile(@"
                namespace N
                {
                    class C : C {
                        public override int M() {
                            $
                        }
                    }
                }");

            var actual   = ResultContext.TypeShape;
            var expected = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element = Type("C")
                },
                MethodHierarchies =
                {
                    new MethodHierarchy(Names.Method("[{0}] [N.C, TestProject].M()", Fix.Int))
                }
            };

            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public override void CreateShape(EntityType type)
        {
            {
                state        = State.CreatingShape;
                shapeType    = type;
                newShapeType = type;

                switch (type)
                {
                case EntityType.Class:
                case EntityType.Delegate:
                case EntityType.Enum:
                case EntityType.Interface:
                case EntityType.Structure:
                    shapeOutline = TypeShape.GetOutline(Style.CurrentStyle);
                    break;

                case EntityType.Package:
                    shapeOutline = PackageShape.GetOutline(Style.CurrentStyle);
                    break;

                case EntityType.Comment:
                    shapeOutline = CommentShape.GetOutline(Style.CurrentStyle);
                    break;
                }
                shapeOutline.Location = new Point((int)mouseLocation.X, (int)mouseLocation.Y);
                Redraw();
            }
        }
Exemple #5
0
        public void Mark(TypeShape typeShape)
        {
            if (IsMarked())
                throw new Exception("This cell is already marked.");

            MarkedBy = typeShape;
        }
Exemple #6
0
        public void PropertyHierarchies()
        {
            var actual = _sut.Anonymize(
                new TypeShape
            {
                PropertyHierarchies =
                {
                    new PropertyHierarchy
                    {
                        Element = P("A"),
                        Super   = P("B"),
                        First   = P("C")
                    }
                }
            });
            var expected =
                new TypeShape
            {
                PropertyHierarchies =
                {
                    new PropertyHierarchy
                    {
                        Element = P("A").ToAnonymousName(),
                        Super   = P("B").ToAnonymousName(),
                        First   = P("C").ToAnonymousName()
                    }
                }
            };

            Assert.AreEqual(expected, actual);
        }
Exemple #7
0
    public void GenerateShape(int[,] shape, TypeShape type)
    {
        int r = 0;

        switch (type)
        {
        case TypeShape.crossBar_1:
            shape = CtrlData.Cube_Cross_1;
            r     = CtrlData.NotRoll;
            break;

        case TypeShape.crossBar_2:

            shape = CtrlData.Cube_Cross_2;
            r     = CtrlData.Roll_Cross;
            break;

        case TypeShape.crossBar_3:

            shape = CtrlData.Cube_Cross_3;
            r     = CtrlData.Roll_Cross;
            break;

        case TypeShape.crossBar_4:
            shape = CtrlData.Cube_Cross_4;
            r     = CtrlData.Roll_Cross;
            break;

        case TypeShape.square:
            shape = CtrlData.Cube_Quare;
            r     = CtrlData.NotRoll;
            break;

        case TypeShape.L_4_0:
            shape = CtrlData.Cube_L4_0;
            r     = CtrlData.Roll_Cube_L;
            r     = Random.Range(0, CtrlData.Roll_Cube_L);
            break;

        case TypeShape.L4_90:
            shape = CtrlData.Cube_L4_90;
            r     = CtrlData.Roll_Cube_L;
            break;

        case TypeShape.L3_0:
            shape = CtrlData.Cube_L3_0;
            r     = CtrlData.Roll_Cube_L;
            break;

        case TypeShape.L3_90:
            shape = CtrlData.Cube_L3_90;
            r     = Random.Range(0, CtrlData.Roll_Cube_L);
            break;

        case TypeShape.three_cube:
            shape = CtrlData.Cube_3;
            r     = CtrlData.Roll_Cube_L;
            break;
        }
    }
        public void SSTDeclaration_WithSupertypes_OnlyInterface()
        {
            var thisType   = Names.Type("TestClass,P");
            var interface1 = Names.Type("i:IDoesSomething,P");

            var sst = new SST {
                EnclosingType = thisType
            };
            var typeShape = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element    = thisType,
                    Implements =
                    {
                        new TypeHierarchy {
                            Element = interface1
                        }
                    }
                }
            };

            AssertPrintWithCustomContext(
                sst,
                new SSTPrintingContext {
                TypeShape = typeShape
            },
                "class TestClass : IDoesSomething",
                "{",
                "}");
        }
        public void DoesNotStepIntoNestedTypes()
        {
            CompleteInNamespace(@"
                class C
                    {
                        $

                        public class N
                        {
                            // should not include any of these
                            public delegate void D();
                            public event Action E;
                            public int F;
                            public void M() {}
                            public int P { get; set; }
                        }
                    }
                ");

            var actual   = ResultContext.TypeShape;
            var expected = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy("N.C, TestProject"),
                NestedTypes   = { Names.Type("N.C+N, TestProject") }
            };

            Assert.AreEqual(expected, actual);
        }
Exemple #10
0
        public StepResult PutShape(TypeShape shape, int x, int y, bool checkEmpty = true)
        {
            if (x >= countCellWidth || y >= countCellHeight || x < 0 || y < 0)
            {
                return(StepResult.Illegal);
            }
            if (checkEmpty && fields[y, x] != EmptyCell && shape != TypeShape.Empty)
            {
                return(StepResult.Illegal);
            }

            if (shape == TypeShape.Empty)
            {
                return(RemoveShape(x, y));
            }

            TypeShape[] newShapes = new TypeShape[Shapes.Length + 1];
            byte        newIndex  = (byte)(newShapes.Length - 1);

            if (newIndex == 0)
            {
                currentShapeLocation = new ShapeLocation(x, y);
            }

            Shapes.CopyTo(newShapes, 0);
            newShapes[newIndex] = (TypeShape)shape;
            fields[y, x]        = newIndex;
            Shapes = newShapes;

            return(StepResult.Ok);
        }
        public void SSTDeclaration_WithSupertypes_OnlySuperclass()
        {
            var thisType  = Names.Type("TestClass,P");
            var superType = Names.Type("SuperClass,P");

            var sst = new SST {
                EnclosingType = thisType
            };
            var typeShape = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element = thisType,
                    Extends = new TypeHierarchy {
                        Element = superType
                    }
                }
            };

            AssertPrintWithCustomContext(
                sst,
                new SSTPrintingContext {
                TypeShape = typeShape
            },
                "class TestClass : SuperClass",
                "{",
                "}");
        }
Exemple #12
0
        public override void CreateShape(EntityType type, Point?where = null)
        {
            base.CreateShape(type);

            switch (type)
            {
            case EntityType.Class:
            case EntityType.Delegate:
            case EntityType.Enum:
            case EntityType.Interface:
            case EntityType.Structure:
                shapeOutline = TypeShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.Package:
                shapeOutline = PackageShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.Comment:
                shapeOutline = CommentShape.GetOutline(Style.CurrentStyle);
                break;
            }

            //shapeOutline.Location = new Point((int) mouseLocation.X, (int) mouseLocation.Y);
            shapeOutline.Location = where ?? new Point((int)mouseLocation.X, (int)mouseLocation.Y);
            Redraw();
        }
Exemple #13
0
    // Update is called once per frame
    void Update()
    {
        point = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);

        if (Input.GetKeyDown(KeyCode.B))
        {
            string s = Shape.Render(Shape.RotationMaxtrix(CtrlData.Cube_3, roll));
            Debug.Log(s);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            int[,] type10 = new int[1, 1]
            {
                { 1 },
            };

            //  string ss = Shape.Render(Shape.RotationMaxtrix(type10, i));

            type = CtrlGamePlay.Ins.MatrixToType(type10);


            //  type =  CtrlGamePlay.Ins.MatrixToType(type10);
            //   isCorrect = CtrlGamePlay.Ins.isTypeOf(TypeShape.crossBar_3,Shape.Clone(type10));



            //  roll = CtrlGamePlay.RollShape(type, type1);
        }
        Vector2 pos = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);

        row    = (int)pos.x;
        column = (int)pos.y;
        // isCorrect = CtrlGamePlay.IsPushShapeCorrect(CtrlGamePlay.Ins.Board,row, column);
    }
 public ColoredArea(Vector3 initialPos, int range, Color colorArea, TypeShape shape)
 {
     InitialPosition = initialPos;
     Range           = range;
     ColorArea       = colorArea;
     Shape           = shape;
 }
Exemple #15
0
        public void TypeHierarchy()
        {
            var actual = _sut.Anonymize(
                new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element    = T("elem"),
                    Extends    = H("ext"),
                    Implements = { H("impl") }
                }
            });
            var expected =
                new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element    = T("elem").ToAnonymousName(),
                    Extends    = AnonH("ext"),
                    Implements = { AnonH("impl") }
                }
            };

            Assert.AreEqual(expected, actual);
        }
Exemple #16
0
        public void DefaultSafe()
        {
            var actual   = _sut.Anonymize(new TypeShape());
            var expected = new TypeShape();

            Assert.AreEqual(expected, actual);
        }
        public void Equality_ReallyTheSame()
        {
            var a = new TypeShape
            {
                TypeHierarchy       = SomeTypeHierarchy,
                NestedTypes         = { Names.Type("T2,P") },
                Delegates           = { new DelegateTypeName() },
                EventHierarchies    = { new EventHierarchy() },
                Fields              = { new FieldName() },
                MethodHierarchies   = { new MethodHierarchy() },
                PropertyHierarchies = { new PropertyHierarchy() }
            };
            var b = new TypeShape
            {
                TypeHierarchy       = SomeTypeHierarchy,
                NestedTypes         = { Names.Type("T2,P") },
                Delegates           = { new DelegateTypeName() },
                EventHierarchies    = { new EventHierarchy() },
                Fields              = { new FieldName() },
                MethodHierarchies   = { new MethodHierarchy() },
                PropertyHierarchies = { new PropertyHierarchy() }
            };

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void FindsNestedTypes()
        {
            const string nested   = "e:Newtonsoft.Json.JsonReader+State, Newtonsoft.Json, 6.0.0.0";
            var          expected = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy(nested),
                Fields        =
                {
                    Enum(nested, "Start"),
                    Enum(nested, "Complete"),
                    Enum(nested, "Property"),
                    Enum(nested, "ObjectStart"),
                    Enum(nested, "Object"),
                    Enum(nested, "ArrayStart"),
                    Enum(nested, "Array"),
                    Enum(nested, "Closed"),
                    Enum(nested, "PostValue"),
                    Enum(nested, "ConstructorStart"),
                    Enum(nested, "Constructor"),
                    Enum(nested, "Error"),
                    Enum(nested, "Finished")
                }
            };

            CollectionAssert.Contains(_typeShapes, expected);
        }
Exemple #19
0
        public void ReturnsEmptyTypeShapeIfTypeIsNotInAssembly()
        {
            var typeName  = GetTypeName("SomeOtherType", "Assembly1");
            var typeShape = _uut.OpenTypeShape(typeName);
            var expected  = new TypeShape();

            Assert.AreEqual(expected, typeShape);
        }
Exemple #20
0
    public static int CountRoll(TypeShape type)
    {
        int roll = 0;

        switch (type)
        {
        case TypeShape.crossBar_1:
            roll = 0;
            break;

        case TypeShape.crossBar_2:
            roll = 2;
            break;

        case TypeShape.crossBar_3:
            roll = 2;
            break;

        case TypeShape.crossBar_4:
            roll = 2;
            break;

        case TypeShape.L_4_0:
            roll = 4;
            break;

        case TypeShape.L4_90:
            roll = 4;

            break;

        case TypeShape.square:
            roll = 4;
            break;


        case TypeShape.three_cube:
            roll = 4;
            break;

        case TypeShape.L3_0:
            roll = 4;
            break;

        case TypeShape.L3_90:
            roll = 4;
            break;

        case TypeShape.T:
            roll = 4;
            break;

        default:
            Debug.Log("Khong Co Type nhu the");
            break;
        }
        return(roll);
    }
Exemple #21
0
    public static TypeShape GetShapeType(int i)
    {
        TypeShape type = TypeShape.None;

        switch (i)
        {
        case 0:
            type = TypeShape.crossBar_1;
            break;

        case 1:
            type = TypeShape.crossBar_2;
            break;

        case 2:
            type = TypeShape.crossBar_3;
            break;

        case 3:
            type = TypeShape.crossBar_4;
            break;

        case 4:
            type = TypeShape.L_4_0;
            break;

        case 5:
            type = TypeShape.L4_90;

            break;

        case 6:
            type = TypeShape.square;
            break;


        case 7:
            type = TypeShape.three_cube;
            break;

        case 8:
            type = TypeShape.L3_0;
            break;

        case 9:
            type = TypeShape.L3_90;
            break;

        case 10:
            type = TypeShape.T;
            break;

        default:
            Debug.Log("Khong Co Type nhu the");
            break;
        }
        return(type);
    }
Exemple #22
0
    public static int[,] GetMatrixShapeType(TypeShape type)
    {
        int[,] matrix = null;

        switch (type)
        {
        case TypeShape.crossBar_1:
            matrix = CtrlData.Cube_Cross_1;
            break;

        case TypeShape.crossBar_2:
            matrix = CtrlData.Cube_Cross_2;
            break;

        case TypeShape.crossBar_3:
            matrix = CtrlData.Cube_Cross_3;
            break;

        case TypeShape.crossBar_4:
            matrix = CtrlData.Cube_Cross_4;
            break;

        case TypeShape.L_4_0:
            matrix = CtrlData.Cube_L4_0;
            break;

        case TypeShape.L4_90:
            matrix = CtrlData.Cube_L4_90;

            break;

        case TypeShape.square:
            matrix = CtrlData.Cube_Quare;
            break;


        case TypeShape.three_cube:
            matrix = CtrlData.Cube_3;
            break;

        case TypeShape.L3_0:
            matrix = CtrlData.Cube_L3_0;
            break;

        case TypeShape.L3_90:
            matrix = CtrlData.Cube_L3_90;
            break;

        case TypeShape.T:
            matrix = CtrlData.T;
            break;

        default:
            Debug.Log("Khong Co Type nhu the");
            break;
        }
        return(matrix);
    }
Exemple #23
0
 /// <summary>
 /// Either finds a dynamic type that matches the specified propertyNames and propertyTypes or creates a 
 /// new DynamicType that does.  
 /// </summary>
 /// <param name="propertyNames"></param>
 /// <param name="propertyTypes"></param>
 /// <returns></returns>
 public static DynamicTypeInfo FindOrCreate(IEnumerable<String> propertyNames, IEnumerable<Type> propertyTypes) {
   var typeShape = new TypeShape(propertyNames, propertyTypes);
   var dti = FindByTypeShape(typeShape);
   if (dti != null) {
     return dti;
   } else {
     return new DynamicTypeInfo(typeShape);
   }
 }
Exemple #24
0
 public RShape()
 {
     base.controlType = ControlType.ControlShape;
     this.typeShape   = TypeShape.矩形;
     this.borderWidth = 0;
     this.BackColor   = Color.White;
     base.Width       = 200;
     base.Height      = 150;
 }
Exemple #25
0
        public void Mark(TypeShape typeShape)
        {
            if (IsMarked())
            {
                throw new Exception("This cell is already marked.");
            }

            MarkedBy = typeShape;
        }
Exemple #26
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 397;
         hashCode = (hashCode * 397) ^ TypeShape.GetHashCode();
         hashCode = (hashCode * 397) ^ SST.GetHashCode();
         return(hashCode);
     }
 }
        public void Equality_DifferentMethods()
        {
            var a = new TypeShape
            {
                MethodHierarchies = { new MethodHierarchy() }
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equality_DifferentType()
        {
            var a = new TypeShape
            {
                TypeHierarchy = SomeTypeHierarchy
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equality_DifferentNestedTypes()
        {
            var a = new TypeShape
            {
                NestedTypes = { Names.Type("T2,P") }
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equality_DifferentDelegates()
        {
            var a = new TypeShape
            {
                Delegates = { new DelegateTypeName() }
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equality_DifferentFields()
        {
            var a = new TypeShape
            {
                Fields = { new FieldName() }
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equality_DifferentProperties()
        {
            var a = new TypeShape
            {
                PropertyHierarchies = { new PropertyHierarchy() }
            };
            var b = new TypeShape();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
Exemple #33
0
		internal void Relocate(TypeShape shape)
		{
			IDiagram diagram = shape.Diagram;
			if (diagram != null)
			{
				Point absolute = new Point(shape.Right, shape.Top);
				Size relative = new Size(
					(int) (absolute.X * diagram.Zoom) - diagram.Offset.X + MarginSize,
					(int) (absolute.Y * diagram.Zoom) - diagram.Offset.Y);

				this.Location = ParentLocation + relative;
			}
		}
Exemple #34
0
 /// <summary>
 /// For internal use only.
 /// </summary>
 /// <param name="typeShape"></param>
 /// <returns></returns>
 private static DynamicTypeInfo FindByTypeShape(TypeShape typeShape) {
   DynamicTypeInfo result;
   lock (__lock) {
     if (TypeShapeMap.TryGetValue(typeShape, out result)) {
       return result;
     } else {
       return null;
     }
   }
 }
Exemple #35
0
 /// <summary>
 /// Called by FindOrCreate to create a new dynamictypeinfo based on the selected properties and types  
 /// </summary>
 private DynamicTypeInfo(TypeShape typeShape) {
   _propertyNames = typeShape.PropertyNames;
   _propertyTypes = typeShape.PropertyTypes;
   if (_propertyNames.Count != _propertyTypes.Count) {
     throw new ArgumentException("Number of property names and property types must be the same");
   }
   DynamicTypeName = BuildDynamicTypeName();
   CreateDynamicType();
   // originalType will be set by CreateDynamicType if not already set.
 }