Пример #1
0
        private void stackBrowser1_OnAddMaster(string name, string port, FilterLevel level, MasterStackConfig config)
        {
            var observer = new EventedDataObserver(this);
            var control  = this.stackDisplayControl.AddMaster(name, observer.MeasurementSource);

            control.CommandAcceptor = sm.AddMaster(port, name, level, observer, config);
        }
Пример #2
0
        public static string Name(this FilterLevel level)
        {
            switch (level)
            {
            case FilterLevel.Lowest:
                return("Lowest");

            case FilterLevel.Low:
                return("Low");

            case FilterLevel.BelowNormal:
                return("BelowNormal");

            case FilterLevel.Normal:
                return("Normal");

            case FilterLevel.AboveNormal:
                return("AboveNormal");

            case FilterLevel.High:
                return("High");

            case FilterLevel.Highest:
                return("Highest");

            default:
                throw new ArgumentOutOfRangeException(nameof(level), level, null);
            }
        }
Пример #3
0
        public void FiltersEventsWithLevelExactValue()
        {
            var expected = new[]
            {
                new EventExpectation
                {
                    Level = Level.Error,
                    Logger = "Root.ChildA.LoggerA1",
                    Thread = "Thread-5",
                    Timestamp = 1411231353795L,
                    Message = "#5. Test event F.",
                    Throwable = null,
                    Id = 672
                }
            };

            using (var sourceStream = new MemoryStream (sampleBytes))
            using (var source = Log4JFile.Create (sourceStream))
            using (var subject = new FilterLevel (Level.Error, Level.Error))
            {
                source.Encoding = Encoding.GetEncoding (1251);
                var actual = source.GetEvents ().Where (subject);
                Assert.That (actual, Is.EqualTo (expected));
            }
        }
Пример #4
0
        public override void Build()
        {
            if (_southLatBound >= _northLatBound || _westLonBound >= _eastLonBound)
            {
                throw new ArgumentException("Incoherent bounds : southLatBound >= northLatBound or westLonBound >= eastLonBound");
            }
            if (_width < 0 || _height < 0)
            {
                throw new ArgumentException("Dimension must be greater or equal 0");
            }
            if (_sourceModule == null)
            {
                throw new ArgumentException("A source module must be provided");
            }
            if (_noiseMap == null)
            {
                throw new ArgumentException("A noise map must be provided");
            }
            _noiseMap.SetSize(_width, _height);
            Sphere sphere       = new Sphere((IModule3D)_sourceModule);
            float  num          = _eastLonBound - _westLonBound;
            float  num2         = _northLatBound - _southLatBound;
            float  num3         = num / (float)_width;
            float  num4         = num2 / (float)_height;
            float  westLonBound = _westLonBound;
            float  num5         = _southLatBound;

            for (int i = 0; i < _height; i++)
            {
                westLonBound = _westLonBound;
                for (int j = 0; j < _width; j++)
                {
                    FilterLevel filterLevel = FilterLevel.Source;
                    if (_filter != null)
                    {
                        filterLevel = _filter.IsFiltered(j, i);
                    }
                    float num6;
                    if (filterLevel == FilterLevel.Constant)
                    {
                        num6 = _filter.ConstantValue;
                    }
                    else
                    {
                        num6 = sphere.GetValue(num5, westLonBound);
                        if (filterLevel == FilterLevel.Filter)
                        {
                            num6 = _filter.FilterValue(j, i, num6);
                        }
                    }
                    _noiseMap.SetValue(j, i, num6);
                    westLonBound += num3;
                }
                num5 += num4;
                if (_callBack != null)
                {
                    _callBack(i);
                }
            }
        }
Пример #5
0
 public FilterObject(State FilterState, FilterLevel level, List <string> objectTypes, List <operation> operations)
 {
     filterState = FilterState;
     lev         = level;
     objTypes    = objectTypes;
     ops         = operations;
 }
