Beispiel #1
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "MatrixType" /> class.
 /// </summary>
 public MatrixType()
     : base("matrix", 3)
 {
     ParameterTypes.Add(typeof(TypeBase));
     ParameterTypes.Add(typeof(Literal));
     ParameterTypes.Add(typeof(Literal));
 }
Beispiel #2
0
        private ConfigParam AddParam(string key, string description, ParameterTypes type, string section, string defalt, object value, params string[] values)
        {
            bool   commandLine = commandLineKeys.ContainsKey(section) && commandLineKeys[section].Contains(key);
            string shortKey    = commandLine && commandLineShortKeys.ContainsKey(section) ? commandLineShortKeys[section][key] : null;

            if (!mParameters.ContainsKey(section))
            {
                mParameters.Add(section, new Dictionary <string, ConfigParam>());
            }
            if (!mParameters[section].ContainsKey(key))
            {
                ConfigParam param = new ConfigParam(key, description, type, section, Group, defalt, commandLine, shortKey, value != null ? value.ToString() : "null", mFile, values);
                mParameters[section].Add(key, param);
                return(param);
            }
            else
            {
                ConfigParam param = mParameters[section][key];
                param.AddGroup(Group);
                if (!param.CommandLine && commandLine)
                {
                    param.CommandLine = true;
                }
                if (param.ShortKey == null && shortKey != null)
                {
                    param.ShortKey = shortKey;
                }
                return(param);
            }
        }
        protected Parameter GetValidParameter(ParameterTypes parameterTypes = ParameterTypes.String, string key = "myparameter")
        {
            var parameter = new Parameter()
            {
                Name          = "parameter",
                Key           = key,
                Id            = "abc123",
                ParameterType = EntityHeader <ParameterTypes> .Create(parameterTypes),
            };

            if (parameterTypes == ParameterTypes.State)
            {
                parameter.StateSet = new EntityHeader <StateSet>()
                {
                    Id = "abc123", Text = "dontcare"
                };
            }
            else if (parameterTypes == ParameterTypes.ValueWithUnit)
            {
                parameter.UnitSet = new EntityHeader <UnitSet>()
                {
                    Id = "abc123", Text = "dontcare"
                };
            }

            return(parameter);
        }
Beispiel #4
0
 public override string GetClepsTypeString()
 {
     return(String.Format("fn {0} ({1})",
                          ReturnType.GetClepsTypeString(),
                          String.Join(",", ParameterTypes.Select(p => p.GetClepsTypeString()))
                          ));
 }
Beispiel #5
0
 public bool IsCompatibleWith(BasicSignature other)
 {
     return(CallingConvention == other.CallingConvention &&
            ((ParameterTypes == null && other.ParameterTypes == null) ||
             ParameterTypes.SequenceEqual(other.ParameterTypes)) &&
            ReturnType.Equals(other.ReturnType));
 }
Beispiel #6
0
 public AllowableStorageContentTypeAttribute(ParameterTypes storageType, bool anyValueButThis = false, bool isRequired = true, string customMessage = "")
 {
     StorageType     = storageType;
     IsRequired      = isRequired;
     CustomMessage   = customMessage;
     AnyValueButThis = anyValueButThis;
 }
 public void ParameterTypesNegateTest()
 {
     Assert.AreEqual(false, ParameterTypes.NegateObject(true));
     Assert.AreEqual("not ok", ParameterTypes.NegateObject("ok"));
     Assert.AreEqual(-1L, ParameterTypes.NegateObject(1));
     Assert.AreEqual("anything but null", ParameterTypes.NegateObject(null));
 }
        public void Derived_Parameter_Matches(Type _, Func <Type, bool> criteria, int expectedCount)
        {
            // We do not care what the Type was, per se, but the Cases should furnish something.
            _.AssertNotNull();

            bool TryReportParameterTypes(IEnumerable <Type> reportedTypes)
            {
                OutputHelper.WriteLine(
                    $"Reporting {expectedCount} expected "
                    // ReSharper disable once PossibleNullReferenceException
                    + $"types: {Join(", ", reportedTypes.Select(x => $"'{x.FullName} : {x.BaseType.FullName}'"))}"
                    );
                return(true);
            }

            var parameterTypes = ParameterTypes.ToArray();

            try
            {
                parameterTypes.Where(criteria.AssertNotNull()).AssertEqual(expectedCount, x => x.Count())
                .AssertTrue(TryReportParameterTypes);
            }
            catch (Exception ex)
            {
                OutputHelper.WriteLine("Failed to verify derived Parameter matches.");
                parameterTypes.AssertTrue(TryReportParameterTypes);
                throw;
            }
        }
        public string AsNativeName()
        {
            var paramTypes = ParameterTypes.Select((t) => t.AsNativeName());
            var paramStr   = string.Join(",", paramTypes);

            return($"({paramStr}) => {ReturnType.AsNativeName()}");
        }
