Exemple #1
0
        }         // proc WriteObject

        #endregion

        #region -- WriteSafeCall ----------------------------------------------------------

        public static void WriteSafeCall(this IDEContext r, XElement x, string successMessage = null)
        {
            if (x == null)
            {
                x = new XElement("return");
            }

            DEConfigItem.SetStatusAttributes(x, true, successMessage);

            WriteXml(r, x);
        }         // proc WriteSafeCall
Exemple #2
0
        public DEConfigurationElement(IServiceProvider sp, XmlSchemaElement element)
            : base(element)
        {
            this.sp = sp;

            getClassType = new Lazy <Type>(() =>
            {
                var classType = (Type)null;
                var appInfo   = element.Annotation?.Items.OfType <XmlSchemaAppInfo>().FirstOrDefault();
                if (appInfo != null)
                {
                    var classTypeElement = appInfo.Markup.OfType <XmlElement>().Where(x => x.LocalName == "class").FirstOrDefault();
                    if (classTypeElement != null)
                    {
                        var typeString = classTypeElement.InnerText;
                        try
                        {
                            if (typeString.IndexOf(',') == -1)                                     // this is relative type
                            {
                                var sourceUri = DEConfigItem.GetSourceUri(appInfo);
                                var posType   = sourceUri.LastIndexOf(',');
                                if (posType != -1)
                                {
                                    typeString = typeString + ", " + sourceUri.Substring(0, posType);
                                }
                            }

                            classType = Type.GetType(typeString, true, false);
                        }
                        catch (Exception e)
                        {
                            sp.LogProxy().Warn(new DEConfigurationException(appInfo, "Could not resolve type.", e));                                     // todo: exception mit position im schema
                        }
                    }
                }
                return(classType);
            }
                                           );
        }         // ctor
Exemple #3
0
        }         // proc WriteSafeCall

        public static void WriteSafeCall(this IDEContext r, string errorMessage)
        {
            WriteXml(r,
                     DEConfigItem.CreateDefaultXmlReturn(false, errorMessage)
                     );
        }         // proc WriteSafeCall
Exemple #4
0
        }         // func AsPlainText

        #endregion

        #region -- UseNode ------------------------------------------------------------

        /// <summary>Change the current config item, to a new one, specified by the path.</summary>
        /// <param name="current">Start node.</param>
        /// <param name="path">Path to change (should not start with /).</param>
        /// <param name="offset">Offset within the path.</param>
        /// <returns></returns>
        public static DEConfigItem UseNode(DEConfigItem current, string path, int offset = 0)
        {
            if (offset >= path.Length)
                return(current); }
Exemple #5
0
            }             // func CreateSelector

            private PpsDataSelector InvokeCreateSelector(PpsSysConnectionHandle connection, DEConfigItem c, bool throwException)
            {
                try
                {
                    var parameterInfo = method.GetParameters();
                    var args          = new object[parameterInfo.Length];

                    for (var i = 0; i < parameterInfo.Length; i++)
                    {
                        var parameterType = parameterInfo[i].ParameterType;
                        if (parameterType == typeof(PpsDataSource) || parameterType == typeof(PpsSysDataSource))
                        {
                            args[i] = connection?.DataSource;
                        }
                        else
                        {
                            throw new ArgumentNullException(parameterInfo[i].Name, $"Could not assign type {parameterType.Name}.");
                        }
                    }

                    return((PpsDataSelector)method.Invoke(c, args));
                }
                catch (TargetInvocationException)
                {
                    if (throwException)
                    {
                        throw;
                    }
                    return(null);
                }
            }             // proc InvokeCreateSelector