Пример #6
0
        // Parameters
        protected virtual void AddBaseParametersToQuery(StringBuilder queryBuilder)
        {
            if (_filteredLanguages.Any())
            {
                var languages = string.Join(Uri.EscapeDataString(", "), _filteredLanguages.Select(x => x.ToLowerInvariant()));
                queryBuilder.AddParameterToQuery("language", languages);
            }

            if (StallWarnings)
            {
                queryBuilder.AddParameterToQuery("stall_warnings", "true");
            }

            if (FilterLevel != StreamFilterLevel.None)
            {
                queryBuilder.AddParameterToQuery("filter_level", FilterLevel.ToString().ToLowerInvariant());
            }

            if (!string.IsNullOrEmpty(_customRequestParameters.FormattedCustomQueryParameters))
            {
                queryBuilder.Append(string.Format("&{0}", _customRequestParameters.FormattedCustomQueryParameters));
            }

            if (TweetMode == TweetMode.Extended)
            {
                queryBuilder.AddParameterToQuery("tweet_mode", "extended");
            }
        }
        public override void Build()
        {
            if (_lowerAngleBound >= _upperAngleBound || _lowerHeightBound >= _upperHeightBound)
            {
                throw new ArgumentException("Incoherent bounds : lowerAngleBound >= upperAngleBound or lowerZBound >= upperHeightBound");
            }
            if (_width < 0 || _height < 0)
            {
                throw new ArgumentException("Dimension must be greater or equal 0");
            }
            if (_sourceModule == null)
            {
                throw new ArgumentException("A source module must be provided");
            }
            if (_noiseMap == null)
            {
                throw new ArgumentException("A noise map must be provided");
            }
            _noiseMap.SetSize(_width, _height);
            Cylinder cylinder        = new Cylinder((IModule3D)_sourceModule);
            float    num             = _upperAngleBound - _lowerAngleBound;
            float    num2            = _upperHeightBound - _lowerHeightBound;
            float    num3            = num / (float)_width;
            float    num4            = num2 / (float)_height;
            float    lowerAngleBound = _lowerAngleBound;
            float    num5            = _lowerHeightBound;

            for (int i = 0; i < _height; i++)
            {
                lowerAngleBound = _lowerAngleBound;
                for (int j = 0; j < _width; j++)
                {
                    FilterLevel filterLevel = FilterLevel.Source;
                    if (_filter != null)
                    {
                        filterLevel = _filter.IsFiltered(j, i);
                    }
                    float num6;
                    if (filterLevel == FilterLevel.Constant)
                    {
                        num6 = _filter.ConstantValue;
                    }
                    else
                    {
                        num6 = cylinder.GetValue(lowerAngleBound, num5);
                        if (filterLevel == FilterLevel.Filter)
                        {
                            num6 = _filter.FilterValue(j, i, num6);
                        }
                    }
                    _noiseMap.SetValue(j, i, num6);
                    lowerAngleBound += num3;
                }
                num5 += num4;
                if (_callBack != null)
                {
                    _callBack(i);
                }
            }
        }
Пример #8
0
        public void MatchesAllInnerFilters()
        {
            var expected = new[]
            {
                new EventExpectation
                {
                    Level = Level.Debug,
                    Logger = "Root.ChildB.LoggerB2",
                    Thread = "Thread-2",
                    Timestamp = 1411231353792L,
                    Message = "#2. Test event B.",
                    Throwable = null,
                    Id = 165
                }
            };

            using (var sourceStream = new MemoryStream (sampleBytes))
            using (var source = Log4JFile.Create (sourceStream))
            using (var childFilter1 = new FilterLevel (Level.MinValue, Level.Info))
            using (var childFilter2 = new FilterTimestamp (1411231353792L, Int64.MaxValue))
            using (var subject = new FilterAll ())
            {
                source.Encoding = Encoding.GetEncoding (1251);

                subject.Add (childFilter1);
                subject.Add (childFilter2);

                var actual = source.GetEvents ().Where (subject);
                Assert.That (actual, Is.EqualTo (expected));
            }
        }
Пример #9
0
        private void UpdateTexturesParameters(Keys[] pressedKeys, Keys[] prevPressedKeys)
        {
            if (pressedKeys.Contains(Keys.P) && !prevPressedKeys.Contains(Keys.P))
            {
                multisampling = !multisampling;
            }
            if (pressedKeys.Contains(Keys.OemMinus))
            {
                mipMapLevelOfDetailBias = mipMapLevelOfDetailBias - 0.1f;
            }

            if (pressedKeys.Contains(Keys.OemPlus))
            {
                mipMapLevelOfDetailBias = mipMapLevelOfDetailBias + 0.1f;
            }


            if (pressedKeys.Contains(Keys.OemCloseBrackets) && !prevPressedKeys.Contains(Keys.OemCloseBrackets))
            {
                magFilter = (FilterLevel)(((int)magFilter + 1) % 3);
            }

            if (pressedKeys.Contains(Keys.OemOpenBrackets) && !prevPressedKeys.Contains(Keys.OemOpenBrackets))
            {
                mipFilter = (FilterLevel)(((int)mipFilter + 1) % 3);
            }
        }
Пример #10
0
 private void UpdateFiltersWithValue(FilterLevel value)
 {
     for (var i = 0; i < _filters.Length; i++)
     {
         _filters[i] = value;
     }
 }
