Beispiel #1
0
        public ITRestRequest AddParameter(string name, object value, TParameterType type)
        {
            ParameterType parameterType = (ParameterType)Enum.Parse(typeof(ParameterType), type.ToString());

            this._request = this._request.AddParameter(name, value, parameterType);
            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// Execute the <see cref="ICommand"/> to create a <see cref="ParameterType"/>
        /// </summary>
        /// <typeparam name="TParameterType">A kind of <see cref="ParameterType"/></typeparam>
        /// <remarks>
        /// A new transaction is created to allow a <see cref="ParameterType"/> to be created "on the fly"
        /// </remarks>
        private void ExecuteCreateGenericParameterTypeCommand <TParameterType>() where TParameterType : ParameterType, new()
        {
            ParameterType parameterType;

            parameterType      = new TParameterType();
            parameterType.Name = this.SelectedRow.Identifiable.LongName;

            var enumDatatype = this.SelectedRow.Identifiable as DatatypeDefinitionEnumeration;

            if (enumDatatype != null)
            {
                var enumParameterType = new EnumerationParameterType {
                    Name = enumDatatype.LongName
                };
                foreach (var specifiedValue in enumDatatype.SpecifiedValues.OrderBy(x => x.Properties.Key))
                {
                    var enumerationDefinition = new EnumerationValueDefinition
                    {
                        Name      = specifiedValue.LongName,
                        ShortName = specifiedValue.Properties.OtherContent
                    };

                    enumParameterType.ValueDefinition.Add(enumerationDefinition);
                }

                parameterType = enumParameterType;
            }

            var siteDirectory            = this.Session.RetrieveSiteDirectory();
            var transactionContext       = TransactionContextResolver.ResolveContext(siteDirectory);
            var parameterTypeTransaction = new ThingTransaction(transactionContext);

            this.AddContainedThingToTransaction(parameterTypeTransaction, parameterType);

            var result = this.ThingDialogNavigationService.Navigate(parameterType, parameterTypeTransaction, this.Session, true, ThingDialogKind.Create, this.ThingDialogNavigationService);

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            // refresh parameter type list and set the mapping to the new parameter type
            this.PopulateParameterTypes();
            ((DatatypeDefinitionMappingRowViewModel)this.SelectedRow).FilterPossibleParameterTypes();
            this.CastSelectedRow.MappedThing = this.ParameterTypes.Single(x => x.Iid == parameterType.Iid);
        }