Esempio n. 1
0
		public Stat AddStat(APIMember Member, string Name)
		{
			for(APIPage Page = Member; Page != null; Page = Page.Parent)
			{
				APIModule Module = Page as APIModule;
				if(Module != null)
				{
					// Get the stats for this module
					ModuleStats ModuleStatsInst;
					if(!Modules.TryGetValue(Module.Name, out ModuleStatsInst))
					{
						ModuleStatsInst = new ModuleStats();
						Modules.Add(Module.Name, ModuleStatsInst);
					}

					// Find the name of this stat
					Stat StatInst;
					if (!ModuleStatsInst.Stats.TryGetValue(Name, out StatInst))
					{
						StatInst = new Stat();
						ModuleStatsInst.Stats.Add(Name, StatInst);
					}

					// Update the current 
					return StatInst;
				}
			}
			return null;
		}
Esempio n. 2
0
		public Stats(IEnumerable<APIMember> InMembers)
		{
			List<APIMember> Members = new List<APIMember>(InMembers);

			// Generate the page counts
			foreach(APIPage Page in Members)
			{
				Type PageType = Page.GetType();
				int PageCount = PageCounts.ContainsKey(PageType)? PageCounts[PageType] : 0;
				PageCounts.Remove(PageType);
				PageCounts.Add(PageType, PageCount + 1);
			}

			// Check all the records
			foreach(APIRecord Record in Members.OfType<APIRecord>())
			{
				AddStat(Record, "Class descriptions", Record.BriefDescription, Record.FullDescription);
			}

			// Check all the functions
			foreach(APIFunction Function in Members.OfType<APIFunction>())
			{
				AddStat(Function, "Function descriptions", Function.BriefDescription, Function.FullDescription);
			}

			// Check all the constants
			foreach (APIConstant Constant in Members.OfType<APIConstant>())
			{
				AddStat(Constant, "Constant descriptions", Constant.BriefDescription, Constant.FullDescription);
			}

			// Check all the enums
			foreach(APIEnum Enum in Members.OfType<APIEnum>())
			{
				AddStat(Enum, "Enum descriptions", Enum.BriefDescription, Enum.FullDescription);
				foreach (APIEnumValue EnumValue in Enum.Values)
				{
					AddStat(Enum, "Enum value descriptions", EnumValue.BriefDescription, EnumValue.FullDescription);
				}
			}

			// Check all the typedefs
			foreach (APITypeDef TypeDef in Members.OfType<APITypeDef>())
			{
				AddStat(TypeDef, "Typedef descriptions", TypeDef.BriefDescription, TypeDef.FullDescription);
			}

			// Check all the variables
			foreach (APIVariable Variable in Members.OfType<APIVariable>())
			{
				AddStat(Variable, "Variable descriptions", Variable.BriefDescription, Variable.FullDescription);
			}

			// Create the totals
			foreach(KeyValuePair<string, ModuleStats> ModulePair in Modules)
			{
				foreach(KeyValuePair<string, Stat> StatPair in ModulePair.Value.Stats)
				{
					Stat TotalStat;
					if (!Totals.TryGetValue(StatPair.Key, out TotalStat))
					{
						TotalStat = new Stat();
						Totals.Add(StatPair.Key, TotalStat);
					}
					TotalStat.NumDocumented += StatPair.Value.NumDocumented;
					TotalStat.NumUndocumented += StatPair.Value.NumUndocumented;
				}
			}
		}