Пример #11
0
 public TcpSettings(String name, String address, UInt16 port, FilterLevel level, UInt64 timeout)
 {
     this.name = name;
     this.address = address;
     this.port = port;
     this.level = level;
     this.timeout = timeout;
 }
Пример #12
0
 public FilterObject(State FilterState, FilterLevel level, List <string> objectTypes, List <operation> operations, List <string> attributes)
 {
     filterState      = FilterState;
     lev              = level;
     objTypes         = objectTypes;
     ops              = operations;
     availableAttribs = attributes;
 }
Пример #13
0
 public TcpSettings(String name, String address, UInt16 port, FilterLevel level, UInt64 timeout)
 {
     this.name    = name;
     this.address = address;
     this.port    = port;
     this.level   = level;
     this.timeout = timeout;
 }
Пример #14
0
 public void Clear()
 {
     ObjectTypes.Clear();
     ops.Clear();
     availableAttribs.Clear();
     reportAttribs.Clear();
     attribFilters.Clear();
     lev = new FilterLevel();
 }
Пример #15
0
 public LogEntry(FilterLevel filterLevel, String loggerName, String location, string message, DateTime time, int errorCode)
 {
     this.filterLevel = filterLevel;
     this.loggerName = loggerName;
     this.location = location;
     this.message = message;
     this.time = time;
     this.errorCode = errorCode;
     this.keyValues = new Dictionary<string,string>();
 }
Пример #16
0
 public LogEntry(FilterLevel filterLevel, String loggerName, String location, string message, DateTime time, int errorCode)
 {
     this.filterLevel = filterLevel;
     this.loggerName  = loggerName;
     this.location    = location;
     this.message     = message;
     this.time        = time;
     this.errorCode   = errorCode;
     this.keyValues   = new Dictionary <string, string>();
 }
Пример #17
0
 void TcpSettingsForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (DialogResult == DialogResult.OK && OnTcpAdded != null)
     {
         String      name    = this.textBoxName.Text;
         String      address = this.textBoxAddress.Text;
         UInt16      port    = Decimal.ToUInt16(this.numericUpDownPort.Value);
         FilterLevel level   = this.filterLevelComboBox1.SelectedLevel;
         UInt64      timeout = Decimal.ToUInt64(this.numericUpDownTimeout.Value);
         OnTcpAdded(new TcpSettings(name, address, port, level, timeout));
     }
 }
Пример #18
0
        private void stackBrowser1_OnAddMaster(string name, string port, FilterLevel level, MasterStackConfig config)
        {
            //create the new form
            var observer = new EventedDataObserver(this);
            var display = new MasterDataDisplay(observer.MeasurementSource); //synchronize all updates on this form

            display.Dock = DockStyle.Fill;
            TabPage page = new TabPage(name);
            this.tabControlDisplay.TabPages.Add(page);
            page.Controls.Add(display);
            display.CommandAcceptor = sm.AddMaster(port, name, level, observer, config);
        }
Пример #19
0
 void dialog_OnAddMaster(String name, FilterLevel level, MasterStackConfig config, TreeNode portNode)
 {
     if (this.OnAddMaster != null)
     {
         if (portNode.Nodes.ContainsKey(name))
         {
             MessageBox.Show("Port already contains a stack called: " + name);
         }
         else
         {
             this.OnAddMaster(name, portNode.Text, level, config);
             TreeNode     master            = portNode.Nodes.Add(name, name);
             EventHandler removeStackAction = (obj, e) => this.RemoveStackClick(portNode, master);
             master.ContextMenuStrip = this.WireNewMasterMenuStrip(removeStackAction);
         }
     }
 }
Пример #20
0
 void dialog_OnAddMaster(String name, FilterLevel level, MasterStackConfig config, TreeNode portNode)
 {
     if (this.OnAddMaster != null)
     {
         if (portNode.Nodes.ContainsKey(name))
         {
             MessageBox.Show("Port already contains a stack called: " + name);
         }
         else
         {
             this.OnAddMaster(name, portNode.Text, level, config);
             TreeNode master = portNode.Nodes.Add(name, name);
             EventHandler removeStackAction = (obj, e) => this.RemoveStackClick(portNode, master);
             master.ContextMenuStrip = this.WireNewMasterMenuStrip(removeStackAction);
         }
     }
 }
