Esempio n. 1
0
        protected void loadModel(string fileName)
        {
            UmlDescriptor.Initialize();
            var umlSerializer = new WhiteStarUmlSerializer();
            var model         = umlSerializer.ReadModelFromFile(fileName, out var diagnostics);

            if (this.model != null && this.model.Name.Equals(model.Name))
            {
                return;
            }
            this.model = model;
        }
        protected SequenceCompilation Compile(string fileId, bool assertEmptyDiagnostics = true)
        {
            UmlDescriptor.Initialize();
            string text    = File.ReadAllText($@"..\..\..\InputFiles\WebSequenceDiagrams\{fileId}.wsd");
            var    st      = SequenceSyntaxTree.ParseText(text);
            var    options = new SequenceCompilationOptions(SequenceLanguage.Instance, Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary, topLevelBinderFlags: (BinderFlags)BinderFlags.IgnoreAccessibility, concurrentBuild: false);
            var    comp    = SequenceCompilation.Create("Test").WithOptions(options).AddSyntaxTrees(st);

            comp.ForceComplete();
            if (assertEmptyDiagnostics)
            {
                AssertEmptyDiagnostics(comp);
            }
            return(comp);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            /*var xmiSerializer = new UmlXmiSerializer();
             * var model = xmiSerializer.ReadModelFromFile("../../../PrimitiveTypes.xmi");
             * foreach (var primitiveType in model.Objects.OfType<PrimitiveType>())
             * {
             *  Console.WriteLine(primitiveType.MName);
             * }
             * xmiSerializer.WriteModelToFile("../../../PrimitiveTypes2.xmi", model);*/
            UmlDescriptor.Initialize();
            var umlSerializer = new WhiteStarUmlSerializer();
            var model         = umlSerializer.ReadModelFromFile("../../../potyogos.uml", out var diagnostics);
            //var model = umlSerializer.ReadModelFromFile("../../../Async.uml", out var diagnostics);
            DiagnosticFormatter df = new DiagnosticFormatter();

            if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error))
            {
                diagnostics = diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).ToImmutableArray();
            }
            for (int i = 0; i < 10 && i < diagnostics.Length; i++)
            {
                Console.WriteLine(df.Format(diagnostics[i]));
            }
            Console.WriteLine(model);
            var wsdSerializer = new WebSequenceDiagramsSerializer();
            var wsdModel      = wsdSerializer.ReadModelFromFile(new string[] { "../../../5.1.2.txt" }, model, out diagnostics);

            if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error))
            {
                diagnostics = diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).ToImmutableArray();
            }
            for (int i = 0; i < 10 && i < diagnostics.Length; i++)
            {
                Console.WriteLine(df.Format(diagnostics[i]));
            }
            Console.WriteLine(wsdModel);
            model = wsdModel;
            var xmiSerializer = new UmlXmiSerializer();

            //xmiSerializer.WriteModelToFile("../../../pacman.xmi", model);
            //xmiSerializer.WriteModelToFile("../../../Async.xmi", model);
            //xmiSerializer.WriteModelToFile("../../../Wsd.xmi", wsdModel);
            xmiSerializer.WriteModelToFile("../../../model.xmi", model);
            var check = xmiSerializer.ReadModelFromFile("../../../model.xmi");

            Console.WriteLine(check);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            UmlDescriptor.Initialize();
            var umlSerializer      = new WhiteStarUmlSerializer();
            var model              = umlSerializer.ReadModelFromFile("../../../Pacman.uml", out var diagnostics);
            DiagnosticFormatter df = new DiagnosticFormatter();

            if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error))
            {
                diagnostics = diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).ToImmutableArray();
            }
            for (int i = 0; i < 10 && i < diagnostics.Length; i++)
            {
                Console.WriteLine(df.Format(diagnostics[i]));
            }
            Console.WriteLine(model);
            foreach (var cls in model.Objects.OfType <Class>())
            {
                Console.WriteLine(cls.Name);
                foreach (var prop in cls.OwnedAttribute)
                {
                    Console.WriteLine($"  {prop.Name}: {prop.Type.Name}");
                }
                foreach (var op in cls.OwnedOperation)
                {
                    Console.WriteLine($"  {op.Name}()");
                }
            }
            foreach (var ir in model.Objects.OfType <InterfaceRealization>())
            {
                Console.WriteLine(ir.Client.FirstOrDefault() + " --|> " + ir.Supplier.FirstOrDefault());
            }
            foreach (var gen in model.Objects.OfType <Generalization>())
            {
                Console.WriteLine(gen.Specific + " -|> " + gen.General);
            }
            foreach (var dep in model.Objects.OfType <Dependency>())
            {
                Console.WriteLine(dep.Client.FirstOrDefault() + " --> " + dep.Supplier.FirstOrDefault());
            }
            foreach (var assoc in model.Objects.OfType <Association>())
            {
                Console.WriteLine(assoc.MemberEnd[0] + " - " + assoc.MemberEnd[1]);
            }
        }