public void UpdateMemberCodeBlock(MemberCodeBlock memberCodeBlock) { Requires.NotNull(memberCodeBlock); Requires.PropertyNotNegative(memberCodeBlock, "MemberCodeBlockId"); using (var context = DataContext.Instance()) { var rep = context.GetRepository <MemberCodeBlock>(); rep.Update(memberCodeBlock); } }
public int AddMemberCodeBlock(ref MemberCodeBlock memberCodeBlock) { Requires.NotNull(memberCodeBlock); using (var context = DataContext.Instance()) { var rep = context.GetRepository <MemberCodeBlock>(); rep.Insert(memberCodeBlock); } return(memberCodeBlock.CodeBlockId); }
private int AddMemberToClass(int moduleId, int classId, XmlNode memberNode, MemberType memberType, ref System.IO.StreamWriter log) { int res = -1; bool isDeprecated = false; string deprecationMessage = ""; if (memberNode.SelectSingleNode("deprecation") != null) { isDeprecated = true; deprecationMessage = memberNode.SelectSingleNode("deprecation").InnerText; } try { var documentation = memberNode.SelectSingleNode("documentation").InnerXml.Trim(); var description = tryGetDescription(documentation); var fullName = memberNode.SelectSingleNode("fullName").InnerText.Trim(); var m = Sprocs.GetOrCreateMember(classId, (int)memberType, memberNode.Attributes["name"].InnerText.Trim(), fullName, memberNode.SelectSingleNode("declaration").InnerText, documentation, description, Version, isDeprecated, deprecationMessage.Trim()); var existingCodeblocks = MemberCodeBlockRepository.Instance.GetMemberCodeBlocksByMember(m.MemberId); log.Log(StartTime, "Member {0} (ID={1})", m.MemberName, m.MemberId); res = m.MemberId; MemberCodeBlock block = null; foreach (XmlNode codeNode in memberNode.SelectNodes("codeblock")) { var cb = CodeBlock.FromXmlBlock(moduleId, codeNode); if (!cb.IsPresentIn(existingCodeblocks)) { CodeBlocksController.SaveCodeBlock(cb, System.IO.Path.GetDirectoryName(FilePath)); log.Log(StartTime, "New Codeblock {0}", cb.Hash); MemberCodeBlock mcb = new MemberCodeBlock { EndColumn = cb.EndColumn, EndLine = cb.EndLine, StartColumn = cb.StartColumn, StartLine = cb.StartLine, FileName = cb.FileName, MemberId = m.MemberId, CodeHash = cb.Hash, Version = Version }; if (mcb.EndLine != 0 && mcb.EndLine > mcb.StartLine) { block = Sprocs.GetOrCreateMemberCodeBlock(mcb.MemberId, mcb.CodeHash, mcb.Version, mcb.FileName, (int)mcb.StartLine, (int)mcb.StartColumn, (int)mcb.EndLine, (int)mcb.EndColumn); } } if (block == null) { block = MemberCodeBlockRepository.Instance.GetMemberCodeBlock(m.MemberId, Version); } foreach (XmlNode refNode in codeNode.SelectNodes("refs/ref")) { var refName = refNode.InnerText; if (refName != fullName) { Sprocs.GetOrCreateReference(block.CodeBlockId, refName, int.Parse(refNode.Attributes["os"].InnerText)); } } } } catch (Exception ex) { Exceptions.LogException(ex); log.Log(StartTime, "Exception {0}. Stacktrace: {1}.", ex.Message, ex.StackTrace); } return(res); }