Пример #21
0
        public void FilterLevelTest()
        {
            IPipe pipeNull = new PipeNull();

            //Creamos una tag falsa de Level
            Dictionary <string, Attribute> attributeList = new Dictionary <string, Attribute>();
            Attribute attribute = new Attribute("Name", "level1");

            attributeList.Add(attribute.Key, attribute);
            Tag tag = new Tag("Level", attributeList);

            //Creamos un filter Level
            IFilterConditional filterLevel = new FilterLevel();
            IPipe pipe0 = new PipeConditional(filterLevel, pipeNull, pipeNull);

            //Nos fijamos que el resultado de la pipe sea un VisitorLevel
            Assert.True(pipe0.Send(tag) is VisitorLevel);
        }
Пример #22
0
        private TextureFilter TextureFilterFromMinMagMip(FilterLevel minFilter, FilterLevel magFilter, FilterLevel mipFilter)
        {
            var def = TextureFilter.Point;

            if (minFilter == FilterLevel.Anisotropic && magFilter == FilterLevel.Anisotropic)
            {
                return(TextureFilter.Anisotropic);
            }

            if (minFilter == FilterLevel.Point)
            {
                if (magFilter == FilterLevel.Point)
                {
                    if (mipFilter == FilterLevel.Point)
                    {
                        return(TextureFilter.Point);
                    }
                    return(def);
                }
                if (mipFilter == FilterLevel.Point)
                {
                    return(TextureFilter.MinPointMagLinearMipPoint);
                }
                return(TextureFilter.MinPointMagLinearMipLinear);
            }
            if (magFilter == FilterLevel.Point)
            {
                if (mipFilter == FilterLevel.Point)
                {
                    return(TextureFilter.MinLinearMagPointMipPoint);
                }
                return(TextureFilter.MinLinearMagPointMipLinear);
            }
            if (mipFilter == FilterLevel.Point)
            {
                return(TextureFilter.LinearMipPoint);
            }
            return(TextureFilter.Linear);
        }
Пример #23
0
        // Parameters
        protected virtual void AddBaseParametersToQuery(StringBuilder queryBuilder)
        {
            if (_filteredLanguages.Any())
            {
                queryBuilder.AddParameterToQuery("language", string.Join(Uri.EscapeDataString(", "), _filteredLanguages));
            }

            if (StallWarnings)
            {
                queryBuilder.AddParameterToQuery("stall_warnings", "true");
            }

            if (FilterLevel != StreamFilterLevel.None)
            {
                queryBuilder.AddParameterToQuery("filter_level", FilterLevel.ToString());
            }

            if (!string.IsNullOrEmpty(_customRequestParameters.FormattedCustomQueryParameters))
            {
                queryBuilder.Append(string.Format("&{0}", _customRequestParameters.FormattedCustomQueryParameters));
            }
        }
Пример #24
0
 public LogMessageFilter(Stream stream)
 {
     byte version = stream.ReadNextByte();
     switch (version)
     {
         case 1:
             FilterLevel = (FilterLevel)stream.ReadNextByte();
             if (stream.ReadBoolean())
                 TimeFilter = new TimestampMatching(stream);
             if (stream.ReadBoolean())
                 Classification = new EnumMatchingFlags(stream);
             if (stream.ReadBoolean())
                 Level = new EnumMatchingFlags(stream);
             if (stream.ReadBoolean())
                 Flags = new EnumMatchingFlags(stream);
             if (stream.ReadBoolean())
                 Assembly = new StringMatching(stream);
             if (stream.ReadBoolean())
                 Type = new StringMatching(stream);
             if (stream.ReadBoolean())
                 RelatedType = new StringMatching(stream);
             if (stream.ReadBoolean())
                 StackDetails = new StackDetailsMatching(stream);
             if (stream.ReadBoolean())
                 StackTraceDetails = new StackTraceMatching(stream);
             if (stream.ReadBoolean())
                 EventName = new StringMatching(stream);
             if (stream.ReadBoolean())
                 MessageText = new StringMatching(stream);
             if (stream.ReadBoolean())
                 DetailsText = new StringMatching(stream);
             if (stream.ReadBoolean())
                 ExceptionText = new StringMatching(stream);
             break;
         default:
             throw new VersionNotFoundException();
     }
 }
Пример #25
0
    /// <summary>
    /// Given a message channel and a severity level, determine whether the channel filter levels allow the message to pass through
    /// Returns true if the message should be logged, and false if it should be silenced
    /// </summary>
    public bool ApplyFilter(string channel, UnityEngine.Object source, LogSeverity severity, object message, params object[] par)
    {
        FilterLevel channelFilterLevel = DefaultFilterLevel;

        if (PerChannelFilterLevels.ContainsKey(channel))
        {
            channelFilterLevel = PerChannelFilterLevels[channel];
        }

        switch (severity)
        {
        case LogSeverity.Message:
            return(channelFilterLevel == FilterLevel.Message);

        case LogSeverity.Warning:
            return(channelFilterLevel == FilterLevel.Message || channelFilterLevel == FilterLevel.Warning);

        case LogSeverity.Error:
            return(channelFilterLevel != FilterLevel.None);

        default:
            throw new NotImplementedException();
        }
    }
