private static bool AreDifferentOperators(FieldGetter firstOperator, FieldGetter secondOperator, int[] calls, int i, int j, LocalOperation[] localOperations) { if (firstOperator.FieldName != secondOperator.FieldName) { return(true); } if (!firstOperator.Instance.Equals(secondOperator.Instance)) { return(true); } var definitions = new HashSet <LocalVariable> { firstOperator.Instance }; var isReassigned = false; for (var index = calls[i] + 1; index < calls[j]; index++) { var op = localOperations[index]; var def = op.GetDefinition(); if (def == null) { continue; } if (!definitions.Contains(def)) { continue; } isReassigned = true; break; } return(isReassigned); }
public FieldSymbol(string name, TypeProxy type, FieldGetter getter = null, FieldSetter setter = null, FieldRef getref = null) : base(name, type) { this.getter = getter; this.setter = setter; this.getref = getref; }
public bool Equals(FieldGetter other) { if (object.ReferenceEquals(null, other)) { return(false); } return(object.ReferenceEquals(this, other) || object.Equals(other._fieldInfo, _fieldInfo)); }
public ValueBinder( string?fieldName, FieldGetter <TParams, TField> getter, IEnumerable <ValueBinder.Converter <TField> > converters) { _fieldName = fieldName; _getter = getter; if (converters is ValueBinder.Converter <TField>[] array) { _converters = array; } else { _converters = converters.ToArray(); } }
private string GetFieldValue(FieldGetter fieldGetter, string deviceId) { string result = null; char[] charField = null; uint fieldLength = 0; fieldGetter(deviceId, charField, ref fieldLength); if (0 < fieldLength) { charField = new char[fieldLength]; fieldGetter(deviceId, charField, ref fieldLength); result = new string(charField); } return(result); }
private void Evaluate() { this.textBox1.Text = "Make sure you select an item in the Details Tree"; if (txtWith.Text == string.Empty || textReplace.Text == string.Empty) { this.textBox1.Text = "The result of your Formatting Rule will appear here..."; } else { DBFormatting current = this.fromInput(); DBFormatting.cache = new DBFormatting[] { current }; if (txtWith.Text.IndexOf("<Episode", 0) >= 0) { if (ep == null) { return; } this.textBox1.Text = FieldGetter.resolveDynString(this.textReplace.Text, ep, true, true); } else if (txtWith.Text.IndexOf("<Season", 0) >= 0) { if (season == null) { return; } this.textBox1.Text = FieldGetter.resolveDynString(this.textReplace.Text, season, true, true); } else { if (txtWith.Text.IndexOf("<Series", 0) >= 0) { if (series == null) { return; } this.textBox1.Text = FieldGetter.resolveDynString(this.textReplace.Text, series, true, true); } } DBFormatting.cache = null; } }
private SummaryValue <double> GetSummary(FieldGetter field, bool skipZero, bool total, bool getStdDev) { int skip = 0; double a = 0; double tot = 0; int i = 0; double stdDev = 0; for (i = 0; i < this.results.Count; i++) { double x = field(this.results[i]); if (skipZero && x == 0 || double.IsNaN(x) || double.IsInfinity(x)) { skip++; } else { tot += x; if (getStdDev) { //standard deviation double ap = a; a += (x - ap) / (i + 1); stdDev += (x - a) * (x - ap); } } } if (!total || (!m_isTotal && !Settings.ResultSummaryTotal)) { tot = tot / NoOfResults(skip); } if (getStdDev) { stdDev = stdDev / NoOfResults(skip); stdDev = Math.Sqrt(stdDev); } return(new SummaryValue <double>(tot, stdDev)); }
public void LoadField(string fieldName) { var firstVar = _evaluator.Pop(); var vreg = SetNewVReg(); var computedType = firstVar.ComputedType(); if (computedType.ClrType.IsByRef) { computedType = new TypeDescription(computedType.ClrType.GetElementType()); } vreg.FixedType = new TypeDescription( computedType.ClrType.LocateField(fieldName).FieldType); var assignment = new FieldGetter { AssignedTo = vreg, FieldName = fieldName, Instance = (LocalVariable)firstVar }; AddOperation(OperationKind.GetField, assignment); }
static void GenericLdtokenFieldsTest() { Func <FieldInfo, string> FieldFullName = (fi) => fi.FieldType + " " + fi.DeclaringType.ToString() + "::" + fi.Name; IFieldGetter getter1 = new FieldGetter <string>(); IFieldGetter getter2 = new FieldGetter <object>(); IFieldGetter getter3 = new FieldGetter <int>(); foreach (var instArg in new Type[] { typeof(String), typeof(object), typeof(int) }) { IFieldGetter getter = (IFieldGetter)Activator.CreateInstance(typeof(FieldGetter <>).MakeGenericType(instArg)); string expectedField1 = "System.Int32 Gen`1[???]::m_Field1".Replace("???", instArg.ToString()); string expectedField2 = "System.String Gen`1[???]::m_Field2".Replace("???", instArg.ToString()); string expectedField3 = "??? Gen`1[???]::m_Field3".Replace("???", instArg.ToString()); string expectedField4 = "System.Collections.Generic.List`1[???] Gen`1[???]::m_Field4".Replace("???", instArg.ToString()); string expectedField5 = "System.Collections.Generic.KeyValuePair`2[???,System.Int32] Gen`1[???]::m_Field5".Replace("???", instArg.ToString()); string expectedDllField1 = "System.String MyGeneric`2[???,???]::m_Field1".Replace("???", instArg.ToString()); string expectedDllField2 = "??? MyGeneric`2[???,???]::m_Field2".Replace("???", instArg.ToString()); string expectedDllField3 = "System.Collections.Generic.List`1[???] MyGeneric`2[???,???]::m_Field3".Replace("???", instArg.ToString()); string expectedDllField4 = "System.Collections.Generic.KeyValuePair`2[???,System.Int32] MyGeneric`2[???,???]::m_Field4".Replace("???", instArg.ToString()); string expectedDllField5 = "System.Int32 MyGeneric`2[???,???]::m_Field5".Replace("???", instArg.ToString()); Assert.AreEqual(expectedField1, FieldFullName(getter.GetGenT_Field1())); Assert.AreEqual(expectedField2, FieldFullName(getter.GetGenT_Field2())); Assert.AreEqual(expectedField3, FieldFullName(getter.GetGenT_Field3())); Assert.AreEqual(expectedField4, FieldFullName(getter.GetGenT_Field4())); Assert.AreEqual(expectedField5, FieldFullName(getter.GetGenT_Field5())); Assert.AreEqual(expectedDllField1, FieldFullName(getter.GetGenDllT_Field1())); Assert.AreEqual(expectedDllField2, FieldFullName(getter.GetGenDllT_Field2())); Assert.AreEqual(expectedDllField3, FieldFullName(getter.GetGenDllT_Field3())); Assert.AreEqual(expectedDllField4, FieldFullName(getter.GetGenDllT_Field4())); Assert.AreEqual(expectedDllField5, FieldFullName(getter.GetGenDllT_Field5())); } }
public bool Equals(FieldGetter other) { if (object.ReferenceEquals(null, other)) return false; return (object.ReferenceEquals(this, other) || object.Equals(other._fieldInfo, _fieldInfo)); }
private double GetSummaryValue(FieldGetter field, bool skipZero, bool total) { return(GetSummary(field, skipZero, total, false).Value); }
private SummaryValue <double> GetSummary(FieldGetter field, bool skipZero, bool total) { return(GetSummary(field, skipZero, total, true)); }