public void WriteTo(IProjectObject parent, IXmlReadWriteWrapper element, RedDotAttribute attribute, string value) { if (string.IsNullOrEmpty(value)) { element.SetAttributeValue(attribute.ElementName, null); } else { Guid guid = element.IsAttributeSet(parent, attribute.ElementName) ? element.GetGuid(attribute.ElementName) : Guid.Empty; var languageVariantName = element.GetAttributeValue("languagevariantid"); var languageVariant = parent.Project.LanguageVariants[languageVariantName]; try { Guid textGuid = parent.Project.SetTextContent(guid, languageVariant, ((int)Type).ToString(CultureInfo.InvariantCulture), value); element.SetAttributeValue(attribute.ElementName, textGuid.ToRQLString()); } catch (Exception e) { throw new SmartAPIException(parent.Session.ServerLogin, string.Format("Could not set {0} text for {1} in language {2}", Type.ToString().ToLower(), parent, languageVariantName), e); } } }
private T GetDefaultConversion <T>(IXmlReadWriteWrapper element, Type type) { if (type == typeof(string)) { return((T)(object)element.GetAttributeValue(ElementName)); } if (type == typeof(bool)) { return((T)(object)element.GetBoolAttributeValue(ElementName)); } if (type == typeof(int?)) { return((T)(object)element.GetIntAttributeValue(ElementName)); } throw new SmartAPIInternalException(string.Format("No matching conversion for element {0} to type {1}", ElementName, type.Name)); }