Пример #26
0
        public void NegatesInnerFilter()
        {
            var expected = new[]
            {
                new EventExpectation
                {
                    Level = Level.Debug,
                    Logger = "Root.ChildB.LoggerB2",
                    Thread = "Thread-2",
                    Timestamp = 1411231353792L,
                    Message = "#2. Test event B.",
                    Throwable = null,
                    Id = 165
                },
                new EventExpectation
                {
                    Level = Level.Fatal,
                    Logger = "Root.ChildA.LoggerA2",
                    Thread = "Thread-3",
                    Timestamp = 1411231353792L,
                    Message = "#3. Test event C. С кирилицей.",
                    Throwable = null,
                    Id = 330
                }
            };

            using (var sourceStream = new MemoryStream (sampleBytes))
            using (var source = Log4JFile.Create (sourceStream))
            using (var childFilter = new FilterLevel (Level.Info, Level.Error))
            using (var subject = new FilterNot (childFilter))
            {
                source.Encoding = Encoding.GetEncoding (1251);
                var actual = source.GetEvents ().Where (subject);
                Assert.That (actual, Is.EqualTo (expected));
            }
        }
        }        //end SetBounds

        /// <summary>
        /// Builds the noise map.
        ///
        /// @pre SetBounds() was previously called.
        /// @pre NoiseMap was previously defined.
        /// @pre a SourceModule was previously defined.
        /// @pre The width and height values specified by SetSize() are
        /// positive.
        /// @pre The width and height values specified by SetSize() do not
        /// exceed the maximum possible width and height for the noise map.
        ///
        /// @post The original contents of the destination noise map is
        /// destroyed.
        ///
        /// @throw noise::ArgumentException See the preconditions.
        ///
        /// If this method is successful, the destination noise map contains
        /// the coherent-noise values from the noise module specified by
        /// the SourceModule.
        /// </summary>
        public override void Build()
        {
            if (_lowerXBound >= _upperXBound || _lowerZBound >= _upperZBound)
            {
                throw new ArgumentException("Incoherent bounds : lowerXBound >= upperXBound or lowerZBound >= upperZBound");
            }            //end if

            if (_width < 0 || _height < 0)
            {
                throw new ArgumentException("Dimension must be greater or equal 0");
            }            //end if

            if (_sourceModule == null)
            {
                throw new ArgumentException("A source module must be provided");
            }            //end if

            if (_noiseMap == null)
            {
                throw new ArgumentException("A noise map must be provided");
            }            //end if

            // Resize the destination noise map so that it can store the new output
            // values from the source model.
            _noiseMap.SetSize(_width, _height);

            // Create the plane model.
            Plane model = new Plane(_sourceModule);

            float xExtent = _upperXBound - _lowerXBound;
            float zExtent = _upperZBound - _lowerZBound;
            float xDelta  = xExtent / (float)_width;
            float zDelta  = zExtent / (float)_height;
            float xCur    = _lowerXBound;
            float zCur    = _lowerZBound;

            // Fill every point in the noise map with the output values from the model.
            for (int z = 0; z < _height; z++)
            {
                xCur = _lowerXBound;

                for (int x = 0; x < _width; x++)
                {
                    float       finalValue;
                    FilterLevel level = FilterLevel.Source;

                    if (_filter != null)
                    {
                        level = _filter.IsFiltered(x, z);
                    }                    //end if

                    if (level == FilterLevel.Constant)
                    {
                        finalValue = _filter.ConstantValue;
                    }                    //end if
                    else
                    {
                        if (_seamless)
                        {
                            float swValue, seValue, nwValue, neValue;

                            swValue = model.GetValue(xCur, zCur);
                            seValue = model.GetValue(xCur + xExtent, zCur);
                            nwValue = model.GetValue(xCur, zCur + zExtent);
                            neValue = model.GetValue(xCur + xExtent, zCur + zExtent);

                            float xBlend = 1.0f - ((xCur - _lowerXBound) / xExtent);
                            float zBlend = 1.0f - ((zCur - _lowerZBound) / zExtent);

                            float z0 = Libnoise.Lerp(swValue, seValue, xBlend);
                            float z1 = Libnoise.Lerp(nwValue, neValue, xBlend);

                            finalValue = (float)Libnoise.Lerp(z0, z1, zBlend);
                        }                        //end if
                        else
                        {
                            finalValue = (float)model.GetValue(xCur, zCur);
                        }                        //end else

                        if (level == FilterLevel.Filter)
                        {
                            finalValue = _filter.FilterValue(x, z, finalValue);
                        }                //end if
                    }                    //end else

                    _noiseMap.SetValue(x, z, finalValue);

                    xCur += xDelta;
                }                //end for

                zCur += zDelta;

                if (_callBack != null)
                {
                    _callBack(z);
                } //end if
            }     //end for
        }         //end Build
 private void stackBrowser1_OnAddMaster(string name, string port, FilterLevel level, MasterStackConfig config)
 {
     var observer = new EventedDataObserver(this);
     var control = this.stackDisplayControl.AddMaster(name, observer.MeasurementSource);
     control.CommandAcceptor = sm.AddMaster(port, name, level, observer, config);
 }