Beispiel #10
0
 /// <summary>
 /// Adds the parameter.
 /// </summary>
 /// <param name="parameterType">
 /// Type of the parameter.
 /// </param>
 /// <param name="value">
 /// The value.
 /// </param>
 public void AddParameter(ParameterTypes parameterType, object value)
 {
     if (!this.Parameters.ContainsKey(parameterType))
     {
         this.Parameters.Add(parameterType, value);
     }
 }
Beispiel #11
0
        public MethodDeclarationSyntax Output()
        {
            TypeSyntax retType;

            if (ReturnType == null)
            {
                retType = PredefinedType(Token(SyntaxKind.VoidKeyword));
            }
            else
            {
                retType = ReturnType.GenReferenceTo();
            }

            ParameterListSyntax parameters =
                ParameterList(
                    SeparatedList(
                        ParameterTypes.Select(
                            (pt, i) => Parameter(Identifier($"arg{i}")).WithType(pt.GenReferenceTo()))));

            return
                (MethodDeclaration(retType, Name)
                 .WithModifiers(TokenList(Token(SyntaxKind.StaticKeyword)))
                 .WithParameterList(parameters)
                 .WithBody(Body));
        }
Beispiel #12
0
        private ParameterTypesRating GetParameterTypesRating(List <SignatureType> searchParameterTypes)
        {
            var parameterRating = new ParameterTypesRating();

            if (ParameterTypes.Count == 0 && searchParameterTypes.Count == 0)
            {
                parameterRating.AddExactMatch();
            }

            if (ParameterTypes.Count < searchParameterTypes.Count)
            {
                return(parameterRating.SetFailed());
            }

            parameterRating.SetGenericParameterCount(ParameterTypes.Count(p => p.IsGeneric));

            for (var i = 0; i < ParameterTypes.Count; i++)
            {
                var thisType = this.ParameterTypes[i];

                if (searchParameterTypes.Count > i)
                {
                    var otherType = searchParameterTypes[i];

                    if (otherType.FoundMatchingType == thisType.FoundMatchingType || otherType.FoundMatchingType == typeof(NullObject))
                    {
                        parameterRating.AddExactMatch();
                        continue;
                    }

                    if (thisType.FoundMatchingType.IsInterface && TypeHelpers.ImplementsInterface(otherType.FoundMatchingType, thisType.FoundMatchingType))
                    {
                        parameterRating.AddCastableMatch();
                        continue;
                    }

                    if (TypeHelpers.IsImplicitCastableTo(otherType.FoundMatchingType, thisType.FoundMatchingType))
                    {
                        parameterRating.AddCastableMatch();
                        continue;
                    }

                    if (TypeHelpers.InheritFromClass(otherType.FoundMatchingType, thisType.FoundMatchingType, true, false))
                    {
                        parameterRating.AddInheritanceLevel(TypeHelpers.InheritFromClassLevel(otherType.FoundMatchingType, thisType.FoundMatchingType));
                        continue;
                    }

                    return(parameterRating.SetFailed());
                }

                if (!thisType.IsOptional)
                {
                    return(parameterRating.SetFailed());
                }
            }

            return(parameterRating);
        }
 public Parameter(string key, string displayName, ParameterTypes type, object defaultValue)
 {
     Key          = key;
     DisplayName  = displayName;
     Type         = type;
     DefaultValue = defaultValue;
     Value        = defaultValue;
 }
Beispiel #14
0
 public override AstExpression Clone()
 {
     return(CopyValuesTo(new AstFunctionTypeExpr(
                             ParameterTypes.Select(p => p.Clone()).ToList(),
                             ReturnType?.Clone(),
                             IsFatFunction,
                             Directives)));
 }
Beispiel #15
0
 public override int GetHashCode()
 {
     unchecked {
         return(CallingConvention.GetHashCode() ^
                (ParameterTypes != null? ParameterTypes.SequenceHashCode() : 0) ^
                ReturnType.GetHashCode());
     }
 }
