public void TestToDynamicObject() { string json = ResourceStringLoader.LoadString("X3Platform.Tests.defaults.test_json"); // string json = "{\"id\":\"0001\",\"name\":\"x3platform\",\"age\":5,\"groups\":[0,1,2,3],\"createDate\":\"1970-01-01\"}"; dynamic obj = JsonMapper.ToDynamicObject(json); Assert.AreEqual("0001", obj.id); Assert.AreEqual("x3platform", obj.name); Assert.AreEqual(true, obj.locking); Assert.AreEqual(5, obj.age); Assert.AreEqual(null, obj.nullValue); Assert.AreEqual("x3", obj.objectValue.name); Assert.AreEqual(0, obj.groups[0]); Assert.AreEqual(1, obj.groups[1]); Assert.AreEqual(2, obj.groups[2]); Assert.AreEqual(3, obj.groups[3]); string result = AjaxUtil.Parse <dynamic>(obj); string result1 = JsonMapper.ToJson(obj); Assert.AreEqual("a1", obj.name); TestInfo t = new TestInfo(); t.Id = "a"; dynamic obj1 = JsonMapper.ToDynamicObject(t); }
/// <summary> /// Initialize a new instance of the <see cref="FilteredFileNameEditorAttribute"/> class with the <see cref="Type"/> containing the resources and the resource key. /// </summary> /// <param name="resourceType">The <see cref="Type"/> containing the resources.</param> /// <param name="resourceKey">The resource key.</param> public FilteredFileNameEditorAttribute(Type resourceType, string resourceKey) { if (null == resourceType) { throw new ArgumentNullException("resourceType"); } this.filter = ResourceStringLoader.LoadString(resourceType.FullName, resourceKey, resourceType.Assembly); this.CheckFileExists = true; }
/// <summary> /// Gets the pattern used for building the regular expression. /// </summary> /// <returns>The regular expression pattern.</returns> public string GetPattern() { if (!string.IsNullOrEmpty(pattern)) { return(pattern); } else { return(ResourceStringLoader.LoadString(patternResourceType.FullName, patternResourceName, patternResourceType.Assembly)); } }
public void TestLoadString() { // ResourceManager rm = new ResourceManager("X3Platform.Tests.ResourceString", Assembly.GetExecutingAssembly()); string result = ResourceStringLoader.LoadString("X3Platform.Tests.defaults.test_resources"); // Assert.IsNotNull(result); // result = ResourceStringLoader.LoadString("X3Platform.Tests.I18N", "aa"); // Assert.IsNotNull(result); }
public static string GetExceptionMessage(string exceptionMessage, string exceptionMessageResourceName, string exceptionMessageResourceType) { if (!string.IsNullOrEmpty(exceptionMessageResourceName)) { Type resourceType = Type.GetType(exceptionMessageResourceType, false); if (null != resourceType) { exceptionMessage = ResourceStringLoader.LoadString(resourceType.FullName, exceptionMessageResourceName, resourceType.Assembly); } } return(exceptionMessage); }
internal string GetMessageTemplate() { if (!string.IsNullOrEmpty(this.MessageTemplate)) { return(this.MessageTemplate); } Type messageTemplateResourceType = this.GetMessageTemplateResourceType(); if (messageTemplateResourceType != null) { return(ResourceStringLoader.LoadString(messageTemplateResourceType.FullName, this.MessageTemplateResourceName, messageTemplateResourceType.Assembly)); } return(null); }
public void TestUpload() { // 测试帐号id // string accountId = "52cf89ba-7db5-4e64-9c64-3c868b6e7a99"; AjaxRequestData reqeustData = new AjaxRequestData(); reqeustData.ActionUri = new Uri(apiHostPrefix + "/api/attachment.file.upload.aspx"); var content = ResourceStringLoader.LoadString("X3Platform.AttachmentStorage.Tests.data.api.attachment.upload.json"); var responseText = AjaxRequest.Request(reqeustData, "POST", "application/x-www-form-urlencoded", content); dynamic response = JsonMapper.ToDynamicObject(responseText); Assert.AreEqual("0", response["mobileRespHeader"]["respCode"].ToString()); }
/// <summary> /// Returns the message template for the represented validator. /// </summary> /// <remarks> /// The textual message is given precedence over the resource based mechanism. /// </remarks> public string GetMessageTemplate() { if (null != this.messageTemplate) { return(this.messageTemplate); } if (null != this.messageTemplateResourceName && null != this.messageTemplateResourceType) { return(ResourceStringLoader.LoadString(this.messageTemplateResourceType.FullName, this.messageTemplateResourceName, this.messageTemplateResourceType.Assembly)); } if (null != this.messageTemplateResourceName || null != this.messageTemplateResourceType) { throw new InvalidOperationException(Resources.ExceptionPartiallyDefinedResourceForMessageTemplate); } return(null); }
string IStringResolver.GetString() { string value; if (!(this.resourceType == null || string.IsNullOrEmpty(this.resourceName))) { value = ResourceStringLoader.LoadString( this.resourceType.FullName, this.resourceName, this.resourceType.Assembly); } else { value = this.fallbackValue; } return(value); }
/// <summary> /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. /// Builds a <see cref="ReplaceHandler"/> based on an instance of <see cref="ReplaceHandlerData"/>. /// </summary> /// <seealso cref="ExceptionHandlerCustomFactory"/> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="ReplaceHandlerData"/>.</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>A fully initialized instance of <see cref="ReplaceHandler"/>.</returns> public IExceptionHandler Assemble(IBuilderContext context, ExceptionHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { ReplaceHandlerData castedObjectConfiguration = (ReplaceHandlerData)objectConfiguration; string exceptionMessage = castedObjectConfiguration.ExceptionMessage; if (!string.IsNullOrEmpty(castedObjectConfiguration.ExceptionMessageResourceName)) { Type exceptionMessageResourceType = Type.GetType(castedObjectConfiguration.ExceptionMessageResourceType, false); if (null != exceptionMessageResourceType) { exceptionMessage = ResourceStringLoader.LoadString(exceptionMessageResourceType.FullName, castedObjectConfiguration.ExceptionMessageResourceName, exceptionMessageResourceType.Assembly); } } ReplaceHandler createdObject = new ReplaceHandler(exceptionMessage, castedObjectConfiguration.ReplaceExceptionType); return(createdObject); }
/// <summary> /// Gets the localized string based on the key. /// </summary> /// <param name="value">The key to the string resources.</param> /// <returns>The localized string.</returns> protected override string GetLocalizedString(string value) { return(ResourceStringLoader.LoadString(resourceType.FullName, value, resourceType.Assembly)); }
/// <summary> /// Gets the pattern used for building the regular expression. /// </summary> /// <returns>The regular expression pattern.</returns> public string GetPattern() => !string.IsNullOrEmpty(Pattern) ? Pattern : ResourceStringLoader.LoadString(PatternResourceType.FullName, PatternResourceName, PatternResourceType.Assembly);
public void ExcutingLoadStringWithNullResourceNameThrows() { ResourceStringLoader.LoadString("Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Properties.Resources", null); }
public void ExcutingLoadStringWithNullBaseNameThrows() { ResourceStringLoader.LoadString(null, "ValidationCaption"); }
public void CanLoadStringFromExecutingAssembly() { string value = ResourceStringLoader.LoadString("Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Properties.Resources", "ValidationCaption"); Assert.AreEqual("Validation", value); }
public void CanLoadStringFromCallingAssembly() { string value = ResourceStringLoader.LoadString(typeof(Resources).FullName, "Test"); Assert.AreEqual("Test", value); }