Пример #29
0
        /// <summary>
        /// Filters all sensitive words which has matched with speficed filter condition and replaces to specified replacement.
        /// </summary>
        /// <param name="level">Filter condtion.</param>
        /// <param name="source">The source string.</param>
        /// <param name="replacement">The replacement.</param>
        /// <returns>Returns the filtered string.</returns>
        public static string Filter(FilterLevel level, string source, string replacement)
        {
            var result = string.Empty;

            if (string.IsNullOrWhiteSpace(source))
            {
                return result;
            }

            try
            {
                switch (level)
                {
                    case FilterLevel.All:
                        result = source.FilterString(PhoneNumberPattern, replacement)
                            .FilterString(EmailAddressPattern, replacement)
                            .FilterString(HttpAddressPattern, replacement);
                        break;
                    case FilterLevel.Email:
                        result = source.FilterString(EmailAddressPattern, replacement);
                        break;
                    case FilterLevel.PhoneAndEmail:
                        result = source.FilterString(PhoneNumberPattern, replacement)
                            .FilterString(EmailAddressPattern, replacement);
                        break;
                    case FilterLevel.PhoneAndUrl:
                        replacement = source.FilterString(PhoneNumberPattern, replacement)
                            .FilterString(HttpAddressPattern, replacement);
                        break;
                    case FilterLevel.PhoneNumber:
                        result = source.FilterString(PhoneNumberPattern, replacement);
                        break;
                    case FilterLevel.Url:
                        result = source.FilterString(HttpAddressPattern, replacement);
                        break;
                    case FilterLevel.UrlAndEmail:
                        result = source.FilterString(HttpAddressPattern, replacement)
                            .FilterString(EmailAddressPattern, replacement);
                        break;
                    default:
                        result = source;
                        break;
                }
            }
            catch
            {
                result = source;
            }

            return result;
        }
Пример #30
0
        private static TimeSpan TimeoutSpan = new TimeSpan(0, 0, 10); // 10 seconds.

        #endregion Fields

        #region Methods

        /// <summary>
        /// Filters all sensitive words which has matched with speficed filter condition and replaces to default replacement.
        /// </summary>
        /// <param name="level">Filter condtion.</param>
        /// <param name="source">The source string.</param>
        /// <returns>Returns the filtered string.</returns>
        public static string Filter(FilterLevel level, string source)
        {
            return Filter(level, source, DefaultReplacement);
        }
Пример #31
0
 public DebugFilter(FilterLevel level, string prefix)
 {
     this.level  = (int)level;
     this.prefix = prefix;
 }
