public static string SerializeServerExtensionData(Dictionary <string, object> serverExtensionData) { return(JsmlSerializer.Serialize(serverExtensionData, "data", new JsmlSerializer.SerializeOptions { Hook = _serverExtensionDataHook, DataContractTest = IsServerExtensionDataContract })); }
public static string SerializeWorkItemProgress(WorkItemProgress data) { return(JsmlSerializer.Serialize(data, "data", new JsmlSerializer.SerializeOptions { Hook = _workItemProgressHook, DataContractTest = IsWorkItemProgressContract })); }
public void Test_DataContract_non_public_constructor() { var jsml = JsmlSerializer.Serialize(new TestContract3("foo"), "data"); var obj = JsmlSerializer.Deserialize <TestContract3>(jsml); Assert.AreEqual("foo", obj.Value); }
public static string SerializeWorkItemRequest(WorkItemRequest data) { return(JsmlSerializer.Serialize(data, "data", new JsmlSerializer.SerializeOptions { Hook = _workItemRequestHook, DataContractTest = IsWorkItemRequestContract })); }
public string GetOperationNames(string serviceContractName) { string[] names = null; Platform.GetService <IJsmlShimService>( service => names = service.GetOperationNames(new GetOperationNamesRequest(serviceContractName)).OperationNames); return(JsmlSerializer.Serialize(names, "operationNames")); }
/// <summary> /// Invokes the specified operation on the specified service contract, passing the specified JSML-encoded request object. /// </summary> /// <param name="serviceContractTypeName"></param> /// <param name="operationName"></param> /// <param name="jsmlRequest"></param> /// <returns></returns> public static string InvokeOperation(string serviceContractTypeName, string operationName, string jsmlRequest) { Type contract = Type.GetType(serviceContractTypeName); MethodInfo operation = contract.GetMethod(operationName); ParameterInfo[] parameters = operation.GetParameters(); if (parameters.Length != 1) { throw new InvalidOperationException("Can only invoke methods with exactly one input parameter."); } object service = null; try { service = Platform.GetService(contract); object innerRequest = JsmlSerializer.Deserialize(parameters[0].ParameterType, jsmlRequest); object innerResponse = operation.Invoke(service, new object[] { innerRequest }); return(JsmlSerializer.Serialize(innerResponse, "responseData")); } finally { if (service != null && service is IDisposable) { (service as IDisposable).Dispose(); } } }
/// <summary> /// Writes the specified data to the specified xml writer. /// </summary> /// <param name="writer"></param> /// <param name="data"></param> private static void Write(XmlWriter writer, object data) { // bug #5300: do not write out the "Unique" flag anymore var options = new JsmlSerializer.SerializeOptions { DataMemberTest = (m => AttributeUtils.HasAttribute <DataMemberAttribute>(m) && m.Name != "Unique") }; JsmlSerializer.Serialize(writer, data, data.GetType().Name, options); }
public static string SerializeExternalQueryResult(ImageServerExternalQueryResult data) { return(JsmlSerializer.Serialize(data, "ImageServerExternalQueryResult", new JsmlSerializer.SerializeOptions { Hook = ExternalQueryHook, DataContractTest = IsImageServerExternalQueryContract })); }
public static string SerializeNotification(ImageServerNotification data) { return(JsmlSerializer.Serialize(data, "ImageServerNotification", new JsmlSerializer.SerializeOptions { Hook = ExternalRequestHook, DataContractTest = IsImageServerExternalRequestContract })); }
public static string SerializeWorkQueueUidData(WorkQueueUidData data) { return(JsmlSerializer.Serialize(data, "WorkQueueUidData", new JsmlSerializer.SerializeOptions { Hook = WorkItemDataHook, DataContractTest = IsWorkQueueDataContract, DataMemberTest = IsXmlSerializationDataMember })); }
/// <summary> /// Log the specified operation. /// </summary> /// <param name="operation">The name of the operation performed.</param> /// <param name="detailsDataContract">The audit message details.</param> private static void Log(string operation, object detailsDataContract) { if (LoginSession.Current == null) { return; } lock (_auditLog) { _auditLog.WriteEntry(operation, JsmlSerializer.Serialize(detailsDataContract, "Audit")); } }
/// <summary> /// Attempts to resolve the specified search string to a staff (returns a JSML encoded <see cref="StaffSummary"/>. /// </summary> /// <param name="search"></param> /// <returns></returns> public string ResolveStaffName(string search) { StaffSummary staff; var lookupHandler = new StaffLookupHandler(_component.Host.DesktopWindow); var resolved = lookupHandler.ResolveName(search, out staff); // bug #2896: the name may "resolve" to nothing, so we still need to check if staff actually has a value if (!resolved || staff == null) { resolved = lookupHandler.ResolveNameInteractive(search, out staff); } return(resolved ? JsmlSerializer.Serialize(staff, "staff") : null); }
public static XmlDocument SerializeExternalQueryResultToXmlDocument(ImageServerExternalQueryResult data) { var s = JsmlSerializer.Serialize(data, "ImageServerExternalQueryResult", new JsmlSerializer.SerializeOptions { Hook = ExternalQueryHook, DataContractTest = IsImageServerExternalQueryContract }); var d = new XmlDocument(); d.LoadXml(s); return(d); }
public static XmlDocument SerializeNotificationToXmlDocument(ImageServerNotification data) { var s = JsmlSerializer.Serialize(data, "ImageServerNotification", new JsmlSerializer.SerializeOptions { Hook = ExternalRequestHook, DataContractTest = IsImageServerExternalRequestContract }); var d = new XmlDocument(); d.LoadXml(s); return(d); }
/// <summary> /// Attempts to resolve the specified search string to a staff (returns a JSML encoded <see cref="StaffSummary"/>. /// </summary> /// <param name="search"></param> /// <param name="jsmlStaffTypesFilter">JSML encoded string list of staff types codes to filter with.</param> /// <returns></returns> public string ResolveFilteredStaffName(string search, string jsmlStaffTypesFilter) { StaffSummary staff; var filter = JsmlSerializer.Deserialize <List <String> >(jsmlStaffTypesFilter); var lookupHandler = new StaffLookupHandler(_component.Host.DesktopWindow, filter.ToArray()); var resolved = lookupHandler.ResolveName(search, out staff); // bug #2896: the name may "resolve" to nothing, so we still need to check if staff actually has a value if (!resolved || staff == null) { resolved = lookupHandler.ResolveNameInteractive(search, out staff); } return(resolved ? JsmlSerializer.Serialize(staff, "staff") : null); }
public static XmlDocument SerializeWorkQueueUidDataToXmlDocument(WorkQueueUidData data) { var s = JsmlSerializer.Serialize(data, "WorkQueueUidData", new JsmlSerializer.SerializeOptions { Hook = WorkItemDataHook, DataContractTest = IsWorkQueueDataContract, DataMemberTest = IsXmlSerializationDataMember }); var d = new XmlDocument(); d.LoadXml(s); return(d); }
public void PostCommit(IServiceOperationRecorderContext recorderContext) { var request = (ConfigurationDocumentRequestBase)recorderContext.Request; var data = new OperationData { Operation = "SetConfigurationDocument", DocumentName = request.DocumentKey.DocumentName, DocumentVersion = request.DocumentKey.Version.ToString(), DocumentUser = request.DocumentKey.User ?? "{application}", DocumentInstanceKey = StringUtilities.NullIfEmpty(request.DocumentKey.InstanceKey) ?? "{default}" }; var xml = JsmlSerializer.Serialize(data, "Audit"); recorderContext.Write(data.Operation, xml); }
public void Test_Polymorhpic_data_contracts() { // normally it isn't necessary to explicitly add subtypes, if those types are defined in *plugins* // but since Common is not a plugin, we need to explicitly add the types PolymorphicDataContractHook <TestPolyDataContractAttribute> .RegisterKnownType(typeof(TestContract4_A)); PolymorphicDataContractHook <TestPolyDataContractAttribute> .RegisterKnownType(typeof(TestContract4_B)); TestContract4 input, output; input = new TestContract4_A() { Data = "foo", DataA = "bar", Child = new TestContract4_B { Data = "x", DataB = "b" } }; var serialized = JsmlSerializer.Serialize(input, "data", new JsmlSerializer.SerializeOptions { Hook = new PolymorphicDataContractHook <TestPolyDataContractAttribute>() }); output = JsmlSerializer.Deserialize <TestContract4>(serialized, new JsmlSerializer.DeserializeOptions { Hook = new PolymorphicDataContractHook <TestPolyDataContractAttribute>() }); Assert.IsInstanceOf(typeof(TestContract4_A), output); Assert.AreEqual("foo", output.Data); Assert.AreEqual("bar", ((TestContract4_A)output).DataA); Assert.IsInstanceOf(typeof(TestContract4_B), output.Child); Assert.AreEqual("x", output.Child.Data); Assert.AreEqual("b", ((TestContract4_B)output.Child).DataB); }
private static void SerializeHelper(object input, string expectedJsml, JsmlSerializer.SerializeOptions options) { var jsml = JsmlSerializer.Serialize(input, "Tag", options); Assert.AreEqual(expectedJsml, jsml); }
/// <summary> /// Gets a JSML-encoded FacilitySummary containing details of the client's current working facility /// </summary> /// <returns></returns> public string GetWorkingFacility() { return(JsmlSerializer.Serialize(LoginSession.Current.WorkingFacility, "facility")); }
/// <summary> /// Writes an audit log entry for the specified change set. /// </summary> void IEntityChangeSetRecorder.WriteLogEntry(IEnumerable <EntityChange> changeSet, AuditLog auditLog) { var xml = JsmlSerializer.Serialize(WriteChangeSet(_operationName, changeSet), "ChangeSet"); auditLog.WriteEntry(_operationName, xml); }
/// <summary> /// Gets the healthcard context object (JSML encoded). /// </summary> /// <returns></returns> public string GetHealthcareContext() { return(JsmlSerializer.Serialize(_component.GetHealthcareContext(), "context")); }
public string ToJsml() { return(JsmlSerializer.Serialize(this, "Report")); }
public string GetOperationNames(string serviceContractName) { var names = ShimUtil.GetOperationNames(serviceContractName); return(JsmlSerializer.Serialize(names, "operationNames")); }
private void Write(IServiceOperationRecorderContext recorderContext) { var xml = JsmlSerializer.Serialize(_capturedData, "Audit"); recorderContext.Write(_capturedData.Operation, xml); }
/// <summary> /// Writes the specified data to the specified xml writer. /// </summary> /// <param name="writer"></param> /// <param name="data"></param> protected static void Write(XmlWriter writer, object data) { JsmlSerializer.Serialize(writer, data, data.GetType().Name); }