Ejemplo n.º 1
0
        public void SwitchRowIntoEditMode(int index, BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            if (_editModeHost.Value == null)
            {
                throw new InvalidOperationException(
                          string.Format("Cannot initialize row edit mode: The BocList '{0}' does not have a Value.", _editModeHost.ID));
            }

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (index >= _editModeHost.Value.Count)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            RestoreAndEndEditMode(columns);

            if (_editModeHost.IsReadOnly || IsListEditModeActive || IsRowEditModeActive)
            {
                return;
            }

            _editedRowIDs =
                new List <string> {
                _editModeHost.RowIDProvider.GetItemRowID(new BocListRow(index, (IBusinessObject)_editModeHost.Value[index]))
            };
            _editMode = EditMode.RowEditMode;
            CreateEditModeControls(columns);
            SetFocus(_rows.First());
            LoadValues(false);
        }
Ejemplo n.º 2
0
        public void Succeed_ICollection()
        {
            ArrayList list   = new ArrayList();
            ArrayList result = ArgumentUtility.CheckNotNullOrItemsNull("arg", list);

            Assert.That(result, Is.SameAs(list));
        }
Ejemplo n.º 3
0
        public void Fail_zItemNullICollection()
        {
            ArrayList list = new ArrayList();

            list.Add(null);
            ArgumentUtility.CheckNotNullOrItemsNull("arg", list);
        }
Ejemplo n.º 4
0
        public bool AddAndEditRow(IBusinessObject businessObject, BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            RestoreAndEndEditMode(columns);

            if (_editModeHost.IsReadOnly || IsListEditModeActive || IsRowEditModeActive)
            {
                return(false);
            }

            int index = AddRow(businessObject, columns);

            if (index < 0)
            {
                return(false);
            }

            SwitchRowIntoEditMode(index, columns);

            if (!IsRowEditModeActive)
            {
                throw new InvalidOperationException(
                          string.Format("BocList '{0}': Could not switch newly added row into edit mode.", _editModeHost.ID));
            }
            _isEditNewRow = true;
            return(true);
        }
Ejemplo n.º 5
0
        public void SwitchListIntoEditMode(BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            if (_editModeHost.Value == null)
            {
                throw new InvalidOperationException(
                          string.Format("Cannot initialize list edit mode: The BocList '{0}' does not have a Value.", _editModeHost.ID));
            }

            RestoreAndEndEditMode(columns);

            if (_editModeHost.IsReadOnly || IsRowEditModeActive || IsListEditModeActive)
            {
                return;
            }

            _editedRowIDs =
                _editModeHost.Value.Cast <IBusinessObject>().Select((o, i) => _editModeHost.RowIDProvider.GetItemRowID(new BocListRow(i, o))).ToList();
            _editMode = EditMode.ListEditMode;
            CreateEditModeControls(columns);
            if (_rows.Any())
            {
                SetFocus(_rows.First());
            }
            LoadValues(false);
        }
