public static void Main() { test_is(); DerivedType derivedObj = new DerivedType(); BaseType baseObj1 = new BaseType(); BaseType baseObj2 = derivedObj; DerivedType derivedObj2 = baseObj2 as DerivedType; if( derivedObj2 != null ) { Console.WriteLine( "Conversion Succeeded" ); } else { Console.WriteLine( "Conversion Failed" ); } derivedObj2 = baseObj1 as DerivedType; if( derivedObj2 != null ) { Console.WriteLine( "Conversion Succeeded" ); } else { Console.WriteLine( "Conversion Failed" ); } BaseType baseObj3 = derivedObj as BaseType; if( baseObj3 != null ) { Console.WriteLine( "Conversion Succeeded" ); } else { Console.WriteLine( "Conversion Failed" ); } System.Console.WriteLine("Press any key to continue..."); System.Console.ReadKey(); }
public void Should_allow_hierarchy_conversion_for_parameter() { var func = CreateFunc <DerivedType, BaseType>(Expr.Return(Expr.Parameter(0, typeof(BaseType)))); var value = new DerivedType(); Assert.That(func(value), Is.SameAs(value)); }
public virtual List <string> GetFields() { List <string> fields = new List <string>(); PropertyInfo[] propertyArray = DerivedType.GetProperties(); if (StartFromProperty < 0 || StartFromProperty > propertyArray.Count()) { Log.LogError("startFrom is not in range."); return(fields); } if (EndToProperty < 0) { EndToProperty = propertyArray.Count(); } if (EndToProperty > propertyArray.Count()) { Log.LogError("endTo is not in range."); return(fields); } for (int i = StartFromProperty; i < EndToProperty; i++) { PropertyInfo property = propertyArray[i]; fields.Add(property.Name); } return(fields); }
public void Should_cast_to_derived_type() { BaseType baseType = new DerivedType(); DerivedType casted = CreateConvertFunc <BaseType, DerivedType>().Invoke(baseType); Assert.That(casted, Is.SameAs(baseType)); }
public void ToHashSet_NullSelector_Exception() { IEnumerable <DerivedType> a = new DerivedType[0]; Func <DerivedType, int> selector = null; Assert.That(() => a.ToHashSet(selector), Throws.InstanceOf <ArgumentNullException>()); }
public void PolymorphicRoot([Values] RecorderMode mode) { BaseType root = new DerivedType(); var deserialized = DoRecorderRoundTrip(root, mode); Assert.AreEqual(root.GetType(), deserialized.GetType()); }
public void Should_allow_comparison_of_the_same_class_hierarchy() { var val = new DerivedType(); Assert.That(IsEqual <BaseType, DerivedType>(val, val), Is.EqualTo(true)); Assert.That(IsEqual(new BaseType(), new DerivedType()), Is.EqualTo(false)); }
public void Should_cast_to_base_type() { var derivedType = new DerivedType(); BaseType casted = CreateConvertFunc <DerivedType, BaseType>().Invoke(derivedType); Assert.That(casted, Is.SameAs(derivedType)); }
public void TestContainsKey_PropertyInherited_ReturnsTrue() { BaseType b = new DerivedType(); PropertyDictionary dictionary = new PropertyDictionary(b); bool result = dictionary.ContainsKey("Inherited"); Assert.IsTrue(result, "The property name was not found."); }
public void OfType_WhenAssignable_ReturnsSomeOfAssignedType() { Option <DerivedType> derived = new DerivedType(); var result = derived.OfType <SuperType>(); result.Should().BeOfType <Some <SuperType> >(); }
public static void TestDCast_isinst() { BaseType TestDerivedType = new DerivedType(); for (int x = 0; x < Iterations; x++) { (TestDerivedType as DerivedType).TestDerivedMethod(); } }
public void InitializesNewInstanceForDerivedInstanceMember() { var derived = new DerivedType(); var sut = new InstanceMember(info, derived); Assert.Same(info, sut.Info); Assert.Same(derived, sut.Instance); }
public void Equals_SomesWithDifferentTypes_AreUnequal() { var derived = new DerivedType(); Option <SuperType> superSome = derived; Option <DerivedType> derivedSome = derived; superSome.Should().NotBeEquivalentTo(derivedSome); derivedSome.Should().NotBeEquivalentTo(superSome); }
public static void TestDCast_castclass() { BaseType TestDerivedType = new DerivedType(); for (int x = 0; x < Iterations; x++) { ((DerivedType)TestDerivedType).TestDerivedMethod(); } }
private void CastClass() { DerivedType derivedType1_1 = new DerivedType(); BaseType base1 = derivedType1_1; DerivedType derivedType1_2 = (DerivedType)base1; DerivedType2 derivedType2_1 = new DerivedType2(); BaseType base2 = derivedType2_1; DerivedType2 derivedType2_2 = (DerivedType2)base2; }
public static void TestMuliCast_3x() { BaseType TestBaseType = new DerivedType(); for (int x = 0; x < Iterations; x++) { ((DerivedType)TestBaseType).TestDerivedMethod(); ((DerivedType)TestBaseType).TestDerivedMethod2(); ((DerivedType)TestBaseType).TestDerivedMethod3(); } }
public static void TestSingleCast_3x() { BaseType TestBaseType = new DerivedType(); for (int x = 0; x < Iterations; x++) { DerivedType TestDerivedType = (DerivedType)TestBaseType; TestDerivedType.TestDerivedMethod(); TestDerivedType.TestDerivedMethod2(); TestDerivedType.TestDerivedMethod3(); } }
public override object CreateResource(string containerName, string fullTypeName) { if (containerName == "Entities") { if (fullTypeName == DerivedTypeName) { var instance = new DerivedType(); return(this.CreateToken(instance)); } } return(base.CreateResource(containerName, fullTypeName)); }
protected override void ProcessRecord() { if (this.MyInvocation.BoundParameters.ContainsKey("InputObject")) { BaseType = InputObject is Type type ? type.FullName : InputObject.GetType().FullName; } IEnumerable <Type> derivedTypes = DerivedType.GetDerivedTypes(BaseType, asses, Recurse.ToBool()); WriteObject(derivedTypes, true); }
public static void TestMuliCast_30x() { BaseType TestBaseType = new DerivedType(); for (int x = 0; x < Iterations; x++) { //Simulate 3 x 10 method calls while casting for (int y = 0; y < 10; y++) { ((DerivedType)TestBaseType).TestDerivedMethod(); ((DerivedType)TestBaseType).TestDerivedMethod2(); ((DerivedType)TestBaseType).TestDerivedMethod3(); } } }
public void DerivedConverterTest([ValuesExcept(RecorderMode.Validation)] RecorderMode mode) { Dec.Config.TestParameters = new Dec.Config.UnitTestParameters { explicitConverters = new Type[] { typeof(DerivedConverter) } }; // we're only doing this to kick off the converter init new Dec.Parser().Finish(); BaseType root = new DerivedType(); var deserialized = DoRecorderRoundTrip(root, mode); Assert.AreEqual(root.GetType(), deserialized.GetType()); }
public static void TestSingleCast_30x() { BaseType TestBaseType = new DerivedType(); for (int x = 0; x < Iterations; x++) { DerivedType TestDerivedType = (DerivedType)TestBaseType; //Simulate 3 x 10 method calls on already-cast object for (int y = 0; y < 10; y++) { TestDerivedType.TestDerivedMethod(); TestDerivedType.TestDerivedMethod2(); TestDerivedType.TestDerivedMethod3(); } } }
public void IncomingParameterMatchesOverridenParameter_ThatDoesNotHasAttribute() { // Test for https://github.com/dotnet/aspnetcore/issues/13162 // Arrange var parameters = new ParameterViewBuilder { { nameof(DerivedType.VirtualProp), 123 }, }.Build(); var target = new DerivedType(); // Act parameters.SetParameterProperties(target); // Assert Assert.Equal(123, target.VirtualProp); }
private void AddDerived(string originalId, ReqTable.RequirementRow row, DerivedType type) { if (!derivedRequirements.ContainsKey(originalId)) { DerivedRequirement originalReq = new DerivedRequirement(originalId, CoveredStatus.Unverified); originalReq.AddDerivedRequirement(row.REQ_ID, type); derivedRequirements.Add(originalId, originalReq); } else { if (!derivedRequirements[originalId].DerivedReqs.ContainsKey(row.REQ_ID)) { DerivedRequirement originalReq = derivedRequirements[originalId]; originalReq.AddDerivedRequirement(row.REQ_ID, type); derivedRequirements[originalId] = originalReq; } } }
/// <summary> /// Add child requirement. /// </summary> /// <param name="reqID">The requirement ID.</param> /// <param name="type">The derived requirement type.</param> public void AddDerivedRequirement(string reqID, DerivedType type) { //self loop if (reqID == this.id) { throw new InvalidOperationException("Found loop in the derived requirements: " + reqID + " is derived from itself."); } if (!derivedReqs.ContainsKey(reqID)) { derivedReqs.Add(reqID, type); } else { if (ReportingLog.Log != null) { ReportingLog.Log.TraceWarning( string.Format("Found duplicate derived requirement {0} in requirement {1}.", reqID, id)); } derivedReqs[reqID] = type; } }
static void Main() { DerivedType derivedObj = new DerivedType(); BaseType baseObj1 = new BaseType(); BaseType baseObj2 = derivedObj; DerivedType derivedObj2 = baseObj2 as DerivedType; if (derivedObj2 != null) { Console.WriteLine("Conversion Succeeded"); } else { Console.WriteLine("Conversion Failed"); } derivedObj2 = baseObj1 as DerivedType; if (derivedObj2 != null) { Console.WriteLine("Conversion Succeeded"); } else { Console.WriteLine("Conversion Failed"); } BaseType baseObj3 = derivedObj as BaseType; if (baseObj3 != null) { Console.WriteLine("Conversion Succeeded"); } else { Console.WriteLine("Conversion Failed"); } }
public DerivedType EchoDerivedType([FromUri] DerivedType input) { return(input); }
static void Main(string[] args) { DerivedType d = new DerivedType(); d = d.Save(); }
public DerivedType EchoDerivedType(DerivedType param_DerivedType) { return param_DerivedType; }
public static int[] SomeArray(DerivedType type) { return(SomeDict[type]); }
public DerivedValue(DerivedType type) { Type = type; AddressRecords = new List <AddressRecord>(); }
private void AddDerived(string originalId, ReqTable.RequirementRow row, DerivedType type) { if (!derivedRequirements.ContainsKey(originalId)) { DerivedRequirement originalReq = new DerivedRequirement(originalId, CoveredStatus.Unverified); originalReq.AddDerivedRequirement(row.REQ_ID, type); derivedRequirements.Add(originalId, originalReq); } else { if (!derivedRequirements[originalId].DerivedReqs.ContainsKey(row.REQ_ID)) { DerivedRequirement originalReq = derivedRequirements[originalId]; originalReq.AddDerivedRequirement(row.REQ_ID, type); derivedRequirements[originalId] = originalReq; } } }
public static void Main (string[] args) { var t = new DerivedType(); Console.WriteLine(t.Prop); }
public void Bad2(string x, DerivedType y) { Console.WriteLine("Base: {0}, {1}", x, y); }
bool Equals(DerivedType other) => string.Equals(TypeName, other.TypeName) && string.Equals(ParameterName, other.ParameterName) && string.Equals(EnumMember, other.EnumMember);
/// <summary> /// Add child requirement. /// </summary> /// <param name="reqID">The requirement ID.</param> /// <param name="type">The derived requirement type.</param> public void AddDerivedRequirement(string reqID, DerivedType type) { //self loop if (reqID == this.id) { throw new InvalidOperationException("Found loop in the derived requirements: " + reqID + " is derived from itself."); } if (!derivedReqs.ContainsKey(reqID)) { derivedReqs.Add(reqID, type); } else { if (ReportingLog.Log != null) { ReportingLog.Log.TraceWarning( string.Format("Found duplicate derived requirement {0} in requirement {1}.", reqID, id)); } derivedReqs[reqID] = type; } }
public DerivedType[] ReverseDerivedTypeArray(DerivedType[] param_DerivedType) { if (param_DerivedType == null) { return null; } return param_DerivedType.Reverse().ToArray(); }