Beispiel #16
0
 public MetaFunctionType(
     IEnumerable <DataType> parameterTypes,
     DataType resultType)
     : base(Lifetime.Forever)
 {
     ParameterTypes = parameterTypes.ToFixedList();
     ResultType     = resultType;
     IsResolved     = ParameterTypes.All(pt => pt.IsResolved) && ResultType.IsResolved;
 }
Beispiel #17
0
        private BlockSyntax GenBlock(bool root)
        {
            _level++;

            ScopeFrame scope = new ScopeFrame();

            _scope.Add(scope);

            if (root)
            {
                scope.Variables.AddRange(ParameterTypes.Select((p, i) => new VariableIdentifier(p, $"arg{i}")));
            }

            BlockSyntax block = Block(GenStatements());

            _scope.RemoveAt(_scope.Count - 1);
            _level--;

            return(block);

            IEnumerable <StatementSyntax> GenStatements()
            {
                int             numStatements = Options.BlockStatementCountDist.Sample(Random.Rng);
                StatementSyntax retStmt       = null;

                for (int i = 0; i < numStatements; i++)
                {
                    StatementSyntax stmt = GenStatement();
                    if (stmt is ReturnStatementSyntax)
                    {
                        retStmt = stmt;
                        break;
                    }

                    yield return(stmt);
                }

                if (root && retStmt == null)
                {
                    retStmt = GenReturn();
                }

                if (Options.EnableChecksumming)
                {
                    foreach (StatementSyntax stmt in GenChecksumming(scope.Variables, _genChecksumSiteId))
                    {
                        yield return(stmt);
                    }
                }

                if (retStmt != null)
                {
                    yield return(retStmt);
                }
            }
        }
 public HumanTaskDefBuilder AddPresentationParameter(string name, ParameterTypes type, string expression)
 {
     _humanTaskDef.PresentationParameters.Add(new PresentationParameter
     {
         Expression = expression,
         Name       = name,
         Type       = type
     });
     return(this);
 }
Beispiel #19
0
        private ParameterTypes[] ConvertParameterTypes(string[] parameterTypes)
        {
            ParameterTypes[] ret = new ParameterTypes[parameterTypes.Length];
            for (int i = 0; i < parameterTypes.Length; ++i)
            {
                ret[i] = (ParameterTypes)Enum.Parse(typeof(ParameterTypes), parameterTypes[i]);
            }

            return(ret);
        }
 public NotificationDefBuilder AddPresentationParameter(string name, ParameterTypes type, string expression)
 {
     _notification.PresentationParameters.Add(new PresentationParameter
     {
         Expression = expression,
         Name       = name,
         Type       = type
     });
     return(this);
 }
        protected Parameter GetParameter(string name, string key, ParameterTypes parameterType = ParameterTypes.String, string parameterName = "String")
        {
            var parameter = new Parameter();

            parameter.Name          = name;
            parameter.Key           = key;
            parameter.ParameterType = EntityHeader <ParameterTypes> .Create(parameterType);

            return(parameter);
        }
Beispiel #22
0
        private void Open(object param)
        {
            try
            {
                if (_model != null)
                {
                    var cancel = AskSaveCancel();
                    if (cancel)
                    {
                        return;
                    }
                }

                var filePath = _dialogService.ChooseFileToOpen(_fileExtension, _fileFilter);
                if (filePath == null)
                {
                    return;
                }

                _openFile = filePath;

                XmlSerializer serializer = new XmlSerializer(typeof(KNX));
                using (var reader = new StreamReader(_openFile))
                {
                    _model = (KNX)serializer.Deserialize(reader);
                }

                _manufacturerData   = _model.ManufacturerData.First();
                _hardware           = _manufacturerData.Hardware.First();
                _product            = _hardware.Products.First();
                _catalogSection     = _manufacturerData.Catalog.First();
                _catalogItem        = _catalogSection.CatalogItem.First();
                _hardware2Program   = _hardware.Hardware2Programs.First();
                _applicationProgram = _manufacturerData.ApplicationPrograms.First();
                _appProgRef         = _hardware2Program.ApplicationProgramRef.First();
                _codeSegment        = _applicationProgram.Static.Code.RelativeSegment.First();

                var parameterList = _applicationProgram.Static.Parameters.OfType <Parameter_t>();

                foreach (var item in parameterList)
                {
                    item.AllTypes = ParameterTypes;
                    item.Type     = ParameterTypes.First(t => t.Id == item.ParameterType);
                    Parameters.Add(item);
                }

                RaiseChanged();
            }
            catch (Exception ex)
            {
                ClearData();
                _dialogService.ShowMessage(ex.ToString());
            }
        }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CastMethod" /> class.
 /// </summary>
 /// <param name="extendedType">Type of the extended.</param>
 /// <param name="info">The info.</param>
 /// <param name="isExplicit">if set to <see langword="true" /> [is explicit].</param>
 /// <remarks></remarks>
 internal CastMethod([NotNull] ExtendedType extendedType, [NotNull] MethodInfo info, bool isExplicit)
     : base(extendedType, info)
 {
     Debug.Assert(info.Name == "op_Explicit" || info.Name == "op_Implicit");
     IsExplicit = isExplicit;
     // ReSharper disable once AssignNullToNotNullAttribute
     FromType = ParameterTypes.First();
     Debug.Assert(FromType != null);
     ToType = ReturnType;
     Debug.Assert(FromType == extendedType.Type || ToType == extendedType.Type);
 }
