Beagrep.Daemon.FilterFactory.GetFilterVersion C# (CSharp) Метод

GetFilterVersion() публичный статический Метод

public static GetFilterVersion ( string filter_name ) : int
filter_name string
Результат int
        public static int GetFilterVersion(string filter_name)
        {
            if (filter_versions_by_name.ContainsKey (filter_name)) {
                return filter_versions_by_name [filter_name];
            } else {
                return -1;
            }
        }

Usage Example

Пример #1
0
        // To be used if the last_write_time to use for comparison is not the
        // one obtained from path
        public bool IsUpToDateAndFiltered(string path, DateTime last_write_time)
        {
            FileAttributes attr;

            attr = Read(path);

            // If there are no attributes set on the file, there is no
            // way that we can be up-to-date.
            if (attr == null)
            {
                return(false);
            }

            if (!FilterFactory.DirtyFilterCache)
            {
                // If the filters are same as in last run,
                // since attr is not null, check the timestamps (bypass HasFilterInfo)
                if (last_write_time == DateTime.MaxValue)
                {
                    return(attr.LastWriteTime >= FileSystem.GetLastWriteTimeUtc(path));
                }
                else
                {
                    return(attr.LastWriteTime >= last_write_time);
                }
            }

            // If there is a new filter in the mean time
            // take previous filter information into consideration.
            if (!attr.HasFilterInfo)
            {
                return(false);
            }

            int current_filter_version;

            current_filter_version = FilterFactory.GetFilterVersion(attr.FilterName);
            if (current_filter_version > attr.FilterVersion)
            {
                return(false);
            }

            if (last_write_time == DateTime.MaxValue)
            {
                return(attr.LastWriteTime >= FileSystem.GetLastWriteTimeUtc(path));
            }
            else
            {
                return(attr.LastWriteTime >= last_write_time);
            }
        }