public MemberReferenceField(GenericContext gc, MemberReferenceHandle handle) : base(gc.Cx) { this.handle = handle; this.gc = gc; mr = Cx.MdReader.GetMemberReference(handle); declType = (Type)Cx.CreateGeneric(gc, mr.Parent); }
/// <summary> /// Add Created Perf Record /// </summary> private void Pa(Prf CurrLog, Cx CurrCodeType, string Comments = null) { if (C == null || C.P != true || CurrLog == null) { return; } var Log = CurrLog; if (C.Pr == true && CurrCodeType != null && CurrCodeType.S != null && CurrCodeType.S.Pr == true) { Log.Ie = Pp(CurrCodeType); } Log.C = Comments; var End = _.d; Log.De = End; Log.T = (End - Log.Ds).Ticks; Log.Ms = (End - Log.Ds).TotalMilliseconds; L.P.Add(Log); Rn++; if (Rl > 1 && Rn > Rl) { Sv(); } }
public override void VisitCompilationUnit(CompilationUnitSyntax compilationUnit) { foreach (var m in compilationUnit.ChildNodes()) { Cx.Try(m, null, () => ((CSharpSyntaxNode)m).Accept(this)); } ExtractGlobalStatements(compilationUnit); // Gather comments: foreach (var trivia in compilationUnit.DescendantTrivia(compilationUnit.Span, descendIntoTrivia: true)) { CommentPopulator.ExtractComment(Cx, trivia); } foreach (var trivia in compilationUnit.GetLeadingTrivia()) { CommentPopulator.ExtractComment(Cx, trivia); } foreach (var trivia in compilationUnit.GetTrailingTrivia()) { CommentPopulator.ExtractComment(Cx, trivia); } }
public MethodSpecificationMethod(GenericContext gc, MethodSpecificationHandle handle) : base(gc) { this.handle = handle; ms = Cx.MdReader.GetMethodSpecification(handle); typeParams = ms.DecodeSignature(Cx.TypeSignatureDecoder, gc); unboundMethod = (Method)Cx.CreateGeneric(gc, ms.Method); }
public MemberReferenceMethod(GenericContext gc, MemberReferenceHandle handle) : base(gc) { this.handle = handle; this.gc = gc; mr = Cx.MdReader.GetMemberReference(handle); signature = mr.DecodeMethodSignature(new SignatureDecoder(), gc); parent = (GenericContext)Cx.CreateGeneric(gc, mr.Parent); var declType = parent is Method parentMethod ? parentMethod.DeclaringType : parent as Type; if (declType is null) { throw new InternalError("Parent context of method is not a type"); } declaringType = declType; nameLabel = Cx.GetString(mr.Name); var typeSourceDeclaration = declaringType.SourceDeclaration; sourceDeclaration = typeSourceDeclaration == declaringType ? (Method)this : typeSourceDeclaration.LookupMethod(mr.Name, mr.Signature); }
/// <summary> /// Add Log Information /// </summary> private void Ai(Cx CurrCodeType, string Comments = null, Mx CustomMethodContext = null) { if (C == null || C.L != true) { return; } Ce(CurrCodeType, CustomMethodContext); var r = new Inf() { C = Comments }; if (CurrCodeType != null) { r.X = CurrCodeType.CxId; } if (CustomMethodContext != null) { r.M = CustomMethodContext.CmId; } L.I.Add(r); Rn++; if (Rl > 1 && Rn > Rl) { Sv(); } }
public override void VisitAttributeList(AttributeListSyntax node) { if (Cx.Extractor.Mode.HasFlag(ExtractorMode.Standalone)) { return; } var outputAssembly = Assembly.CreateOutputAssembly(Cx); var kind = node.Target?.Identifier.Kind() switch { SyntaxKind.AssemblyKeyword => Entities.AttributeKind.Assembly, SyntaxKind.ModuleKeyword => Entities.AttributeKind.Module, _ => throw new InternalError(node, "Unhandled global target") }; foreach (var attribute in node.Attributes) { if (attributeLookup.Value(attribute) is AttributeData attributeData) { var ae = Entities.Attribute.Create(Cx, attributeData, outputAssembly, kind); Cx.BindComments(ae, attribute.GetLocation()); } } } }
public override IEnumerable <SvgAttribute> GetAttributes() { var baseAttributes = base.GetAttributes(); if (baseAttributes != null) { foreach (var attr in baseAttributes) { yield return(attr); } } var ci = CultureInfo.InvariantCulture; yield return(new SvgAttribute("cx", "0", () => Cx.ToString(ci), v => Cx = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("cy", "0", () => Cy.ToString(ci), v => Cy = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("rx", "0", () => Rx.ToString(ci), v => Rx = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("ry", "0", () => Ry.ToString(ci), v => Ry = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("stroke-width", () => StrokeWidth.ToString(ci), v => StrokeWidth = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("stroke", () => ColorTranslator.ToSvg(Stroke), v => Stroke = SvgAttribute.ParseColorAttribute(v, Stroke.A) )); yield return(new SvgAttribute("stroke-opacity", "1", () => ((double)Stroke.A / 255).ToString(ci), v => Stroke = SvgAttribute.ParseOpacityAttribute(v, Stroke) )); yield return(new SvgAttribute("fill", () => Fill.A == 0 ? "none" : ColorTranslator.ToSvg(Fill), v => Fill = SvgAttribute.ParseColorAttribute(v, Fill.A) )); yield return(new SvgAttribute("fill-opacity", "1", () => ((double)Fill.A / 255).ToString(ci), v => Fill = SvgAttribute.ParseOpacityAttribute(v, Fill) )); }
private IEnumerable <IExtractionProduct> Decode(byte[]?ilbytes, Dictionary <int, Instruction> jump_table) { // Sequence points are stored in order of offset. // We use an enumerator to locate the correct sequence point for each instruction. // The sequence point gives the location of each instruction. // The location of an instruction is given by the sequence point *after* the // instruction. IEnumerator <PDB.SequencePoint>?nextSequencePoint = null; PdbSourceLocation?instructionLocation = null; if (methodDebugInformation != null) { nextSequencePoint = methodDebugInformation.SequencePoints.GetEnumerator(); if (nextSequencePoint.MoveNext()) { instructionLocation = Cx.CreateSourceLocation(nextSequencePoint.Current.Location); yield return(instructionLocation); } else { nextSequencePoint = null; } } var child = 0; for (var offset = 0; offset < (ilbytes?.Length ?? 0);) { var instruction = new Instruction(Cx, this, ilbytes !, offset, child++); yield return(instruction); if (nextSequencePoint != null && offset >= nextSequencePoint.Current.Offset) { instructionLocation = Cx.CreateSourceLocation(nextSequencePoint.Current.Location); yield return(instructionLocation); if (!nextSequencePoint.MoveNext()) { nextSequencePoint = null; } } if (instructionLocation != null) { yield return(Tuples.cil_instruction_location(instruction, instructionLocation)); } jump_table.Add(instruction.Offset, instruction); offset += instruction.Width; } foreach (var i in jump_table) { foreach (var t in i.Value.JumpContents(jump_table)) { yield return(t); } } }
public override Type Construct(IEnumerable <Type> typeArguments) { if (TotalTypeParametersCount != typeArguments.Count()) { throw new InternalError("Mismatched type arguments"); } return(Cx.Populate(new ConstructedType(Cx, this, typeArguments))); }
private void Populate() { if (ContainingNamespace is object) { Cx.Populate(ContainingNamespace); } Cx.Populate(this); }
/// <summary> /// Add details on contexts with check /// </summary> private void Ce(Cx CurrCodeType = null, Mx CustomMethodContext = null) { if (CurrCodeType != null && !L.X.Contains(CurrCodeType)) { L.X.Add(CurrCodeType); } if (CustomMethodContext != null && !L.C.Contains(CustomMethodContext)) { L.C.Add(CustomMethodContext); } }
/// <summary> /// Gets the primitive type corresponding to this type, if possible. /// </summary> /// <param name="t">The resulting primitive type, or null.</param> /// <returns>True if this type is a primitive type.</returns> public bool TryGetPrimitiveType([NotNullWhen(true)] out PrimitiveType?t) { if (TryGetPrimitiveTypeCode(out var code)) { t = Cx.Create(code); return(true); } t = null; return(false); }
public void WykonajAkcje() { //Włączenie Debug, aby działał należy wygenerować DLL w trybie DEBUG DebuggerSession.MarkLineAsBreakPoint(); //Pobieranie danych z Contextu Pracownik pracownik = null; if (Cx.Contains(typeof(Pracownik))) { pracownik = (Pracownik)Cx[typeof(Pracownik)]; } if (Cx.Contains(typeof(Pracownik[]))) { var someObject = Cx[typeof(Pracownik[])]; IList workersColletion = (IList)someObject; foreach (var worker in workersColletion) { workers.Add((Pracownik)worker); pracownik = (Pracownik)worker; } } double result = this.Parametry.Operacja == '+' ? this.Parametry.X + this.Parametry.Y : this.Parametry.Operacja == '-' ? this.Parametry.X - this.Parametry.Y : this.Parametry.Operacja == '*' ? this.Parametry.X * this.Parametry.Y : this.Parametry.Y == 0 ? this.Parametry.X / (this.Parametry.Y = 1) : this.Parametry.X / this.Parametry.Y; //Modyfikacja danych //Aby modyfikować dane musimy mieć otwartą sesję, któa nie jest read only using (Session nowaSesja = this.Cx.Login.CreateSession(false, false, "ModyfikacjaPracownika")) { //Otwieramy Transaction aby można było edytować obiekt z sesji using (ITransaction trans = nowaSesja.Logout(true)) { foreach (var worker in workers) { //Pobieramy obiekt z Nowo utworzonej sesji var pracownikZSesja = nowaSesja.Get(worker); //Features - są to pola rozszerzające obiekty w bazie danych, dzięki czemu nie jestesmy ogarniczeni to kolumn jakie zostały utworzone przez producenta pracownikZSesja.Features["DataObliczen"] = this.Parametry.DataObliczen; //pracownikZSesja.Features["Wynik"] = this.MakeOperation(this.Parametry.X, this.Parametry.Y, this.Parametry.Operacja); pracownikZSesja.Features["Wynik"] = result; //Zatwierdzamy zmiany wykonane w sesji trans.CommitUI(); } } //Zapisujemy zmiany nowaSesja.Save(); // Zakładam że zgodnie ze biblioteka napiana jest w standardzie C# 8.0 i instrukcja using zapewnia poprawne wywolanie IDisposable } }
public DefinitionMethod(GenericContext gc, MethodDefinitionHandle handle) : base(gc) { md = Cx.MdReader.GetMethodDefinition(handle); this.gc = gc; this.handle = handle; name = Cx.GetString(md.Name); declaringType = (Type)Cx.CreateGeneric(this, md.GetDeclaringType()); signature = md.DecodeSignature(new SignatureDecoder(), this); methodDebugInformation = Cx.GetMethodDebugInformation(handle); }
protected IEnumerable <Parameter> MakeParameters(IEnumerable <Type> parameterTypes) { var i = 0; if (!IsStatic) { yield return(Cx.Populate(new Parameter(Cx, this, i++, DeclaringType))); } foreach (var p in parameterTypes) { yield return(Cx.Populate(new Parameter(Cx, this, i++, p))); } }
public string to_string() { string str = n.ToString() + " " + nj.ToString() + " " + nx.ToString() + "\r\n"; str += Lj.ToString() + " " + Lx.ToString() + "\r\n"; str += Vj.ToString() + " " + Vx.ToString() + "\r\n"; str += Cj.ToString() + " " + Cx.ToString() + "\r\n"; str += Pt.ToString() + " " + At.ToString() + "\r\n"; foreach (var t in targets) { str += t.to_string() + "\r\n"; } return(str); }
protected IEnumerable <IExtractionProduct> GetParameterExtractionProducts(IEnumerable <Type> parameterTypes) { var i = 0; if (!IsStatic) { yield return(Cx.Populate(new Parameter(Cx, this, i++, DeclaringType))); } foreach (var p in GetParameterExtractionProducts(parameterTypes, this, this, Cx, i)) { yield return(p); } }
/// <summary> /// Realiza la desconexion con la Base de Datos /// Devuelve un Boleano y un mensaje en caso de error. /// </summary> /// <returns>bool</returns> public bool Desconectar() { try { Cx.Close(); this.Log.Write("*<- Conexion Cerrada"); } catch (SQLiteException ex) { this.Log.Write("*error Al cerrar conexion ->" + ex.ToString()); this.Mensaje = ex.ToString(); return(false); } return(true); }
public override void WriteAssemblyPrefix(TextWriter trapFile) { if (!string.IsNullOrWhiteSpace(assemblyName)) { var an = new AssemblyName(assemblyName); trapFile.Write(an.Name); trapFile.Write('_'); trapFile.Write((an.Version ?? new Version(0, 0, 0, 0)).ToString()); trapFile.Write(Type.AssemblyTypeNameSeparator); } else { Cx.WriteAssemblyPrefix(trapFile); } }
public override void WriteId(TextWriter trapFile) { trapFile.WriteSubId(type); trapFile.Write('.'); trapFile.Write(Cx.GetString(pd.Name)); trapFile.Write("("); var index = 0; var signature = pd.DecodeSignature(new SignatureDecoder(), gc); foreach (var param in signature.ParameterTypes) { trapFile.WriteSeparator(",", ref index); param.WriteId(trapFile, gc); } trapFile.Write(")"); }
public PrimitiveType Create(PrimitiveTypeCode code) { var e = primitiveTypes[(int)code]; if (e is null) { e = new PrimitiveType(this, code) { Label = Cx.GetNewLabel() }; Cx.DefineLabel(e, Cx.TrapWriter.Writer, Cx.Extractor); primitiveTypes[(int)code] = e; } return(e); }
/// <summary> /// Metodo Comunes para Insertar, Actualizar y Eliminar /// </summary> /// <param name="SQL"></param> /// <returns></returns> private bool Execute(string SQL, SQLiteParameter[] param, string nameConsulta) { bool error = true; if (this.Conectar()) { SQLiteTransaction trans = Cx.BeginTransaction(); try { Cmd.CommandText = SQL; if (param != null) { Cmd.Parameters.AddRange(param); } if (Cmd.ExecuteNonQuery() == -1) { this.Log.Write("* " + nameConsulta + " 0 rows afected"); this.Mensaje = "No hay Columnas Afectadas"; error = false; } trans.Commit(); this.Log.Write("* " + nameConsulta + " Ok"); } catch (SQLiteException ex) { trans.Rollback(); this.Log.Write("* " + nameConsulta + "\n" + ex.ToString()); this.Mensaje = ex.ToString(); error = false; } catch (NullReferenceException ex) { trans.Rollback(); this.Log.Write("* " + nameConsulta + "\n" + ex.ToString()); this.Mensaje = ex.ToString(); error = false; } finally { Desconectar(); } } return(error); }
public override void WriteAssemblyPrefix(TextWriter trapFile) { var ct = ContainingType; if (ct is null) { Cx.WriteAssemblyPrefix(trapFile); } else if (IsPrimitiveType) { trapFile.Write(Type.PrimitiveTypePrefix); } else { ct.WriteAssemblyPrefix(trapFile); } }
/// <summary> /// Realiza la conexion con la Base de Datos /// Recibe un String ConexionString /// Devuelve un Boleano y un mensaje en caso de error. /// </summary> /// <returns>bool</returns> public bool Conectar() { try { Cx.Open(); Cmd.Connection = Cx; Cmd.CommandType = System.Data.CommandType.Text; this.Log.Write("*-> Conexion Abierta"); } catch (SQLiteException ex) { this.Log.Write("*error Al abrir conexion ->" + ex.ToString()); this.Mensaje = ex.ToString(); return(false); } return(true); }
public override void VisitAttributeList(AttributeListSyntax node) { if (Cx.Extractor.Standalone) { return; } var outputAssembly = Assembly.CreateOutputAssembly(Cx); foreach (var attribute in node.Attributes) { if (attributeLookup.Value(attribute) is AttributeData attributeData) { var ae = Entities.Attribute.Create(Cx, attributeData, outputAssembly); Cx.BindComments(ae, attribute.GetLocation()); } } }
void statusChanged(object sender, StatusChangeEventArgs args) { try { if ((args.NewState & SCRState.Present) != 0 && (args.NewState & SCRState.InUse) == 0 && (args.NewState & SCRState.Mute) == 0) { var(Success, Report) = Cx.GetUid(_contextFactory, args.ReaderName); tk1.Text += "!UI Thread??"; Application.Current.Dispatcher.BeginInvoke(new Action(() => { tk1.Text += Success ? $"{Report}\r\n" : $"{args.LastState,-18} ► {args.NewState,-18} + {BitConverter.ToString(args.Atr)} => {Report}\r\n"; if (Success) { GetUID_finis(); } })); } } catch (Exception ex) { tk1.Text += $"{ex.Message}\r\n";; } }
/// <summary> /// Add Log Error /// </summary> private void Ae(Cx CurrCodeType, string Comments = null, Exception CurrExc = null, Mx CustomMethodContext = null) { if (C == null || C.L != true) { return; } Ce(CurrCodeType, CustomMethodContext); var r = new Err() { C = Comments }; if (CurrCodeType != null) { r.X = CurrCodeType.CxId; } if (CustomMethodContext != null) { r.M = CustomMethodContext.CmId; } if (CurrExc != null) { r.Esr = CurrExc.Source; r.Em = CurrExc.Message; if (S.S.Ea != true) { r.Et = CurrExc.StackTrace; r.Es = CurrExc.ToString(); r.Ets = CurrExc.TargetSite.ToString(); } } L.E.Add(r); Rn++; if (Rl > 1 && Rn > Rl) { Sv(); } }
public T Populate <T>(T e) where T : IExtractedEntity { if (e.Label.Valid) { return(e); // Already populated } if (ids.TryGetValue(e, out var existing)) { // It exists already e.Label = existing; } else { e.Label = Cx.GetNewLabel(); Cx.DefineLabel(e, Cx.TrapWriter.Writer, Cx.Extractor); ids.Add(e, e.Label); Cx.PopulateLater(() => { foreach (var c in e.Contents) { c.Extract(this); } }); #if DEBUG_LABELS using var writer = new StringWriter(); e.WriteId(writer); var id = writer.ToString(); if (debugLabels.TryGetValue(id, out var previousEntity)) { Cx.Extractor.Message(new Message("Duplicate trap ID", id, null, severity: Util.Logging.Severity.Warning)); } else { debugLabels.Add(id, e); } #endif } return(e); }
/// <summary> /// Get Current Process Performance Details /// </summary> public Guid?Pp(Cx CurrCodeType) { if (C == null || C.Pp != true) { return(null); } Prd r = new Prd(); if (Pr == null) { Pr = Process.GetCurrentProcess(); } if (Pr != null) { try { Pr.Refresh(); r.Ch = Pr.HandleCount; r.Sx = Pr.NonpagedSystemMemorySize64; r.Mx = Pr.PagedMemorySize64; r.Sp = Pr.PagedSystemMemorySize64; r.Px = Pr.PeakPagedMemorySize64; r.Vp = Pr.PeakVirtualMemorySize64; r.Wp = Pr.PeakWorkingSet64; r.Mp = Pr.PrivateMemorySize64; r.Tp = Pr.PrivilegedProcessorTime; r.Ct = Pr.Threads.Count; r.V = Pr.VirtualMemorySize64; r.W = Pr.WorkingSet64; } catch (Exception exc) { int ttt = 555; } } L.Pd.Add(r); return(r.PrdId); }