public void OpenFilterList(object sender) { TypeNameList.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(BindingPath)); DataGridHeaderFilterButton button = (DataGridHeaderFilterButton)sender; FilterPopup.PlacementTarget = button; FilterPopup.Placement = PlacementMode.Relative; FilterPopup.IsOpen = true; }
public void TypeNameIntList() { TypeNameList <int> l = new TypeNameList <int>(); l.Add(1); l.Add(2); l.Add(3); string json = JsonConvert.SerializeObject(l, Formatting.Indented); Assert.AreEqual(@"[ 1, 2, 3 ]", json); }
public void TypeNameComponentList() { var c1 = new TestComponentSimple(); TypeNameList <object> l = new TypeNameList <object>(); l.Add(c1); l.Add(new Employee { BirthDate = new DateTime(2000, 12, 12, 12, 12, 12, DateTimeKind.Utc), Department = "Department!" }); l.Add("String!"); l.Add(long.MaxValue); string json = JsonConvert.SerializeObject(l, Formatting.Indented); Assert.AreEqual(@"[ { ""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"", ""MyProperty"": 0 }, { ""$type"": ""Newtonsoft.Json.Tests.TestObjects.Employee, Newtonsoft.Json.Tests"", ""FirstName"": null, ""LastName"": null, ""BirthDate"": ""2000-12-12T12:12:12Z"", ""Department"": ""Department!"", ""JobTitle"": null }, ""String!"", 9223372036854775807 ]", json); TypeNameList <object> l2 = JsonConvert.DeserializeObject <TypeNameList <object> >(json); Assert.AreEqual(4, l2.Count); CustomAssert.IsInstanceOfType(typeof(TestComponentSimple), l2[0]); CustomAssert.IsInstanceOfType(typeof(Employee), l2[1]); CustomAssert.IsInstanceOfType(typeof(string), l2[2]); CustomAssert.IsInstanceOfType(typeof(long), l2[3]); }
/// <summary> /// Adds information about an operation implementation to this collection. /// </summary> /// <param name="operationName">The operation's name.</param> /// <param name="parameterTypes">The operation's parameter types (order matters).</param> /// <param name="getImplementationFunc">A method to get the operation's implementation.</param> public void Add(string operationName, IEnumerable <Type> parameterTypes, Delegates.GetExecuteOperationFunc <TContractImplementation> getImplementationFunc) { if (operationName == null) { throw new ArgumentNullException(nameof(operationName)); } if (parameterTypes == null) { throw new ArgumentNullException(nameof(parameterTypes)); } if (getImplementationFunc == null) { throw new ArgumentNullException(nameof(getImplementationFunc)); } // Add an entry for the operation name if it doesn't exist if (!this.OperationImplementationInfos.ContainsKey(operationName)) { this.OperationImplementationInfos.Add(operationName, new Dictionary <TypeNameList, OperationImplementationInfo>()); } // Get the operation overloads IDictionary <TypeNameList, OperationImplementationInfo> overloads = this.OperationImplementationInfos[operationName]; // Make sure that the overload isn't already defined TypeNameList parameterTypeNames = new TypeNameList(parameterTypes); // Should match ParameterValue.TypeCSharpName if (overloads.ContainsKey(parameterTypeNames)) { throw new ArgumentException($"In operation '{operationName}', an overload with the following parameters is already defined: {parameterTypes}"); } // Store the implementation info OperationImplementationInfo implementationInfo = new OperationImplementationInfo(operationName, parameterTypes, getImplementationFunc); overloads.Add(parameterTypeNames, implementationInfo); }