Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / IfAction.cs / 1 / IfAction.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml.Xsl.XsltOld {
using Res = System.Xml.Utils.Res;
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
internal class IfAction : ContainerAction {
internal enum ConditionType {
ConditionIf,
ConditionWhen,
ConditionOtherwise
}
private ConditionType type;
private int testKey = Compiler.InvalidQueryKey;
internal IfAction(ConditionType type) {
this.type = type;
}
internal override void Compile(Compiler compiler) {
CompileAttributes(compiler);
if (this.type != ConditionType.ConditionOtherwise) {
CheckRequiredAttribute(compiler, this.testKey != Compiler.InvalidQueryKey, Keywords.s_Test);
}
if (compiler.Recurse()) {
CompileTemplate(compiler);
compiler.ToParent();
}
}
internal override bool CompileAttribute(Compiler compiler) {
string name = compiler.Input.LocalName;
string value = compiler.Input.Value;
if (Keywords.Equals(name, compiler.Atoms.Test)) {
if (this.type == ConditionType.ConditionOtherwise) {
return false;
}
this.testKey = compiler.AddBooleanQuery(value);
}
else {
return false;
}
return true;
}
internal override void Execute(Processor processor, ActionFrame frame) {
Debug.Assert(processor != null && frame != null);
switch (frame.State) {
case Initialized:
if (this.type == ConditionType.ConditionIf || this.type == ConditionType.ConditionWhen) {
Debug.Assert(this.testKey != Compiler.InvalidQueryKey);
bool value = processor.EvaluateBoolean(frame, this.testKey);
if (value == false) {
frame.Finished();
break;
}
}
processor.PushActionFrame(frame);
frame.State = ProcessingChildren;
break; // Allow children to run
case ProcessingChildren:
if (this.type == ConditionType.ConditionWhen ||this.type == ConditionType.ConditionOtherwise) {
Debug.Assert(frame.Container != null);
frame.Exit();
}
frame.Finished();
break;
default:
Debug.Fail("Invalid IfAction execution state");
break;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml.Xsl.XsltOld {
using Res = System.Xml.Utils.Res;
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
internal class IfAction : ContainerAction {
internal enum ConditionType {
ConditionIf,
ConditionWhen,
ConditionOtherwise
}
private ConditionType type;
private int testKey = Compiler.InvalidQueryKey;
internal IfAction(ConditionType type) {
this.type = type;
}
internal override void Compile(Compiler compiler) {
CompileAttributes(compiler);
if (this.type != ConditionType.ConditionOtherwise) {
CheckRequiredAttribute(compiler, this.testKey != Compiler.InvalidQueryKey, Keywords.s_Test);
}
if (compiler.Recurse()) {
CompileTemplate(compiler);
compiler.ToParent();
}
}
internal override bool CompileAttribute(Compiler compiler) {
string name = compiler.Input.LocalName;
string value = compiler.Input.Value;
if (Keywords.Equals(name, compiler.Atoms.Test)) {
if (this.type == ConditionType.ConditionOtherwise) {
return false;
}
this.testKey = compiler.AddBooleanQuery(value);
}
else {
return false;
}
return true;
}
internal override void Execute(Processor processor, ActionFrame frame) {
Debug.Assert(processor != null && frame != null);
switch (frame.State) {
case Initialized:
if (this.type == ConditionType.ConditionIf || this.type == ConditionType.ConditionWhen) {
Debug.Assert(this.testKey != Compiler.InvalidQueryKey);
bool value = processor.EvaluateBoolean(frame, this.testKey);
if (value == false) {
frame.Finished();
break;
}
}
processor.PushActionFrame(frame);
frame.State = ProcessingChildren;
break; // Allow children to run
case ProcessingChildren:
if (this.type == ConditionType.ConditionWhen ||this.type == ConditionType.ConditionOtherwise) {
Debug.Assert(frame.Container != null);
frame.Exit();
}
frame.Finished();
break;
default:
Debug.Fail("Invalid IfAction execution state");
break;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QilXmlWriter.cs
- RegexStringValidator.cs
- DataObjectSettingDataEventArgs.cs
- X509SubjectKeyIdentifierClause.cs
- TextCompositionManager.cs
- RequestCachingSection.cs
- DataGrid.cs
- BindingGroup.cs
- SystemWebSectionGroup.cs
- FamilyTypeface.cs
- ISCIIEncoding.cs
- CompiledQueryCacheKey.cs
- SecurityVerifiedMessage.cs
- FtpWebRequest.cs
- wmiprovider.cs
- WebConvert.cs
- SurrogateEncoder.cs
- WmpBitmapDecoder.cs
- DataGridViewRowCollection.cs
- EventLogTraceListener.cs
- TextEffectCollection.cs
- RemotingAttributes.cs
- Timeline.cs
- KeyInstance.cs
- InvokeWebServiceDesigner.cs
- PrintPreviewControl.cs
- XmlException.cs
- Unit.cs
- ToolStripSplitStackLayout.cs
- StrokeNodeOperations.cs
- ObjectListDataBindEventArgs.cs
- HiddenFieldDesigner.cs
- ZoneButton.cs
- DiagnosticTrace.cs
- UrlPropertyAttribute.cs
- StringArrayEditor.cs
- Logging.cs
- XamlPathDataSerializer.cs
- InputLanguageSource.cs
- FieldToken.cs
- RuleElement.cs
- StringFormat.cs
- Schema.cs
- autovalidator.cs
- CancellationTokenRegistration.cs
- xmlglyphRunInfo.cs
- ZoneLinkButton.cs
- DesignerActionItemCollection.cs
- xmlNames.cs
- DebugView.cs
- HostingEnvironmentSection.cs
- Attachment.cs
- SlipBehavior.cs
- PageAsyncTaskManager.cs
- Path.cs
- CollectionViewSource.cs
- XmlUTF8TextReader.cs
- ResourceSetExpression.cs
- EmbeddedMailObject.cs
- FixedSOMLineRanges.cs
- XmlILConstructAnalyzer.cs
- ProfilePropertyNameValidator.cs
- TextEditorSelection.cs
- DrawToolTipEventArgs.cs
- ApplicationContext.cs
- BitmapData.cs
- DependencySource.cs
- IMembershipProvider.cs
- UnsafeNativeMethods.cs
- SortFieldComparer.cs
- ApplicationSecurityInfo.cs
- Subtree.cs
- ObjectParameterCollection.cs
- FixedNode.cs
- FlowDocumentReaderAutomationPeer.cs
- SafeMILHandle.cs
- WsdlBuildProvider.cs
- WebPartMenu.cs
- ErrorTolerantObjectWriter.cs
- UrlMappingCollection.cs
- XmlChildEnumerator.cs
- ConsoleCancelEventArgs.cs
- httpstaticobjectscollection.cs
- UnsafeNativeMethodsPenimc.cs
- TextBlockAutomationPeer.cs
- CompatibleComparer.cs
- ManagementNamedValueCollection.cs
- MultiAsyncResult.cs
- AccessKeyManager.cs
- GeneralTransform2DTo3D.cs
- DynamicILGenerator.cs
- HttpResponseHeader.cs
- WindowsRichEdit.cs
- SqlMethodTransformer.cs
- ErrorsHelper.cs
- QueryStringHandler.cs
- Pair.cs
- CodeDirectiveCollection.cs
- AstTree.cs
- TableRow.cs