Exemple #1
0
 // ────────────────────────── Constructors ──────────────────────────
 public Generator(Context context)
 {
     _context = context;
 }
Exemple #2
0
 private static XElement GetServiceModelConfiguration(Context context)
 {
     if (context.Config == null) return null;
     var configuration = new Configuration(context.Config);
     return new XElement("configuration",
         from element in configuration.Source.Root.Elements() select element);
 }
Exemple #3
0
        private static XElement GetServices(Context context, Contracts contracts)
        {
            var servicesElement = new XElement("services");

            XmlComments xmlComments = null;
            if (context.XmlComments != null)
                xmlComments = new XmlComments(context.XmlComments);

            var types = context.Assemblies.FindTypes(
                t => (t.IsClass && (from contract in contracts.Services select contract.Type).Contains(t)) ||
                     t.ImplementsInterface(from contract in contracts.Services select contract.Type));

            foreach (var type in types)
            {
                var serviceElement = new XElement("service",
                    new XAttribute("id", type.AssemblyQualifiedName.Hash()),
                    new XAttribute("type", type.FullName),
                    new XAttribute("assembly", type.Assembly.FullName));

                if (xmlComments != null)
                    serviceElement.Add(
                        new XElement("comments",
                            xmlComments.GetTypeComments(type)));

                if (context.ServiceWebsite != null)
                    serviceElement.Add(new XElement("website",
                        from file in context.ServiceWebsite
                        where file.Type.Equals(type.FullName, StringComparison.OrdinalIgnoreCase)
                        select new XElement("path",
                                new XText(file.Uri.ToString()))));

                if (context.Config != null)
                    serviceElement.Add(new XElement("endpoints",
                        new Configuration(context.Config).GetEndpoints(type.FullName)));

                serviceElement.Add(new XElement("contracts",
                    from contract in contracts.Services
                    where type.ImplementsInterface(contract.Type) || type == contract.Type
                    select new XElement("contract", new XText(contract.Type.FullName))));

                servicesElement.Add(serviceElement);
            }
            return servicesElement;
        }
Exemple #4
0
 private static XElement GetMetadata(Context context)
 {
     if (context.MergeDocuments == null) return null;
     return new XElement("metadata", from document in context.MergeDocuments select document.Root);
 }