public bool Includes(string functionName, params string[] parameterTypes)
 {
     return(functions.Find(a =>
     {
         if (a.name != functionName)
         {
             return false;
         }
         if (parameterTypes.Length == 0 &&
             a.parameters.Count == 1 && a.parameters[0].type.GetName() == "void")
         {
             return true;
         }
         if (a.parameters.Count != parameterTypes.Length)
         {
             return false;
         }
         for (int loop = 0; loop < a.parameters.Count; ++loop)
         {
             IParameterType fVar = ParameterType.GetParameterType(
                 parameterTypes[loop]);
             if (!a.parameters[loop].type.Equals(fVar) &&
                 !(
                     a.parameters[loop].type.GetName().StartsWith("int") &&
                     !a.parameters[loop].type.GetName().EndsWith("_ptr") &&
                     fVar.GetName().StartsWith("int") &&
                     !fVar.GetName().EndsWith("_ptr") /* &&
                                                       * fVariables.ElementAt(loop).address.length == -2*/))
             {
                 return false;
             }
         }
         return true;
     }) != null);
 }
        /// <summary>
        /// Add an actual type to parameter type mapping. Actual type mappings are weak.
        /// Note: If no matching type is found, the objects base types are traversed all the way up to <see cref="object"/>.
        /// </summary>
        /// <param name="actualType">The actual type.</param>
        /// <param name="type">The parameter type to map to.</param>
        public void AddActualTypeMapping(Type actualType, IParameterType type)
        {
            if (actualType == null)
            {
                throw new ArgumentNullException(nameof(actualType));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (_actualTypeMappings.ContainsKey(actualType))
            {
                throw new InvalidOperationException($"Cannot add duplicate actual type to parameter type mapping for associated type {actualType}" +
                                                    $" and type {type}, actual type is already mapped to {_actualTypeMappings[actualType]}.");
            }

            _actualTypeMappings.Add(actualType, type);
        }
        /// <summary>
        /// Add an identifier to parameter type mapping. Identifier mappings are strong.
        /// </summary>
        /// <param name="identifier">The identifier to map. No registry resolve notation, only direct identifiers.</param>
        /// <param name="type">The parameter type to map to.</param>
        public void AddIdentifierMapping(string identifier, IParameterType type)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (_identifierMappings.ContainsKey(identifier))
            {
                throw new InvalidOperationException($"Cannot add duplicate identifier to parameter type mapping for identifier {identifier}" +
                                                    $" and type {type}, identifier is already mapped to {_identifierMappings[identifier]}.");
            }

            _identifierMappings.Add(identifier, type);
        }
Exemple #4
0
 public bool Equals(IParameterType other)
 {
     return(other is PT_Int16 &&
            GetLengthInBytes() == other.GetLengthInBytes() &&
            GetName() == other.GetName());
 }
Exemple #5
0
 public ZakupkiParameter(IParameterType type, string value)
 {
     Type  = type;
     Value = value;
 }
 public ZakupkiParameter(IParameterType type, string value)
 {
     Type = type;
     Value = value;
 }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IParameterType parameter = (IParameterType)value;

            writer.WriteValue(parameter.GetName());
        }
Exemple #8
0
 private void assert(IParameterType result, string expectedString)
 {
     Assert.IsNotNull(result, "should not be null");
     Assert.AreEqual(result.ToString(), expectedString);
 }