Ejemplo n.º 1
0
		public void Add(RangeTypes type)
		{
			if(RangeTypes.None >= type || RangeTypes.InvalidRangeType <= type)
				return;

			this.List.Add(type);
		}
Ejemplo n.º 2
0
        private void cbbRangeType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime || currentDate == DateTime.MinValue)
            {
                return;
            }

            rangeType = eRangeTypeManager.GetValue();
            SetDate();
        }
Ejemplo n.º 3
0
		private void ApplyRules(string content, RangeTypes rangeType)
		{
			foreach(WsScanRule rule in m_scanRules)
			{
				if((rule.Ranges.Count != 0) && (!rule.Ranges.Contains(rangeType)))
					continue;

				m_results.Add(rangeType, rule.Condition, rule.Apply(content));
			}
		}
Ejemplo n.º 4
0
		internal WsMatchInRangeCollection GetMatches(RangeTypes type, string condition)
		{
			WsMatchInRangeCollection matches = new WsMatchInRangeCollection();
			foreach(WsMatchInRange match in this.List)
			{
				if(type == match.RangeType && condition == match.Condition)
					matches.Add(match);
			}
			return matches;
		}
Ejemplo n.º 5
0
		internal void Add(RangeTypes rangeType, string condition, ArrayList matches)
		{
			this.List.Add(new WsMatchInRange(rangeType, condition, matches));
			m_totalMatchCount += matches.Count;
			foreach(string match in matches)
			{
				if(m_rawList.ContainsKey(match))
					m_rawList[match] = Convert.ToInt32(m_rawList[match])+1;
				else
					m_rawList.Add(match, 1);
			}
		}
