Пример #1
0
        public EntityDescription(Type sourceType,  Dictionary<string, EntityDescription> entityLookup)
        {
            if(sourceType == null)
                sourceType = typeof(void);

            this.AssemblyName = sourceType.Assembly.FullName;
            this.Name = ProcessName(sourceType);
            this.FullName = sourceType.FullName;
            
            if(FullName.StartsWith("System"))
            {
                return; // for the sake of saving space/grief, we don't need to fully explore/explain System types
            }

            this.Properties = new List<EntityDescription>();

            EntityDescription entity;

            foreach(var property in sourceType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy))
            {
                if(!entityLookup.TryGetValue(property.PropertyType.FullName, out entity))
                {
                    entity = new EntityDescription(property.PropertyType, entityLookup);
                    entityLookup.Add(entity.FullName, entity);
                }

                Properties.Add(entity);
            }
        }
Пример #2
0
        private void PrepareDescriptions()
        {
            // we don't have to process all of our method candidates every time, only after we load new assemblies.
            if (descriptionsUpToDate) return;

            methodDescriptions.Clear();
            entityDescriptions.Clear();

            MethodDescription createdMD;
            XPathNavigator xml;

            // first we add the descriptions for every (top-versioned) exposed method, and every entity referenced by those methods
            foreach(var kv in topCandidates)
            {
                if (!assemblyXmlComments.TryGetValue(kv.Value.Assembly, out xml)) xml = null;
                createdMD = MethodDescription.Create(kv.Key, kv.Value.Version, kv.Value.Assembly, kv.Value.MethodInfo, xml, entityDescriptions);
                if(createdMD != null)
                {
                    methodDescriptions.Add(createdMD.ExposedName, createdMD);
                }
            }

            // then we add descriptions for any remaining entities that had [ExposedEntity] tags, but weren't referenced by methods
            foreach(var type in explicitEntities)
            {
                if (entityDescriptions.ContainsKey(type.FullName))
                    continue;

                var entry = new EntityDescription(type, entityDescriptions);
                entityDescriptions.Add(entry.FullName, entry);
            }

            descriptionsUpToDate = true;
        }
Пример #3
0
        public static MethodDescription Create(string exposedName, Version version, Assembly assembly, MethodInfo methodInfo, XPathNavigator xmlDocumentation, Dictionary<string, EntityDescription> entityLookup)
        {
            // using a static Create rather than standard constructor for the sake of this sanity check
            if (string.IsNullOrEmpty(exposedName) || assembly == null || methodInfo == null)
                return null;

            string summaryComments = null;
            string returnsComments = null;
            string knownComment = null;
            bool subscribes;
            Dictionary<string, string> paramComments = new Dictionary<string, string>();

            ParseXML(methodInfo, xmlDocumentation, ref summaryComments, ref returnsComments, paramComments);

            Type returnType = GetReturnType(methodInfo, out subscribes);

            var retval = new MethodDescription(exposedName, summaryComments, returnsComments, subscribes, assembly, methodInfo, version);

            EntityDescription entity;

            if(!entityLookup.TryGetValue(returnType.FullName, out entity))
            {
                entity = new EntityDescription(returnType, entityLookup);
                entityLookup.Add(entity.FullName, entity);
            }

            retval.Returns = entity;

            foreach(var paramInfo in methodInfo.GetParameters())
            {
                if(!entityLookup.TryGetValue(paramInfo.ParameterType.FullName, out entity))
                {
                    entity = new EntityDescription(paramInfo.ParameterType, entityLookup);
                    entityLookup.Add(entity.FullName, entity);
                }
                if (!paramComments.TryGetValue(paramInfo.Name, out knownComment))
                    knownComment = null;
                retval.Parameters.Add(new ParamDescription() { ParamComments = knownComment, ParamName = paramInfo.Name, ParamType = entity });
            }

            return retval;
        }