public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 23 + Fields.GetHashCode(); hash = hash * 23 + Properties.GetHashCode(); hash = hash * 23 + Methods.GetHashCode(); hash = hash * 23 + Constructors.GetHashCode(); hash = hash * 23 + Gettable.GetHashCode(); hash = hash * 23 + Settable.GetHashCode(); hash = hash * 23 + Indexers.GetHashCode(); hash = hash * 23 + Events.GetHashCode(); hash = hash * 23 + Inherited.GetHashCode(); hash = hash * 23 + Targeted.GetHashCode(); hash = hash * 23 + NonTargeted.GetHashCode(); hash = hash * 23 + Public.GetHashCode(); hash = hash * 23 + NonPublic.GetHashCode(); hash = hash * 23 + ReadOnly.GetHashCode(); hash = hash * 23 + WriteOnly.GetHashCode(); hash = hash * 23 + Extensions.GetHashCode(); hash = hash * 23 + Operators.GetHashCode(); hash = hash * 23 + Conversions.GetHashCode(); hash = hash * 23 + Parameters.GetHashCode(); hash = hash * 23 + Obsolete.GetHashCode(); hash = hash * 23 + OpenConstructedGeneric.GetHashCode(); hash = hash * 23 + TypeInitializers.GetHashCode(); return(hash); } }
public void TestInherited() { var obj = new Inherited { L2 = 2 }; Assert.AreEqual(Inherited.DebuggerSize, obj.GetExclusiveSize()); }
static void Main(string[] args) { Inherited obj = new Inherited("Alpha"); obj.test(); Inherited1 obj1 = new Inherited1(); //This will fail as there is no ctor with single param. obj1.test(); }
/// <summary> /// Gets an object variable, and also looks inside ancestor objects. /// </summary> /// <param name="identifier">Name of the variable to find.</param> public VariableSymbol?GetVariable(string identifier) { // Attempt to get the variable from the current class, // but if it is not found there, try call this method // from the ancestor instead (if there is one), // in order to try to find it there. return(Environment.GetVariable(identifier, false) ?? Inherited?.GetVariable(identifier)); }
public CheckedClassDeclStatement?GetParentClassForFunction(string identifier) { if (Environment.GetFunction(identifier, false) != null) { return(this); } return(Inherited?.GetParentClassForFunction(identifier)); }
public void ToDictionary_WhenInheritedProperties_MustReturnDictionaryFilledAlsoWithInheritedPropertiesAndValues() { var result = new Inherited { SomeData = "Foo", SomeInt = 2, SomeDouble = 1.0d }.ToDict(); result.Count.Should().Be(3); result["SomeData"].Should().Be("Foo"); result["SomeInt"].Should().Be(2); result["SomeDouble"].Should().Be(1.0d); }
public void When_put_of_a_new_entity_extending_a_document_Then_the_entity_will_be_created() { var id = "956cba86-a20c-4a85-a8b4-a7039ba771c8"; var entity = new Inherited { _id = id, Value = "Test" }; var response = SUT.PutAsync(entity).Result; response.Should().BeSuccessfulPutOfNew(id, i => i._id, i => i._rev); }
public bool HasAncestor(string identifier) { // The ancestor was found if (Inherited?.Identifier.Value == identifier) { return(true); } return(Inherited?.HasAncestor(identifier) ?? false); // Return false if "Inherited" is null (there are no more ancestors to compare) }
public void When_put_of_an_existing_entity_extending_a_document_Then_the_entity_will_be_updated() { var id = "b638d1c5-772a-48f4-b6ee-f2c1f7d5e410"; var entity = new Inherited { _id = id, Value = "Test" }; SUT.PostAsync(entity).Wait(); var response = SUT.PutAsync(entity).Result; response.Should().BeSuccessfulPut(id, i => i._id, i => i._rev); }
public void Run() { var @default = new Default(); // var withParameters = new WithParameters(); var withParameters2 = new WithParameters(1); var withParameters3 = new WithParameters(1, 1); // var private = new Private(); var private2 = Private.Create(); var private3 = Private.Create(1); var privateWithNested = new PrivateWithNested.Nested(); var privateWithNested2 = privateWithNested.Create(); var copy = new CopyInstance { Property1 = 1, Property2 = 1 }; var copy2 = new CopyInstance(copy); var parameterless = new Parameterless(); var overloaded = new Overloaded(1); var overloaded2 = new Overloaded(1, 1); var hasReturn = new HasReturn(1, 1); var @static = Static.Field2; var static2 = new Static(1); var staticClass = StaticInStaticClass.Field; var inherited = new Inherited(1); var inherited2 = new Inherited(); var initializeReadonly = new InitializeReadonlyWithStatic(1); var nestedWithStatic = new OuterWithStatic.InnerWithStatic(1); var innerStaticClass = OuterStaticClass.InnerStaticClass.Field; // var @private = new AccessModifiers(); // var @protected = new AccessModifiers(1); var @internal = new AccessModifiers(1, 1); var protectedInternal = new AccessModifiers(1, 1, 1); // var @privateProtected = new AccessModifiers(1, 1, 1, 1); var @public = new AccessModifiers(1, 1, 1, 1, 1); var canNot = new CanNot(); CanNotBeInStaticClass.StepIn(); }
public void InjectingConstructorExpression_IsCorrectlyTransformed() { var cspec = GetConstructorSpecWithFiveArguments(); var source = new Inherited(1, 2, 3, "4", "5"); var copied = ((Expression <Func <IConstructorPropertySource, Inherited> >) cspec.InjectingConstructorExpression).Compile()(new MockedPropertySource(source)); Assert.That(copied.TheAbstract, Is.EqualTo(source.TheAbstract)); Assert.That(copied.TheOptional, Is.EqualTo(source.TheOptional)); Assert.That(copied.TheOverridable, Is.EqualTo(source.TheOverridable)); Assert.That(copied.TheRequired, Is.EqualTo(source.TheRequired)); Assert.That(copied.TheUntouchable, Is.EqualTo(source.TheUntouchable)); }
public void Execute() { var obj = new Inherited() { PublicProperty = 1, PublicProperty2 = 2, PublicProperty3 = 3, PublicProperty4 = 4, PublicProperty5 = 5 }; var clone = (Inherited)_model.DeepClone(obj); Assert.AreEqual(obj.PublicProperty, clone.PublicProperty); Assert.AreEqual(obj.PublicProperty2, clone.PublicProperty2); Assert.AreEqual(obj.PublicProperty3, clone.PublicProperty3); Assert.AreEqual(obj.PublicProperty5, clone.PublicProperty5); Assert.AreEqual(0, clone.PublicProperty4); }
public void When_put_of_a_new_and_then_a_put_of_an_existing_entity_extending_a_document_Then_the_entity_will_first_be_created_and_then_updated() { var id = "b638d1c5-772a-48f4-b6ee-f2c1f7d5e410"; var entity = new Inherited { _id = id, Value = "Test" }; var putResponse1 = SUT.PutAsync(entity).Result; putResponse1.Should().BeSuccessfulPutOfNew(id, i => i._id, i => i._rev); var putResponse2 = SUT.PutAsync(entity).Result; putResponse2.Should().BeSuccessfulPut(id, i => i._id, i => i._rev); }
public static void Test() { var inherited = new Inherited(); var json1 = JsonConvert.SerializeObject(inherited, Formatting.Indented, new JsonSerializerSettings() { ContractResolver = new PreferDerivedPropertyContractResolver() }); var veryInherited = new VeryInherited(); var json2 = JsonConvert.SerializeObject(veryInherited, Formatting.Indented, new JsonSerializerSettings() { ContractResolver = new PreferDerivedPropertyContractResolver() }); Debug.WriteLine(json1); Debug.WriteLine(json2); }
/// <summary> /// Gets an object function, and also looks inside ancestor objects. /// </summary> /// <param name="identifier">Name of the function to find.</param> public CheckedFunctionDeclStatement?GetFunction(string identifier, List <IDataType>?typeArguments = null, bool lookInInherited = true) { // Attempt to get the function from the current class, // but if it is not found there, try call this method // from the ancestor instead (if there is one), // in order to try to find it there. var function = Environment.GetFunction(identifier, false); if (function != null) { return(function.GetCheckedFromClass(this, typeArguments)); } else { return(lookInInherited ? Inherited?.GetFunction(identifier, typeArguments) : null); } }
public ParadigmsContext(ParadigmsContext inheritFrom) { Inherited = inheritFrom.Keyed.Keys; Keyed = Inherited.ToDictionary(k => k, k => true); }
public String ToString() { return("Id-" + Id + "-" + DisplayName + "-" + Type.ToString() + "- Inherited:" + Inherited.ToString() + "- Denyed:" + Denyed.ToString()); }
public MockedPropertySource(Inherited source) { this.source = source; }