Beispiel #1
0
        internal async Task SetValueAsync(object argTarget, string argValue)
        {
            await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStartAsync("Entering {0}", MethodBase.GetCurrentMethod().Name);

            await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Attempting to set the Argument {0} with the value {1}", argTarget.ToString(), CommandLineArgument.ToNullableString(argValue));

            if (this.IsSet && !this.SupportsMultiple)
            {
                await CrmSvcUtil.CrmSvcUtilLogger.TraceErrorAsync("Attempt to set argument {0} multiple times", this.ArgumentProperty.Name);

                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Cannot set command line argument {0} multiple times", this.ArgumentProperty.Name));
            }
            if (this.IsCollection)
            {
                await this.PopulateCollectionParameterAsync(argTarget, argValue);
            }
            else if (this.IsFlag)
            {
                await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Setting flag property {0} to true", this.ArgumentProperty.Name);

                this.ArgumentProperty.SetValue(argTarget, true, null);
            }
            else
            {
                await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Setting property {0} to value {1}", this.ArgumentProperty.Name, CommandLineArgument.ToNullableString(argValue));

                await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Converting parameter value as ArgumentProperty {0} is defined as type {1}.", this.ArgumentProperty.Name, this.ArgumentProperty.PropertyType.Name);

                var value = Convert.ChangeType(argValue, this.ArgumentProperty.PropertyType, CultureInfo.InvariantCulture);
                this.ArgumentProperty.SetValue(argTarget, value, null);
            }
            this.IsSet = true;
            await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStopAsync("Exiting {0}", MethodBase.GetCurrentMethod().Name);
        }
Beispiel #2
0
        private static async Task <bool> CreateMapEntryAsync(Dictionary <string, CommandLineArgument> propertyMap, PropertyInfo property, CommandLineArgument argument, string type, string value)
        {
            if (!string.IsNullOrEmpty(value))
            {
                await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Property {0} has defined a {1} {2}", property.Name, type, value);

                propertyMap.Add(value.ToUpperInvariant(), argument);
                return(true);
            }
            return(false);
        }