コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        public void WriteTo(IProjectObject parent, IXmlReadWriteWrapper element, RedDotAttribute attribute, IFile value)
        {
            if (parent == null)
            {
                throw new SmartAPIInternalException("Parent project object may not be null for ExampleFileConverter");
            }

            if (value == null)
            {
                ClearFile(element);
                return;
            }

            if (!element.IsAttributeSet(parent, ELTFOLDERGUID))
            {
                throw new SmartAPIException(parent.Session.ServerLogin,
                                            string.Format(
                                                "Cannot set an example file ({0}) without an active folder in element {1}",
                                                value, parent));
            }

            if (ConverterHelper.AreFromTheSameProject(parent, value))
            {
                SetFromSameProject(parent, element, value);
            }
            else
            {
                if (value.Folder.IsAssetManager)
                {
                    SetValuesFromAssetManagerFolder(parent, element, value);
                }
                else
                {
                    var ownFolder = parent.Project.Folders.GetByName(value.Folder.Name);
                    SetValuesFromTopLevelFolder(parent, element, value, ownFolder);
                }
            }
        }