public void Can_run_nested_service() { var request = new Nested(); var response = appHost.ExecuteService(request) as NestedResponse; Assert.That(response, Is.Not.Null); }
public void ShouldPatchMultipleNestedProperties() { using (var store = NewDocumentStore(requestedStorage: "esent")) { var test1 = new Nested { Inner = new Nested { Inner = new Nested { Property1 = "value1", Property2 = "value2" } } }; using (var session = store.OpenSession()) { session.Store(test1); session.SaveChanges(); } using (var session = store.OpenSession()) { session.Advanced.UseOptimisticConcurrency = true; session.Advanced.Defer( new PatchCommandData { Key = test1.Id, Patches = new[] { new PatchRequest { Type = PatchCommandType.Modify, Name = "Inner.Inner", Nested = new[] { new PatchRequest { Type = PatchCommandType.Set, Name = "Property1", Value = "value3" }, new PatchRequest { Type = PatchCommandType.Set, Name = "Property2", Value = "value4" } } } } }); session.SaveChanges(); } using (var session = store.OpenSession()) { var test2 = session.Load<Nested>(test1.Id); Assert.Equal("value3", test2.Inner.Inner.Property1); Assert.Equal("value4", test2.Inner.Inner.Property2); } } }
/// <summary> /// Translate this instance to json /// </summary> public JObject ToJson() { var jObject = new JObject( new JProperty("Type", new JValue(Type.ToString())), new JProperty("Value", Value), new JProperty("Name", new JValue(Name)), new JProperty("Position", Position == null ? null : new JValue(Position.Value)), new JProperty("Nested", Nested == null ? null : new JArray(Nested.Select(x => x.ToJson()))), new JProperty("AllPositions", AllPositions == null ? null : new JValue(AllPositions.Value)) ); if (PrevVal != null) { jObject.Add(new JProperty("PrevVal", PrevVal)); } return(jObject); }
unsafe static void Main(string[] args) { // 컴파일 가능 { BlittableStruct inst = new BlittableStruct(); BlittableStruct *pInst = &inst; } // BlittableStruct와 동일한 메모리 구조임에도 C# 7.3 이전에는 컴파일 오류 { BlittableGenericStruct <byte> inst = new BlittableGenericStruct <byte>(); BlittableGenericStruct <byte> *pInst = &inst; } Nested <byte> inst1 = new Nested <byte>(); // BlittableGenericStruct<byte> 타입 자체가 unmanaged 조건을 만족하지만 // C# 7.3 이전에는 컴파일 오류 Nested <BlittableGenericStruct <byte> > inst2 = new Nested <BlittableGenericStruct <byte> >(); // C# 7.3 이전에는 컴파일 오류 CallUnmanaged(new BlittableGenericStruct <byte>()); // 아래의 코드는 아무리 실행해도 GC가 발생하지 않는다. // while (true) { using (NativeMemory <int> buf = new NativeMemory <int>(1024)) { Span <int> viewBuf = buf.GetView(); for (int i = 0; i < viewBuf.Length; i++) { viewBuf[i] = i; } } using (NativeMemory <byte> buf = new NativeMemory <byte>(1024)) { Span <byte> viewBuf = buf.GetView(); for (int i = 0; i < viewBuf.Length; i++) { viewBuf[i] = (byte)i; } } } }
public void Serialize_SimpleValues() { var source = new Nested { Value2 = 123, Value1 = null }; string json = JsonSerializer.Serialize(source, _options); json.ShouldBeCrossPlatJson( @"{ ""value1"": null, ""dictionary"": null, ""value2"": 123 }".Trim()); }
public void Array_Nested() { Nested[] a = new Nested[] { new Nested( new Blittable(1, 2, 3, 4, -5, -6, -7, 8.0f, 9.0, typeof(ITests).GUID), new NonBlittable(false, 'X', "First", (long?)PropertyValue.CreateInt64(123))), new Nested( new Blittable(10, 20, 30, 40, -50, -60, -70, 80.0f, 90.0, typeof(IStringable).GUID), new NonBlittable(true, 'Y', "Second", (long?)PropertyValue.CreateInt64(456))), new Nested( new Blittable(1, 2, 3, 4, -5, -6, -7, 8.0f, 9.0, typeof(IInspectable).GUID), new NonBlittable(false, 'Z', "Third", (long?)PropertyValue.CreateInt64(789))) }; Nested[] b = new Nested[a.Length]; Nested[] c; Nested[] d = Tests.Array15(a, b, out c); Assert.True(AllEqual(a, b, c, d)); }
public void Serialize_SimpleValues() { /* Given */ var source = new Nested { Value2 = 123, Value1 = null }; /* When */ var json = JsonSerializer.Serialize(source, _options); /* Then */ Assert.Equal( @"{ ""dictionary"": null, ""value1"": null, ""value2"": 123 }".Trim().ReplaceLineEndings(), json); }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 23 + Matching.GetHashCode(); foreach (var type in types) { if (type != null) { hash = hash * 23 + type.GetHashCode(); } } hash = hash * 23 + Value.GetHashCode(); hash = hash * 23 + Reference.GetHashCode(); hash = hash * 23 + Classes.GetHashCode(); hash = hash * 23 + Interfaces.GetHashCode(); hash = hash * 23 + Structs.GetHashCode(); hash = hash * 23 + Enums.GetHashCode(); hash = hash * 23 + Delegates.GetHashCode(); hash = hash * 23 + Public.GetHashCode(); hash = hash * 23 + NonPublic.GetHashCode(); hash = hash * 23 + Abstract.GetHashCode(); hash = hash * 23 + Generic.GetHashCode(); hash = hash * 23 + OpenConstructedGeneric.GetHashCode(); hash = hash * 23 + Static.GetHashCode(); hash = hash * 23 + Sealed.GetHashCode(); hash = hash * 23 + Nested.GetHashCode(); hash = hash * 23 + Primitives.GetHashCode(); hash = hash * 23 + Object.GetHashCode(); hash = hash * 23 + NonSerializable.GetHashCode(); hash = hash * 23 + Obsolete.GetHashCode(); hash = hash * 23 + GenericParameterAttributeFlags.GetHashCode(); return(hash); } }
public void Commit() { if (_status != SqlTransactionStatus.Opened) { throw new InvalidOperationException(); } if (!RestoreSuperIsolationLevel()) { RollbackAll(); } else { if (_sub != null) { _sub.OnCommitAbove(); _sub = null; } _status = SqlTransactionStatus.Committed; RestoreSuperIsolationLevel(); _super.OnSubClose(_super, 1); } }
internal new TestResultsHolder Clone() { return(new TestResultsHolder { Id = Id, ParentId = ParentId, IsSuite = IsSuite, Name = Name, Skipped = Skipped, Failure = Failure, Duration = Duration, Failures = Failures.ToList(), Nested = new List <SuiteOrTest>(Nested.Select(n => n.Clone())), Logs = Logs.ToList(), UserAgent = UserAgent, Running = Running, TestsFailed = TestsFailed, TestsFinished = TestsFinished, TestsSkipped = TestsSkipped, TotalTests = TotalTests }); }
public static void MaybeEnvelope(this HttpResponse response, HttpRequest request, JsonConversionOptions options, IList <Error> errors, out object body) { if (FeatureRequested(request, options.EnvelopeOperator)) { body = new Envelope { Status = response.StatusCode, Headers = response.Headers, Errors = errors, HasErrors = errors?.Count > 0 }; } else { body = new Nested { Errors = errors, HasErrors = errors?.Count > 0 }; } response.StatusCode = (int)HttpStatusCode.OK; }
public void WhenDestructuringNestedClassThenItWillBePopulatedAccordingly() { var options = new CustomPolicyOptions().AddPolicy("add hello", IsStringNamePropertyName, value => $"Hello {value}!"); var events = new List <LogEvent>(); var logger = new LoggerConfiguration() .Destructure.With(new CustomRuleDestructuringPolicy(options)) .WriteTo.Sink(new DelegatingSink(events.Add)) .CreateLogger(); var sut = new Nested { HasInner = true, Child = { Name = "me" } }; logger.Information("Hello {@Data}", sut); Assert.That(events.Count, Is.EqualTo(1)); var logEvent = events[0]; Assert.That(logEvent.Properties, Does.ContainKey("Data")); Assert.That(logEvent.Properties["Data"], Is.TypeOf <StructureValue>()); var logProperties = ((StructureValue)logEvent.Properties["Data"]).Properties; AssertLogProperty(logProperties, nameof(Nested.HasInner), true.ToString()); var childProperty = logProperties.FirstOrDefault(p => p.Name == nameof(Nested.Child)); Assert.That(childProperty, Is.Not.Null); Assert.That(childProperty !.Value, Is.TypeOf <StructureValue>()); var properties = ((StructureValue)childProperty.Value).Properties; AssertLogProperty(properties, nameof(Test.ReadOnly), "\"never changed\""); AssertLogProperty(properties, nameof(Test.Default), "\"hello\""); AssertLogProperty(properties, nameof(Test.Name), "\"Hello me!\""); }
public void Serialize_Nested_Simple_Null() { var source = new Nested { Dictionary = new Dictionary <string, object> { ["string"] = null }.ToInputs(), Value2 = 123, Value1 = "string" }; string json = JsonSerializer.Serialize(source, _options); json.ShouldBeCrossPlatJson( @"{ ""value1"": ""string"", ""dictionary"": { ""string"": null }, ""value2"": 123 }".Trim()); }
public void Nested_generic() { var value = new Nested <Nested <int> >() { Value = 1, Tail = new Nested <int> { Value = 2, Tail = 3, } }; var ctx = new object(); Serializer.Serialize(ref value, ref ctx, new AssertingWriter(ctx, 1, Manifests.Int32Type, 2, 2, Manifests.Object, 6, 0, 1, Manifests.Int32Type, 4, 2, Manifests.Int32Type, 6 )); }
public async Task Test__LightSession() { // Arrange var model = new DummyModel { Name = "Foo", Children = new List <Nested>() }; await _repository.For <DummyModel>().Save(model); var nested = new Nested { ParentRef = model }; await _repository.For <Nested>().Save(nested); // Act var entity = await _repository.For <DummyModel>().Light().Get(x => x.Id == model.Id); // Assert Assert.Null(entity.Children); }
public void FlexObject_JsonConcreteSeralizeFormat() { var parent = new FlexObject(); parent["test"] = "testProperty"; parent["nested"] = new Nested(); var parentJson = JsonConvert.SerializeObject(parent); string correctJson = @" { 'test' : 'testProperty', 'nested' : { 'Property1' : 'one' } }"; JObject target = JObject.Parse(correctJson); JObject fromFlexObject = JObject.Parse(parentJson); bool areSame = JToken.DeepEquals(target, fromFlexObject); Assert.IsTrue(areSame, "Json documents did not match"); }
public void Serialize_Nested_ComplexValues() { /* Given */ var source = new Nested { Dictionary = new Dictionary <string, object> { ["int"] = 123, ["string"] = "string", ["complex"] = new Dictionary <string, object> { ["double"] = 1.123d } }, Value2 = 123, Value1 = "string" }; /* When */ var json = JsonSerializer.Serialize(source, _options); /* Then */ Assert.Equal( @"{ ""dictionary"": { ""int"": 123, ""string"": ""string"", ""complex"": { ""double"": 1.123 } }, ""value1"": ""string"", ""value2"": 123 }".Trim().ReplaceLineEndings(), json); }
public C(Nested n) { N = n; }
public async Task <FileResponse> ChangePasswordNestedAsync(Nested nested, CancellationToken cancellationToken) { return(FileResponse.Create(nested.ChangePassword.AccessToken, nested.ChangePassword.CurrentPassword, nested.ChangePassword.ProposedPassword)); }
/// <summary>Serialize the instance into the stream</summary> public static void Serialize(Stream stream, Nested instance) { if (instance.NestedData != null) { // Key for field: 1, LengthDelimited stream.WriteByte(10); using (var ms1 = new MemoryStream()) { Proto.test.Data.Serialize(ms1, instance.NestedData); // Length delimited byte array uint ms1Length = (uint)ms1.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, ms1Length); stream.Write(ms1.GetBuffer(), 0, (int)ms1Length); } } }
public void Pathing_Tests_IValidatableObject() { Nested <NestedSubType> n; n = new Nested <NestedSubType>(); n.Options = new List <NestedSubType> { new NestedSubType() { ReturnValidationError = false }, new NestedSubType() { ReturnValidationError = false } }; var result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNull(result); n = new Nested <NestedSubType>(); n.Options = new List <NestedSubType> { new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }, new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true } }; result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNotNull(result); for (int i = 0; i < result.Count; i++) { Assert.AreEqual($"Options[{i}].UserName", result[i].MemberNames.FirstOrDefault()); } n = new Nested <NestedSubType>(); n.Options = new List <NestedSubType> { new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = false }, new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = false } }; result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNotNull(result); for (int i = 0; i < result.Count; i++) { Assert.AreEqual($"Options[{i}].UserName", result[i].MemberNames.FirstOrDefault()); } n = new Nested <NestedSubType>(); n.Options = new List <NestedSubType> { new NestedSubType() { ReturnValidationError = false }, }; n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }); n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = false, UseValidationPathResult = true }); n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }); result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual($"Options[0].EndlessNesting[0].UserName", result[0].MemberNames.FirstOrDefault()); Assert.AreEqual($"Options[0].EndlessNesting[2].UserName", result[1].MemberNames.FirstOrDefault()); }
/// <summary>Serialize the instance into the stream</summary> public static void Serialize(Stream stream, Nested instance) { var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop(); if (instance.NestedData != null) { // Key for field: 1, LengthDelimited stream.WriteByte(10); msField.SetLength(0); Proto.Test.Nullables.Data.Serialize(msField, instance.NestedData); // Length delimited byte array uint length1 = (uint)msField.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length1); msField.WriteTo(stream); } global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static Nested DeserializeLength(Stream stream, int length) { var instance = new Nested(); DeserializeLength(stream, length, instance); return instance; }
/// <summary>Helper: create a new instance to deserializing into</summary> public static Nested Deserialize(Stream stream) { var instance = new Nested(); Deserialize(stream, instance); return instance; }
public static void Initialize() { Console.WriteLine("- Singleton Initialize"); Nested.Initialize(); }
// ************************************************************ // FACTORY // ************************************************************ #region /// <summary> /// Method used ton instanciate the Markit Equity IV in-memory cache (singleton). /// </summary> public static Markit_Equity_IV Instance(MarkitEquityUnderlying underlying) { return(Nested.instance(underlying)); }
// public static T Instance // { // get { return Nested.instance; } // } public static WebControlHelper CreateInstance(IControlView view) { return(Nested.CreateLocalInstance(view)); }
public void Pathing_Tests_IValidatableObject_BaseType() { Nested <NestedSubTypeBase> n; //var t = AttributeFinder.FindValidatableProperties(typeof(NestedSubType)); //t.First().Item1.GetCustomAttributes( n = new Nested <NestedSubTypeBase>(); n.Options = new List <NestedSubTypeBase> { new NestedSubType() { ReturnValidationError = false }, new NestedSubType() { ReturnValidationError = false } }; var result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNull(result); n = new Nested <NestedSubTypeBase>(); n.Options = new List <NestedSubTypeBase> { new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }, new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true } }; result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNotNull(result); for (int i = 0; i < result.Count; i++) { Assert.AreEqual($"Options[{i}].UserName", result[i].MemberNames.FirstOrDefault()); } n = new Nested <NestedSubTypeBase>(); n.Options = new List <NestedSubTypeBase> { new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = false }, new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = false } }; result = ValidationHandler.Validate(n, new Dictionary <object, object>(), false); Assert.IsNotNull(result); for (int i = 0; i < result.Count; i++) { Assert.AreEqual($"Options[{i}].UserName", result[i].MemberNames.FirstOrDefault()); } //n = new Nested<NestedSubTypeBase>(); //n.Options = new List<NestedSubTypeBase> { // new NestedSubType() { ReturnValidationError = false}, //}; //n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }); //n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = false, UseValidationPathResult = true }); //n.Options[0].EndlessNesting.Add(new NestedSubType() { ReturnValidationError = true, UseValidationPathResult = true }); //result = ValidationHandler.Validate(n, new Dictionary<object, object>(), false); //Assert.IsNotNull(result); //Assert.AreEqual(2, result.Count); //Assert.AreEqual($"Options[0].EndlessNesting[0].UserName", result[0].MemberNames.FirstOrDefault()); //Assert.AreEqual($"Options[0].EndlessNesting[2].UserName", result[1].MemberNames.FirstOrDefault()); }
/// <summary>Helper: Serialize with a varint length prefix</summary> public static void SerializeLengthDelimited(Stream stream, Nested instance) { var data = SerializeToBytes(instance); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length); stream.Write(data, 0, data.Length); }
internal void AddNested(MetaEntry m) { Nested.Add(m); }
static int Main () { Nested n = new Nested (); return n.D() == MyEnum.V ? 0 : 1; }
public static void Initialize() { Nested.Initialize(); }
// ReSharper disable once UnusedParameter.Local void Method(Nested.Nested2 param) { }
private void Foo() { Nested nested = new Nested("bar"); }
public void NoILWay() { var n = new Nested(); n.Fun("Test"); Assert.Equal("Test", n.PassedParam); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static Nested DeserializeLengthDelimited(Stream stream) { var instance = new Nested(); DeserializeLengthDelimited(stream, instance); return instance; }
public void ResizeObjects(Point dest) { Point offset; offset = new Point(dest.X - MovingPoint.X, dest.Y - MovingPoint.Y); foreach (DrawableObject obj in SelectedObjects) { obj.ResizeCheck(ref offset, ResizingType); } foreach (DrawableObject obj in SelectedObjects) { if (obj is Transition) { PreviousObject = OnObject; OnObject = draw.GetOnObject(dest); OnTransition = (Transition)obj; if (OnObject == null) { offset = new Point(dest.X - MovingPoint.X, dest.Y - MovingPoint.Y); OnTransition.Resize(offset, ResizingType); if (ResizingType == ResizingTypes.Spline0) { OnTransition.StartObject = null; } else if (ResizingType == ResizingTypes.Spline3) { OnTransition.EndObject = null; } } else if (ResizingType == ResizingTypes.Spline0) { if ((obj is Transition && (OnObject is End || OnObject is Abort || OnObject is Relation)) || (obj is SuperTransition && (OnObject is Alias || OnObject is SimpleState || OnObject is StateAlias)) || (OnObject is Origin && OnObject.OutTransitions.Length != 0 && OnTransition != OnObject.OutTransitions.First())) { OnObject = null; return; } else { double angle; OnObject.Intersect(dest, ref StartDrawPoint, ref OnTransition.StartAngle); offset = new Point(StartDrawPoint.X - MovingPoint.X, StartDrawPoint.Y - MovingPoint.Y); OnTransition.Resize(offset, ResizingType); OnTransition.OutDir(OnObject.OutDir(StartDrawPoint, out angle), 1); } if (PreviousObject != OnObject) { OnTransition.StartObject = OnObject; } } else if (ResizingType == ResizingTypes.Spline3) { if (OnObject is Origin || OnObject is Relation) { OnObject = null; return; } else { double angle; OnObject.Intersect(dest, ref StartDrawPoint, ref OnTransition.EndAngle); offset = new Point(StartDrawPoint.X - MovingPoint.X, StartDrawPoint.Y - MovingPoint.Y); OnTransition.Resize(offset, ResizingType); OnTransition.OutDir(OnObject.OutDir(StartDrawPoint, out angle), 2); } if (PreviousObject != OnObject) { OnTransition.EndObject = OnObject; } } } else if (obj is SimpleState || obj is StateAlias) { State oState = (State)obj; obj.Resize(offset, ResizingType); foreach (Transition oTransition in oState.InTransitions) { oTransition.MoveEndTo(oState.PointFromAngle(oTransition.EndAngle)); } foreach (Transition oTransition in oState.OutTransitions) { oTransition.MoveStartTo(oState.PointFromAngle(oTransition.StartAngle)); } } else if (obj is SuperState) { SuperState oState = (SuperState)obj; obj.Resize(offset, ResizingType); foreach (Transition oTransition in oState.InTransitions) { oTransition.MoveEndTo(oState.PointFromOffset(ResizingType, oTransition.EndPoint, oTransition.EndAngle)); } foreach (Transition oTransition in oState.OutTransitions) { oTransition.MoveStartTo(oState.PointFromOffset(ResizingType, oTransition.StartPoint, oTransition.StartAngle)); } } else if (obj is Nested) { Nested oState = (Nested)obj; obj.Resize(offset, ResizingType); foreach (Transition oTransition in oState.InTransitions) { oTransition.MoveEndTo(oState.PointFromOffset(ResizingType, oTransition.EndPoint, oTransition.EndAngle)); } foreach (Transition oTransition in oState.OutTransitions) { oTransition.MoveStartTo(oState.PointFromOffset(ResizingType, oTransition.StartPoint, oTransition.StartAngle)); } } else { obj.Resize(offset, ResizingType); } } MovingPoint.Offset(offset); }
/// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary> public static Nested Deserialize(byte[] buffer) { var instance = new Nested(); using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return instance; }
public static int Main() { Nested n = new Nested(); return(n.D() == MyEnum.V ? 0 : 1); }
/// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary> public static byte[] SerializeToBytes(Nested instance) { using (var ms = new MemoryStream()) { Serialize(ms, instance); return ms.ToArray(); } }
public static bool test() { Nested n = new Nested(); return n.test() == 2 && n.obj.field == 3; }
/// <summary> /// 创建工厂。 /// </summary> /// <typeparam name="TResult">返回数据类型。</typeparam> /// <returns></returns> public Func <object, TResult> Create <TResult>(Type sourceType) => Nested <TResult> .Create(this, sourceType ?? throw new ArgumentNullException(nameof(sourceType)));
public Task <FileResponse> ChangePasswordNestedAsync(Nested nested) { return(ChangePasswordNestedAsync(nested, CancellationToken.None)); }
private static void NextOne(ref Nested arg1) { }
AutoPropertyNestedAccess() { this.nested = new Nested(this); }