예제 #1
0
        private Version(string version)
        {
            var match = VersionRegex.Match(version);

            if (!match.Success)
            {
                throw new ArgumentException($"'{version}' is not a valid eHSN version identifier.");
            }

            _versionComponents = match.Groups["components"].Value
                                 .Split('.')
                                 .Select(int.Parse)
                                 .ToArray();

            _suffix  = match.Groups["suffix"].Value;
            _version = version;
        }
예제 #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="parseLogLevel">Indicates that the <b>LOG-LEVEL</b> environment variable should be parsed (defaults to <c>true</c>).</param>
        /// <param name="version">
        /// Optionally specifies the semantic version of the current program.  This can be a somewhat arbitrary
        /// string that matches this regex: <b>"[0-9a-zA-Z\.-_/]+"</b>.  This defaults to <c>null</c>.
        /// </param>
        /// <param name="logFilter">
        /// Optionally specifies a filter predicate to be used for filtering log entries.  This examines
        /// the <see cref="LogEvent"/> and returns <c>true</c> if the event should be logged or <c>false</c>
        /// when it is to be ignored.  All events will be logged when this is <c>null</c>.
        /// </param>
        /// <param name="isLogEnabledFunc">
        /// Optionally specifies a function that will be called at runtime to
        /// determine whether to event logging is actually enabled.  This defaults
        /// to <c>null</c> which will always log events.
        /// </param>
        /// <param name="name">
        /// Optionally specifies the logr manager's name.  This can be useful when debugging the
        /// log manager itself.
        /// </param>
        /// <param name="writer">Optionally specifies the output writer.  This defaults to <see cref="Console.Error"/>.</param>
        public LogManager(bool parseLogLevel = true, string version = null, Func <LogEvent, bool> logFilter = null, Func <bool> isLogEnabledFunc = null, TextWriter writer = null, string name = null)
        {
            this.Name = name;

            if (parseLogLevel && !Enum.TryParse <LogLevel>(Environment.GetEnvironmentVariable("LOG_LEVEL"), true, out logLevel))
            {
                logLevel = LogLevel.Info;
            }

            if (!string.IsNullOrEmpty(version) && VersionRegex.IsMatch(version))
            {
                this.Version = version;
            }
            else
            {
                this.Version = "unknown";
            }

            this.logFilter        = logFilter;
            this.isLogEnabledFunc = isLogEnabledFunc;
            this.writer           = writer;

            // $hack(jefflill):
            //
            // On Linux, we're going to initialize the [emitCount] to the index persisted to
            // the [/dev/shm/log-index] file if this is present and parsable.  This will
            // align the .NET logging index with any event written via startup scripts.
            //
            //      https://github.com/nforgeio/neonKUBE/issues/578

            emitCount = 0;

            if (NeonHelper.IsLinux)
            {
                try
                {
                    emitCount = long.Parse(File.ReadAllText("/dev/shm/log-index").Trim());
                }
                catch
                {
                    // Ignore any exceptions; we'll just start the index at 0.
                }
            }
        }
예제 #3
0
            void OnComment(Token token)
            {
                var value = (string)token.Value;

                var comment = value.Trim();

                var versionMatch = VersionRegex.Match(comment);

                if (versionMatch.Success)
                {
                    var version = int.Parse(versionMatch.Groups[1].Value);
                    if (version > 1)
                    {
                        throw new InvalidDataException("Don't know how to parse yarn.lock with version " + version);
                    }
                }

                _comments.Add(comment);
            }
        public bool Validate(out IList <string> messages)
        {
            messages = (
                from k in Vars.Keys
                where ValidVarRegex.IsMatch(k) == false
                select "Vars has key '" + k + "' which contains invalid characters. Allowed: Aa-Zz 0-9 - _"
                ).ToList();

            if (string.IsNullOrWhiteSpace(Project))
            {
                messages.Add("A project name must be specified in the configuration.");
            }

            if (VersionRegex.IsMatch(Version) == false)
            {
                messages.Add("A valid version number in the format YY.MM.DD.II must be provided.");
            }

            return(messages.Count == 0);
        }
예제 #5
0
        // Takes the topmost selected drawing from data grid and sends to previewcontrol for displaying on sidebar
        public static void ShowDrawing()
        {
            MainForm.eDrawings.Control.eDrawingControlWrapper.CloseActiveDoc("");

            IEnumerator <IDrawing> selected = DataGrid.GetSelectedDrawings(MainReference.DataGridReference);

            if (selected.MoveNext())
            {
                Current = selected.Current.Path;

                MainReference.PreviewNameTextBoxRefernce.Text = Current.Split('\\').Last();

                MainReference.PreviewLastModifiedTextBoxReference.Text = File.GetLastWriteTime(Current).ToShortDateString();

                Match regMatch = VersionRegex.Match(Path.GetFileNameWithoutExtension(Current));
                MainReference.PreviewRevisionTextBoxReference.Text = (regMatch.Success) ? regMatch.Value.ToUpper() : "";

                MainForm.eDrawings.PreviewControl.eDrawingControlWrapper.OpenDoc(Current, false, false, false, "");
                MainForm.eDrawings.PreviewControl.eDrawingControlWrapper.ViewOperator = EModelView.EMVOperators.eMVOperatorPan;
            }
        }
예제 #6
0
        public static bool IsManyToMany(TableSchema table)
        {
            // Bypass logic if table contains Extended Property for ManyToMany
            if (table.ExtendedProperties.Contains(ExtendedPropertyManyToMany))
            {
                bool manyToMany;
                if (Boolean.TryParse(table.ExtendedProperties[ExtendedPropertyManyToMany].Value.ToString(), out manyToMany))
                {
                    return(manyToMany);
                }
            }

            // 1) Table must have Two ForeignKeys.
            //    a) Must be two unique tables.
            // 2) All columns must be either...
            //    a) Member of the Primary Key.
            //    b) Member of a Foreign Key.
            //    c) A DateTime stamp (CreateDate, EditDate, etc).
            //    d) Name matches Version Regex.

            if (table.ForeignKeys.Count != 2)
            {
                return(false);
            }

            bool result = true;
            List <TableSchema> foreignTables = new List <TableSchema>();

            foreach (ColumnSchema column in table.Columns)
            {
                if (!(column.IsForeignKeyMember ||
                      column.IsPrimaryKeyMember ||
                      column.SystemType.Equals(typeof(DateTime)) ||
                      VersionRegex.IsMatch(column.Name)))
                {
                    result = false;
                    break;
                }
                else if (column.IsForeignKeyMember)
                {
                    foreach (TableKeySchema tks in column.Table.ForeignKeys)
                    {
                        if (tks.ForeignKeyMemberColumns.Contains(column))
                        {
                            if (!foreignTables.Contains(tks.PrimaryKeyTable))
                            {
                                foreignTables.Add(tks.PrimaryKeyTable);
                            }
                            break;
                        }
                    }
                }
            }

            if (foreignTables.Count != 2)
            {
                result = false;
            }

            return(result);
        }