Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Base / Interaction / Model / ModelFactory.cs / 1305376 / ModelFactory.cs
namespace System.Activities.Presentation.Model {
using System.Activities.Presentation.Services;
using System.Activities.Presentation;
using System;
///
/// The ModelFactory class should be used to create instances
/// of items in the designer. ModelFactory is designed to be
/// a static API for convenience. The underlying implementation
/// of this API simply calls through to the ModelService’s
/// CreateItem method.
///
public static class ModelFactory {
///
/// Creates a new item for the given item type.
///
///
/// The designer's editing context.
///
///
/// The type of item to create.
///
///
/// An optional array of arguments that should be passed to the constructor of the item.
///
///
/// The newly created item type.
///
/// if itemType or context is null.
/// if there is no editing model in the context that can create new items.
public static ModelItem CreateItem(EditingContext context, Type itemType, params object[] arguments) {
return CreateItem(context, itemType, CreateOptions.None, arguments);
}
///
/// Creates a new item for the given item type.
///
///
/// The designer's editing context.
///
///
/// The type of item to create.
///
///
/// A set of create options to use when creating the item. The default value is CreateOptions.None.
///
///
/// An optional array of arguments that should be passed to the constructor of the item.
///
///
/// The newly created item type.
///
/// if itemType or context is null.
/// if there is no editing model in the context that can create new items.
public static ModelItem CreateItem(EditingContext context, Type itemType, CreateOptions options, params object[] arguments) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (itemType == null) throw FxTrace.Exception.ArgumentNull("itemType");
if (!EnumValidator.IsValid(options)) throw FxTrace.Exception.AsError(new ArgumentOutOfRangeException("options"));
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateItem(itemType, options, arguments);
}
///
/// Creates a new model item by creating a deep copy of the isntance provided.
///
///
/// The designer's editing context.
///
///
/// The item to clone.
///
///
/// The newly created item.
///
public static ModelItem CreateItem(EditingContext context, object item) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (item == null) throw FxTrace.Exception.ArgumentNull("item");
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateItem(item);
}
///
/// Create a new model item that represents a the value of a static member of a the given class.
/// For example, to add a reference to Brushes.Red to the model call this methods with
/// typeof(Brushes) and the string "Red". This will be serialized into XAML as
/// {x:Static Brushes.Red}.
///
///
/// The designer's editing context.
///
///
/// The type that contains the static member being referenced.
///
///
/// The name of the static member being referenced.
///
///
public static ModelItem CreateStaticMemberItem(EditingContext context, Type type, string memberName) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (type == null) throw FxTrace.Exception.ArgumentNull("type");
if (memberName == null) throw FxTrace.Exception.ArgumentNull("memberName");
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateStaticMemberItem(type, memberName);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
namespace System.Activities.Presentation.Model {
using System.Activities.Presentation.Services;
using System.Activities.Presentation;
using System;
///
/// The ModelFactory class should be used to create instances
/// of items in the designer. ModelFactory is designed to be
/// a static API for convenience. The underlying implementation
/// of this API simply calls through to the ModelService’s
/// CreateItem method.
///
public static class ModelFactory {
///
/// Creates a new item for the given item type.
///
///
/// The designer's editing context.
///
///
/// The type of item to create.
///
///
/// An optional array of arguments that should be passed to the constructor of the item.
///
///
/// The newly created item type.
///
/// if itemType or context is null.
/// if there is no editing model in the context that can create new items.
public static ModelItem CreateItem(EditingContext context, Type itemType, params object[] arguments) {
return CreateItem(context, itemType, CreateOptions.None, arguments);
}
///
/// Creates a new item for the given item type.
///
///
/// The designer's editing context.
///
///
/// The type of item to create.
///
///
/// A set of create options to use when creating the item. The default value is CreateOptions.None.
///
///
/// An optional array of arguments that should be passed to the constructor of the item.
///
///
/// The newly created item type.
///
/// if itemType or context is null.
/// if there is no editing model in the context that can create new items.
public static ModelItem CreateItem(EditingContext context, Type itemType, CreateOptions options, params object[] arguments) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (itemType == null) throw FxTrace.Exception.ArgumentNull("itemType");
if (!EnumValidator.IsValid(options)) throw FxTrace.Exception.AsError(new ArgumentOutOfRangeException("options"));
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateItem(itemType, options, arguments);
}
///
/// Creates a new model item by creating a deep copy of the isntance provided.
///
///
/// The designer's editing context.
///
///
/// The item to clone.
///
///
/// The newly created item.
///
public static ModelItem CreateItem(EditingContext context, object item) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (item == null) throw FxTrace.Exception.ArgumentNull("item");
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateItem(item);
}
///
/// Create a new model item that represents a the value of a static member of a the given class.
/// For example, to add a reference to Brushes.Red to the model call this methods with
/// typeof(Brushes) and the string "Red". This will be serialized into XAML as
/// {x:Static Brushes.Red}.
///
///
/// The designer's editing context.
///
///
/// The type that contains the static member being referenced.
///
///
/// The name of the static member being referenced.
///
///
public static ModelItem CreateStaticMemberItem(EditingContext context, Type type, string memberName) {
if (context == null) throw FxTrace.Exception.ArgumentNull("context");
if (type == null) throw FxTrace.Exception.ArgumentNull("type");
if (memberName == null) throw FxTrace.Exception.ArgumentNull("memberName");
ModelService ms = context.Services.GetRequiredService();
return ms.InvokeCreateStaticMemberItem(type, memberName);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ScrollProperties.cs
- CollectionViewGroupInternal.cs
- ListSortDescriptionCollection.cs
- WpfWebRequestHelper.cs
- Int32Converter.cs
- InterleavedZipPartStream.cs
- NoneExcludedImageIndexConverter.cs
- ScriptingAuthenticationServiceSection.cs
- SoapParser.cs
- Frame.cs
- PublisherIdentityPermission.cs
- JsonWriter.cs
- ScaleTransform3D.cs
- WinInetCache.cs
- CustomError.cs
- BitConverter.cs
- SQLDecimalStorage.cs
- SimpleHandlerBuildProvider.cs
- HttpCachePolicy.cs
- BinaryMessageFormatter.cs
- DetailsViewDeletedEventArgs.cs
- CodeGotoStatement.cs
- PassportAuthenticationModule.cs
- ThreadAbortException.cs
- Constants.cs
- JsonReaderWriterFactory.cs
- ProgressBarRenderer.cs
- BeginStoryboard.cs
- sqlpipe.cs
- JsonWriter.cs
- ToolStripItemTextRenderEventArgs.cs
- ObjectReferenceStack.cs
- MetadataArtifactLoaderResource.cs
- PropertyIDSet.cs
- ModelTreeEnumerator.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- Profiler.cs
- ListViewItem.cs
- MatrixStack.cs
- BridgeDataReader.cs
- _emptywebproxy.cs
- LineUtil.cs
- SqlCacheDependency.cs
- ReadOnlyActivityGlyph.cs
- SecurityTokenValidationException.cs
- SchemaInfo.cs
- BoolLiteral.cs
- EntityPropertyMappingAttribute.cs
- ThemeDictionaryExtension.cs
- ResourceDictionaryCollection.cs
- DeclarationUpdate.cs
- DataGridViewRowConverter.cs
- EdgeProfileValidation.cs
- TypeDelegator.cs
- CursorConverter.cs
- SystemColors.cs
- HashMembershipCondition.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- SliderAutomationPeer.cs
- WSHttpBindingBase.cs
- UInt32.cs
- DoubleAnimation.cs
- EnumBuilder.cs
- RotateTransform.cs
- UITypeEditor.cs
- StrokeSerializer.cs
- Expander.cs
- DbQueryCommandTree.cs
- HtmlImageAdapter.cs
- ConstrainedDataObject.cs
- ADRoleFactory.cs
- httpstaticobjectscollection.cs
- Compiler.cs
- XmlSchemaAnnotation.cs
- XXXInfos.cs
- ObjectDataSourceView.cs
- ClientConfigPaths.cs
- Font.cs
- Parameter.cs
- _HeaderInfoTable.cs
- ScrollItemProviderWrapper.cs
- ClientCredentialsSecurityTokenManager.cs
- AlphabetConverter.cs
- DbConnectionHelper.cs
- Scheduler.cs
- InfoCardSymmetricAlgorithm.cs
- AmbientLight.cs
- WorkflowFileItem.cs
- SrgsText.cs
- UnknownBitmapDecoder.cs
- WindowsFormsSynchronizationContext.cs
- EventProviderClassic.cs
- LongTypeConverter.cs
- ProfileGroupSettingsCollection.cs
- ServerValidateEventArgs.cs
- CharConverter.cs
- ListDataBindEventArgs.cs
- StylusEditingBehavior.cs
- Error.cs
- ListViewEditEventArgs.cs