예제 #1
0
        public void TestFull()
        {
            // start ArDeveloper
            // add files (json, txt, html, urlsniff)
            // process files
            //      build
            //      runplugins (??)
            //      output common interface
            // ArDevelopmentPlanner builds output
            // done

            //var ar2 = new ArDeveloper(developerConfig => { developerConfig.PluginLocation = "" });

            var arDev = new ArDeveloper();

            arDev.Test();

            arDev.AddInterpreter(new SimpleFileInterpreter());
            arDev.AddInterpreter(new ManualInterpreter());

            var config = new SingleFileOutputProcessorConfig()
            {
                OutputPath = @"C:\Projects\Other\ARestedDevelopment\ARested.Tests\SampleFiles\Gen\singlefileoutput\ONE.cs"
            };

            arDev.AddOutputProcessor(new SingleFileOutputProcessor(config));

            var config2 = new SingleFileOutputProcessorConfig()
            {
                OutputPath = @"C:\Projects\Other\ARestedDevelopment\ARested.Tests\SampleFiles\Gen\singlefileoutput\TWO.cs"
            };

            arDev.AddOutputProcessor(new SingleFileOutputProcessor(config2));

            // load resources
            var resource = arDev.LoadResource(new UriResource()
            {
                Name = "my simple file",
                Type = "text/simple",
                Uri  = @"C:\Projects\Other\ARestedDevelopment\ARested.Tests\SampleFiles\simple.txt"
            });

            arDev.LoadResource(new UriResource()
            {
                Name = "a json file",
                Type = "json/simple",
                Uri  = @"C:\Projects\Other\ARestedDevelopment\ARested.Tests\SampleFiles\simple.json"
            });


            var stubDef = new StubDefinition("");

            stubDef.Methods.Add(new MethodDefinition("ManualMETH", "bool", null));

            arDev.LoadResource(new ManualResource()
            {
                Name = "somemanualresource", Def = stubDef
            });

            var result = arDev.Develop();


            var l = arDev.Logs;
        }
예제 #2
0
        /// <summary>
        /// Parse the specified stub as a common model element reference
        /// </summary>
        internal static CommonTypeReference Parse(StubDefinition stub, ClassRepository classRepository)
        {
            CommonTypeReference retVal = new CommonTypeReference();

            // Create the return value basic parameters
            retVal.Name    = stub.Name;
            retVal.SortKey = stub.SortKey;

            if (stub.Annotations != null)
            {
                retVal.Documentation = DocumentationParser.Parse(stub.Annotations.Documentation);
            }

            retVal.DerivedFrom = stub;

            if (stub.SupplierStructuralDomain != null && stub.SupplierStructuralDomain.Code != null)
            {
                retVal.ClassifierCode = stub.SupplierStructuralDomain.Code.Code;
            }

            retVal.Class = new TypeReference();

            // Return value class binding
            if (stub.TypeStaticModel != null)
            {
                Package p = (Package)stub.Container.MemberOfRepository.Find(stub.TypeStaticModel);
                if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count > 0)
                {
                    string entryClassName = stub.EntryClass;

                    if (entryClassName == null)
                    {
                        throw new InvalidOperationException(string.Format("Package '{1}' points to a valid model with more than one entry point, however no entryClass was specified ", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT)));
                    }

                    // Did we find the class with an entry point?
                    var search     = (p as GlobalStaticModel).OwnedClass.Find(o => o.Choice is MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class && (o.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class).Name == entryClassName);
                    var entryClass = search.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class;

                    // Entry class is not null
                    if (entryClass == null)
                    {
                        throw new InvalidOperationException(string.Format("Can't find entry class '{0}' in package '{1}', or entry class is not a class", entryClassName, stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT)));
                    }

                    retVal.Class.Name = string.Format("{0}.{1}", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT), entryClass.Name);
                }
                else if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count == 1)
                {
                    retVal.Class.Name = string.Format("{0}.{1}", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT), (p as GlobalStaticModel).OwnedEntryPoint[0].Name);
                }
                else if (p != null)
                {
                    throw new InvalidOperationException(string.Format("Can't find static model '{0}'!", p.PackageLocation.ToString(MifCompiler.NAME_FORMAT)));
                }
                else
                {
                    return(null); // Can't find the package
                }
            }

            // Pseudo Heiarchy to get back to the class repository
            retVal.MemberOf       = classRepository;
            retVal.Class.MemberOf = classRepository;

            // Notify complete
            retVal.FireParsed();

            // Now return
            return(retVal);
        }