Esempio n. 1
0
        public static ConditionalRegistration CreateFromArgument(DiagnosableParameters argument)
        {
            if (BaseConditionalRegistration.FetchSchema == null || BaseConditionalRegistration.QuerySchema == null || string.IsNullOrEmpty(ConditionalRegistrationLog.ProtocolName))
            {
                throw new InvalidOperationException("Can not use Conditional Diagnostics Handlers without proper initialization. Call 'BaseConditionalRegistration.Initialize' to initialize pre-requisites.");
            }
            string propertiesToFetch;
            string whereClause;

            BaseConditionalRegistration.ParseArgument(argument.Argument, out propertiesToFetch, out whereClause);
            string   arg;
            uint     num;
            TimeSpan timeSpan;

            ConditionalRegistration.ParseOptions(argument.Argument, out arg, out num, out timeSpan);
            return(new ConditionalRegistration(string.Format("[{0}] {1}", argument.UserIdentity, arg), argument.UserIdentity.Replace("/", "-"), Guid.NewGuid().ToString(), propertiesToFetch, whereClause, (int)((num == 0U) ? 10U : num), (timeSpan <= TimeSpan.Zero) ? ConditionalRegistration.DefaultTimeToLive : timeSpan));
        }
        public static PersistentConditionalRegistration CreateFromXml(XElement element)
        {
            if (BaseConditionalRegistration.FetchSchema == null || BaseConditionalRegistration.QuerySchema == null || string.IsNullOrEmpty(ConditionalRegistrationLog.ProtocolName))
            {
                throw new InvalidOperationException("Can not use Conditional Diagnostics Handlers without proper initialization. Call 'BaseConditionalRegistration.Initialize' to initialize pre-requisites.");
            }
            XAttribute xattribute  = element.Attribute(XName.Get("Name"));
            XAttribute xattribute2 = element.Attribute(XName.Get("Registration"));

            if (xattribute == null || xattribute2 == null)
            {
                throw new ArgumentException("[PersistentConditionalRegistration.CreateFromXml] app.config persistent registrations must have both 'Name' and 'Registration' attributes.");
            }
            string propertiesToFetch;
            string whereClause;

            BaseConditionalRegistration.ParseArgument(xattribute2.Value, out propertiesToFetch, out whereClause);
            return(new PersistentConditionalRegistration(xattribute.Value, propertiesToFetch, whereClause));
        }