Ejemplo n.º 6
0
        public void RemoveRows(IBusinessObject[] businessObjects)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("businessObjects", businessObjects);

            var bocListRows = _editModeHost.RemoveRows(businessObjects);

            if (_editModeHost.Value != null)
            {
                if (IsRowEditModeActive)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "Cannot remove rows while the BocList '{0}' is in row edit mode. Call EndEditMode() before removing the rows.",
                                  _editModeHost.ID));
                }
                else if (IsListEditModeActive)
                {
                    foreach (var row in bocListRows.OrderByDescending(r => r.Index))
                    {
                        RemoveRowFromDataStructure(row.Index);
                        _editedRowIDs.RemoveAt(row.Index);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public BocListRow[] AddRows(IBusinessObject[] businessObjects, BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("businessObjects", businessObjects);
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            var bocListRows = _editModeHost.AddRows(businessObjects);

            if (_editModeHost.Value != null)
            {
                EnsureEditModeRestored(columns);
                if (IsListEditModeActive)
                {
                    var newRows = new List <EditableRow>();
                    foreach (var bocListRow in bocListRows.OrderBy(r => r.Index))
                    {
                        var newRow = AddRowToDataStructure(bocListRow, columns);
                        _editedRowIDs.Add(_editModeHost.RowIDProvider.GetItemRowID(bocListRow));
                        newRow.GetDataSource().LoadValues(false);
                        newRows.Add(newRow);
                    }
                    if (newRows.Any())
                    {
                        SetFocus(newRows.First());
                    }
                }
            }

            return(bocListRows);
        }
Ejemplo n.º 8
0
        public AccessInformation(AccessTypeDefinition[] allowedAccessTypes, AccessTypeDefinition[] deniedAccessTypes)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("allowedAccessTypes", allowedAccessTypes);
            ArgumentUtility.CheckNotNullOrItemsNull("deniedAccessTypes", deniedAccessTypes);

            _allowedAccessTypes = allowedAccessTypes;
            _deniedAccessTypes  = deniedAccessTypes;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates an <see cref="IPipeline"/> with the given participant configuration ID containing the specified participants.
        /// </summary>
        /// <remarks>
        /// <see cref="IPipeline"/> instances with equal participant configuration IDs must generate equivalent types.
        /// </remarks>
        /// <param name="pipelineFactory">The <see cref="IPipelineFactory"/> to use for creation. Usually retrieved from the application's IoC container.</param>
        /// <param name="participantConfigurationID">The participant configuration ID.</param>
        /// <param name="participants">The participants that should be used by this object factory.</param>
        /// <returns>An new instance of <see cref="IPipeline"/>.</returns>
        public static IPipeline Create(this IPipelineFactory pipelineFactory, string participantConfigurationID, params IParticipant[] participants)
        {
            ArgumentUtility.CheckNotNull("pipelineFactory", pipelineFactory);
            ArgumentUtility.CheckNotNullOrEmpty("participantConfigurationID", participantConfigurationID);
            ArgumentUtility.CheckNotNullOrItemsNull("participants", participants);

            return(pipelineFactory.Create(participantConfigurationID, PipelineSettings.Defaults, participants));
        }
        public LocalizingMetadataConverter(IMetadataLocalizationConverter localizationConverter, CultureInfo[] cultures)
        {
            ArgumentUtility.CheckNotNull("localizationConverter", localizationConverter);
            ArgumentUtility.CheckNotNullOrItemsNull("cultures", cultures);

            _localizationConverter = localizationConverter;
            _cultures = cultures;
        }
Ejemplo n.º 11
0
        public BocListSortingOrderChangeEventArgs(
            BocListSortingOrderEntry[] oldSortingOrder, BocListSortingOrderEntry[] newSortingOrder)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("oldSortingOrder", oldSortingOrder);
            ArgumentUtility.CheckNotNullOrItemsNull("newSortingOrder", newSortingOrder);

            _oldSortingOrder = oldSortingOrder;
            _newSortingOrder = newSortingOrder;
        }
        public WxeVariablesContainer(WxeFunction function, object[] actualParameters, WxeParameterDeclaration[] parameterDeclarations)
        {
            ArgumentUtility.CheckNotNull("function", function);
            ArgumentUtility.CheckNotNull("actualParameters", actualParameters);
            ArgumentUtility.CheckNotNullOrItemsNull("parameterDeclarations", parameterDeclarations);

            _function              = function;
            _variables             = new NameObjectCollection();
            _parameterDeclarations = parameterDeclarations;
            _actualParameters      = actualParameters;
        }
Ejemplo n.º 13
0
        public bool MatchesStates(IList <StateDefinition> states)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("states", states);

            if (StateUsages.Count == 0 && states.Count > 0)
            {
                return(false);
            }

            return(StateUsages.Select(stateUsage => stateUsage.StateDefinition).All(usedState => states.Contains(usedState)));
        }
Ejemplo n.º 14
0
        public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("typeArguments", typeArguments);

            if (!IsGenericMethodDefinition)
            {
                throw new InvalidOperationException("MakeGenericMethod can only be called on generic method definitions (IsGenericMethodDefinition must be true).");
            }

            return(this.MakeTypePipeGenericMethod(typeArguments));
        }