Beispiel #24
0
        public override bool NotNullObjectEquals(ClepsType obj)
        {
            if (obj.GetType() != typeof(FunctionClepsType))
            {
                return(false);
            }

            FunctionClepsType objToCompare = obj as FunctionClepsType;

            return(ReturnType == objToCompare.ReturnType && ParameterTypes.SequenceEqual(objToCompare.ParameterTypes));
        }
 public NotificationDefBuilder AddInputOperationParameter(string name, ParameterTypes type, bool isRequired)
 {
     _notification.OperationParameters.Add(new Parameter
     {
         Name       = name,
         Type       = type,
         IsRequired = isRequired,
         Usage      = ParameterUsages.INPUT
     });
     return(this);
 }
        protected WorkflowInput GetInput(string name = "in1", string key = "in1", ParameterTypes parameterType = ParameterTypes.String)
        {
            var input = new WorkflowInput();

            input.Name = name;
            input.Key  = key;
            SetAuditParams(input);
            input.InputType = EntityHeader <ParameterTypes> .Create(parameterType);

            return(input);
        }
Beispiel #27
0
        /// <summary>
        /// Reads the parameter.
        /// </summary>
        /// <param name="parameterType">
        /// Type of the parameter.
        /// </param>
        /// <returns>
        /// Return System Object.
        /// </returns>
        public object ReadParameter(ParameterTypes parameterType)
        {
            object value;

            if (this.Parameters.TryGetValue(parameterType, out value))
            {
                return(value);
            }

            return(null);
        }
 public HumanTaskDefBuilder AddOutputOperationParameter(string name, ParameterTypes type, bool isRequired)
 {
     _humanTaskDef.OperationParameters.Add(new Parameter
     {
         Name       = name,
         Type       = type,
         IsRequired = isRequired,
         Usage      = ParameterUsages.OUTPUT
     });
     return(this);
 }
Beispiel #29
0
        /// <summary>
        /// Deep clone.
        /// </summary>
        public virtual Function Clone()
        {
            var result = (Function)MemberwiseClone();

            result.ResultType     = ResultType.Clone();
            result.ParameterTypes = ParameterTypes.Select(p => p.Clone()).ToArray();
            if (InputType != null)
            {
                result.InputType = InputType.Clone();
            }
            return(result);
        }
        protected object DeserializeReplyInternal(Message message, object[] parameters)
        {
            var retParamInfo = ParameterTypes.FirstOrDefault(x => x.ParamType == ParamType.Return);

            if (retParamInfo == null)
            {
                return(null);
            }

            var store = ObjectBuilder.GetModelStore();

            var serializer = ObjectBuilder.GetSerializer();

            var reader = message.GetReaderAtBodyContents();

            reader.Read();

            var model = store.GetModel(retParamInfo.Type, ModeType.Wcf);

            if (model == null)
            {
                throw new InvalidOperationException("The model cannot be null, meta data fetch failed. Type: " + retParamInfo.Type.FullName);
            }

            reader.Read();

            var val = reader.Value;

            var data = BinaryConverter.FromString(val);

            var compressionType = GetMessageCompressionTypeOptions(message);

            if (compressionType != CompressionTypeOptions.None)
            {
                var compressionProvider = new CompressionProvider();

                data = compressionProvider.DeCompress(data, compressionType);
            }

            object retVal;

            try
            {
                retVal = serializer.Deserialize(data, model.MetaData, retParamInfo.Type, ModeType.Wcf);
            }
            catch (SerializationException)
            {
                store.RemoveModel(retParamInfo.Type, ModeType.Wcf);

                throw;
            }
            return(retVal);
        }