Ejemplo n.º 1
0
 public ModelNode(ModelNodeId id, [NotNull] string name, [NotNull] ModelNodeStereotype stereotype, ModelOrigin origin)
 {
     Id         = id;
     Name       = name ?? throw new ArgumentNullException(nameof(name));
     Stereotype = stereotype ?? throw new ArgumentNullException(nameof(stereotype));
     Origin     = origin;
 }
Ejemplo n.º 2
0
 private IModelNode CreateNode(
     [NotNull] string name,
     ModelNodeStereotype stereotype,
     [CanBeNull] object payload)
 {
     return(new ModelNode(CreateModelNodeId(), name, stereotype, payload));
 }
Ejemplo n.º 3
0
        public ModelEvent AddNode(
            string name,
            ModelNodeStereotype stereotype,
            object payload           = null,
            ModelNodeId?parentNodeId = null)
        {
            if (payload != null && _payloadToModelNodeMap.ContainsKey(payload))
            {
                throw new Exception($"The model already contains a node with payload: {payload}");
            }

            var itemEvents = new List <ModelItemEventBase>();

            var newNode = CreateNode(name, stereotype, payload);

            var(newGraph, newPayloadToModelNodeMap) = AddNodeCore(newNode, _graph, _payloadToModelNodeMap, itemEvents);

            var newPayloadToModelRelationshipMap = _payloadToModelRelationshipMap;

            if (parentNodeId.HasValue)
            {
                var containsRelationship = CreateRelationship(parentNodeId.Value, newNode.Id, ModelRelationshipStereotype.Containment, payload: null);
                (newGraph, newPayloadToModelRelationshipMap) = AddRelationshipCore(
                    containsRelationship,
                    newGraph,
                    newPayloadToModelRelationshipMap,
                    itemEvents);
            }

            var newModel = CreateInstance(newGraph, newPayloadToModelNodeMap, newPayloadToModelRelationshipMap);

            return(ModelEvent.Create(newModel, itemEvents));
        }
Ejemplo n.º 4
0
 public ModelNode(ModelNodeId id, [NotNull] string name, ModelNodeStereotype stereotype, object payload = null)
 {
     Id         = id;
     Name       = name;
     Stereotype = stereotype;
     Payload    = payload;
 }
Ejemplo n.º 5
0
        //[NotNull]
        //private static readonly ModelNodeStereotype[] MemberStereotypes =
        //{
        //    ModelNodeStereotypes.Event,
        //    ModelNodeStereotypes.Field,
        //    ModelNodeStereotypes.Method,
        //    ModelNodeStereotypes.Property
        //};

        public IEnumerable <RelatedNodeType> GetRelatedNodeTypes(ModelNodeStereotype stereotype)
        {
            //yield return new RelatedNodeType(CommonDirectedModelRelationshipTypes.Container, "Parent");

            if (stereotype.In(TypesWithMembersStereotypes))
            {
                yield return(new RelatedNodeType(CommonDirectedModelRelationshipTypes.Contained, "Members"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.AssociatedType, "Outgoing Associations"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.AssociatingType, "Incoming Associations"));
            }

            if (stereotype.Equals(ModelNodeStereotypes.Class))
            {
                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.BaseType, "Base types"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.Subtype, "Subtypes"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.ImplementedInterface, "Interfaces"));
            }
            else if (stereotype.Equals(ModelNodeStereotypes.Interface))
            {
                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.BaseType, "Base types"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.Subtype, "Subtypes"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.ImplementerType, "Implementers"));
            }
            else if (stereotype.Equals(ModelNodeStereotypes.Struct))
            {
                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.ImplementedInterface, "Interfaces"));
            }
        }
Ejemplo n.º 6
0
        public IModelNode AddNode(
            string name,
            ModelNodeStereotype stereotype,
            object payload           = null,
            ModelNodeId?parentNodeId = null)
        {
            var modelEvent = MutateWithLockThenRaiseEvents(() => LatestModel.AddNode(name, stereotype, payload, parentNodeId));

            return(modelEvent.ItemEvents.OfType <ModelNodeAddedEvent>().First().AddedNode);
        }
Ejemplo n.º 7
0
 public RelatedNodeItemViewModel(
     ModelNodeId id,
     string name,
     string fullName,
     ModelNodeStereotype stereotype,
     bool isStatic)
 {
     Id         = id;
     Name       = name;
     FullName   = fullName;
     Stereotype = stereotype;
     IsStatic   = isStatic;
 }
        public IEnumerable <RelatedNodeType> GetRelatedNodeTypes(ModelNodeStereotype stereotype)
        {
            if (stereotype.Equals(ModelNodeStereotypes.Property))
            {
                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.AssociatedType, "Type"));
            }
            else if (stereotype.Equals(ModelNodeStereotypes.Class) ||
                     stereotype.Equals(ModelNodeStereotypes.Interface))
            {
                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.BaseType, "Base types"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.Subtype, "Subtypes"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.ImplementerType, "Implementers"));

                yield return(new RelatedNodeType(DirectedModelRelationshipTypes.ImplementedInterface, "Interfaces"));
            }
        }
Ejemplo n.º 9
0
        public ModelEvent AddNode(
            string name,
            ModelNodeStereotype stereotype,
            object payload           = null,
            ModelNodeId?parentNodeId = null)
        {
            var itemEvents = new List <ModelItemEventBase>();

            var newNode  = CreateNode(name, stereotype, payload);
            var newGraph = AddNodeCore(newNode, _graph, itemEvents);

            if (parentNodeId.HasValue)
            {
                var containsRelationship = CreateRelationship(parentNodeId.Value, newNode.Id, ModelRelationshipStereotype.Containment, payload: null);
                newGraph = AddRelationshipCore(containsRelationship, newGraph, itemEvents);
            }

            var newModel = CreateInstance(newGraph);

            return(ModelEvent.Create(newModel, itemEvents));
        }
Ejemplo n.º 10
0
 protected RoslynModelNode(ModelNodeId id, ISymbol roslynSymbol, ModelNodeStereotype stereotype)
     : base(id, roslynSymbol.GetName(), stereotype, roslynSymbol.GetOrigin())
 {
     RoslynSymbol = roslynSymbol ?? throw new ArgumentNullException(nameof(roslynSymbol));
 }
Ejemplo n.º 11
0
 protected virtual IModelNode CreateInstance(ModelNodeId id, [NotNull] string name, [NotNull] ModelNodeStereotype stereotype, ModelOrigin origin)
 {
     return(new ModelNode(id, name, stereotype, origin));
 }
Ejemplo n.º 12
0
 private static IModelNode CreateInstance(ModelNodeId id, [NotNull] string name, ModelNodeStereotype stereotype, [CanBeNull] object payload)
 {
     return(new ModelNode(id, name, stereotype, payload));
 }
Ejemplo n.º 13
0
 protected TypeMemberNode(ModelNodeId id, string name, ModelNodeStereotype stereotype, ModelOrigin origin)
     : base(id, name, stereotype, origin)
 {
 }
Ejemplo n.º 14
0
 protected RoslynTypeNode(ModelNodeId id, INamedTypeSymbol roslynSymbol, ModelNodeStereotype stereotype)
     : base(id, roslynSymbol, stereotype)
 {
     NamedTypeSymbol = roslynSymbol ?? throw new ArgumentNullException(nameof(roslynSymbol));
 }
Ejemplo n.º 15
0
 protected TypeNode(ModelNodeId id, string name, ModelNodeStereotype stereotype, ModelOrigin origin, bool isAbstract)
     : base(id, name, stereotype, origin)
 {
     IsAbstract = isAbstract;
 }