Ejemplo n.º 15
0
        protected virtual XmlSchemaSet GetSchemas(SchemaLoaderBase[] schemas)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("schemas", schemas);

            XmlSchemaSet schemaSet = new XmlSchemaSet();

            foreach (SchemaLoaderBase schema in schemas)
            {
                schemaSet.Add(schema.LoadSchemaSet());
            }
            return(schemaSet);
        }
Ejemplo n.º 16
0
        public int AddRow(IBusinessObject businessObject, BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            var bocListRows = AddRows(new[] { businessObject }, columns);

            if (bocListRows.Length == 0)
            {
                return(-1);
            }
            return(bocListRows.Single().Index);
        }
Ejemplo n.º 17
0
        private AssemblyCompiler(string sourceDirectory, params string[] referencedAssemblies)
        {
            ArgumentUtility.CheckNotNullOrEmpty("sourceDirectory", sourceDirectory);
            ArgumentUtility.CheckNotNullOrItemsNull("referencedAssemblies", referencedAssemblies);

            _sourceDirectory = sourceDirectory;

            _compilerParameters = new CompilerParameters();
            _compilerParameters.GenerateExecutable    = false;
            _compilerParameters.OutputAssembly        = null;
            _compilerParameters.GenerateInMemory      = true;
            _compilerParameters.TreatWarningsAsErrors = false;
            _compilerParameters.ReferencedAssemblies.AddRange(referencedAssemblies);
        }
        /// <summary> Sorts the <paramref name="menuItems"/> by their categories." </summary>
        /// <param name="menuItems"> Must not be <see langword="null"/> or contain items that are <see langword="null"/>. </param>
        /// <param name="generateSeparators"> <see langword="true"/> to generate a separator before starting a new category. </param>
        /// <returns> The <paramref name="menuItems"/>, sorted by their categories. </returns>
        public static WebMenuItem[] GroupMenuItems(WebMenuItem[] menuItems, bool generateSeparators)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("menuItems", menuItems);

            //  <string category, ArrayList menuItems>
            NameObjectCollection groupedMenuItems = new NameObjectCollection();
            ArrayList            categories       = new ArrayList();

            for (int i = 0; i < menuItems.Length; i++)
            {
                WebMenuItem menuItem = menuItems[i];

                string    category = menuItem.Category ?? string.Empty;
                ArrayList menuItemsForCategory;
                if (groupedMenuItems.Contains(category))
                {
                    menuItemsForCategory = (ArrayList)groupedMenuItems[category];
                }
                else
                {
                    menuItemsForCategory = new ArrayList();
                    groupedMenuItems.Add(category, menuItemsForCategory);
                    categories.Add(category);
                }
                menuItemsForCategory.Add(menuItem);
            }

            ArrayList arrayList = new ArrayList();
            bool      isFirst   = true;

            for (int i = 0; i < categories.Count; i++)
            {
                string category = (string)categories[i];
                if (generateSeparators)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        arrayList.Add(WebMenuItem.GetSeparator());
                    }
                }
                arrayList.AddRange((ArrayList)groupedMenuItems[category]);
            }
            return((WebMenuItem[])arrayList.ToArray(typeof(WebMenuItem)));
        }
Ejemplo n.º 19
0
        /// <summary> Creates a new instance. </summary>
        /// <param name="ownerControl"> Owner control. </param>
        /// <param name="supportedTypes">
        ///   Supported types must implement <see cref="IControlItem"/>.
        ///   Must not be <see langword="null"/> or contain items that are <see langword="null"/>.
        /// </param>
        public ControlItemCollection(IControl ownerControl, Type[] supportedTypes)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("supportedTypes", supportedTypes);
            for (int i = 0; i < supportedTypes.Length; i++)
            {
                Type type = supportedTypes[i];
                if (!typeof(IControlItem).IsAssignableFrom(type))
                {
                    throw new ArgumentException(
                              string.Format("Type '{0}' at index {1} does not implement interface 'IControlItem'.", type.FullName, i), "supportedTypes");
                }
            }

            _ownerControl   = ownerControl;
            _supportedTypes = supportedTypes;
        }