Ejemplo n.º 6
0
		internal WsMatchInRange(RangeTypes rangeType, string condition, ArrayList matches)
		{
			m_rangeType = rangeType;
			m_matches = new Hashtable();
			m_totalCount = matches.Count;
			m_condition = condition;
			foreach(string match in matches)
			{
				if(!m_matches.ContainsKey(match))
					m_matches.Add(match, 1);
				else
					m_matches[match] = Convert.ToInt32(m_matches[match]) + 1;
			}
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new color range from memory.
        /// </summary>
        /// <param name="buffer">A <see cref="byte"/> array that contains the <see cref="ColorRange"/> data.</param>
        public ColorRange(byte[] buffer)
        {
            if (buffer.Length != SIZE)
            {
                throw new ArgumentOutOfRangeException($"The buffer must be contains a {SIZE} array length.");
            }

            using (var stream = new BinaryReader(new MemoryStream(buffer)))
            {
                this.colors       = (RangeColors)stream.ReadByte();
                this.type         = (RangeTypes)stream.ReadByte();
                this.isFixed      = stream.ReadBoolean();
                this.blackColor   = stream.ReadByte();
                this._rangeColors = stream.ReadBytes(LENGTH);
            }
        }
Ejemplo n.º 8
0
        private RangeParseResult ParseRangeGroup(IEnumerator <Lexem> tokens, string context)
        {
            Type rangeType = null;

            while (tokens.Current.NextLexem != null && RangeTypes.Contains(tokens.Current.NextLexem.Value))
            {
                rangeType = ParseRangeType(tokens, context: context);
            }

            if (rangeType == null)
            {
                ExpectNextToken(tokens, RangeTypes, context);
            }

            return(ParseRangeGroupContents(tokens, rangeType, context));
        }
Ejemplo n.º 9
0
 public override string ToString()
 {
     return "QueryPlanIndexItemForge{" +
            "unique=" +
            IsUnique +
            ", hashProps=" +
            HashProps.RenderAny() +
            ", rangeProps=" +
            RangeProps.RenderAny() +
            ", hashTypes=" +
            HashTypes.RenderAny() +
            ", rangeTypes=" +
            RangeTypes.RenderAny() +
            ", advanced=" +
            AdvancedIndexProvisionDesc?.IndexDesc.IndexTypeName +
            "}";
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new <see cref="ColorRange"/> instance with default values.
        /// </summary>
        /// <param name="startColorIndex">The start color index to setup the range.</param>
        /// <remarks>By default, when initialize the 16 ranges in a <see cref="PAL"/>,
        /// the idea is create a ramp values from 0 to 255 values and repeat until completes all 16 ranges.
        /// This process is automatically setup in <see cref="ColorRangeTable"/> default constructor.</remarks>
        public ColorRange(ref byte startColorIndex)
        {
            this.colors     = DEFAULT_RANGE_COLORS;
            this.type       = DEFAULT_TYPE;
            this.isFixed    = DEFAULT_FIXED_STATE;
            this.blackColor = DEFAULT_BLACK_COLOR;

            this._rangeColors = new byte[LENGTH];

            byte range = startColorIndex;

            for (int i = 0; i < LENGTH; i++)
            {
                this._rangeColors[i] = range;
                if (++range > byte.MaxValue)
                {
                    range = 0;
                }
            }

            startColorIndex = range;
        }
Ejemplo n.º 11
0
        private RangeParseResult ParseRangeGroupContents(IEnumerator <Lexem> tokens, Type rangeType, string context)
        {
            List <object> minimumValues = new List <object>();
            List <object> maximumValues = new List <object>();

            var range = ParseRange(tokens, rangeType, context: context);

            minimumValues.AddRange(range.Select(r => r.Item1));
            maximumValues.AddRange(range.Select(r => r.Item2));

            if (tokens.Current.NextLexem != null)
            {
                RangeParseResult nextRange = null;
                if (tokens.Current.NextLexem.Value == "(")
                {
                    nextRange = ParseRangeGroupContents(tokens, rangeType, context);
                }
                else if (RangeTypes.Contains(tokens.Current.NextLexem.Value))
                {
                    nextRange = ParseRangeGroup(tokens, context);

                    if (!nextRange.Type.Equals(rangeType))
                    {
                        throw new InvalidDataException("Non-uniform ranges are not supported. First encountered range: " + TypeToRangeDescription(rangeType) + ", next: " + TypeToRangeDescription(nextRange.Type));
                    }
                }

                if (nextRange != null)
                {
                    minimumValues.AddRange(nextRange.MinimumValues);
                    maximumValues.AddRange(nextRange.MaximumValues);
                }
            }

            return(new RangeParseResult()
            {
                Type = rangeType, MinimumValues = minimumValues, MaximumValues = maximumValues
            });
        }
Ejemplo n.º 12
0
        public static void ParseOptionalFields(EmoteType type, string fields, Dictionary <EmoteField, string> fieldDict)
        {
            DefaultFields.TryGetValue(type, out var defaultFields);

            if (defaultFields == null)
            {
                Console.WriteLine($"ParseOptionalFields({type}): couldn't find default field for {type}");
                return;
            }

            // custom parsers
            var tokens = new List <string>()
            {
                fields
            };

            if (defaultFields.Count > 1)
            {
                tokens = GetSubTokens(fields);

                if (tokens.Count > defaultFields.Count)
                {
                    Console.WriteLine($"Warning: ParseOptionalFields({type}): {fields} contains more than default # of fields");
                }
            }

            for (var i = 0; i < tokens.Count && i < defaultFields.Count; i++)
            {
                var token        = tokens[i];
                var defaultField = defaultFields[i];

                switch (defaultField)
                {
                case EmoteField.Amount:

                    var amount = token;

                    if (token.Equals("false", StringComparison.OrdinalIgnoreCase))
                    {
                        amount = "0";
                    }
                    else if (token.Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        amount = "1";
                    }

                    fieldDict.Add(EmoteField.Amount, amount);
                    break;

                case EmoteField.CharacterTitle:
                    var title = Parser.TryParseCharacterTitle(token);
                    if (title != null)
                    {
                        fieldDict.Add(EmoteField.Amount, ((int)title).ToString());
                    }
                    break;

                case EmoteField.PropertyAttributeStat:
                    var propAttr = Parser.TryParsePropertyAttribute(token);
                    if (propAttr != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propAttr).ToString());
                    }
                    break;

                case EmoteField.PropertyAttribute2ndStat:
                    var propVital = Parser.TryParsePropertyAttribute2nd(token);
                    if (propVital != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propVital).ToString());
                    }
                    break;

                case EmoteField.PropertyBoolStat:
                    var propBool = Parser.TryParsePropertyBool(token);
                    if (propBool != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propBool).ToString());
                    }
                    break;

                case EmoteField.PropertyFloatStat:
                    var propFloat = Parser.TryParsePropertyFloat(token);
                    if (propFloat != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propFloat).ToString());
                    }
                    break;

                case EmoteField.PropertyIntStat:
                    var propInt = Parser.TryParsePropertyInt(token);
                    if (propInt != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propInt).ToString());
                    }
                    break;

                case EmoteField.PropertyInt64Stat:
                    var propInt64 = Parser.TryParsePropertyInt64(token);
                    if (propInt64 != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propInt64).ToString());
                    }
                    break;

                case EmoteField.PropertyStringStat:
                    var propStr = Parser.TryParsePropertyString(token);
                    if (propStr != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)propStr).ToString());
                    }
                    break;

                case EmoteField.SkillStat:
                    var skill = Parser.TryParseSkill(token);
                    if (skill != null)
                    {
                        fieldDict.Add(EmoteField.Stat, ((int)skill).ToString());
                    }
                    break;

                case EmoteField.Percent:
                    var percent = Parser.TryParsePercent(token, out _);
                    if (percent != null)
                    {
                        fieldDict.Add(EmoteField.Percent, percent.ToString());
                    }
                    break;

                case EmoteField.Range:

                    if (!RangeTypes.TryGetValue(type, out var rangeType))
                    {
                        Console.WriteLine($"Emote_Line.ParseOptionalTypes({type}) couldn't find RangeType");
                        break;
                    }

                    var range = Parser.TryParseRange(token, rangeType, out _);
                    if (range != null)
                    {
                        if (range.Min != null)
                        {
                            fieldDict.Add(EmoteField.Min, range.Min.ToString());
                        }
                        if (range.Max != null)
                        {
                            fieldDict.Add(EmoteField.Max, range.Max.ToString());
                        }
                    }
                    break;

                case EmoteField.RangeFloat:

                    if (!RangeTypes.TryGetValue(type, out rangeType))
                    {
                        Console.WriteLine($"Emote_Line.ParseOptionalTypes({type}) couldn't find RangeType");
                        break;
                    }

                    var rangeFloat = Parser.TryParseRangeFloat(token, rangeType, out _);
                    if (rangeFloat != null)
                    {
                        if (rangeFloat.Min != null)
                        {
                            fieldDict.Add(EmoteField.MinFloat, rangeFloat.Min.ToString());
                        }
                        if (rangeFloat.Max != null)
                        {
                            fieldDict.Add(EmoteField.MaxFloat, rangeFloat.Max.ToString());
                        }
                    }
                    break;

                case EmoteField.Range64:


                    if (!RangeTypes.TryGetValue(type, out rangeType))
                    {
                        Console.WriteLine($"Emote_Line.ParseOptionalTypes({type}) couldn't find RangeType");
                        break;
                    }

                    var range64 = Parser.TryParseRange64(token, rangeType, out _);
                    if (range64 != null)
                    {
                        if (range64.Min != null)
                        {
                            fieldDict.Add(EmoteField.Min64, range64.Min.ToString());
                        }
                        if (range64.Max != null)
                        {
                            fieldDict.Add(EmoteField.Max64, range64.Max.ToString());
                        }
                    }
                    break;

                case EmoteField.WeenieClassId:

                    var wcid = Parser.TryParseWeenieClassId(token);
                    if (wcid != null)
                    {
                        fieldDict.Add(EmoteField.WeenieClassId, wcid.ToString());
                    }

                    break;

                case EmoteField.Angles:

                    var angles = Parser.TryParseQuaternion(token);
                    if (angles != null)
                    {
                        AddAngles(angles.Value, fieldDict);
                    }
                    break;

                case EmoteField.OriginAngles:

                    var frame = Parser.TryParseFrame(token, false);
                    if (frame != null)
                    {
                        AddOrigin(frame.Origin, fieldDict);
                        AddAngles(frame.Orientation, fieldDict);
                    }
                    else
                    {
                        var origin = Parser.TryParseVector3(token);
                        if (origin != null)
                        {
                            AddOrigin(origin.Value, fieldDict);
                        }
                    }
                    break;

                case EmoteField.Position:

                    var pos = Parser.TryParsePosition(token);
                    if (pos != null)
                    {
                        fieldDict.Add(EmoteField.ObjCellId, pos.ObjCellId.ToString());
                        AddOrigin(pos.Frame.Origin, fieldDict);
                        AddAngles(pos.Frame.Orientation, fieldDict);
                    }
                    break;

                case EmoteField.PScript:

                    var physScript = Parser.TryParsePlayScript(token);
                    if (physScript != null)
                    {
                        fieldDict.Add(EmoteField.PScript, ((int)physScript).ToString());
                    }
                    break;

                case EmoteField.ContractId:

                    var contractId = Parser.TryParseContractId(token);
                    if (contractId != null)
                    {
                        fieldDict.Add(EmoteField.Amount, ((int)contractId).ToString());
                    }
                    break;

                default:
                    fieldDict.Add(defaultField, token);
                    break;
                }
            }
        }
