コード例 #1
0
        private Replacer.ReplaceInfo[] GetPropertyInfos(IBusinessObjectClass businessObjectClass, IBusinessObjectProperty[] properties)
        {
            Replacer.ReplaceInfo[] propertyInfos = new Replacer.ReplaceInfo[properties.Length];

            for (int index = 0; index < properties.Length; index++)
            {
                IBusinessObjectProperty property = properties[index];
                bool found = false;

                foreach (Configuration.ControlInfo controlMapping in _configuration.ControlMappings)
                {
                    if (HasInterface(property.GetType(), controlMapping.propertyType) && property.IsList == controlMapping.isList)
                    {
                        ApplicationConfiguration.ReplaceInfo[] additionalReplaceInfos = new ApplicationConfiguration.ReplaceInfo[] {
                            new ApplicationConfiguration.ReplaceInfo(Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier)
                        };

                        string additionalAttributes = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalAttributes);
                        string additionalElements   = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalElements);

                        propertyInfos[index].replaceInfos = new string[] {
                            Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier,
                            Placeholder.ToString(DefinedPlaceholder.CONTROLTYPE), controlMapping.controlName,
                            Placeholder.ToString(DefinedPlaceholder.ADDITIONALATTRIBUTES), additionalAttributes,
                            Placeholder.ToString(DefinedPlaceholder.ADDITIONALELEMENTS), additionalElements
                        };

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    propertyInfos[index].replaceInfos = null;

                    _warnings.AddWarning(WarningCode.MissingControlMapping, businessObjectClass.Identifier + "." + property.Identifier +
                                         " (" + property.GetType().ToString() + ")");
                }
            }

            return(propertyInfos);
        }
コード例 #2
0
        private ReplaceInfo[] GetReplaceInfos(XmlNodeList nodes)
        {
            ArrayList tempReplaceInfos = new ArrayList();

            for (int index = 0; index < nodes.Count; index++)
            {
                string from = GetValue(nodes[index], "from");
                string to   = GetValue(nodes[index], "to");

                int currentWarningCount = _warnings.Warnings.Count;

                if (!from.StartsWith(PlaceholderPrefix))
                {
                    _warnings.AddWarning(WarningCode.ReplaceInvalidFormat, string.Format("Invalid prefix for {0}", from));
                }

                if (!from.EndsWith(PlaceholderPostfix))
                {
                    _warnings.AddWarning(WarningCode.ReplaceInvalidFormat, string.Format("Invalid postfix for {0}", from));
                }

                if (from == string.Empty)
                {
                    _warnings.AddWarning(WarningCode.ReplaceFromInfoIsEmpty, to);
                }

                if (to == string.Empty)                 // maybe legal
                {
                    _warnings.AddWarning(WarningCode.ReplaceToInfoIsEmpty, from);
                }

                if (from == to)
                {
                    _warnings.AddWarning(WarningCode.ReplaceInfoFromEqualsTo, from);
                }

                if (currentWarningCount == _warnings.Warnings.Count)
                {
                    ReplaceInfo replaceInfo = new ReplaceInfo();

                    replaceInfo.from = from;
                    replaceInfo.to   = to;

                    tempReplaceInfos.Add(replaceInfo);
                }
            }

            ReplaceInfo[] replaceInfos     = new ReplaceInfo[tempReplaceInfos.Count];
            int           replaceInfoIndex = 0;

            foreach (ReplaceInfo replaceInfo in tempReplaceInfos)
            {
                if (replaceInfo.from == null || replaceInfo.to == null)
                {
                    continue;
                }

                replaceInfos[replaceInfoIndex++] = replaceInfo;
            }

            return(replaceInfos);
        }