Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / XamlInterfaces.cs / 1305376 / XamlInterfaces.cs
using System; using System.Collections; using System.Workflow.ComponentModel.Compiler; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Workflow.ComponentModel.Serialization; using System.ComponentModel.Design; using System.Xml; using System.Diagnostics; using System.Collections.Generic; namespace System.Workflow.ComponentModel.Serialization { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class XmlnsDefinitionAttribute : Attribute { public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace) { if (xmlNamespace == null) throw new ArgumentNullException("xmlNamespace"); if (clrNamespace == null) throw new ArgumentNullException("clrNamespace"); this.xmlNamespace = xmlNamespace; this.clrNamespace = clrNamespace; } public string XmlNamespace { get { return this.xmlNamespace; } } public string ClrNamespace { get { return this.clrNamespace; } } public string AssemblyName { get { return this.assemblyName; } set { this.assemblyName = value; } } private string xmlNamespace; private string clrNamespace; private string assemblyName; } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class XmlnsPrefixAttribute : Attribute { private string xmlNamespace; private string prefix; public XmlnsPrefixAttribute(string xmlNamespace, string prefix) { if (xmlNamespace == null) throw new ArgumentNullException("xmlNamespace"); if (prefix == null) throw new ArgumentNullException("prefix"); this.xmlNamespace = xmlNamespace; this.prefix = prefix; } public string XmlNamespace { get { return this.xmlNamespace; } } public string Prefix { get { return this.prefix; } } } [AttributeUsage(AttributeTargets.Class)] public sealed class RuntimeNamePropertyAttribute : Attribute { private string name = null; public RuntimeNamePropertyAttribute(string name) { this.name = name; } public string Name { get { return this.name; } } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class ContentPropertyAttribute : Attribute { private string name; public ContentPropertyAttribute(){} public ContentPropertyAttribute(string name) { this.name = name; } public string Name { get { return this.name; } } } [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public sealed class ConstructorArgumentAttribute : Attribute { private string argumentName; public ConstructorArgumentAttribute(string argumentName) { this.argumentName = argumentName; } public string ArgumentName { get { return this.argumentName; } } } public abstract class MarkupExtension { public abstract object ProvideValue(IServiceProvider provider); } [DesignerSerializer(typeof(MarkupExtensionSerializer), typeof(WorkflowMarkupSerializer))] internal sealed class NullExtension : MarkupExtension { public NullExtension(){} public override object ProvideValue(IServiceProvider serviceProvider) { return null; } } [DesignerSerializer(typeof(TypeExtensionSerializer), typeof(WorkflowMarkupSerializer))] internal sealed class TypeExtension : MarkupExtension { private string typeName; private Type type; public TypeExtension(){} public TypeExtension(string type) { if (type == null) throw new ArgumentNullException("typeName"); this.typeName = type; } public TypeExtension(Type type) { if (type == null) throw new ArgumentNullException("type"); this.type = type; } public override object ProvideValue(IServiceProvider provider) { if (this.type != null) return this.type; if (provider == null) throw new ArgumentNullException("provider"); if (this.typeName == null) throw new InvalidOperationException("typename"); WorkflowMarkupSerializationManager manager = provider as WorkflowMarkupSerializationManager; if (manager == null) throw new ArgumentNullException("provider"); XmlReader reader = manager.WorkflowMarkupStack[typeof(XmlReader)] as XmlReader; if (reader == null) { Debug.Assert(false); return this.typeName; } string typename = this.typeName.Trim(); string prefix = String.Empty; int typeIndex = typename.IndexOf(':'); if (typeIndex >= 0) { prefix = typename.Substring(0, typeIndex); typename = typename.Substring(typeIndex + 1); type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(prefix))); if (type != null) return type; // To Support types whose assembly is not available, we need to still resolve the clr namespace ListxmlnsMappings = null; if (manager.XmlNamespaceBasedMappings.TryGetValue(reader.LookupNamespace(prefix), out xmlnsMappings) && xmlnsMappings != null && xmlnsMappings.Count > 0) return xmlnsMappings[0].ClrNamespace + "." + typename; else return typename; } type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(string.Empty))); // To Support Beta2 format if (type == null) { ITypeProvider typeProvider = provider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) type = typeProvider.GetType(typename); // If not design mode, get the value from serialization manager // At design time, we need to get the type from ITypeProvider else // we need to store the string in the hashtable we maintain internally if (type == null && manager.GetService(typeof(ITypeResolutionService)) == null) type = manager.SerializationManager.GetType(typename); } if (type != null) return type; return this.typeName; } [DefaultValue(null)] [ConstructorArgument("type")] public string TypeName { get { if (this.type != null) return this.type.FullName; return this.typeName; } set { if (value == null) throw new ArgumentNullException("value"); this.typeName = value; } } internal Type Type { get { return this.type; } } } [ContentProperty("Items")] internal sealed class ArrayExtension : MarkupExtension { private ArrayList arrayElementList = new ArrayList(); private Type arrayType; public ArrayExtension() { } public ArrayExtension(Type arrayType) { if (arrayType == null) throw new ArgumentNullException("arrayType"); this.arrayType = arrayType; } public ArrayExtension(Array elements) { if (elements == null) throw new ArgumentNullException("elements"); arrayElementList.AddRange(elements); this.arrayType = elements.GetType().GetElementType(); } // public Type Type { get { return this.arrayType; } set { this.arrayType = value; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public IList Items { get { return arrayElementList; } } public override object ProvideValue(IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); if (this.arrayType == null) throw new InvalidOperationException("ArrayType needs to be set."); object retArray = null; try { retArray = arrayElementList.ToArray(this.arrayType); } catch (System.InvalidCastException) { // throw new InvalidOperationException(); } return retArray; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections; using System.Workflow.ComponentModel.Compiler; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Workflow.ComponentModel.Serialization; using System.ComponentModel.Design; using System.Xml; using System.Diagnostics; using System.Collections.Generic; namespace System.Workflow.ComponentModel.Serialization { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class XmlnsDefinitionAttribute : Attribute { public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace) { if (xmlNamespace == null) throw new ArgumentNullException("xmlNamespace"); if (clrNamespace == null) throw new ArgumentNullException("clrNamespace"); this.xmlNamespace = xmlNamespace; this.clrNamespace = clrNamespace; } public string XmlNamespace { get { return this.xmlNamespace; } } public string ClrNamespace { get { return this.clrNamespace; } } public string AssemblyName { get { return this.assemblyName; } set { this.assemblyName = value; } } private string xmlNamespace; private string clrNamespace; private string assemblyName; } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class XmlnsPrefixAttribute : Attribute { private string xmlNamespace; private string prefix; public XmlnsPrefixAttribute(string xmlNamespace, string prefix) { if (xmlNamespace == null) throw new ArgumentNullException("xmlNamespace"); if (prefix == null) throw new ArgumentNullException("prefix"); this.xmlNamespace = xmlNamespace; this.prefix = prefix; } public string XmlNamespace { get { return this.xmlNamespace; } } public string Prefix { get { return this.prefix; } } } [AttributeUsage(AttributeTargets.Class)] public sealed class RuntimeNamePropertyAttribute : Attribute { private string name = null; public RuntimeNamePropertyAttribute(string name) { this.name = name; } public string Name { get { return this.name; } } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class ContentPropertyAttribute : Attribute { private string name; public ContentPropertyAttribute(){} public ContentPropertyAttribute(string name) { this.name = name; } public string Name { get { return this.name; } } } [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public sealed class ConstructorArgumentAttribute : Attribute { private string argumentName; public ConstructorArgumentAttribute(string argumentName) { this.argumentName = argumentName; } public string ArgumentName { get { return this.argumentName; } } } public abstract class MarkupExtension { public abstract object ProvideValue(IServiceProvider provider); } [DesignerSerializer(typeof(MarkupExtensionSerializer), typeof(WorkflowMarkupSerializer))] internal sealed class NullExtension : MarkupExtension { public NullExtension(){} public override object ProvideValue(IServiceProvider serviceProvider) { return null; } } [DesignerSerializer(typeof(TypeExtensionSerializer), typeof(WorkflowMarkupSerializer))] internal sealed class TypeExtension : MarkupExtension { private string typeName; private Type type; public TypeExtension(){} public TypeExtension(string type) { if (type == null) throw new ArgumentNullException("typeName"); this.typeName = type; } public TypeExtension(Type type) { if (type == null) throw new ArgumentNullException("type"); this.type = type; } public override object ProvideValue(IServiceProvider provider) { if (this.type != null) return this.type; if (provider == null) throw new ArgumentNullException("provider"); if (this.typeName == null) throw new InvalidOperationException("typename"); WorkflowMarkupSerializationManager manager = provider as WorkflowMarkupSerializationManager; if (manager == null) throw new ArgumentNullException("provider"); XmlReader reader = manager.WorkflowMarkupStack[typeof(XmlReader)] as XmlReader; if (reader == null) { Debug.Assert(false); return this.typeName; } string typename = this.typeName.Trim(); string prefix = String.Empty; int typeIndex = typename.IndexOf(':'); if (typeIndex >= 0) { prefix = typename.Substring(0, typeIndex); typename = typename.Substring(typeIndex + 1); type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(prefix))); if (type != null) return type; // To Support types whose assembly is not available, we need to still resolve the clr namespace List xmlnsMappings = null; if (manager.XmlNamespaceBasedMappings.TryGetValue(reader.LookupNamespace(prefix), out xmlnsMappings) && xmlnsMappings != null && xmlnsMappings.Count > 0) return xmlnsMappings[0].ClrNamespace + "." + typename; else return typename; } type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(string.Empty))); // To Support Beta2 format if (type == null) { ITypeProvider typeProvider = provider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) type = typeProvider.GetType(typename); // If not design mode, get the value from serialization manager // At design time, we need to get the type from ITypeProvider else // we need to store the string in the hashtable we maintain internally if (type == null && manager.GetService(typeof(ITypeResolutionService)) == null) type = manager.SerializationManager.GetType(typename); } if (type != null) return type; return this.typeName; } [DefaultValue(null)] [ConstructorArgument("type")] public string TypeName { get { if (this.type != null) return this.type.FullName; return this.typeName; } set { if (value == null) throw new ArgumentNullException("value"); this.typeName = value; } } internal Type Type { get { return this.type; } } } [ContentProperty("Items")] internal sealed class ArrayExtension : MarkupExtension { private ArrayList arrayElementList = new ArrayList(); private Type arrayType; public ArrayExtension() { } public ArrayExtension(Type arrayType) { if (arrayType == null) throw new ArgumentNullException("arrayType"); this.arrayType = arrayType; } public ArrayExtension(Array elements) { if (elements == null) throw new ArgumentNullException("elements"); arrayElementList.AddRange(elements); this.arrayType = elements.GetType().GetElementType(); } // public Type Type { get { return this.arrayType; } set { this.arrayType = value; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public IList Items { get { return arrayElementList; } } public override object ProvideValue(IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); if (this.arrayType == null) throw new InvalidOperationException("ArrayType needs to be set."); object retArray = null; try { retArray = arrayElementList.ToArray(this.arrayType); } catch (System.InvalidCastException) { // throw new InvalidOperationException(); } return retArray; } } } // 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
- TypeInfo.cs
- CustomWebEventKey.cs
- DeploymentExceptionMapper.cs
- SubqueryRules.cs
- ISSmlParser.cs
- Paragraph.cs
- _BasicClient.cs
- CharAnimationBase.cs
- CodeNamespaceCollection.cs
- ViewLoader.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ByteAnimationBase.cs
- EllipseGeometry.cs
- SupportsPreviewControlAttribute.cs
- WebPartZone.cs
- MediaEntryAttribute.cs
- SoapClientMessage.cs
- ReachSerializerAsync.cs
- RemoteWebConfigurationHostStream.cs
- FullTextLine.cs
- UrlParameterReader.cs
- ClrProviderManifest.cs
- TimerElapsedEvenArgs.cs
- TrimSurroundingWhitespaceAttribute.cs
- GenericRootAutomationPeer.cs
- ArglessEventHandlerProxy.cs
- QueryExpression.cs
- DataRow.cs
- MetadataPropertyAttribute.cs
- MenuItem.cs
- DecryptedHeader.cs
- DesignerRegion.cs
- SymmetricKeyWrap.cs
- SecureStringHasher.cs
- InvokeBase.cs
- TextTreeInsertElementUndoUnit.cs
- MessageHeaderInfoTraceRecord.cs
- PassportPrincipal.cs
- DataSourceCache.cs
- WebServiceMethodData.cs
- SHA256Managed.cs
- MenuItemStyle.cs
- CachedBitmap.cs
- DotAtomReader.cs
- DPCustomTypeDescriptor.cs
- FocusTracker.cs
- IODescriptionAttribute.cs
- EnumType.cs
- SqlDataSourceTableQuery.cs
- ModuleBuilder.cs
- DataSourceCacheDurationConverter.cs
- HttpCachePolicyElement.cs
- ElementsClipboardData.cs
- XmlChildEnumerator.cs
- NonSerializedAttribute.cs
- OSFeature.cs
- ConfigurationSectionCollection.cs
- ListViewInsertedEventArgs.cs
- GcSettings.cs
- RecognizedWordUnit.cs
- ServiceRoute.cs
- FocusManager.cs
- SweepDirectionValidation.cs
- DataGridViewCellStyle.cs
- ZoneMembershipCondition.cs
- OlePropertyStructs.cs
- dbenumerator.cs
- XmlElementList.cs
- SystemResourceKey.cs
- RegexFCD.cs
- AssemblyResourceLoader.cs
- ComboBoxAutomationPeer.cs
- CachedTypeface.cs
- HMACMD5.cs
- XpsImageSerializationService.cs
- DataGridColumnHeader.cs
- StatusBarItemAutomationPeer.cs
- SqlRowUpdatedEvent.cs
- XmlQueryContext.cs
- MimePart.cs
- ToolboxItemCollection.cs
- RuleEngine.cs
- TextServicesCompartment.cs
- SvcMapFile.cs
- HttpRequest.cs
- XmlSchemaDocumentation.cs
- WebFormDesignerActionService.cs
- ResXFileRef.cs
- ExpandCollapseProviderWrapper.cs
- PasswordPropertyTextAttribute.cs
- SoapFaultCodes.cs
- BamlLocalizationDictionary.cs
- Span.cs
- webeventbuffer.cs
- ProxyWebPartConnectionCollection.cs
- hwndwrapper.cs
- ListBoxItemAutomationPeer.cs
- TemplateBindingExpressionConverter.cs
- LambdaCompiler.Logical.cs
- CodeAttributeDeclarationCollection.cs