public CElement visitEnumType(ClangSharp.Type Type) { try { if (Type.Declaration.Kind != CursorKind.NoDeclFound) { CDataType datatype = (CDataType)visitArithMeticType(Type); datatype.Kind = DataTypeKind.ENUM_TYPE; datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString()); foreach (ClangSharp.Cursor child in Type.Declaration.Children) { CElement literal = _Factory.fac_getCParser().CParser_VisitVariableCursor(child); datatype.Children.Add(literal); datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + literal.ID); } return(datatype); } else { return(CTypeParser_ParseDataType(Type.Canonical)); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
protected override bool Grabar_Registro() { CElement oElement = new CElement(); oElement.Idelement = Idelement; oElement.Cod_element = tbCodElement.Text; oElement.Name_element = tbDenomination.Text; oElement.Description = tbDescription.Text; oElement.Native_element = tbGroup.Text; oElement.Type_element = 'C'; if (Idelement == 0) { oElement.Usernew = Comun.GetUser(); oElement.Useredit = Comun.GetUser(); oElement.Datenew = Comun.GetDate(); oElement.Dateedit = Comun.GetDate(); } else { oElement.Datenew = Comun.GetDate(); oElement.Dateedit = Comun.GetDate(); } CElementFactory faElement = new CElementFactory(); if (!faElement.Update(oElement)) faElement.Insert(oElement); ComunForm.Send_message(this.Text, TypeMsg.ok, ""); return true; }
public void Visit(CElement element) { if (!String.IsNullOrEmpty(element.Content)) { AddToCurrentParagraph(new MdCodeSpan(element.Content)); } }
public void AstDB_AddElement(CElement Element) { if (ElementMap.ContainsKey(Element.ID) == false) { ElementMap.Add(Element.ID, Element); } }
public void Visit(CElement element) { if (!String.IsNullOrEmpty(element.Content)) { Result.Add(new MdCodeSpan(element.Content)); } }
protected override bool Grabar_Registro() { CElement oElement = new CElement(); oElement.Idelement = Idelement; oElement.Cod_element = tbCodElement.Text; oElement.Name_element = tbDenomination.Text; oElement.Description = tbDescription.Text; oElement.Native_element = tbGroup.Text; oElement.Type_element = 'C'; if (Idelement == 0) { oElement.Usernew = Comun.GetUser(); oElement.Useredit = Comun.GetUser(); oElement.Datenew = Comun.GetDate(); oElement.Dateedit = Comun.GetDate(); } else { oElement.Datenew = Comun.GetDate(); oElement.Dateedit = Comun.GetDate(); } CElementFactory faElement = new CElementFactory(); if (!faElement.Update(oElement)) { faElement.Insert(oElement); } ComunForm.Send_message(this.Text, TypeMsg.ok, ""); return(true); }
/// <summary> /// Analyse all function prototypes /// </summary> /// <param name="Cursor"></param> /// <returns></returns> public CElement CParser_VisitFunctionCursor(Cursor Cursor) { //first compute the md5 of the cursor and check if it already exist in database //if yes return the already created object string md5 = CCodeFramework.Util.Util.ComputeMd5(Cursor); CFunction function; CElement element = _DB.AstDB_FindElement(md5); if (element == null && Cursor.Kind != CursorKind.NoDeclFound) { function = new CFunction(); function.ID = md5; string fileName = Cursor.Location.File.Name.Replace('/', '\\'); function.File = fileName; function.Line = Cursor.Location.Line; function.Column = Cursor.Location.Column; function.ElementID = CCodeFramework.Util.Util.ComputeElementMd5(Cursor); function.ElementKind = ElementKind.Function; function.Name = Cursor.Spelling; function.ProtoTypeHash = CCodeFramework.Util.Util.ComputeMd5(Cursor.ResultType); _DB.AstDB_AddElement(function); //add the function object back to database CElement retur = _typeParser.CTypeParser_ParseDataType(Cursor.ResultType); //find the datatype of the return Type of the function function.ReturnType = retur.ID; function.IsDefinition = Cursor.IsDefinition; function.StorageClass = (CCodeTypes.Types.StorageClass)Cursor.StorageClass; int argCount = Cursor.NumArguments; for (uint i = 0; i < argCount; i++)//iterate through all the arguments and find their name and type { ClangSharp.Cursor cur = Cursor.GetArgument(i); function.ProtoTypeHash += CCodeFramework.Util.Util.ComputeMd5(cur.Type); function.Parameters.Add(CParser_VisitVariableCursor(cur)); } var CalledFunctions = Cursor.Descendants.Where(x => x.Kind == CursorKind.CallExpr);//find all functions called from this function foreach (Cursor called in CalledFunctions) { if (called.Referenced != null) //Referenced contain the original function cursor { if (called.Referenced.Location.File.Name != function.File && called.Referenced.Kind == CursorKind.FunctionDecl) //analyse only those functions which are not defined in the same file { function.Children.Add(CParser_VisitFunctionCursor(called.Referenced).ID); } } } return(function); } else { if (element is CFunction)//if already found in database check if that is of type Function { function = element as CFunction; return(function); } else { return(null); } } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { CElement _element = (CElement)values[0]; bool _is_distinct = (bool)values[1]; return(_is_distinct ? (object)_element.EntitiesDistinct : (object)_element.EntitiesByName); } catch (Exception) { return(null); } }
public CElement AstDB_FindAndAddElement(CElement Element) { CElement element = AstDB_FindElement(Element.ID); if (element == null) { AstDB_AddElement(element); } return(element); }
protected override void Recuperar_Registro() { CElementFactory faElement = new CElementFactory(); CElement oElement = faElement.GetByPrimaryKey(new CElementKeys(Idelement)); tbCodElement.Text = oElement.Cod_element; tbDenomination.Text = oElement.Name_element; tbDescription.Text = oElement.Description; tbGroup.Text = oElement.Native_element; }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CElement businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_element_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idelement", businessObject.Idelement); sqlCommand.Parameters["p_idelement"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters["p_idelement"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_cod_element", businessObject.Cod_element); sqlCommand.Parameters["p_cod_element"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_name_element", businessObject.Name_element); sqlCommand.Parameters["p_name_element"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_description", businessObject.Description); sqlCommand.Parameters["p_description"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_native_element", businessObject.Native_element); sqlCommand.Parameters["p_native_element"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_type_element", businessObject.Type_element); sqlCommand.Parameters["p_type_element"].NpgsqlDbType = NpgsqlDbType.Char; sqlCommand.Parameters.AddWithValue("p_usernew", businessObject.Usernew); sqlCommand.Parameters["p_usernew"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_datenew", businessObject.Datenew); sqlCommand.Parameters["p_datenew"].NpgsqlDbType = NpgsqlDbType.Date; sqlCommand.Parameters.AddWithValue("p_useredit", businessObject.Useredit); sqlCommand.Parameters["p_useredit"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_dateedit", businessObject.Dateedit); sqlCommand.Parameters["p_dateedit"].NpgsqlDbType = NpgsqlDbType.Date; sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status); sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idelement = Convert.ToInt16(sqlCommand.Parameters["p_idelement"].Value); return(true); } catch (Exception ex) { throw new Exception("CElement::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CElement businessObject, IDataReader dataReader) { businessObject.Idelement = (short)dataReader.GetInt16(dataReader.GetOrdinal(CElement.CElementFields.Idelement.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Cod_element.ToString()))) { businessObject.Cod_element = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Cod_element.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Name_element.ToString()))) { businessObject.Name_element = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Name_element.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Description.ToString()))) { businessObject.Description = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Description.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Native_element.ToString()))) { businessObject.Native_element = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Native_element.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Type_element.ToString()))) { businessObject.Type_element = dataReader.GetChar(dataReader.GetOrdinal(CElement.CElementFields.Type_element.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Usernew.ToString()))) { businessObject.Usernew = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Usernew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Datenew.ToString()))) { businessObject.Datenew = dataReader.GetDateTime(dataReader.GetOrdinal(CElement.CElementFields.Datenew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Useredit.ToString()))) { businessObject.Useredit = dataReader.GetString(dataReader.GetOrdinal(CElement.CElementFields.Useredit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Dateedit.ToString()))) { businessObject.Dateedit = dataReader.GetDateTime(dataReader.GetOrdinal(CElement.CElementFields.Dateedit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CElement.CElementFields.Status.ToString()))) { businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CElement.CElementFields.Status.ToString())); } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CElement</returns> internal List <CElement> PopulateObjectsFromReader(IDataReader dataReader) { List <CElement> list = new List <CElement>(); while (dataReader.Read()) { CElement businessObject = new CElement(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
public string Fac_GetComponentName(CElement function) { string dir = (function.File); string path = Path.GetFileName(dir); string[] keys = _SourceGroups.Keys.Where(x => dir.Contains(x)).ToArray(); if (keys.Count() > 0) { path = _SourceGroups[keys[keys.Count() - 1]]; } return(path); }
/// <summary> /// 清除选择 /// </summary> private void ClearSelectElement() { if (null != mSelectElement) { mSelectElement.HideHighLight(); } mSelectElement = null; if (objArrayAll) { objArrayAll.gameObject.SetActive(false); } }
//constructor to publish one file public CServerPublishFiles(MemoryStream buffer, CElement element) { DonkeyHeader header; BinaryWriter writer = new BinaryWriter(buffer); header = new DonkeyHeader((byte)Protocol.ServerCommand.OfferFiles, writer); writer.Write(1); m_AddFileToPacket(writer, element); header.Packetlength = (uint)writer.BaseStream.Length - header.Packetlength + 1; writer.Seek(0, SeekOrigin.Begin); header.Serialize(writer); writer.Write(1); CLog.Log(Types.Constants.Log.Info, "FIL_PUBLISHED", 1); }
public CElement visitStructOrUnionType(ClangSharp.Type type) { try { if (type.Declaration.Kind != CursorKind.NoDeclFound) { CDataType datatype = (CDataType)visitArithMeticType(type); if (type.Declaration.Kind == CursorKind.UnionDecl) { datatype.Kind = DataTypeKind.UNION_TYPE; } else if (type.Declaration.Kind == CursorKind.StructDecl) { datatype.Kind = DataTypeKind.STRUCT_TYPE; } datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString()); foreach (Cursor child in type.Declaration.Children) { datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + child.Spelling + child.Type.Spelling); } foreach (Cursor child in type.Declaration.Children) { if (child.Kind == CursorKind.FieldDecl) { CElement attr = _Factory.fac_getCParser().CParser_VisitVariableCursor(child); if (attr != null) { datatype.Children.Add(attr); } } } return(datatype); } else { return(CTypeParser_ParseDataType(type.Canonical)); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
protected void WriteHead(string sTitle) { XmlElement CRootElement; XmlElement CElement; XmlElement htmlElement; xslDoc = new XmlDocument(); xslDoc.PreserveWhitespace = false; //生成xsl的头 xslDoc.AppendChild(xslDoc.CreateXmlDeclaration("1.0", "", "")); RootElement = xslDoc.CreateElement("xsl-stylesheet"); //根 RootElement.SetAttribute("xmlns:xsl", "http://www.w3.org/1999/XSL/Transform"); RootElement.SetAttribute("version", "1.0"); xslDoc.AppendChild(RootElement); element = xslDoc.CreateElement("xsl-output"); element.SetAttribute("method", "html"); RootElement.AppendChild(element); element = xslDoc.CreateElement("xsl-template"); element.SetAttribute("match", "/"); htmlElement = xslDoc.CreateElement("html"); element.AppendChild(htmlElement); CElement = xslDoc.CreateElement("head"); htmlElement.AppendChild(CElement); CRootElement = CElement; CElement = xslDoc.CreateElement("title"); CRootElement.AppendChild(CElement); CRootElement = CElement; if (sTitle == "") { //'备用title } else { CElement = xslDoc.CreateElement("xsl-value-of"); CElement.SetAttribute("select", sTitle); CRootElement.AppendChild(CElement); } CElement = xslDoc.CreateElement("xsl-apply-templates"); htmlElement.AppendChild(CElement); RootElement.AppendChild(element); }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CElement business object</returns> public CElement SelectByPrimaryKey(CElementKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_element_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idelement", NpgsqlDbType.Smallint, 2, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idelement)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CElement businessObject = new CElement(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CElement::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
public CElement visitPointerType(ClangSharp.Type type) { try { if (type != null) { CDataType datatype = (CDataType)visitArithMeticType(type); if (datatype != null) { datatype.Kind = DataTypeKind.POINTER_TYPE; if (type.Pointee.Canonical.TypeKind == ClangSharp.Type.Kind.FunctionProto) { datatype.Kind = DataTypeKind.FUNCTION_POINTER; } CElement elm = CTypeParser_ParseDataType(type.Pointee); if (elm != null) { datatype.Parent = elm.ID; } datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString() + datatype.Parent); return(datatype); } else { return(null); } } else { return(null); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
/// <summary> /// Function to analyse the Variables /// they can be either global variable or Function arguments /// or Struct Union member fileds or Enumeration types /// </summary> /// <param name="Cursor"></param> /// <returns></returns> public CElement CParser_VisitVariableCursor(Cursor Cursor) { //first compute the md5 of the cursor and check if it already exist in database //if yes return the already created object string md5 = CCodeFramework.Util.Util.ComputeMd5(Cursor); CElement element = _DB.AstDB_FindElement(md5); CVariable variable = null; try { if (null == element) { variable = new CVariable(); variable.Name = Cursor.Spelling; variable.ID = md5; variable.ElementID = CCodeFramework.Util.Util.ComputeElementMd5(Cursor); variable.File = Cursor.Location.File.Name.Replace('/', '\\'); variable.Line = Cursor.Location.Line; variable.Column = Cursor.Location.Column; variable.ElementKind = ElementKind.Variable; if (Cursor.Kind == CursorKind.VarDecl) { variable.VariableType = VariableType.GlobalVariable;//if it is a variable declairation then it must be a global variable } else if (Cursor.Kind == CursorKind.ParmDecl) { variable.VariableType = VariableType.FunctionParameter;//if it is a paramdecl from a function it is a parameter } else if (Cursor.Kind == CursorKind.FieldDecl) { variable.VariableType = VariableType.MemberField;// memeber fields in structure or union } else if (Cursor.Kind == CursorKind.EnumConstantDecl) { variable.VariableType = VariableType.EnumLiteral; //Enumeration literals } _DB.AstDB_AddElement(variable); //add variable to database CElement type = _typeParser.CTypeParser_ParseDataType(Cursor.Type); if (type != null) { variable.Type = type.ID;//assign the md5 as the type } else { variable.Type = ""; } return(variable); } else { if (element is CVariable)//return the Database element only if it is of type Variable { variable = element as CVariable; return(variable); } else { return(null); } } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
private void _Revalidate() { if (!_NeedsRevalidate) { return; } _NeedsRevalidate = false; int numvis = Math.Min(_NumVisible, _Values.Count); if (numvis != _VisibleElements.Count) { _VisibleElements.Clear(); for (int i = 0; i < numvis; i++) { var el = new CElement { Text = new CText(0, 0, 0, _TextH, _MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, _TextColor, "T", _PartyModeID), Img = new CStatic(_PartyModeID) }; el.Img.Aspect = EAspect.Crop; _VisibleElements.Add(el); } } if (numvis == 0) { return; } float elWidth = (Rect.W - _TextRelativeX * 2) / numvis; //Center point of the first entry float xStart = Rect.X + _TextRelativeX + elWidth / 2f; int offset = _GetCurOffset(); for (int i = 0; i < numvis; i++) { CText text = _VisibleElements[i].Text; RectangleF textBounds; float curX = xStart + elWidth * i; if (String.IsNullOrEmpty(_Values[i + offset].Text)) { text.Visible = false; textBounds = new RectangleF(); } else { text.Visible = true; text.Text = _Values[i + offset].Text; text.TranslationID = _Values[i + offset].TranslationId; text.Color = (i + offset == Selection) ? _SelTextColor : _TextColor; textBounds = CBase.Fonts.GetTextBounds(text); text.X = curX; text.Z = Rect.Z; } CStatic img = _VisibleElements[i].Img; if (!DrawTextures || _Values[i + offset].Texture == null) { if (text.Visible) { text.Y = Rect.Y + (Rect.H - textBounds.Height) / 2 - _TextRelativeY; } img.Visible = false; _VisibleElements[i].Bounds = new SRectF(text.X - textBounds.Width / 2f, text.Y, textBounds.Width, textBounds.Height, Rect.Z); } else { text.Y = (int)(Rect.Y + Rect.H - textBounds.Height - _TextRelativeY); img.Texture = _Values[i + offset].Texture; float alpha = (i + offset == _Selection) ? 1f : 0.35f; img.Color = new SColorF(1f, 1f, 1f, alpha); float size = Rect.H - textBounds.Height - 2 * _TextRelativeY; if (size > elWidth) { size = elWidth; } var imgRect = new SRectF(curX - size / 2, Rect.Y + _TextRelativeY, size, size, Rect.Z); img.MaxRect = imgRect; _VisibleElements[i].Bounds = imgRect; } } }
public string Createsyntaxtree(string newcsfile, string oldCsfile, FilesDetails filedetails) { try { List <string> spans = new List <string>(); FilesDetails.FileSpan.TryGetValue(filedetails.Filename, out spans); List <int> sp = spans.ConvertAll(int.Parse); SourceText oldtext = SourceText.From(oldCsfile); var newtree = CSharpSyntaxTree.ParseText(newcsfile); var oldTree = CSharpSyntaxTree.ParseText(oldCsfile); var newTreeroot = newtree.GetRoot(); // var span1 = newtree.GetText().GetTextChanges(oldtext); foreach (var spindex in sp) { var span = newtree.GetText().Lines[2689].Span; var nodes = newTreeroot.DescendantNodes().Where(x => x.Span.IntersectsWith(span)); //get based on nodes span: try { var newElement = ""; newElement = "File Path: " + filedetails.filePath + "\n" + "File Name: " + filedetails.Filename + "\n"; var m = newTreeroot.FindNode(span).FirstAncestorOrSelf <MethodDeclarationSyntax>(); if (m != null) { string methoddetails = m.Modifiers + " " + m.ReturnType + " " + m.Identifier + m.ParameterList; string mname1 = "Method Name: " + methoddetails + "\n"; newElement = newElement + mname1; var lnodes = nodes.ToList(); var blockindex = lnodes.IndexOf(x => x.Kind().ToString() == "Block"); for (int i = blockindex; i < lnodes.Count; i++) { Console.WriteLine(lnodes[i].Kind()); if (lnodes[i].Kind().ToString() == "IdentifierName") { break; } string kindtext = lnodes[i].Kind().ToString(); newElement = newElement + kindtext + "\n"; } } var p = newTreeroot.FindNode(span).FirstAncestorOrSelf <PropertyDeclarationSyntax>(); if (p != null) { string propertydeatils = p.Modifiers + " " + p.Identifier.ToString() + " " + p.ExpressionBody; string PropertyName = "Property: " + propertydeatils + "\n"; newElement = newElement + PropertyName; //Propperty to identifier } var c = newTreeroot.FindNode(span).FirstAncestorOrSelf <ConstructorDeclarationSyntax>(); if (c != null) { string constrctordetails = c.Modifiers + " " + c.Identifier + " " + c.ParameterList; string ConstructorName = "Constructor: " + constrctordetails + "\n"; newElement = newElement + ConstructorName; //block to identifier } } catch (Exception ex) { throw; } } var difflst = newtree.GetChanges(oldTree); if (difflst.Count > 0) { difflst.RemoveAll(x => x.NewText == ""); difflst.RemoveAll(x => x.NewText == "//"); difflst.RemoveAll(x => x.NewText == " "); difflst.RemoveAll(x => x.NewText == " "); difflst.RemoveAll(x => x.NewText == " "); } foreach (var item in difflst) { var newElement = ""; newElement = "File Path: " + filedetails.filePath + "\n" + "File Name: " + filedetails.Filename + "\n"; string parentnode = string.Empty; MethodDeclarationSyntax methodfirst = null; try { methodfirst = newTreeroot.FindNode(item.Span).FirstAncestorOrSelf <MethodDeclarationSyntax>(); } catch (Exception ex) //Only case of Exception { LogEntry.LogMsg.Error(newElement, ex); Console.WriteLine(item); Console.WriteLine(newElement); continue; } if (methodfirst != null) { parentnode = methodfirst.Kind().ToString(); string methoddetails = methodfirst.Modifiers + " " + methodfirst.ReturnType + " " + methodfirst.Identifier + methodfirst.ParameterList; string mname1 = "Method Name: " + methoddetails + "\n"; newElement = newElement + mname1; newElement = newElement + "SyntaxNode Tree:" + "\n"; } PropertyDeclarationSyntax prop = null; try { prop = newTreeroot.FindNode(item.Span).FirstAncestorOrSelf <PropertyDeclarationSyntax>(); } catch (Exception ex) { LogEntry.LogMsg.Error(newElement, ex); Console.WriteLine(item); Console.WriteLine(newElement); continue; } if (prop != null) { parentnode = prop.Kind().ToString(); string propertydeatils = prop.Modifiers + " " + prop.Identifier.ToString() + " " + prop.ExpressionBody; string PropertyName = "Property: " + propertydeatils + "\n"; newElement = newElement + PropertyName + "SyntaxNode Tree:" + "\n";; //newElement = newElement + "SyntaxNode Tree:" + "\n"; } //contructor ConstructorDeclarationSyntax cons = null; try { cons = newTreeroot.FindNode(item.Span).FirstAncestorOrSelf <ConstructorDeclarationSyntax>(); } catch (Exception ex) { LogEntry.LogMsg.Error(newElement, ex); Console.WriteLine(item); Console.WriteLine(newElement); continue; } if (cons != null) { parentnode = cons.Kind().ToString(); string constrctordetails = cons.Modifiers + " " + cons.Identifier + " " + cons.ParameterList; string ConstructorName = "Constructor: " + constrctordetails + "\n"; newElement = newElement + ConstructorName; newElement = newElement + "SyntaxNode Tree:" + "\n"; } if (parentnode != string.Empty) { //Code Elements var codeelementlist = newTreeroot.FindNode(item.Span).DescendantNodesAndSelf(); foreach (var CElement in codeelementlist) { if (!_ignorelist.Contains(CElement.ToString())) { newElement = newElement + CElement.Kind().ToString() + "\n"; } } } CsfileCodeElement = CsfileCodeElement + newElement + "\n"; } return(CsfileCodeElement); } catch (Exception ex) { throw ex; } }
public CXml PublishDataBase(string FilePath) { CXml Cxml = new CXml(); XmlSerializer serializer = new XmlSerializer(typeof(CXml)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ElementMap.Values.OrderBy(x => x.File); foreach (string key in ElementMap.Keys) { CElement element = ElementMap[key]; if (element is CFunction) { CFunction function = element as CFunction; //if (function.StorageClass != StorageClass.Static) { Function f = _factory.Fac_GetXmlFunctionType(function); if (function.IsDefinition == false) { IEnumerable <CElement> definition = ElementMap.Values.Where(x => x.ElementID == function.ElementID).ToList(); foreach (CElement e in definition) { if (e is CFunction) { CFunction def = e as CFunction; if (def.IsDefinition == true) { f.Definition = def.ID; } } } } f.PrototypeID = function.ElementID; f.Component = _factory.Fac_GetComponentName(function); f.Interface = _factory.Fac_GetInterfaceName(function); f.CalledFunctions.AddRange(function.Children); Cxml.Functions.Add(f); } } else if (element is CDataType) { Cxml.DataTypes.Add(_factory.Fac_GetXmlDataType(element as CDataType)); } else if (element is CVariable) { CVariable cv = element as CVariable; if (cv.VariableType == VariableType.GlobalVariable) { Variable v = _factory.Fac_GetXmlVariableType(element as CVariable); v.Component = _factory.Fac_GetComponentName(element); Cxml.Variables.Add(v); } } } try { using (var sww = new Utf8StringWriter()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; settings.Encoding = Encoding.ASCII; using (XmlWriter writer = XmlWriter.Create(sww, settings)) { serializer.Serialize(writer, Cxml, ns); string xml = sww.ToString(); StreamWriter w = new StreamWriter(new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite), Encoding.UTF8); w.Write(xml); w.Close(); } } } catch (Exception err) { Console.WriteLine(err.ToString()); } return(Cxml); }
private bool m_AddFileToPacket(BinaryWriter writer, CElement element) { try { if (!element.File.Empty) { writer.Write(element.File.FileHash); if (element.File.Completed) { writer.Write((uint)0xfbfbfbfb); writer.Write((ushort)0xfbfb); } else { writer.Write((uint)0xfcfcfcfc); writer.Write((ushort)0xfcfc); } uint nParameters = 2; if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.Length)) nParameters++; if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.VBitrate)) nParameters++; if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.VCodec)) nParameters++; writer.Write(nParameters); // name new ParameterWriter((byte)Protocol.FileTag.Name, element.File.FileName, writer); // size new ParameterWriter((byte)Protocol.FileTag.Size, element.File.FileSize, writer); if (element.File.Details.Type == (byte)Constants.FileType.Avi) { if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.Length)) new ParameterWriter(Protocol.FileExtraTags.length.ToString(), (string)element.File.Details.ListDetails[Constants.Avi.Length], writer); if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.VBitrate)) new ParameterWriter(Protocol.FileExtraTags.bitrate.ToString(), Convert.ToUInt32(((string)element.File.Details.ListDetails[Constants.Avi.VBitrate]).Replace(" Kbps", "")), writer); if (element.File.Details.ListDetails.ContainsKey(Constants.Avi.VCodec)) new ParameterWriter(Protocol.FileExtraTags.codec.ToString(), (string)element.File.Details.ListDetails[Constants.Avi.VCodec], writer); } return true; } } catch (Exception e) { Debug.WriteLine(e.ToString()); } return false; }
internal InterfaceFile FileToInterfaceFile(CElement Element) { if (apw) { if (Element==null) return null; InterfaceFile response=new InterfaceFile(); response.Name=Element.File.FileName; response.CompleteName=Element.File.CompleteName; response.Size=Element.File.FileSize; response.BytesDownloaded=Element.File.Transferred; response.RemainingBytes=Element.File.GetRemainingBytes(); response.Status=(byte)Element.File.FileStatus; response.ChunksStatus=Element.File.ChunksStatus; response.UploadPriority=Element.File.UpPriority; response.DownloadPriority=Element.File.DownPriority; response.Gaps=Element.File.Gaps; response.RequestingBlocks=Element.File.RequestingBlocks; response.UploadChunksAvaibility=Element.Statistics.UploadAvaibility; if (response.ChunksStatus.Length==0) { response.ChunksStatus=new byte[CHash.GetChunksCount(Element.File.FileSize)]; for (int i=0; i < response.ChunksStatus.Length; i++) { response.ChunksStatus[i]=(byte)Protocol.ChunkState.Empty; } } if (Element.SourcesList!=null) { response.nSources=(ushort)Element.SourcesList.Count(); response.DownSpeed=Element.SourcesList.GetDownloadSpeed(); response.ChunksAvaibility=Element.SourcesList.GetChunksAvaibility(); response.nValidSources=Element.SourcesList.GetUsableClients(); response.nTransferringSources=Element.SourcesList.GetDownloadingClients(); } else { response.DownSpeed=0; response.nSources=0; } response.strHash=CKernel.HashToString(Element.File.FileHash); if (response.Size!=0) response.PercentCompleted=(decimal)(response.Size-response.RemainingBytes)/response.Size; else response.PercentCompleted=0; response.CategoryID=Element.File.CategoryID; if (Element.File.FileStatus!=Protocol.FileState.Complete) response.Category=CKernel.CategoriesList[Element.File.CategoryID]; else response.Category=""; return response; } else return null; }
/// <summary> /// 处理鼠标行为事件 /// </summary> void OnMouseAction() { if (bLock) { return; } // #region 平移 视角 // if (Input.GetMouseButtonDown(2)) // { // bCameraOffset = true; // } // if (Input.GetMouseButtonUp(2)) // { // bCameraOffset = false; // } // // if (bCameraOffset) // { // vTargetOffset = new Vector3( // vTargetOffset.x + ((Input.GetAxis("Mouse X") * fMoveSpeed)), // vTargetOffset.y + ((Input.GetAxis("Mouse Y") * fMoveSpeed)), // 0 // ); // // //Vector3 vOffset = new Vector3(Input.GetAxis("Mouse X") * fMoveSpeed, 0, Input.GetAxis("Mouse Y") * fMoveSpeed); // //this.transform.Translate(this.transform.position + Vector3.left); // //Debug.Log(this.transform.position); // // return; // } // #endregion #region 移动视角 if (mSelectElement == null) { //!EventSystem.current.IsPointerOverGameObject()是否点在UI上 // // // if (Input.GetMouseButtonDown(1) && GUIUtility.hotControl == 0 && !EventSystem.current.IsPointerOverGameObject()) // { // bRightPress = true; // } if (Input.GetMouseButtonDown(1)) { bRightPress = true; Screen.lockCursor = false; } if (Input.GetMouseButtonUp(1)) { bRightPress = false; } if (bRightPress) { float fCamRotaY; if (bCanRotatDown) { //Mathf.Clamp 钳制.限制value的值在min和max之间, 如果value小于min,返回min。 如果value大于max,返回max,否则返回value fCamRotaY = Mathf.Clamp(vCamRotation.x + (Input.GetAxis("Mouse Y") * fRotatSpeed), 90f, 180); } else { fCamRotaY = vCamRotation.x + (Input.GetAxis("Mouse Y") * fRotatSpeed); } vCamRotation = new Vector3( fCamRotaY, vCamRotation.y + (Input.GetAxis("Mouse X") * fRotatSpeed), 180 ); } } #endregion /// if (Input.GetMouseButtonUp(0)) { bLeftPress = false; } if (Input.GetMouseButtonDown(0)) { if (GUIUtility.hotControl == 0) { ray = mCamera.ScreenPointToRay(Input.mousePosition); // 基本选择物体 if (Physics.Raycast(ray, out hit)) { CElement mElement = hit.collider.gameObject.GetComponent <CElement>(); if (mElement != null) { // 选中 ClearSelectElement(); mSelectElement = mElement; mSelectElement.ShowHighLight(); if (objArrayAll) { objArrayAll.transform.position = mSelectElement.transform.position; float fScale = mCamera.fieldOfView * 0.01f; objArrayAll.transform.localScale = new Vector3(fScale, fScale, fScale); objArrayAll.gameObject.SetActive(true); } else { //分解 , 结合操作 } } } else { ClearSelectElement(); //没有选择 return; } } } }
public CElement CTypeParser_ParseDataType(ClangSharp.Type Type) { string md5 = CCodeFramework.Util.Util.ComputeMd5(Type); CElement element = _DB.AstDB_FindElement(md5); CElement dataType = null; if (element == null) { switch (Type.TypeKind) { case ClangSharp.Type.Kind.Bool: case ClangSharp.Type.Kind.CharU: case ClangSharp.Type.Kind.UChar: case ClangSharp.Type.Kind.Char16: case ClangSharp.Type.Kind.Char32: case ClangSharp.Type.Kind.UShort: case ClangSharp.Type.Kind.UInt: case ClangSharp.Type.Kind.ULong: case ClangSharp.Type.Kind.ULongLong: case ClangSharp.Type.Kind.UInt128: case ClangSharp.Type.Kind.CharS: case ClangSharp.Type.Kind.SChar: case ClangSharp.Type.Kind.WChar: case ClangSharp.Type.Kind.Short: case ClangSharp.Type.Kind.Int: case ClangSharp.Type.Kind.Long: case ClangSharp.Type.Kind.LongLong: case ClangSharp.Type.Kind.Int128: case ClangSharp.Type.Kind.Float: case ClangSharp.Type.Kind.Double: case ClangSharp.Type.Kind.LongDouble: case ClangSharp.Type.Kind.Void: dataType = visitArithMeticType(Type); break; case ClangSharp.Type.Kind.FunctionProto: dataType = _Factory.fac_getCParser().CParser_VisitFunctionCursor(Type.Declaration); if (dataType == null) { dataType = visitFunctionprototype(Type); //if no declairation of the function is found then create it as a new DataType } break; case ClangSharp.Type.Kind.Elaborated: dataType = CTypeParser_ParseDataType(Type.Declaration.Type); break; case ClangSharp.Type.Kind.BlockPointer: case ClangSharp.Type.Kind.Pointer: case ClangSharp.Type.Kind.MemberPointer: case ClangSharp.Type.Kind.LValueReference: dataType = visitPointerType(Type); break; case ClangSharp.Type.Kind.Record: dataType = visitStructOrUnionType(Type); break; case ClangSharp.Type.Kind.IncompleteArray: case ClangSharp.Type.Kind.ConstantArray: dataType = visitArrayType(Type); break; case ClangSharp.Type.Kind.Enum: dataType = visitEnumType(Type); break; case ClangSharp.Type.Kind.Typedef: dataType = visitTypeDefType(Type); break; case ClangSharp.Type.Kind.Unexposed: case ClangSharp.Type.Kind.Invalid: if (Type.Declaration.Type.TypeKind != ClangSharp.Type.Kind.Invalid && Type.Declaration.Type.TypeKind != ClangSharp.Type.Kind.Unexposed) { dataType = CTypeParser_ParseDataType(Type.Declaration.Type); } else if (Type.Canonical.TypeKind != ClangSharp.Type.Kind.Invalid && Type.Canonical.TypeKind != ClangSharp.Type.Kind.Unexposed) { dataType = CTypeParser_ParseDataType(Type.Canonical); } if (dataType == null) { Console.Write(""); } break; default: Console.Write(""); break; } } else { if (element is CDataType) { dataType = element as CDataType; } } return(dataType); }