本文整理匯總了C#中System.Xml.XmlDictionaryWriter.Flush方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDictionaryWriter.Flush方法的具體用法?C# XmlDictionaryWriter.Flush怎麽用?C# XmlDictionaryWriter.Flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.Flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteHeader
private void WriteHeader(XmlDictionaryWriter writer)
{
var nonce = new byte[64];
RandomNumberGenerator.Create().GetBytes(nonce);
string created = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.mszzzz");
writer.WriteStartElement("wsse", "UsernameToken", null);
writer.WriteAttributeString("wsu:Id", "UsernameToken-1");
writer.WriteStartElement("wsse", "Username", null);
writer.WriteString(SystemUser);
writer.WriteEndElement();//End Username
writer.WriteStartElement("wsse", "Password", null);
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
writer.WriteString(ComputePasswordDigest(SystemPassword, nonce, created));
writer.WriteEndElement();//End Password
writer.WriteStartElement("wsse", "Nonce", null);
writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
writer.WriteBase64(nonce, 0, nonce.Length);
writer.WriteEndElement();//End Nonce
writer.WriteStartElement("wsu", "Created", null);
writer.WriteString(created);
writer.WriteEndElement();//End Created
writer.WriteEndElement();//End UsernameToken
writer.Flush();
}
示例2: WriteHeader
private void WriteHeader(XmlDictionaryWriter writer)
{
writer.WriteStartElement("wsse", "UsernameToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
writer.WriteStartElement("wsse", "Username", null);
writer.WriteString(SystemUser);
writer.WriteEndElement();//End Username
writer.WriteStartElement("wsse", "Password", null);
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
writer.WriteString(SystemPassword);
writer.WriteEndElement();//End Password
writer.WriteEndElement();//End UsernameToken
writer.Flush();
}
示例3: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
XmlWriterSettings setting = new XmlWriterSettings();
setting.NewLineHandling = NewLineHandling.Entitize;
setting.CheckCharacters = false;
if (!string.IsNullOrEmpty(body))
{
writer.WriteRaw(body);
}
if (doc != null)
{
doc.WriteContentTo(writer);
writer.Flush();
}
}
示例4: AddReference
public void AddReference(
MessageHeaders headers,
int i,
XmlDictionaryWriter writer,
string headerId,
bool idInserted)
{
HashStream hashStream = this.TakeHashStream();
writer.StartCanonicalization(hashStream, false, this.InclusivePrefixes);
headers.WriteStartHeader(i, writer);
if (idInserted)
{
writer.WriteAttributeString(this.discoveryInfo.DiscoveryPrefix, ProtocolStrings.IdAttributeName, this.discoveryInfo.DiscoveryNamespace, headerId);
}
headers.WriteHeaderContents(i, writer);
writer.WriteEndElement();
writer.EndCanonicalization();
writer.Flush();
// Add a pre-digested reference for this header
this.AddReference(headerId, hashStream.FlushHashAndGetValue());
}
示例5: OnWriteBodyContents
/// <summary>
/// Called when the message body is written to an XML file.
/// </summary>
/// <param name="writer">
/// A <see cref="T:System.Xml.XmlDictionaryWriter"/> that is used to write this message body to an
/// XML file.
/// </param>
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
try
{
this._controller.StreamTo(writer, this._actions);
writer.Flush();
}
catch (Exception e)
{
_logger.Error(e.Message, e);
throw this._exceptionHandler(e);
}
}
示例6: Save
/// <summary>
/// Saves the object graph which represents this expression using the specified <see cref="XmlDictionaryWriter"/>.
/// </summary>
/// <param name="writer">An <see cref="XmlDictionaryWriter"/> used to write the object graph.</param>
public void Save(XmlDictionaryWriter writer)
{
Serializer.WriteObject(writer, this.Node);
writer.Flush();
}
示例7: SimulateWriteFragment
private static void SimulateWriteFragment(XmlDictionaryWriter writer, bool useFragmentAPI, int nestedLevelsLeft)
{
if (nestedLevelsLeft <= 0)
{
return;
}
Random rndGen = new Random(nestedLevelsLeft);
int signatureLen = rndGen.Next(100, 200);
byte[] signature = new byte[signatureLen];
rndGen.NextBytes(signature);
MemoryStream fragmentStream = new MemoryStream();
if (!useFragmentAPI) // simulating in the writer itself
{
writer.WriteStartElement("SignatureValue_" + nestedLevelsLeft);
writer.WriteBase64(signature, 0, signatureLen);
writer.WriteEndElement();
}
if (useFragmentAPI)
{
FragmentHelper.Start(writer, fragmentStream);
}
writer.WriteStartElement("Fragment" + nestedLevelsLeft);
for (int i = 0; i < 5; i++)
{
writer.WriteStartElement(String.Format("Element{0}_{1}", nestedLevelsLeft, i));
writer.WriteAttributeString("attr1", "value1");
writer.WriteAttributeString("attr2", "value2");
}
writer.WriteString("This is a text with unicode characters: <>&;\u0301\u2234");
for (int i = 0; i < 5; i++)
{
writer.WriteEndElement();
}
// write other nested fragments...
SimulateWriteFragment(writer, useFragmentAPI, nestedLevelsLeft - 1);
writer.WriteEndElement(); // Fragment{nestedLevelsLeft}
writer.Flush();
if (useFragmentAPI)
{
FragmentHelper.End(writer);
writer.WriteStartElement("SignatureValue_" + nestedLevelsLeft);
writer.WriteBase64(signature, 0, signatureLen);
writer.WriteEndElement();
FragmentHelper.Write(writer, fragmentStream.GetBuffer(), 0, (int)fragmentStream.Length);
writer.Flush();
}
}
示例8: OnWriteBodyContents
/// <summary>
/// Called when the message body is written to an XML file.
/// </summary>
/// <param name="writer">
/// A <see cref="T:System.Xml.XmlDictionaryWriter"/> that is used to write this message body to an
/// XML file.
/// </param>
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
try
{
this._controller.StreamTo(writer, this._actions);
writer.Flush();
}
catch (SdmxResponseSizeExceedsLimitException e)
{
// error is on payload.
_logger.Warn(e.Message, e);
writer.Flush();
}
catch (SdmxResponseTooLargeException e)
{
// error is on payload.
_logger.Warn(e.Message, e);
writer.Flush();
}
catch (Exception e)
{
_logger.Error(e.Message, e);
throw this._exceptionHandler(e);
}
}
示例9: ReturnXmlWriter
protected override void ReturnXmlWriter(XmlDictionaryWriter writer)
{
Contract.Assert(writer != null, "writer MUST NOT be null");
writer.Flush();
writer.Dispose();
}
示例10: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
try
{
do
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
writer.WriteAttributeString(reader.LocalName, reader.NamespaceURI, reader.Value.Replace(sourcePattern, targetPattern));
}
reader.MoveToElement();
if (reader.IsEmptyElement)
{
writer.WriteEndElement();
}
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value.Replace(sourcePattern, targetPattern));
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
writer.WriteWhitespace(reader.Value);
break;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
break;
case XmlNodeType.EntityReference:
writer.WriteEntityRef(reader.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.DocumentType:
writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
break;
}
}
while (reader.Read());
writer.Flush();
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw;
}
}
示例11: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteNode(JsonReaderWriterFactory.CreateJsonReader(_jsonStream, XmlDictionaryReaderQuotas.Max), false);
writer.Flush();
}
示例12: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
if (!IsEmpty)
{
if (!isInboundRequest)
{
writer.WriteStartElement(IsXmlRpcMethodCall ? XmlRpcProtocol.MethodCall : XmlRpcProtocol.MethodResponse);
if (IsXmlRpcMethodCall)
{
writer.WriteStartElement(XmlRpcProtocol.MethodName);
writer.WriteString((string)properties["XmlRpcMethodName"]);
writer.WriteEndElement();
}
}
writer.WriteNode(bodyReader, true);
if (!isInboundRequest)
{
writer.WriteEndElement();
}
writer.Flush();
}
}
示例13: WriteHeader
private void WriteHeader(XmlDictionaryWriter writer)
{
//Begin Variable setups
var nonce = new byte[64];
RandomNumberGenerator.Create().GetBytes(nonce);
string created = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss.msZ");
//End Variable setups
// Write Namespace attributes on the "wsse:Security" Node
writer.WriteXmlnsAttribute("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
// Begin UsernameToken Holder for UserName, Password, Nonce, and Created Nodes
writer.WriteStartElement("wsse", "UsernameToken", null);
writer.WriteAttributeString("wsu", "Id", null, "UsernameToken-2");
//Begin Username
writer.WriteStartElement("wsse", "Username", null);
writer.WriteString(SystemUser);
writer.WriteEndElement();
//End Username
//Begin Password Plaintext
writer.WriteStartElement("wsse", "Password", null);
if (this.SystermPasswordType == PasswordType.ClearText)
{
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
writer.WriteString(SystemPassword);
}
else if (this.SystermPasswordType == PasswordType.Digest)
{
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
writer.WriteString(ComputePasswordDigest(SystemPassword, nonce, created));
}
writer.WriteEndElement();
//End Password Plaintext
//Begin Password Nonce
writer.WriteStartElement("wsse", "Nonce", null);
writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
writer.WriteBase64(nonce, 0, nonce.Length);
writer.WriteEndElement();
//End Password Nonce
//Begin Created
writer.WriteStartElement("wsu", "Created", null);
writer.WriteString(created);
writer.WriteEndElement();
//End Created
writer.WriteEndElement();
// Begin UsernameToken Holder
writer.Flush();
}
示例14: WriteCanonicalizedBodyWithFragments
void WriteCanonicalizedBodyWithFragments(Stream canonicalStream, XmlDictionaryWriter writer)
{
byte[] buffer = null;
if (this.discoveryInfo.SupportsInclusivePrefixes)
{
buffer = this.BufferBodyAndGetInclusivePrefixes();
}
using (MemoryStream bodyBufferStream = new MemoryStream())
{
writer.StartCanonicalization(canonicalStream, false, this.inclusivePrefixes);
IFragmentCapableXmlDictionaryWriter fragmentingWriter = (IFragmentCapableXmlDictionaryWriter)writer;
fragmentingWriter.StartFragment(bodyBufferStream, false);
this.WriteBufferOrMessageBody(writer, buffer);
fragmentingWriter.EndFragment();
writer.EndCanonicalization();
writer.Flush();
this.fullBodyFragmentLength = (int)bodyBufferStream.Length;
this.fullBodyFragment = bodyBufferStream.ToArray();
}
}
示例15: WriteHeader
/// <summary>
/// Overwrites the default SOAP Security Header values generated by WCF with
/// those required by the UserService which implements WSE 2.0. This is required
/// for interoperability between a WCF Client and a WSE 2.0 Service.
/// </summary>
/// <param name="writer"><see cref="XmlDictionaryWriter"/></param>
private void WriteHeader(XmlDictionaryWriter writer)
{
// Create the Nonce
byte[] nonce = GenerateNonce();
// Create the Created Date
string created = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
// Create the WSSE Security Header, starting with the Username Element
writer.WriteStartElement("wsse", "UsernameToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
writer.WriteStartElement("wsse", "Username", null);
writer.WriteString(config.Username);
writer.WriteEndElement();
// Add the Password Element
writer.WriteStartElement("wsse", "Password", null);
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
writer.WriteString(GeneratePasswordDigest(nonce, created, config.Password));
writer.WriteEndElement();
// Add the Nonce Element
writer.WriteStartElement("wsse", "Nonce", null);
writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
writer.WriteBase64(nonce, 0, nonce.Length);
writer.WriteEndElement();
// Lastly, add the Created Element
writer.WriteStartElement("wsu", "Created", null);
writer.WriteString(created);
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
}
開發者ID:PearsonDevelopersNetwork,項目名稱:LearningStudio-Libraries-SIS-CSharp,代碼行數:40,代碼來源:SecurityHeader.cs