Ejemplo n.º 13
0
		public bool Contains(RangeTypes rangeType)  
		{
			return(List.Contains(rangeType));
		}
Ejemplo n.º 14
0
		public WsMatchInRangeCollection GetMatches(RangeTypes type, string condition)
		{
			return m_matches.GetMatches(type, condition);
		}
Ejemplo n.º 15
0
 /// <summary>
 /// Bestimmt ob ein Wert in einem bestimmten Bereich liegt.
 /// </summary>
 /// <param name="val">Der zu prüfende Wert.</param>
 /// <param name="min">Die Untergrenze des Bereichs.</param>
 /// <param name="max">Die Obergrenze des Bereichs.</param>
 /// <param name="rangeType">Bestimmt ob die Grenzen inklusiv oder exklusiv sind.</param>
 /// <returns><c>True</c>, wenn <paramref name="value"/> in den angegebenen Grenzen liegt. Andernfalls <c>False</c>.</returns>
 public static bool IsInRange(this double val, double min, double max, RangeTypes rangeType)
 {
     return(((rangeType == RangeTypes.Excl || rangeType == RangeTypes.ExclIncl) ? val > min : val >= min) &&
            ((rangeType == RangeTypes.Excl || rangeType == RangeTypes.InclExcl) ? val < max : val <= max));
 }