Ejemplo n.º 20
0
        public virtual void CreateControls(IBusinessObject value, BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            if (_dataSourceFactory == null)
            {
                throw new InvalidOperationException(
                          string.Format("BocList '{0}': DataSourceFactory has not been set prior to invoking CreateControls().", _editModeHost.ID));
            }

            if (_controlFactory == null)
            {
                throw new InvalidOperationException(
                          string.Format("BocList '{0}': ControlFactory has not been set prior to invoking CreateControls().", _editModeHost.ID));
            }

            CreatePlaceHolders(columns);

            _dataSource = _dataSourceFactory.Create(value);

            _rowEditModeControls = new IBusinessObjectBoundEditableWebControl[columns.Length];

            for (int idxColumns = 0; idxColumns < columns.Length; idxColumns++)
            {
                BocSimpleColumnDefinition simpleColumn = columns[idxColumns] as BocSimpleColumnDefinition;

                if (IsColumnEditable(simpleColumn))
                {
                    IBusinessObjectBoundEditableWebControl control = _controlFactory.Create(simpleColumn, idxColumns);

                    if (control != null)
                    {
                        control.ID         = idxColumns.ToString();
                        control.DataSource = _dataSource;
                        IBusinessObjectPropertyPath propertyPath = simpleColumn.GetPropertyPath();
                        control.Property = propertyPath.Properties[0];
                        SetEditControl(idxColumns, control);

                        _rowEditModeControls[idxColumns] = control;
                    }
                }
            }
            _isRowEditModeValidatorsRestored = false;
        }
        public XmlDocument Convert(LocalizedName[] localizedNames, string culture)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("localizedNames", localizedNames);
            ArgumentUtility.CheckNotNull("culture", culture);

            XmlDocument document = new XmlDocument();

            if (!document.Schemas.Contains(_schema.SchemaUri))
            {
                document.Schemas.Add(_schema.LoadSchemaSet());
            }

            XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", string.Empty, string.Empty);

            document.AppendChild(declaration);

            XmlElement   rootElement      = document.CreateElement("localizedNames", _schema.SchemaUri);
            XmlAttribute cultureAttribute = document.CreateAttribute("culture");

            cultureAttribute.Value = culture;
            rootElement.Attributes.Append(cultureAttribute);

            foreach (LocalizedName localizedName in localizedNames)
            {
                XmlElement localizedNameElement = document.CreateElement("localizedName", _schema.SchemaUri);

                XmlAttribute refAttribute = document.CreateAttribute("ref");
                refAttribute.Value = localizedName.ReferencedObjectID;
                XmlAttribute commentAttribute = document.CreateAttribute("comment");
                commentAttribute.Value = localizedName.Comment;
                XmlText text = document.CreateTextNode("\r\n    " + localizedName.Text + "\r\n  ");

                localizedNameElement.Attributes.Append(refAttribute);
                localizedNameElement.Attributes.Append(commentAttribute);
                localizedNameElement.AppendChild(text);

                rootElement.AppendChild(localizedNameElement);
            }

            document.AppendChild(rootElement);

            return(document);
        }
Ejemplo n.º 22
0
        public MethodWrapperEmitter(ILGenerator ilGenerator, MethodInfo wrappedMethod, Type[] wrapperParameterTypes, Type wrapperReturnType)
        {
            ArgumentUtility.CheckNotNull("ilGenerator", ilGenerator);
            ArgumentUtility.CheckNotNull("wrappedMethod", wrappedMethod);
            ArgumentUtility.CheckNotNullOrItemsNull("wrapperParameterTypes", wrapperParameterTypes);
            ArgumentUtility.CheckNotNull("wrapperReturnType", wrapperReturnType);
            if (wrappedMethod.ContainsGenericParameters)
            {
                throw new ArgumentException("Open generic method definitions are not supported by the MethodWrapperGenerator.", "wrappedMethod");
            }
            CheckParameterCount(wrappedMethod, wrapperParameterTypes);
            CheckInstanceParameterType(wrappedMethod, wrapperParameterTypes);
            CheckParameterTypes(wrappedMethod, wrapperParameterTypes);
            CheckReturnTypes(wrappedMethod, wrapperReturnType);

            _ilGenerator           = ilGenerator;
            _wrappedMethod         = wrappedMethod;
            _wrapperParameterTypes = wrapperParameterTypes;
            _wrapperReturnType     = wrapperReturnType;
        }
