public void NestedClassLocal() { NestedClass x = new NestedClass(); x.Property = 123; Console.WriteLine(x.Property); }
public void TestConvertConcreteListField() { var o = new NestedClass { Field1 = new List <int>() }; var _ = Constant(o); }
private object CreateOneToManyObject() { var duplicated = new NestedClass() { Id = 1000, SomeNestedValue = "Nested text value" }; var sampleClass = new SampleClass() { Id = 1, SomeValue = "Some string value", NestedClassId = 1000, NestedValue = duplicated, NestedClasses = new List <NestedClass>() { duplicated, new NestedClass() { Id = 1001, SomeNestedValue = "Nested text value" } } }; return(sampleClass); }
void NowItBecomesInteresting() { NestedClass <string> .InnerClass <int> .InnerInnerClass nested = new NestedClass <string> .InnerClass <int> .InnerInnerClass(); nested.MethodOfNestedClass("a", -1); }
public static IFooable CreateFooable() { NestedClass nc = new NestedClass(); nc.Foo = 42; return(nc); }
public void ToViewModel_Nested_Class() { var model = new NestedClass { Child = new SimpleClass { A = 5, B = "test" }, C = true }; var json = Knockout.ToViewModel(model); Assert.AreEqual("{\"C\":ko.observable(true),\"Child\":{\"A\":ko.observable(5),\"B\":ko.observable(\"test\")}}", json.ToJson()); }
private void SomeMethod() { //NestedClasscan only be created by methods of ParentClass var nc = new NestedClass(); nc.PublicMethod(); //Internally visible nc.PrivateMethod(); //Invalid, not accessible }
static void Main(string[] args) { NestedClass ns = new NestedClass(); ns.SetValue(ns, "Param[1][1][2]", 1); ns.SetValue(ns, "Param", 1); }
public void Nested2_Test() { var c = new NestedClass() { StringProp = "foo", NestedProp = new InnerStructure() { Inner = new InnerStructure2() } }; Utils.TestRoundTrip(c, "Nested2"); }
public void CreateNestedClass() { var actual = _faker.Create <NestedClass>(); var notExpected = new NestedClass(); Assert.AreNotEqual(notExpected.a, actual.a); Assert.AreNotEqual(notExpected.c, actual.c); CollectionAssert.AreNotEqual(notExpected.s, actual.s); }
public void AccessingMethodFromNestedPublicTypeIsDetected() { var expr = new NestedClass().GenerateExpression(); var processor = new MapProposalProcessor(new MemberMapper()); processor.Process(expr); Assert.IsTrue(processor.NonPublicMembersAccessed); }
public void CanInterceptNestedClass() { PostCallCountHandler handler = new PostCallCountHandler(); NestedClass instance = WireupHelper.GetInterceptedInstance <NestedClass>("MakeAValue", handler); int result = instance.MakeAValue(12); Assert.AreEqual(12 * 37 + 12 / 2, result); Assert.AreEqual(1, handler.CallsCompleted); }
public void TestFormDataBuilder() { NestedClass nestedClass = new NestedClass(); nestedClass.NestedClass2 = new NestedClass2(); nestedClass.NestedClass2.Count = 123; TestClass @class = new TestClass( new Address("123 Xenost Street", "", "Moyun", "AZ", "USA", "85203"), "SomeoneName", "$35000", new Dictionary <string, string>() { { "key1", "value1" }, { "key2", "value2" } }, nestedClass ); Dictionary <string, string> outputDict = new Dictionary <string, string>(); FormDataBuilder.CreateFormData(@class, ref outputDict, ""); Assert.Equal(11, outputDict.Count); Assert.True(outputDict.ContainsKey("address[line1]")); Assert.True(outputDict.ContainsKey("address[line2]")); Assert.True(outputDict.ContainsKey("address[city]")); Assert.True(outputDict.ContainsKey("address[state]")); Assert.True(outputDict.ContainsKey("address[country]")); Assert.True(outputDict.ContainsKey("address[zip]")); Assert.True(outputDict.ContainsKey("name")); Assert.True(outputDict.ContainsKey("balance")); Assert.True(outputDict.ContainsKey("metadata[key1]")); Assert.True(outputDict.ContainsKey("metadata[key2]")); Assert.True(outputDict.ContainsKey("nested[nestedclass2[count]]")); Assert.Equal("123 Xenost Street", outputDict["address[line1]"]); Assert.Equal("", outputDict["address[line2]"]); Assert.Equal("Moyun", outputDict["address[city]"]); Assert.Equal("AZ", outputDict["address[state]"]); Assert.Equal("USA", outputDict["address[country]"]); Assert.Equal("85203", outputDict["address[zip]"]); Assert.Equal("SomeoneName", outputDict["name"]); Assert.Equal("$35000", outputDict["balance"]); Assert.Equal("value1", outputDict["metadata[key1]"]); Assert.Equal("value2", outputDict["metadata[key2]"]); Assert.Equal("123", outputDict["nested[nestedclass2[count]]"]); }
public AnotherClass() { // Not compiles since "NestedClass" is defined as nested class var nestedClass = new NestedClass(); // Will compiles var nestedClass = new ParentClass.NestedClass(); // Not compiles since "NestedClass" is defined as nested class NestedClass nestedClass = new NestedClass(); // Will compiles ParentClass.NestedClass nestedClass = new ParentClass.NestedClass(); }
private void AddNestedClass(NestedClass nestedClass) { var table = (NestedClassTable)_tableStream.GetTable(MetadataTokenType.NestedClass); var classRow = new MetadataRow <uint, uint> { Column1 = GetNewToken(nestedClass.Class).Rid, Column2 = GetNewToken(nestedClass.EnclosingClass).Rid }; table.Add(classRow); _members.Add(nestedClass, classRow.MetadataToken); }
public void TryStuff() { RandNum = new Random().Next(100); RandString = RandNum.ToString() + "abc"; // checks whats been added to il for static constructor // read in static consructor with decompiler and see what load field value is set to var aa = typeof(StaticMan); var bb = typeof(StaticTemplateClass <int>); var fieldVal = TestField; /*var z = typeof(StaticTemplateClass<int>); * * foreach (var x in z.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static).OrderBy(f => f.Name)) * { * var name = x.Name; * * var value = x.GetValue(null); * * int i = 0; * i++; * }*/ try { StaticMan.HolyCow(); var a = new NestedClass(); string yy = null; yy = testVar; //testVar = "hello"; a.DoStuff(); var x = new int[] { 1, 2, 3, 4 }; var y = x.Where(i => i > 2).ToArray(); } catch (Exception ex) { } var t = new LibClass(); t.TestMe = 5; t.DoMoreStuff(); }
internal void WriteNestedClass(NestedClass nestedClass) { if (nestedClass.UpdateRowOnRebuild) { object[] parts = new object[] { GetMemberIndex(nestedClass.Class), GetMemberIndex(nestedClass.EnclosingClass), }; nestedClass.MetaDataRow = new MetaDataRow(parts); } writer.Write(nestedClass.MetaDataRow.GenerateBytes()); }
public void SupplyMilk() { Cow x = new Cow(); x.Breed(); NestedClass y = new NestedClass(); y.Boil(); y.size = 32; z.Milk(); }
public unsafe NestedClassEntry(PEFile module, byte *ptr, int metadataOffset, int row) { this.module = module; this.metadata = module.Metadata; this.RID = row; var rowOffset = metadata.GetTableMetadataOffset(TableIndex.NestedClass) + metadata.GetTableRowSize(TableIndex.NestedClass) * (row - 1); this.Offset = metadataOffset + rowOffset; int typeDefSize = metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4; this.nestedClass = new NestedClass(ptr + rowOffset, typeDefSize); }
public void Set_Nested_Prop() { var complex = new ComplexClass(); var nested = new NestedClass(); Set(complex, "Nested", nested); Set(complex, "Nested.Id", 10); Assert.Throws <ArgumentException>(() => Set(complex, "Nested.Id", "")); Assert.NotNull(complex.Nested); Assert.Equal(nested, complex.Nested); Assert.Equal(10, complex.Nested.Id); }
private void showToastForNewComment(string blogID, string commentID) { if (blogID == string.Empty || commentID == string.Empty || blogID == null || commentID == null) { return; } System.Diagnostics.Debug.WriteLine("showToastForNewComment called with - blogID:" + blogID + " commentID:" + commentID); string blogName = string.Empty; List <Blog> blogs = DataService.Current.Blogs.ToList(); foreach (Blog currentBlog in blogs) { if (currentBlog.isWPcom() || currentBlog.hasJetpack()) { string currentBlogID = currentBlog.isWPcom() ? Convert.ToString(currentBlog.BlogId) : currentBlog.getJetpackClientID(); if (currentBlogID == blogID) { blogName = currentBlog.BlogName; } } } if (blogName == String.Empty) { return; } NestedClass nc = new NestedClass(blogID, commentID); UIThread.Invoke(() => { if (App.WaitIndicationService.Waiting) { return; } if (App.PopupSelectionService.IsPopupOpen) { return; } ToastPrompt toast = new ToastPrompt(); toast.MillisecondsUntilHidden = 6000; toast.Title = "New comment on " + blogName; toast.Tap += nc.toast_Tapped; toast.Show(); }); }
private async Task TestFailInAMethod() { await Entity("jalll").TurnOn() .WithAttribute("test", "lslslsl").ExecuteAsync(); Entity("jalll").WhenStateChange(to: "test") .AndNotChangeFor(System.TimeSpan.FromSeconds(1)) .Call(async(e, n, o) => { Entity("Test").TurnOn(); var x = new NestedClass(this); await x.DoAThing(); }); }
private static void TestLayoutClass() { ExplicitClass es = new ExplicitClass(); es.f1 = 100; es.f2 = 100.0f; es.f3 = "Hello"; NestedClass ns = new NestedClass(); ns.f1 = 100; ns.f2 = es; ThrowIfNotEquals(true, StructTest_NestedClass(ns), "LayoutClass marshalling scenario1 failed."); }
NestedClass GetNestedClassInstance() { var normalInstance = new NormalClass(); normalInstance.X = 1; normalInstance.Y = "2"; normalInstance.Z = 4.5; normalInstance.V = 'V'; var nestedInstance = new NestedClass(); nestedInstance.A = 10; nestedInstance.B = "11"; nestedInstance.C = 12.25; nestedInstance.D = normalInstance; return(nestedInstance); }
public void NestedConcrete() { var inspector = new NestedClass().DeepFieldInspector(); Assert.That(inspector.GetValue("Field1"), Is.EqualTo(1)); Assert.That(inspector.GetValue("Field2"), Is.EqualTo(2)); Assert.That(inspector.GetValue("Method1"), Is.EqualTo(999)); Assert.That(inspector.GetValue("Inner1.Field1"), Is.EqualTo(11)); Assert.That(inspector.GetValue("Inner1.Field2"), Is.EqualTo(12)); Assert.That(inspector.GetValue("Inner1.Field3"), Is.EqualTo(13)); Assert.That(inspector.GetValue("Inner2.Field1"), Is.EqualTo(21)); Assert.That(inspector.GetValue("Inner2.Field2"), Is.EqualTo(22)); Assert.That(inspector.GetValue("Inner2.Field3"), Is.EqualTo(23)); Assert.That(inspector.GetValue("Inner1.Field4"), Is.Null); Assert.That(inspector.GetValue("Inner2.Field4"), Is.Null); }
public static void TestSuppressions(Type[] types) { // StaticMethod is a static method on a Requires annotated type, so it should warn. But Requires in the // class suppresses other Requires messages StaticMethod(); var nested = new NestedClass(); // Requires in the class suppresses DynamicallyAccessedMembers messages types[1].GetMethods(); void LocalFunction(int a) { } LocalFunction(2); }
public void NestedProperties() { NestedClass obj1 = new NestedClass(new SimpleStruct(1, 1)); NestedClass obj2 = new NestedClass(new SimpleStruct(0, 0)); Circuit circuit = new Circuit(); Node node1 = new Node(obj1); Node node2 = new Node(obj2); circuit.AddNode(node1); circuit.AddRoot(node1); circuit.AddNode(node2); node1.Attach("str.x", node2, "str.y"); circuit.Execute(); Assert.True(obj2.str.y == obj1.str.x, "Node2.str.y is " + obj2.str.y + " but should be " + obj1.str.x + "."); }
public void GetHashCode_should_return_value_for_nested_class() { var normalInstance = new NormalClass(); normalInstance.X = 1; normalInstance.Y = "2"; normalInstance.Z = 4.5; normalInstance.V = 'V'; var nestedInstance = new NestedClass(); nestedInstance.A = 10; nestedInstance.B = "11"; nestedInstance.C = 12.25; nestedInstance.D = normalInstance; var result = nestedInstance.GetHashCode(); Assert.NotEqual(0, result); }
[DataRow(null, null, null, null)] // 全てのプロパティがNullの場合 public void IsBadRequestParameterInvalidParamNestedClass(int?arg1, int?arg2, string arg3, string arg4) { NestedClass param = new NestedClass() { Inner = new FlatPropertiesClass() { ReqParam = arg1, NotReqParam = arg2, Max10LenReqParam = arg3, Max10Min3LenParam = arg4 } }; bool result = RequestValidator.IsBadRequestParameter(param, out string message); // BadRequestあり Assert.IsTrue(result); // messageには何か入っていること Assert.IsNotNull(message); }
public void TryStuff() { RandNum = new Random().Next(100); RandString = RandNum.ToString() + "abc"; // checks whats been added to il for static constructor // read in static consructor with decompiler and see what load field value is set to var aa = typeof(StaticMan); var bb = typeof(StaticTemplateClass <int>); var fieldVal = TestField; try { StaticMan.HolyCow(); var a = new NestedClass(); string yy = null; yy = testVar; //testVar = "hello"; a.DoStuff(); var x = new int[] { 1, 2, 3, 4 }; var y = x.Where(i => i > 2).ToArray(); } catch (Exception ex) { } var t = new LibClass(); t.TestMe = 5; t.DoMoreStuff(); }
public void FeatureMatcherGeneratesNestedPropertyMismatchDescriptionsCorrectly( int intVal, int mismatchedIntVal, string mismatchIntDescription) { var sut = Describe.Object <NestedClass>() .Property(x => x.InnerClass.IntProperty, new FakeMatcher <int>(false, "", i => i == mismatchedIntVal ? mismatchIntDescription : i.ToString())); var expectedDescription = "was a(n) NestedClass where:\r\n" + " member InnerClass.IntProperty value " + mismatchIntDescription; var mismatched = new NestedClass { InnerClass = new SimpleFlatClass { IntProperty = mismatchedIntVal, } }; sut.ShouldHaveMismatchDescriptionForValue(mismatched, expectedDescription); }
private CodeTypeDeclaration GenerateNestedClass(NestedClass cls, CodeNamespace nameSpace) { if (cls == null) throw new ArgumentNullException( "cls", "Nested class not supplied"); if (nameSpace == null) throw new ArgumentNullException("nameSpace", "Namespace not supplied"); if (String.IsNullOrEmpty(cls.Name)) throw new ArgumentException("Class name cannot be blank", "cls"); CodeTypeDeclaration classDeclaration = GetNestedClassDeclaration(cls, nameSpace); // Properties and Fields foreach (var property in cls.Properties) { PropertyData propertyData = new PropertyData(property); AddMemberField(classDeclaration, propertyData); if (propertyData.DebuggerDisplay) classDeclaration.CustomAttributes.Add(propertyData.GetDebuggerDisplayAttribute()); if (propertyData.DefaultMember) classDeclaration.CustomAttributes.Add(propertyData.GetDefaultMemberAttribute()); } return classDeclaration; }
private object CreateOneToManyObject() { var duplicated = new NestedClass() { Id = 1000, SomeNestedValue = "Nested text value" }; var sampleClass = new SampleClass() { Id = 1, SomeValue = "Some string value", NestedClassId = 1000, NestedValue = duplicated, NestedClasses = new List<NestedClass>() { duplicated, new NestedClass() { Id = 1001, SomeNestedValue = "Nested text value" } } }; return sampleClass; }
public void TryStuff() { RandNum = new Random().Next(100); RandString = RandNum.ToString() + "abc"; // checks whats been added to il for static constructor // read in static consructor with decompiler and see what load field value is set to var aa = typeof(StaticMan); var bb = typeof(StaticTemplateClass<int>); var fieldVal = TestField; try { StaticMan.HolyCow(); var a = new NestedClass(); string yy = null; yy = testVar; //testVar = "hello"; a.DoStuff(); var x = new int[] { 1, 2, 3, 4 }; var y = x.Where(i => i > 2).ToArray(); } catch (Exception ex) { } var t = new LibClass(); t.TestMe = 5; t.DoMoreStuff(); }
private CodeTypeDeclaration GenerateNestedClass(NestedClass cls, CodeNamespace nameSpace) { if (cls == null) throw new ArgumentNullException("Nested class not supplied", "cls"); if (nameSpace == null) throw new ArgumentNullException("Namespace not supplied", "namespace"); if (String.IsNullOrEmpty(cls.Name)) throw new ArgumentException("Class name cannot be blank", "cls"); if (!CodeGenerationContext.IsClassGenerated(cls)) { if (CodeGenerationContext.IsClassWithSameNameGenerated(cls.Name)) throw new ArgumentException( "Ambiguous class name. Code for a class with the same name already generated. Please use a different name.", cls.Name); CodeTypeDeclaration classDeclaration = GetNestedClassDeclaration(cls, nameSpace); // Properties and Fields foreach (ModelProperty property in cls.Properties) { CodeMemberField memberField = GetMemberField(classDeclaration, property); classDeclaration.Members.Add(memberField); if (property.DebuggerDisplay) classDeclaration.CustomAttributes.Add(property.GetDebuggerDisplayAttribute()); if (property.DefaultMember) classDeclaration.CustomAttributes.Add(property.GetDefaultMemberAttribute()); } return classDeclaration; } else return CodeGenerationContext.GetTypeDeclaration(cls); }
private void showToastForNewComment(string blogID, string commentID) { if (blogID == string.Empty || commentID == string.Empty || blogID == null || commentID == null) return; System.Diagnostics.Debug.WriteLine("showToastForNewComment called with - blogID:" + blogID + " commentID:" + commentID); string blogName = string.Empty; List<Blog> blogs = DataService.Current.Blogs.ToList(); foreach (Blog currentBlog in blogs) { if (currentBlog.isWPcom() || currentBlog.hasJetpack()) { string currentBlogID = currentBlog.isWPcom() ? Convert.ToString(currentBlog.BlogId) : currentBlog.getJetpackClientID(); if (currentBlogID == blogID) { blogName = currentBlog.BlogName; } } } if (blogName == String.Empty) return; NestedClass nc = new NestedClass(blogID, commentID); UIThread.Invoke(() => { if (App.WaitIndicationService.Waiting) return; if (App.PopupSelectionService.IsPopupOpen) return; ToastPrompt toast = new ToastPrompt(); toast.MillisecondsUntilHidden = 6000; toast.Title = "New comment on " + blogName; toast.Tap += nc.toast_Tapped; toast.Show(); }); }
public void TryStuff() { RandNum = new Random().Next(100); RandString = RandNum.ToString() + "abc"; // checks whats been added to il for static constructor // read in static consructor with decompiler and see what load field value is set to var aa = typeof(StaticMan); var bb = typeof(StaticTemplateClass<int>); var fieldVal = TestField; /*var z = typeof(StaticTemplateClass<int>); foreach (var x in z.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static).OrderBy(f => f.Name)) { var name = x.Name; var value = x.GetValue(null); int i = 0; i++; }*/ try { StaticMan.HolyCow(); var a = new NestedClass(); string yy = null; yy = testVar; //testVar = "hello"; a.DoStuff(); var x = new int[] { 1, 2, 3, 4 }; var y = x.Where(i => i > 2).ToArray(); } catch (Exception ex) { } var t = new LibClass(); t.TestMe = 5; t.DoMoreStuff(); }
public string get_NonExistingProperty() { NestedClass nested = new NestedClass(); return "dummy" + nested; }
public void Nested1_Test() { var c = new NestedClass() { NestedProp = new InnerStructure() { Inner = new InnerStructure2() } }; Utils.TestRoundTrip(c, "Nested1"); }
public void Nested5_Test() { var c = new NestedClass() { StringProp = "foo", NestedProp = new InnerStructure() { StringProp = "bar", Inner = new InnerStructure2() { SomeBytes = new byte[255] } } }; Utils.TestRoundTrip(c, "Nested5"); }
public PropertyData(ModelProperty p) { Name = p.Name; Access = p.Access; Accessor = p.Accessor; Check = p.Check; Column = p.Column; ColumnType = p.ColumnType; CustomAccess = p.CustomAccess; CustomColumnType = p.CustomColumnType; CustomMemberType = p.CustomMemberType; DebuggerDisplay = p.DebuggerDisplay; DefaultMember = p.DefaultMember; ColumnDefault = p.ColumnDefault; Description = p.Description; Formula = p.Formula; Generator = p.Generator; Index = p.Index; Insert = p.Insert; KeyType = p.KeyType; Length = p.Length; NotNull = p.NotNull; Params = p.Params; PropertyType = p.PropertyType; SequenceName = p.SequenceName; SqlType = p.SqlType; Unique = p.Unique; UniqueKey = p.UniqueKey; UnsavedValue = p.UnsavedValue; Update = p.Update; ValidatorPropertyStorage = p.GetValidatorValue(); ModelClass = p.ModelClass; NestedClass = p.NestedClass; }
private CodeTypeDeclaration GetNestedClassDeclaration(NestedClass cls, CodeNamespace nameSpace) { if (cls == null) throw new ArgumentException("Nested class not supplied.", "cls"); if (String.IsNullOrEmpty(cls.Name)) throw new ArgumentException("Nested class name cannot be blank.", "cls"); CodeTypeDeclaration classDeclaration = CreateClass(cls.Name); if (cls.DoesImplementINotifyPropertyChanged()) { classDeclaration.BaseTypes.Add(new CodeTypeReference(Common.INotifyPropertyChangedType)); AddINotifyPropertyChangedRegion(classDeclaration); } if (!String.IsNullOrEmpty(cls.Description)) classDeclaration.Comments.AddRange(GetSummaryComment(cls.Description)); if (cls.Model.UseGeneratedCodeAttribute) classDeclaration.CustomAttributes.Add(AttributeHelper.GetGeneratedCodeAttribute()); // Make a note as "generated" to prevent recursive generation attempts CodeGenerationContext.AddClass(cls, classDeclaration); nameSpace.Types.Add(classDeclaration); return classDeclaration; }
public PropertyData(string name, NestedClass nestedClass) : this(name) { NestedClass = nestedClass; }