Exemplo n.º 1
0
 private static void Update(IReferenceTypeFactory nodeDesign, UAReferenceType nodeSet, Action <TraceMessage> traceEvent)
 {
     nodeSet.InverseName.ExportLocalizedTextArray(nodeDesign.AddInverseName);
     nodeDesign.Symmetric = nodeSet.Symmetric;
     if (nodeSet.Symmetric && (nodeSet.InverseName != null && nodeSet.InverseName.Where(x => !string.IsNullOrEmpty(x.Value)).Any()))
     {
         XML.LocalizedText _notEmpty = nodeSet.InverseName.Where(x => !string.IsNullOrEmpty(x.Value)).First();
         traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.WrongInverseName, string.Format("If ReferenceType {0} is symmetric the InverseName {1}:{2} shall be omitted.", nodeSet.NodeIdentifier(), _notEmpty.Locale, _notEmpty.Value)));
     }
     else if (!nodeSet.Symmetric && !nodeSet.IsAbstract && (nodeSet.InverseName == null || !nodeSet.InverseName.Where(x => !string.IsNullOrEmpty(x.Value)).Any()))
     {
         traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.WrongInverseName, string.Format("If ReferenceType {0} is not symmetric and not abstract the InverseName shall be specified.", nodeSet.NodeIdentifier())));
     }
 }
Exemplo n.º 2
0
 public void DisplayNameArraysEqualTest()
 {
     XML.LocalizedText[] _first = null;
     Assert.IsTrue(_first.LocalizedTextArraysEqual(_first));
     Assert.IsFalse(_first.LocalizedTextArraysEqual(new XML.LocalizedText[] { }));
     _first = new XML.LocalizedText[] { };
     Assert.IsTrue(_first.LocalizedTextArraysEqual(new XML.LocalizedText[] { }));
     _first = new XML.LocalizedText[] { new XML.LocalizedText()
                                        {
                                            Locale = "Locale1", Value = "Value1"
                                        }, new XML.LocalizedText()
                                        {
                                            Locale = "Locale2", Value = "Value2"
                                        } };
     Assert.IsTrue(_first.LocalizedTextArraysEqual(new XML.LocalizedText[] { new XML.LocalizedText()
                                                                             {
                                                                                 Locale = "Locale2", Value = "Value2"
                                                                             }, new XML.LocalizedText()
                                                                             {
                                                                                 Locale = "Locale1", Value = "Value1"
                                                                             } }));
 }
Exemplo n.º 3
0
        internal static XML.LocalizedText[] Truncate(this XML.LocalizedText[] localizedText, int maxLength, Action <TraceMessage> reportError)
        {
            if (localizedText == null || localizedText.Length == 0)
            {
                return(null);
            }
            List <XML.LocalizedText> _ret = new List <XML.LocalizedText>();

            foreach (XML.LocalizedText _item in localizedText)
            {
                if (_item.Value.Length > maxLength)
                {
                    reportError(TraceMessage.BuildErrorTraceMessage(BuildError.WrongDisplayNameLength, string.Format
                                                                        ("The localized text starting with '{0}:{1}' of length {2} is too long.", _item.Locale, _item.Value.Substring(0, 20), _item.Value.Length)));
                    XML.LocalizedText _localizedText = new XML.LocalizedText()
                    {
                        Locale = _item.Locale,
                        Value  = _item.Value.Substring(0, maxLength)
                    };
                }
            }
            return(localizedText);
        }
Exemplo n.º 4
0
 private static string ConvertToString(XML.LocalizedText x)
 {
     return($"{ x.Locale}:{x.Value}");
 }