Code:
/ 4.0 / 4.0 / 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. 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
- safesecurityhelperavalon.cs
- EncoderParameter.cs
- WCFModelStrings.Designer.cs
- PrimitiveSchema.cs
- ObjectViewQueryResultData.cs
- DrawingContextFlattener.cs
- ConfigurationManagerInternal.cs
- DirectoryInfo.cs
- SqlRowUpdatedEvent.cs
- DecoderFallback.cs
- NameTable.cs
- WindowsAuthenticationEventArgs.cs
- Rule.cs
- StateBag.cs
- ConnectionConsumerAttribute.cs
- XhtmlBasicValidatorAdapter.cs
- RoutedUICommand.cs
- Content.cs
- ListViewDeleteEventArgs.cs
- RemoteWebConfigurationHostServer.cs
- SHA384Cng.cs
- PathStreamGeometryContext.cs
- SafePEFileHandle.cs
- SqlReorderer.cs
- Ray3DHitTestResult.cs
- DesignerRegionCollection.cs
- XamlPoint3DCollectionSerializer.cs
- baseaxisquery.cs
- DragAssistanceManager.cs
- DynamicDataRoute.cs
- EventSourceCreationData.cs
- ISFClipboardData.cs
- Size.cs
- _DigestClient.cs
- DigitalSignature.cs
- UriSection.cs
- DPCustomTypeDescriptor.cs
- GetMemberBinder.cs
- ScrollViewer.cs
- TypeValidationEventArgs.cs
- dataprotectionpermissionattribute.cs
- CharacterMetricsDictionary.cs
- GlyphRunDrawing.cs
- InputProviderSite.cs
- ContentFileHelper.cs
- TextChange.cs
- TreeBuilderXamlTranslator.cs
- OneOfElement.cs
- MarkupCompilePass2.cs
- BCLDebug.cs
- XmlQualifiedNameTest.cs
- ComponentResourceKey.cs
- HMACSHA384.cs
- SmtpCommands.cs
- EditorPartCollection.cs
- WebPartHeaderCloseVerb.cs
- CachedTypeface.cs
- KeyToListMap.cs
- X509ChainElement.cs
- AutomationProperties.cs
- DataObject.cs
- InternalControlCollection.cs
- SQLInt32.cs
- SchemaTableColumn.cs
- figurelength.cs
- NotImplementedException.cs
- DoubleAnimation.cs
- FieldAccessException.cs
- FunctionQuery.cs
- OracleMonthSpan.cs
- SizeConverter.cs
- ValidatedControlConverter.cs
- HttpHandlerAction.cs
- linebase.cs
- EventWaitHandleSecurity.cs
- PolyQuadraticBezierSegment.cs
- DigestTraceRecordHelper.cs
- ObjectQueryState.cs
- SystemTcpStatistics.cs
- HitTestWithPointDrawingContextWalker.cs
- StatusBar.cs
- UrlEncodedParameterWriter.cs
- ExpressionEditorAttribute.cs
- ZoomPercentageConverter.cs
- SqlNotificationEventArgs.cs
- ResolvedKeyFrameEntry.cs
- COM2Properties.cs
- TextServicesContext.cs
- SimpleParser.cs
- WebPartZone.cs
- ListViewDeleteEventArgs.cs
- CuspData.cs
- StrokeFIndices.cs
- AsyncInvokeContext.cs
- DiagnosticsConfiguration.cs
- ContractAdapter.cs
- LinqTreeNodeEvaluator.cs
- TextBreakpoint.cs
- XmlAttribute.cs
- RangeValidator.cs