Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / Configuration.cs / 1305376 / Configuration.cs
namespace System.Workflow.ComponentModel.Compiler { using System.Xml; using System.Collections.Generic; using System.Configuration; using System.Globalization; using System.Xml.Serialization; using System.Text.RegularExpressions; internal sealed class WorkflowCompilerConfigurationSectionGroup : ConfigurationSectionGroup { public WorkflowCompilerConfigurationSectionGroup() { } } internal sealed class AuthorizedTypesSectionHandler : IConfigurationSectionHandler { const string TargetFxVersionAttribute = "version"; #region IConfigurationSectionHandler Members object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section) { Dictionary> authorizedTypes = new Dictionary >(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(AuthorizedType)); foreach (XmlNode targetFx in section.ChildNodes) { XmlAttribute versionAttribute = targetFx.Attributes.GetNamedItem(TargetFxVersionAttribute) as XmlAttribute; if (versionAttribute != null) { string version = versionAttribute.Value; if (!string.IsNullOrEmpty(version)) { IList versionTypes; if (!authorizedTypes.TryGetValue(version, out versionTypes)) { versionTypes = new List (); authorizedTypes.Add(version, versionTypes); } foreach (XmlNode authorizedTypeNode in targetFx.ChildNodes) { AuthorizedType authorizedType = xmlSerializer.Deserialize(new XmlNodeReader(authorizedTypeNode)) as AuthorizedType; if (authorizedType != null) { versionTypes.Add(authorizedType); } } } } } return authorizedTypes; } #endregion } [XmlType("authorizedType")] public sealed class AuthorizedType { private string assemblyName; private string namespaceName; private string typeName; private bool isAuthorized; private Regex regex; [XmlAttribute] public string Assembly { get { return this.assemblyName; } set { this.assemblyName = value; } } [XmlAttribute] public string Namespace { get { return this.namespaceName; } set { this.namespaceName = value; } } [XmlAttribute] public string TypeName { get { return this.typeName; } set { this.typeName = value; } } [XmlAttribute] public string Authorized { get { return this.isAuthorized.ToString(); } set { this.isAuthorized = bool.Parse(value); } } [XmlIgnore] public Regex RegularExpression { get { if (this.regex == null) { this.regex = new Regex(MakeRegex(string.Format(CultureInfo.InvariantCulture, "{0}.{1}, {2}", new object[] { this.namespaceName, this.typeName, this.assemblyName })), RegexOptions.Compiled); return this.regex; } return this.regex; } } private static string MakeRegex(string inputString) { // RegEx uses the following as meta characters: // [\^$.|?*+() // Of these we translate * and ? to DOS wildcard equivalents in RegEx. // We escape rest of the Regex meta characters to thwart any luring // attacks caused by malformed inputString using meta characters. string outputString = inputString.Replace(@"\", @"\\"); outputString = outputString.Replace("[", @"\["); outputString = outputString.Replace("^", @"\^"); outputString = outputString.Replace("$", @"\$"); outputString = outputString.Replace("|", @"\|"); outputString = outputString.Replace("+", @"\+"); outputString = outputString.Replace("(", @"\("); outputString = outputString.Replace(")", @"\)"); outputString = outputString.Replace(".", @"\x2E"); outputString = outputString.Replace("*", @"[\w\x60\x2E]{0,}"); outputString = outputString.Replace("?", @"\w{1,1}"); // Make whitespaces optional outputString = outputString.Replace(" ", @"\s{0,}"); return outputString; } } } // 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
- XmlSchemaRedefine.cs
- PrivateFontCollection.cs
- WindowsIPAddress.cs
- AddInController.cs
- FileReader.cs
- Point3DIndependentAnimationStorage.cs
- CellConstantDomain.cs
- SimpleHandlerFactory.cs
- BufferModesCollection.cs
- PopOutPanel.cs
- TextDpi.cs
- MaskInputRejectedEventArgs.cs
- SpecularMaterial.cs
- DataGridViewSortCompareEventArgs.cs
- ProxyFragment.cs
- DLinqTableProvider.cs
- KnownBoxes.cs
- XmlSiteMapProvider.cs
- DataComponentNameHandler.cs
- _ScatterGatherBuffers.cs
- DocumentCollection.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- HttpServerVarsCollection.cs
- WSSecurityTokenSerializer.cs
- Globals.cs
- ValidatorCompatibilityHelper.cs
- XPathSelfQuery.cs
- SqlWriter.cs
- WindowsStatic.cs
- TickBar.cs
- ServiceDescriptionSerializer.cs
- CertificateElement.cs
- TypeLibConverter.cs
- BinHexEncoder.cs
- StyleHelper.cs
- ResourceCodeDomSerializer.cs
- UnauthorizedAccessException.cs
- DefinitionUpdate.cs
- PageTheme.cs
- CollectionViewProxy.cs
- WeakReferenceKey.cs
- DeclaredTypeValidator.cs
- UnsignedPublishLicense.cs
- FileSystemEventArgs.cs
- Peer.cs
- ListContractAdapter.cs
- SelectionPattern.cs
- GenericEnumerator.cs
- ConfigPathUtility.cs
- DirtyTextRange.cs
- UnsafeNativeMethods.cs
- ObjectTag.cs
- TextAction.cs
- XmlDataSourceNodeDescriptor.cs
- HotSpotCollection.cs
- XmlAttributeAttribute.cs
- OdbcDataAdapter.cs
- RectAnimationUsingKeyFrames.cs
- MethodBody.cs
- AnnotationComponentManager.cs
- HandleRef.cs
- ButtonBaseAutomationPeer.cs
- AttributeSetAction.cs
- ThreadStaticAttribute.cs
- GridViewUpdatedEventArgs.cs
- WpfWebRequestHelper.cs
- AtomMaterializer.cs
- ComplexType.cs
- LogStore.cs
- SQLBytes.cs
- Int16Converter.cs
- OpenTypeCommon.cs
- Composition.cs
- StretchValidation.cs
- TemplateComponentConnector.cs
- TrackingQueryElement.cs
- DataPagerFieldItem.cs
- CodeDirectiveCollection.cs
- PathFigureCollection.cs
- ZoneIdentityPermission.cs
- Application.cs
- StaticExtensionConverter.cs
- Speller.cs
- ConnectionManagementSection.cs
- VisualStyleInformation.cs
- ExpressionLexer.cs
- EncoderParameter.cs
- Encoding.cs
- PrinterResolution.cs
- StatusBarDesigner.cs
- BeginStoryboard.cs
- RightsManagementPermission.cs
- FormViewRow.cs
- ExpressionBuilder.cs
- EventHandlersStore.cs
- DataGridItem.cs
- MDIClient.cs
- Rule.cs
- SQLInt16.cs
- UIElementHelper.cs