Ejemplo n.º 23
0
        public void EnsureEditModeRestored(BocColumnDefinition[] columns)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("columns", columns);

            if (_isEditModeRestored)
            {
                return;
            }
            _isEditModeRestored = true;

            if (IsRowEditModeActive || IsListEditModeActive)
            {
                if (_editModeHost.Value == null)
                {
                    throw new InvalidOperationException(
                              string.Format("Cannot restore edit mode: The BocList '{0}' does not have a Value.", _editModeHost.ID));
                }
                CreateEditModeControls(columns);
                LoadValues(true);
            }
        }
Ejemplo n.º 24
0
        public ForwardingProxyBuilder(string name, ModuleScope moduleScope, Type proxiedType, Type[] interfaces)
        {
            ArgumentUtility.CheckNotNullOrEmpty("name", name);
            ArgumentUtility.CheckNotNull("moduleScope", moduleScope);
            ArgumentUtility.CheckNotNull("proxiedType", proxiedType);
            ArgumentUtility.CheckNotNullOrItemsNull("interfaces", interfaces);

            _proxiedType  = proxiedType;
            _classEmitter = CreateClassEmitter(name, interfaces, moduleScope);
            _proxied      = CreateProxiedField();
            CreateProxyCtor(proxiedType);

            _classEmitter.TypeBuilder.AddInterfaceImplementation(typeof(IProxy));

            var setProxiedMethod = _classEmitter.CreateInterfaceMethodImplementation(
                typeof(IProxy).GetMethod("SetProxied", _declaredInstanceBindingFlags));
            var arg = setProxiedMethod.ArgumentReferences[0];
            var argAsProxiedType = new ConvertExpression(proxiedType, arg.ToExpression());

            setProxiedMethod.AddStatement(new AssignStatement(_proxied, argAsProxiedType));
            setProxiedMethod.AddStatement(new ReturnStatement());
        }
        /// <summary>Tests whether the <paramref name="property"/>'s type is part of the <paramref name="supportedPropertyInterfaces"/> array.</summary>
        /// <param name="property">The <see cref="IBusinessObjectProperty"/> to be tested. Must not be <see langword="null"/>.</param>
        /// <param name="supportedPropertyInterfaces">
        ///   The list of interfaces to test the <paramref name="property"/> against. Use <see langword="null"/> if no restrictions are made. Items must
        ///   not be <see langword="null"/>.
        /// </param>
        /// <returns>
        ///   <see langword="true"/> if the <paramref name="property"/>'s type is found in the <paramref name="supportedPropertyInterfaces"/> array.
        /// </returns>
        public bool IsPropertyInterfaceSupported(IBusinessObjectProperty property, Type[] supportedPropertyInterfaces)
        {
            ArgumentUtility.CheckNotNull("property", property);
            if (supportedPropertyInterfaces == null)
            {
                return(true);
            }
            ArgumentUtility.CheckNotNullOrItemsNull("supportedPropertyInterfaces", supportedPropertyInterfaces);

            bool isSupportedPropertyInterface = false;

            for (int i = 0; i < supportedPropertyInterfaces.Length; i++)
            {
                Type supportedInterface = supportedPropertyInterfaces[i];
                if (supportedInterface.IsAssignableFrom(property.GetType()))
                {
                    isSupportedPropertyInterface = true;
                    break;
                }
            }
            return(isSupportedPropertyInterface);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Substitutes the type parameters of the generic type definition and returns a <see cref="MethodInfo"/> object representing the resulting
        /// constructed method. Use this as a replacement for <see cref="MethodInfo.MakeGenericMethod"/>.
        /// </summary>
        /// <param name="genericMethodDefinition">The generic method definition.</param>
        /// <param name="typeArguments">The type arguments.</param>
        /// <returns>The generic method instantiation.</returns>
        public static MethodInfo MakeTypePipeGenericMethod(this MethodInfo genericMethodDefinition, params Type[] typeArguments)
        {
            ArgumentUtility.CheckNotNull("genericMethodDefinition", genericMethodDefinition);
            ArgumentUtility.CheckNotNullOrItemsNull("typeArguments", typeArguments);

            if (!genericMethodDefinition.IsGenericMethodDefinition)
            {
                var message = string.Format(
                    "'{0}' is not a generic method definition. MakeTypePipeGenericMethod may only be called on a method for which "
                    + "MethodInfo.IsGenericMethodDefinition is true.",
                    genericMethodDefinition.Name);
                throw new InvalidOperationException(message);
            }

            var typeParameters = genericMethodDefinition.GetGenericArguments();

            GenericArgumentUtility.ValidateGenericArguments(typeParameters, typeArguments, genericMethodDefinition.Name);

            var instantiationInfo = new MethodInstantiationInfo(genericMethodDefinition, typeArguments);

            return(instantiationInfo.Instantiate());
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Substitutes the type parameters of the generic type definition and returns a <see cref="Type"/> object representing the resulting
        /// constructed generic type. Use this as a replacement for <see cref="Type.MakeGenericType"/>.
        /// </summary>
        /// <param name="genericTypeDefinition">The generic type definition.</param>
        /// <param name="typeArguments">The type arguments.</param>
        /// <returns>The generic type instantiation.</returns>
        public static Type MakeTypePipeGenericType(this Type genericTypeDefinition, params Type[] typeArguments)
        {
            ArgumentUtility.CheckNotNull("typeArguments", typeArguments);
            ArgumentUtility.CheckNotNullOrItemsNull("typeArguments", typeArguments);

            if (!genericTypeDefinition.IsGenericTypeDefinition)
            {
                var message = string.Format(
                    "'{0}' is not a generic type definition. {1} may only be called on a type for which Type.IsGenericTypeDefinition is true.",
                    genericTypeDefinition.Name,
                    MethodInfo.GetCurrentMethod().Name);
                throw new InvalidOperationException(message);
            }

            var typeParameters = genericTypeDefinition.GetGenericArguments();

            GenericArgumentUtility.ValidateGenericArguments(typeParameters, typeArguments, genericTypeDefinition.Name);

            var instantiationContext = new TypeInstantiationContext();
            var instantiationInfo    = new TypeInstantiationInfo(genericTypeDefinition, typeArguments);

            return(instantiationContext.Instantiate(instantiationInfo));
        }
        /// <summary>
        ///   Converts a list of parameter values into a <see cref="NameValueCollection"/>.
        /// </summary>
        /// <param name="parameterDeclarations">
        ///  The <see cref="WxeParameterDeclaration"/> list used for serializing the <paramref name="parameterValues"/>.
        ///  Must not be <see langword="null"/> or contain items that are <see langword="null"/>.
        /// </param>
        /// <param name="parameterValues">
        ///   The list parameter values. Must not be <see langword="null"/>.
        /// </param>
        /// <returns>
        ///   A <see cref="NameValueCollection"/> containing the serialized <paramref name="parameterValues"/>.
        ///   The names of the parameters are used as keys.
        /// </returns>
        public static NameValueCollection SerializeParametersForQueryString(WxeParameterDeclaration[] parameterDeclarations, object[] parameterValues)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("parameterDeclarations", parameterDeclarations);
            ArgumentUtility.CheckNotNull("parameterValues", parameterValues);

            NameValueCollection serializedParameters = new NameValueCollection();

            for (int i = 0; i < parameterDeclarations.Length; i++)
            {
                WxeParameterDeclaration parameterDeclaration = parameterDeclarations[i];
                object parameterValue = null;
                if (i < parameterValues.Length)
                {
                    parameterValue = parameterValues[i];
                }
                string serializedValue = parameterDeclaration.Converter.ConvertToString(parameterValue, null);
                if (serializedValue != null)
                {
                    serializedParameters.Add(parameterDeclaration.Name, serializedValue);
                }
            }
            return(serializedParameters);
        }
Ejemplo n.º 29
0
 public void Fail_zItemNullIEnumerable()
 {
     ArgumentUtility.CheckNotNullOrItemsNull("arg", GetEnumerableWithNullValue());
 }
Ejemplo n.º 30
0
 public void Fail_NullICollection()
 {
     ArgumentUtility.CheckNotNullOrItemsNull("arg", (ICollection)null);
 }