public IValue XMLValue(IValue givenType, string presentation) { var typeValue = TypeManager.GetTypeDescriptorFor(givenType.GetRawValue()); if (typeValue.Equals(TypeDescriptor.FromDataType(DataType.Boolean))) { return(ValueFactory.Create(XmlConvert.ToBoolean(presentation))); } else if (typeValue.Equals(TypeDescriptor.FromDataType(DataType.Date))) { return(ValueFactory.Create(XmlConvert.ToDateTime(presentation, XmlDateTimeSerializationMode.Unspecified))); } else if (typeValue.Equals(TypeDescriptor.FromDataType(DataType.Number))) { return(ValueFactory.Create(XmlConvert.ToDecimal(presentation))); } else if (typeValue.Equals(TypeDescriptor.FromDataType(DataType.String))) { return(ValueFactory.Create(presentation)); } else if (typeValue.Equals(TypeDescriptor.FromDataType(DataType.Undefined)) && presentation == "") { return(ValueFactory.Create()); } else { throw RuntimeException.InvalidArgumentValue(); } }
public static SymbolsEnum CreateInstance() { var type = TypeManager.RegisterType("Символы", typeof(SymbolsEnum)); var stringType = TypeDescriptor.FromDataType(DataType.String); var instance = new SymbolsEnum(type, stringType); instance.AddValue("ПС", new SymbolsEnumValue(instance, "\n")); instance.AddValue("ВК", new SymbolsEnumValue(instance, "\r")); instance.AddValue("ВТаб", new SymbolsEnumValue(instance, "\v")); instance.AddValue("Таб", new SymbolsEnumValue(instance, "\t")); instance.AddValue("ПФ", new SymbolsEnumValue(instance, "\f")); instance.AddValue("НПП", new SymbolsEnumValue(instance, "\u00A0")); return(instance); }
IValueAdjuster GetAdjusterForType(TypeTypeValue type) { if (type.Value.Equals(TypeDescriptor.FromDataType(DataType.Number))) { return(NumberQualifiers); } if (type.Value.Equals(TypeDescriptor.FromDataType(DataType.String))) { return(StringQualifiers); } if (type.Value.Equals(TypeDescriptor.FromDataType(DataType.Date))) { return(DateQualifiers); } if (type.Value.Equals(TypeDescriptor.FromDataType(DataType.Boolean))) { return(new BooleanTypeAdjuster()); } return(null); }