Пример #32
0
 public DebugFilter(FilterLevel level)
 {
     this.level = (int)level;
 }
        public override void Build()
        {
            if (_lowerXBound >= _upperXBound || _lowerZBound >= _upperZBound)
            {
                throw new ArgumentException("Incoherent bounds : lowerXBound >= upperXBound or lowerZBound >= upperZBound");
            }
            if (_width < 0 || _height < 0)
            {
                throw new ArgumentException("Dimension must be greater or equal 0");
            }
            if (_sourceModule == null)
            {
                throw new ArgumentException("A source module must be provided");
            }
            if (_noiseMap == null)
            {
                throw new ArgumentException("A noise map must be provided");
            }
            _noiseMap.SetSize(_width, _height);
            Plane plane       = new Plane(_sourceModule);
            float num         = _upperXBound - _lowerXBound;
            float num2        = _upperZBound - _lowerZBound;
            float num3        = num / (float)_width;
            float num4        = num2 / (float)_height;
            float lowerXBound = _lowerXBound;
            float num5        = _lowerZBound;

            for (int i = 0; i < _height; i++)
            {
                lowerXBound = _lowerXBound;
                for (int j = 0; j < _width; j++)
                {
                    FilterLevel filterLevel = FilterLevel.Source;
                    if (_filter != null)
                    {
                        filterLevel = _filter.IsFiltered(j, i);
                    }
                    float num6;
                    if (filterLevel == FilterLevel.Constant)
                    {
                        num6 = _filter.ConstantValue;
                    }
                    else
                    {
                        if (_seamless)
                        {
                            float value  = plane.GetValue(lowerXBound, num5);
                            float value2 = plane.GetValue(lowerXBound + num, num5);
                            float value3 = plane.GetValue(lowerXBound, num5 + num2);
                            float value4 = plane.GetValue(lowerXBound + num, num5 + num2);
                            float a      = 1f - (lowerXBound - _lowerXBound) / num;
                            float a2     = 1f - (num5 - _lowerZBound) / num2;
                            float n      = Libnoise.Lerp(value, value2, a);
                            float n2     = Libnoise.Lerp(value3, value4, a);
                            num6 = Libnoise.Lerp(n, n2, a2);
                        }
                        else
                        {
                            num6 = plane.GetValue(lowerXBound, num5);
                        }
                        if (filterLevel == FilterLevel.Filter)
                        {
                            num6 = _filter.FilterValue(j, i, num6);
                        }
                    }
                    _noiseMap.SetValue(j, i, num6);
                    lowerXBound += num3;
                }
                num5 += num4;
                if (_callBack != null)
                {
                    _callBack(i);
                }
            }
        }
Пример #34
0
 void IFilterVisitor.Visit(FilterLevel filter)
 => lastResult_ = new Level(filter.Min, filter.Max);
Пример #35
0
        public void FiltersEventsWithMinLevel()
        {
            var expected = new[]
            {
                new EventExpectation
                {
                    Level = Level.Fatal,
                    Logger = "Root.ChildA.LoggerA2",
                    Thread = "Thread-3",
                    Timestamp = 1411231353792L,
                    Message = "#3. Test event C. С кирилицей.",
                    Throwable = null,
                    Id = 330
                },
                new EventExpectation
                {
                    Level = Level.Warn,
                    Logger = "Root.ChildA.LoggerA1",
                    Thread = "Thread-4",
                    Timestamp = 1411231353793L,
                    Message = "#4. Test event E.",
                    Throwable = null,
                    Id = 507
                },
                new EventExpectation
                {
                    Level = Level.Error,
                    Logger = "Root.ChildA.LoggerA1",
                    Thread = "Thread-5",
                    Timestamp = 1411231353795L,
                    Message = "#5. Test event F.",
                    Throwable = null,
                    Id = 672
                }
            };

            using (var sourceStream = new MemoryStream (sampleBytes))
            using (var source = Log4JFile.Create (sourceStream))
            using (var subject = new FilterLevel (Level.Warn, Level.MaxValue))
            {
                source.Encoding = Encoding.GetEncoding (1251);
                var actual = source.GetEvents ().Where (subject);
                Assert.That (actual, Is.EqualTo (expected));
            }
        }
Пример #36
0
        public LogMessageFilter(Stream stream)
        {
            byte version = stream.ReadNextByte();

            switch (version)
            {
            case 1:
                FilterLevel = (FilterLevel)stream.ReadNextByte();
                if (stream.ReadBoolean())
                {
                    TimeFilter = new TimestampMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    Classification = new EnumMatchingFlags(stream);
                }
                if (stream.ReadBoolean())
                {
                    Level = new EnumMatchingFlags(stream);
                }
                if (stream.ReadBoolean())
                {
                    Flags = new EnumMatchingFlags(stream);
                }
                if (stream.ReadBoolean())
                {
                    Assembly = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    Type = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    RelatedType = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    StackDetails = new StackDetailsMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    StackTraceDetails = new StackTraceMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    EventName = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    MessageText = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    DetailsText = new StringMatching(stream);
                }
                if (stream.ReadBoolean())
                {
                    ExceptionText = new StringMatching(stream);
                }
                break;

            default:
                throw new VersionNotFoundException();
            }
        }
 void IFilterVisitor.Visit(FilterLevel filter)
 => lastResult_ = null;
Пример #38
0
 public FilterObject(State FilterState, FilterLevel level, List <string> objectTypes)
 {
     filterState = FilterState;
     lev         = level;
     objTypes    = objectTypes;
 }
Пример #39
0
 public FilterObject(State FilterState, FilterLevel level)
 {
     filterState = FilterState;
     lev         = level;
 }
