public ApiNamespace GetNearestApiNamespace(int moduleId, string fullQualifier) { ApiNamespace res = null; using (var context = DataContext.Instance()) { var rep = context.GetRepository <ApiNamespace>(); var crtQualifier = fullQualifier; while (true) { var crt = rep.Find("WHERE NamespaceName=@0", crtQualifier).FirstOrDefault(); if (crt != null) { res = crt; break; } if (crtQualifier.IndexOf('.') < 0) { break; } crtQualifier = crtQualifier.Substring(0, crtQualifier.LastIndexOf('.')); } } return(res); }
public void UpdateApiNamespace(ApiNamespace apiNamespace) { Requires.NotNull(apiNamespace); using (var context = DataContext.Instance()) { var rep = context.GetRepository <ApiNamespace>(); rep.Update(apiNamespace); } }
public int AddApiNamespace(ref ApiNamespace apiNamespace) { Requires.NotNull(apiNamespace); Requires.PropertyNotNegative(apiNamespace, "ModuleId"); using (var context = DataContext.Instance()) { var rep = context.GetRepository <ApiNamespace>(); rep.Insert(apiNamespace); } return(apiNamespace.NamespaceId); }
public ApiNamespace GetOrCreateNamespace(int moduleId, string namespaceName) { var fullNamespace = ""; ApiNamespace crtNamespace = null; foreach (var segment in namespaceName.Split('.')) { fullNamespace = (fullNamespace + "." + segment).TrimStart('.'); crtNamespace = Sprocs.GetOrCreateNamespace(moduleId, crtNamespace == null ? 0 : crtNamespace.NamespaceId, fullNamespace, segment); } return(crtNamespace); }
private static ApiNamespace GetNamespace(string name, IEnumerable <ApiBaseItem> items, int p) { IGrouping <bool, ApiBaseItem>[] split = items.GroupBy(i => i.NameSegments.Length == p + 1).ToArray(); // true - end type IGrouping <bool, ApiBaseItem> endTypes = split.FirstOrDefault(g => g.Key); // false, more segments - with nested namespace IGrouping <bool, ApiBaseItem> withNestedNs = split.FirstOrDefault(g => !g.Key); ApiNamespace ns = new ApiNamespace(name); if (endTypes != null) { ns.ApiItems = endTypes.ToArray(); } if (withNestedNs != null) { ns.Namespaces = GetNamespaces(withNestedNs.ToArray(), p + 1); } return(ns); }
public ApiNamespaceWriter(DiffItem item) { this.item = item; ns = item.Item as ApiNamespace; }
public ApiRootWriter(DiffItem item, string title) { this.item = item; this.title = title; this.api = item.Item as ApiNamespace; }
public ApiNamespaceWriter(DiffItem item) { _item = item; _ns = (item.Item as ApiNamespace) !; }
public void AddToModule() { StartTime = DateTime.Now; string logFile = System.IO.Path.GetDirectoryName(FilePath) + "\\" + System.IO.Path.GetFileNameWithoutExtension(FilePath) + ".log"; var log = new System.IO.StreamWriter(logFile, false); log.Log(StartTime, "Beginning import of {0}", FilePath); Component component = Sprocs.GetOrCreateComponent(ModuleId, File, Version); ComponentHistory historyItem = Sprocs.GetOrCreateComponentHistory(component.ComponentId, FullName, Version, VersionNormalized, CodeLines, CommentLines, EmptyLines); log.Log(StartTime, "Component is {0}, ID={1}, version={2}", component.ComponentName, component.ComponentId, Version); foreach (XmlNode depNode in DocumentElement.SelectSingleNode("dependencies").SelectNodes("dependency")) { var dep = Sprocs.GetOrCreateDependency(historyItem.ComponentHistoryId, depNode.InnerText, depNode.Attributes["version"].InnerText, depNode.Attributes["versionnorm"].InnerText, depNode.Attributes["name"].InnerText); } List <int> handledClassIds = new List <int>(); foreach (XmlNode namespaceNode in DocumentElement.SelectNodes("namespace")) { ApiNamespace ns = ApiNamespaceRepository.Instance.GetOrCreateNamespace(ModuleId, namespaceNode.Attributes["name"].InnerText); log.Log(StartTime, "Namespace {0}", ns.NamespaceName); foreach (XmlNode classNode in namespaceNode.SelectNodes("class")) { List <int> handledMemberIds = new List <int>(); bool isDeprecated = false; string deprecationMessage = ""; if (classNode.SelectSingleNode("deprecation") != null) { isDeprecated = true; deprecationMessage = classNode.SelectSingleNode("deprecation").InnerText; } try { var documentation = classNode.SelectSingleNode("documentation").InnerXml.Trim(); var description = tryGetDescription(documentation); ApiClass cl = Sprocs.GetOrCreateClass(ns.NamespaceId, component.ComponentId, classNode.Attributes["name"].InnerText.Trim(), classNode.SelectSingleNode("fullName").InnerText.Trim(), classNode.SelectSingleNode("declaration").InnerText.Trim(), documentation, description, Version, isDeprecated, deprecationMessage.Trim(), bool.Parse(classNode.Attributes["IsAbstract"].InnerText), bool.Parse(classNode.Attributes["IsAnsiClass"].InnerText), bool.Parse(classNode.Attributes["IsArray"].InnerText), bool.Parse(classNode.Attributes["IsAutoClass"].InnerText), bool.Parse(classNode.Attributes["IsAutoLayout"].InnerText), bool.Parse(classNode.Attributes["IsBeforeFieldInit"].InnerText), bool.Parse(classNode.Attributes["IsByReference"].InnerText), bool.Parse(classNode.Attributes["IsClass"].InnerText), bool.Parse(classNode.Attributes["IsDefinition"].InnerText), bool.Parse(classNode.Attributes["IsEnum"].InnerText), bool.Parse(classNode.Attributes["IsExplicitLayout"].InnerText), bool.Parse(classNode.Attributes["IsFunctionPointer"].InnerText), bool.Parse(classNode.Attributes["IsGenericInstance"].InnerText), bool.Parse(classNode.Attributes["IsGenericParameter"].InnerText), bool.Parse(classNode.Attributes["IsImport"].InnerText), bool.Parse(classNode.Attributes["IsInterface"].InnerText), bool.Parse(classNode.Attributes["IsNested"].InnerText), bool.Parse(classNode.Attributes["IsNestedAssembly"].InnerText), bool.Parse(classNode.Attributes["IsNestedPrivate"].InnerText), bool.Parse(classNode.Attributes["IsNestedPublic"].InnerText), bool.Parse(classNode.Attributes["IsNotPublic"].InnerText)); log.Log(StartTime, "Class {0} (ID={1})", cl.ClassName, cl.ClassId); foreach (XmlNode memberNode in classNode.SelectNodes("constructors/constructor")) { handledMemberIds.Add(AddMemberToClass(ModuleId, cl.ClassId, memberNode, MemberType.Constructor, ref log)); } foreach (XmlNode memberNode in classNode.SelectNodes("methods/method")) { handledMemberIds.Add(AddMemberToClass(ModuleId, cl.ClassId, memberNode, MemberType.Method, ref log)); } foreach (XmlNode memberNode in classNode.SelectNodes("fields/field")) { handledMemberIds.Add(AddMemberToClass(ModuleId, cl.ClassId, memberNode, MemberType.Field, ref log)); } foreach (XmlNode memberNode in classNode.SelectNodes("properties/property")) { handledMemberIds.Add(AddMemberToClass(ModuleId, cl.ClassId, memberNode, MemberType.Property, ref log)); } foreach (XmlNode memberNode in classNode.SelectNodes("events/event")) { handledMemberIds.Add(AddMemberToClass(ModuleId, cl.ClassId, memberNode, MemberType.Event, ref log)); } foreach (var m in MemberRepository.Instance.GetMembersByApiClass(cl.ClassId)) { if (!handledMemberIds.Contains(m.MemberId)) { Sprocs.MemberDisappeared(m.MemberId, Version); } } handledClassIds.Add(cl.ClassId); log.Log(StartTime, "Finished class {0}", cl.ClassName); } catch (Exception ex) { Exceptions.LogException(ex); log.Log(StartTime, "Exception {0}. Stacktrace: {1}.", ex.Message, ex.StackTrace); } } } foreach (ApiClass c in ApiClassRepository.Instance.GetApiClassesByComponent(component.ComponentId)) { if (!handledClassIds.Contains(c.ClassId)) { Sprocs.ClassDisappeared(c.ClassId, Version); } } try { System.IO.File.Delete(this.FilePath); log.Log(StartTime, "Deleted {0}", FilePath); } catch (Exception ex) { log.Log(StartTime, "Could not delete {0}", FilePath); } log.Log(StartTime, "Finished component {0}", component.ComponentName); log.Flush(); log.Close(); }