예제 #1
0
 private Event(Event eventToCopyFrom)
     : base(null)
 {
     eventToCopyFrom.CloneInto(this);
     DataType = eventToCopyFrom.DataType.Clone();
     foreach (string mod in eventToCopyFrom.Modifiers)
     {
         Modifiers.Add(mod);
     }
     AddAccessorText = eventToCopyFrom.AddAccessorText;
     RemoveAccessorText = eventToCopyFrom.RemoveAccessorText;
     InitialValue = eventToCopyFrom.InitialValue;
 }
예제 #2
0
 private bool IsTheSame(Event comparisonEvent)
 {
     return IsTheSame(comparisonEvent, ComparisonDepth.Signature);
 }
예제 #3
0
        private bool IsTheSame(Event comparisonEvent, ComparisonDepth depth)
        {
            if (comparisonEvent == null)
            {
                return false;
            }

            if (Name == comparisonEvent.Name)
            {
                // Function names are the same, so now compare the class names
                {
                    if (depth == ComparisonDepth.Signature)
                    {
                        return true;
                    }
                    if (DataType != comparisonEvent.DataType)
                    {
                        return false;
                    }
                    if (!base.IsTheSame(comparisonEvent, depth))
                    {
                        return false;
                    }
                    if (InitialValue != comparisonEvent.InitialValue)
                    {
                        ComparisonDifference += GetType().Name + ".InitialValue";
                        return false;
                    }
                    if (!Utility.StringCollectionsAreTheSame(Modifiers, comparisonEvent.Modifiers))
                    {
                        ComparisonDifference += GetType().Name + ".Modifiers";
                        return false;
                    }
                    // Why are these checks on parents here?
                    //if (!ParentObject.IsTheSame(comparisonEvent.ParentObject))
                    //{

                    //}
                    return true;
                }
            }
            return false;
        }
        public void Event_Added_Accessors()
        {
            const string name = "MyEvent1";
            const string addAccessorText = "{ // add accessor }";
            const string removeAccessorText = "{ // remove accessor }";
            DataType type1 = new DataType(controller, DataType1);
            string expectedResult = String.Format("{0} event {1} {2}\n{{\n\tadd{3}\tremove{4}}}".Replace("\n",Environment.NewLine),Modifier1, DataType1, name, addAccessorText, removeAccessorText);

            Event merged1 = new Event(controller);
            Event merged2 = new Event(controller);
            Event merged3 = new Event(controller);

            Event changing = new Event(controller, type1, name, Modifier1);
            changing.AddAccessorText = addAccessorText;
            changing.RemoveAccessorText = removeAccessorText;
            Event unchanging = new Event(controller, type1, name, Modifier1);

            Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult);
        }
        public void Event_Changed_Modifier()
        {
            const string name = "MyEvent1";
            DataType type1 = new DataType(controller, DataType1);
            string expectedResult = String.Format("{0} event {1} {2}", Modifier2, DataType1, name);

            Event merged1 = new Event(controller);
            Event merged2 = new Event(controller);
            Event merged3 = new Event(controller);

            Event changing = new Event(controller, type1, name, Modifier2);
            Event unchanging = new Event(controller, type1, name, Modifier1);

            Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult);
        }
        public void Event()
        {
            Event item = new Event(controller, new DataType(controller, "Delegate1"), "Event1", "public");
            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Event1"));

            Class cl = new Class(controller, "Class1");
            cl.AddChild(item);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Event1"));
        }
        public void Event()
        {
            Event inter = new Event(controller);
            inter.Name = "FileAdded";
            inter.Modifiers.Add("public");
            inter.DataType = new DataType(controller, "EventHandler");

            Assert.That(inter.IsTheSame(inter.Clone(), ComparisonDepth.Outer), Is.True);
        }
예제 #8
0
        private void Process_Event_Declaration(EventDeclaration node)
        {
            if (node == null) throw new ArgumentNullException("node");
            Event ev = new Event(controller);
            ev.Name = node.Name.Text;
            ev.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));
            ev.DataType = FormatterUtility.GetDataTypeFromTypeReference(node.EventType, document, controller);
            if (node.AddAccessor != null || node.RemoveAccessor != null || node.RaiseEventAccessor != null)
            {
                throw new Exception(
                    "The formatter does not currently support add/remove accessors on events. Please contact Slyce Support if you require this functionality.");
            }

            SetupBaseConstruct(node, ev);
        }
        public void Event()
        {
            Event inter = new Event(controller);
            inter.Name = "FileAdded";
            inter.Modifiers.Add("public");
            inter.DataType = new DataType(controller,"EventHandler");
            CodeRoot root = CreateClassAndNamespace(inter);

            CodeRootMap map = new CodeRootMap();
            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);
            map.AddCodeRoot(root, Version.PrevGen);

            string result = map.GetMergedCodeRoot().ToString();
            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            Assertions.StringContains(result, "public event EventHandler FileAdded");
        }
예제 #10
0
 public VBEventPrinter(Event obj)
 {
     this.obj = obj;
 }