Пример #40
0
        }        //end SetBounds

        /// <summary>
        /// Builds the noise map.
        ///
        /// @pre SetBounds() was previously called.
        /// @pre NoiseMap was previously defined.
        /// @pre a SourceModule was previously defined.
        /// @pre The width and height values specified by SetSize() are
        /// positive.
        /// @pre The width and height values specified by SetSize() do not
        /// exceed the maximum possible width and height for the noise map.
        ///
        /// @post The original contents of the destination noise map is
        /// destroyed.
        ///
        /// @throw noise::ArgumentException See the preconditions.
        ///
        /// If this method is successful, the destination noise map contains
        /// the coherent-noise values from the noise module specified by
        /// the SourceModule.
        /// </summary>
        public override void Build()
        {
            if (_lowerAngleBound >= _upperAngleBound || _lowerHeightBound >= _upperHeightBound)
            {
                throw new ArgumentException("Incoherent bounds : lowerAngleBound >= upperAngleBound or lowerZBound >= upperHeightBound");
            }            //end if

            if (_width < 0 || _height < 0)
            {
                throw new ArgumentException("Dimension must be greater or equal 0");
            }            //end if

            if (_sourceModule == null)
            {
                throw new ArgumentException("A source module must be provided");
            }            //end if

            if (_noiseMap == null)
            {
                throw new ArgumentException("A noise map must be provided");
            }            //end if

            // Resize the destination noise map so that it can store the new output
            // values from the source model.
            _noiseMap.SetSize(_width, _height);

            // Create the plane model.
            Cylinder model = new Cylinder((IModule3D)_sourceModule);

            float angleExtent  = _upperAngleBound - _lowerAngleBound;
            float heightExtent = _upperHeightBound - _lowerHeightBound;

            float xDelta = angleExtent / (float)_width;
            float yDelta = heightExtent / (float)_height;

            float curAngle  = _lowerAngleBound;
            float curHeight = _lowerHeightBound;

            // Fill every point in the noise map with the output values from the model.
            for (int y = 0; y < _height; y++)
            {
                curAngle = _lowerAngleBound;

                for (int x = 0; x < _width; x++)
                {
                    float       finalValue;
                    FilterLevel level = FilterLevel.Source;

                    if (_filter != null)
                    {
                        level = _filter.IsFiltered(x, y);
                    }                    //end if

                    if (level == FilterLevel.Constant)
                    {
                        finalValue = _filter.ConstantValue;
                    }                    //end if
                    else
                    {
                        finalValue = (float)model.GetValue(curAngle, curHeight);

                        if (level == FilterLevel.Filter)
                        {
                            finalValue = _filter.FilterValue(x, y, finalValue);
                        }                //end if
                    }                    //end else

                    _noiseMap.SetValue(x, y, finalValue);

                    curAngle += xDelta;
                }                //end for

                curHeight += yDelta;

                if (_callBack != null)
                {
                    _callBack(y);
                } //end if
            }     //end for
        }         //end Build
Пример #41
0
 public WebApiAttribute(FilterLevel level)
 {
     Level = level;
 }
Пример #42
0
        public void FiltersEventsWithMaxLevel()
        {
            var expected = new[]
            {
                new EventExpectation
                {
                    Level = Level.Info,
                    Logger = "Root.ChildA.LoggerA2",
                    Thread = "Thread-1",
                    Timestamp = 1411231353782L,
                    Message = "#1. Test event A.",
                    Throwable = null,
                    Id = 0
                },
                new EventExpectation
                {
                    Level = Level.Debug,
                    Logger = "Root.ChildB.LoggerB2",
                    Thread = "Thread-2",
                    Timestamp = 1411231353792L,
                    Message = "#2. Test event B.",
                    Throwable = null,
                    Id = 165
                },
                new EventExpectation
                {
                    Level = Level.Warn,
                    Logger = "Root.ChildA.LoggerA1",
                    Thread = "Thread-4",
                    Timestamp = 1411231353793L,
                    Message = "#4. Test event E.",
                    Throwable = null,
                    Id = 507
                }
            };

            using (var sourceStream = new MemoryStream (sampleBytes))
            using (var source = Log4JFile.Create (sourceStream))
            using (var subject = new FilterLevel (Level.MinValue, Level.Warn))
            {
                source.Encoding = Encoding.GetEncoding (1251);
                var actual = source.GetEvents ().Where (subject);
                Assert.That (actual, Is.EqualTo (expected));
            }
        }
Пример #43
0
 public UberLoggerFilterChannels(FilterLevel defaultFilterLevel, Dictionary <string, FilterLevel> perChannelFilterLevels)
 {
     PerChannelFilterLevels = perChannelFilterLevels;
     DefaultFilterLevel     = defaultFilterLevel;
 }