Ejemplo n.º 16
0
        private IEnumerable <Tuple <object, object> > ParseRange(IEnumerator <Lexem> tokens, Type rangeType, string context)
        {
            if (tokens.Current.NextLexem != null && RangeTypes.Contains(tokens.Current.NextLexem.Value))
            {
                return(Enumerable.Empty <Tuple <object, object> >());
            }

            ExpectNextToken(tokens, "(", context: context + " range");

            TypeConverter converter = TypeDescriptor.GetConverter(rangeType);

            List <Tuple <object, object> > result = new List <Tuple <object, object> >();

            List <string> rangeTokens = new List <string>();
            string        token       = GetNextToken(tokens, context: context + " range");

            while (token != ")") // scanner guarantees that all parentheses are matched
            {
                rangeTokens.Add(token);
                token = GetNextToken(tokens, context: context + " range");
            }

            if (rangeTokens.Count == 2)
            {
                result.Add(ParseRangeValues(rangeTokens[0], rangeTokens[1], converter, context: context));
            }
            else if (rangeTokens.Count == 3)
            {
                int count = 0;

                Exception innerException = null;
                try
                {
                    count = int.Parse(rangeTokens[0], CultureInfo.InvariantCulture);
                }
                catch (FormatException e)
                {
                    innerException = e;
                }
                catch (OverflowException e)
                {
                    innerException = e;
                }
                catch (ArgumentNullException e)
                {
                    innerException = e;
                }

                if (innerException != null)
                {
                    throw new InvalidDataException("Could not parse range multiplicity value: '" + rangeTokens[0] + "' when parsing " + context);
                }

                var rangeTuple = ParseRangeValues(rangeTokens[1], rangeTokens[2], converter, context: context);
                for (int i = 0; i < count; ++i)
                {
                    result.Add(rangeTuple);
                }
            }

            return(result);
        }
Ejemplo n.º 17
0
		public RangeTypes[] ToArray()
		{
			RangeTypes[] types = new RangeTypes[this.Count];
			int i = 0;
			foreach(RangeTypes type in this.List)
			{
				types[i++] = type;
			}

			return types;
		}