本文整理汇总了C#中Stream.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ThrowIfNull方法的具体用法?C# Stream.ThrowIfNull怎么用?C# Stream.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ThrowIfNull方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadAsync
/// <summary>
/// Uploads a provided file to the target parent folder
/// If the file already exists, an error will be thrown
/// </summary>
/// <param name="fileRequest"></param>
/// <param name="stream"></param>
/// <returns></returns>
public async Task<BoxFile> UploadAsync(BoxFileRequest fileRequest, Stream stream, List<string> fields = null)
{
stream.ThrowIfNull("stream");
fileRequest.ThrowIfNull("fileRequest")
.Name.ThrowIfNullOrWhiteSpace("filedRequest.Name");
fileRequest.Parent.ThrowIfNull("fileRequest.Parent")
.Id.ThrowIfNullOrWhiteSpace("fileRequest.Parent.Id");
BoxMultiPartRequest request = new BoxMultiPartRequest(_config.FilesUploadEndpointUri)
.Param(ParamFields, fields)
.FormPart(new BoxStringFormPart()
{
Name = "metadata",
Value = _converter.Serialize(fileRequest)
})
.FormPart(new BoxFileFormPart()
{
Name = "file",
Value = stream,
FileName = fileRequest.Name
});
IBoxResponse<BoxCollection<BoxFile>> response = await ToResponseAsync<BoxCollection<BoxFile>>(request).ConfigureAwait(false);
// We can only upload one file at a time, so return the first entry
return response.ResponseObject.Entries.FirstOrDefault();
}
示例2: StreamParser
/// <summary>
/// Initializes a new instance of the StreamParser class for the specified
/// stream.
/// </summary>
/// <param name="stream">The stream to read the XML data from.</param>
/// <param name="leaveOpen">true to leave the stream open when the StreamParser
/// instance is closed, otherwise false.</param>
/// <exception cref="ArgumentNullException">The stream parameter is
/// null.</exception>
/// <exception cref="XmlException">The parser has encountered invalid
/// or unexpected XML data.</exception>
/// <exception cref="CultureNotFoundException">The culture specified by the
/// XML-stream in it's 'xml:lang' attribute could not be found.</exception>
public StreamParser(Stream stream, bool leaveOpen = false) {
stream.ThrowIfNull("stream");
this.leaveOpen = leaveOpen;
this.stream = stream;
reader = XmlReader.Create(stream, new XmlReaderSettings() {
// Ignore restricted XML data (Refer to RFC 3920, 11.1 Restrictions).
IgnoreProcessingInstructions = true,
IgnoreComments = true,
IgnoreWhitespace = true
});
// Read up to the opening stream tag.
ReadRootElement();
}
示例3: SISession
/// <summary>
/// Initializes a new instance of the SISession class.
/// </summary>
/// <param name="sid">The identifier of the session.</param>
/// <param name="stream">The IO-stream from which data is read, or to
/// which data is written.</param>
/// <param name="size">The total number of bytes to read from, or to
/// write to the stream.</param>
/// <param name="receiving">true if data is being received over the session;
/// Otherwise false.</param>
/// <param name="from">The JID of the XMPP entity that wishes to send data.</param>
/// <param name="to">The JID of the XMPP entity that wishes to receive
/// data.</param>
/// <param name="extension">The instance of the data-stream extension
/// negotiated during session-initiation.</param>
/// <exception cref="ArgumentNullException">The sid parameter or the stream
/// parameter or the from parameter or the to parameter or the extension
/// parameter is null.</exception>
/// <exception cref="ArgumentException">The receiving parameter is true, but
/// the specified stream cannot be written, or the receiving parameter is
/// false, but the specified stream cannot be read.</exception>
/// <exception cref="ArgumentOutOfRangeException">The size parameter is
/// negative.</exception>
public SISession(string sid, Stream stream, long size, bool receiving,
Jid from, Jid to, IDataStream extension) {
sid.ThrowIfNull("sid");
stream.ThrowIfNull("stream");
size.ThrowIfOutOfRange(0, Int64.MaxValue);
from.ThrowIfNull("from");
to.ThrowIfNull("to");
extension.ThrowIfNull("extension");
if (receiving && !stream.CanWrite)
throw new ArgumentException("The specified stream cannot be written.");
if (!receiving && !stream.CanRead)
throw new ArgumentException("The specified stream cannot be read.");
Sid = sid;
Stream = stream;
Size = size;
Count = 0;
Receiving = receiving;
From = from;
To = to;
Extension = extension;
}
示例4: UploadNewVersionAsync
/// <summary>
/// This method is used to upload a new version of an existing file in a user’s account. Similar to regular file uploads,
/// these are performed as multipart form uploads An optional If-Match header can be included to ensure that client only
/// overwrites the file if it knows about the latest version. The filename on Box will remain the same as the previous version.
/// </summary>
/// <param name="fileName"></param>
/// <param name="stream"></param>
/// <param name="etag"></param>
/// <returns></returns>
public async Task<BoxFile> UploadNewVersionAsync(string fileName, string fileId, Stream stream, string etag = null, List<string> fields = null)
{
stream.ThrowIfNull("stream");
fileName.ThrowIfNullOrWhiteSpace("fileName");
BoxMultiPartRequest request = new BoxMultiPartRequest(new Uri(string.Format(Constants.FilesNewVersionEndpointString, fileId)))
.Header("If-Match", etag)
.Param(ParamFields, fields)
.FormPart(new BoxFileFormPart()
{
Name = "filename",
Value = stream,
FileName = fileName
});
IBoxResponse<BoxCollection<BoxFile>> response = await ToResponseAsync<BoxCollection<BoxFile>>(request).ConfigureAwait(false);
// We can only upload one file at a time, so return the first entry
return response.ResponseObject.Entries.FirstOrDefault();
}
示例5: DownloadCoreAsync
/// <summary>
/// The core download logic. It downloads the media in parts, where each part's size is defined by
/// <see cref="ChunkSize"/> (in bytes).
/// </summary>
/// <param name="url">The URL of the resource to download.</param>
/// <param name="stream">The download will download the resource into this stream.</param>
/// <param name="cancellationToken">A cancellation token to cancel this download in the middle.</param>
/// <returns>A task with the download progress object. If an exception occurred during the download, its
/// <see cref="IDownloadProgress.Exception "/> property will contain the exception.</returns>
private async Task<IDownloadProgress> DownloadCoreAsync(string url, Stream stream,
CancellationToken cancellationToken)
{
url.ThrowIfNull("url");
stream.ThrowIfNull("stream");
if (!stream.CanWrite)
{
throw new ArgumentException("stream doesn't support write operations");
}
RequestBuilder builder = null;
var uri = new Uri(url);
if (string.IsNullOrEmpty(uri.Query))
{
builder = new RequestBuilder() { BaseUri = new Uri(url) };
}
else
{
builder = new RequestBuilder() { BaseUri = new Uri(url.Substring(0, url.IndexOf("?"))) };
// Remove '?' at the beginning.
var query = uri.Query.Substring(1);
var pairs = from parameter in query.Split('&')
select parameter.Split('=');
// Add each query parameter. each pair contains the key [0] and then its value [1].
foreach (var p in pairs)
{
builder.AddParameter(RequestParameterType.Query, p[0], p[1]);
}
}
builder.AddParameter(RequestParameterType.Query, "alt", "media");
long currentRequestFirstBytePos = 0;
try
{
// This "infinite" loop stops when the "to" byte position in the "Content-Range" header is the last
// byte of the media ("length"-1 in the "Content-Range" header).
// e.g. "Content-Range: 200-299/300" - "to"(299) = "length"(300) - 1.
while (true)
{
var currentRequestLastBytePos = currentRequestFirstBytePos + ChunkSize - 1;
// Create the request and set the Range header.
var request = builder.CreateRequest();
request.Headers.Range = new RangeHeaderValue(currentRequestFirstBytePos,
currentRequestLastBytePos);
using (var response = await service.HttpClient.SendAsync(request, cancellationToken).
ConfigureAwait(false))
{
// Read the content and copy to the parameter's stream.
var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
responseStream.CopyTo(stream);
// Read the headers and check if all the media content was already downloaded.
var contentRange = response.Content.Headers.ContentRange;
long mediaContentLength;
if (contentRange == null)
{
// Content range is null when the server doesn't adhere the media download protocol, in
// that case we got all the media in one chunk.
currentRequestFirstBytePos = mediaContentLength =
response.Content.Headers.ContentLength.Value;
}
else
{
currentRequestFirstBytePos = contentRange.To.Value + 1;
mediaContentLength = contentRange.Length.Value;
}
if (currentRequestFirstBytePos == mediaContentLength)
{
var progress = new DownloadProgress(DownloadStatus.Completed, mediaContentLength);
UpdateProgress(progress);
return progress;
}
}
UpdateProgress(new DownloadProgress(DownloadStatus.Downloading, currentRequestFirstBytePos));
}
}
catch (TaskCanceledException ex)
{
Logger.Error(ex, "Download media was canceled");
UpdateProgress(new DownloadProgress(ex, currentRequestFirstBytePos));
throw ex;
}
catch (Exception ex)
{
//.........这里部分代码省略.........
示例6: InitiateFileTransfer
/// <summary>
/// Offers the XMPP user with the specified JID the file with the specified
/// name and, if accepted by the user, transfers the file using the supplied
/// stream.
/// </summary>
/// <param name="to">The JID of the XMPP user to offer the file to.</param>
/// <param name="stream">The stream to read the file-data from.</param>
/// <param name="name">The name of the file, as offered to the XMPP user
/// with the specified JID.</param>
/// <param name="size">The number of bytes to transfer.</param>
/// <param name="cb">A callback method invoked once the other site has
/// accepted or rejected the file-transfer request.</param>
/// <param name="description">A description of the file so the receiver can
/// better understand what is being sent.</param>
/// <returns>Sid of file transfer</returns>
/// <exception cref="ArgumentNullException">The to parameter or the stream
/// parameter or the name parameter is null.</exception>
/// <exception cref="ArgumentOutOfRangeException">The value of the size
/// parameter is negative.</exception>
/// <exception cref="NotSupportedException">The XMPP entity with the
/// specified JID does not support the 'SI File Transfer' XMPP
/// extension.</exception>
/// <exception cref="XmppErrorException">The server or the XMPP entity
/// with the specified JID returned an XMPP error code. Use the Error
/// property of the XmppErrorException to obtain the specific error
/// condition.</exception>
/// <exception cref="XmppException">The server returned invalid data or
/// another unspecified XMPP error occurred.</exception>
public string InitiateFileTransfer(Jid to, Stream stream, string name, long size,
string description = null, Action<bool, FileTransfer> cb = null)
{
to.ThrowIfNull("to");
stream.ThrowIfNull("stream");
name.ThrowIfNull("name");
size.ThrowIfOutOfRange(0, Int64.MaxValue);
//FIXME FIXME
//if (!ecapa.Supports(to, Extension.SIFileTransfer)) {
// throw new NotSupportedException("The XMPP entity does not support the " +
// "'SI File Transfer' extension.");
//}
//FIXME FIXME
// Perform stream-initiation asynchronously so that the caller is not
// blocked until the other site has either accepted or rejected our offer.
return InitiateStreamAsync(to, name, size, description, (result, iq) =>
{
OnInitiationResult(result, to, name, stream, size, description, cb);
});
}
示例7: DownloadCoreAsync
/// <summary>
/// The core download logic. We download the media and write it to an output stream
/// ChunkSize bytes at a time, raising the ProgressChanged event after each chunk.
///
/// The chunking behavior is largely a historical artifact: a previous implementation
/// issued multiple web requests, each for ChunkSize bytes. Now we do everything in
/// one request, but the API and client-visible behavior are retained for compatibility.
/// </summary>
/// <param name="url">The URL of the resource to download.</param>
/// <param name="stream">The download will download the resource into this stream.</param>
/// <param name="cancellationToken">A cancellation token to cancel this download in the middle.</param>
/// <returns>A task with the download progress object. If an exception occurred during the download, its
/// <see cref="IDownloadProgress.Exception "/> property will contain the exception.</returns>
private async Task<IDownloadProgress> DownloadCoreAsync(string url, Stream stream,
CancellationToken cancellationToken)
{
url.ThrowIfNull("url");
stream.ThrowIfNull("stream");
if (!stream.CanWrite)
{
throw new ArgumentException("stream doesn't support write operations");
}
// Add alt=media to the query parameters.
var uri = new UriBuilder(url);
if (uri.Query == null || uri.Query.Length <= 1)
{
uri.Query = "alt=media";
}
else
{
// Remove the leading '?'. UriBuilder.Query doesn't round-trip.
uri.Query = uri.Query.Substring(1) + "&alt=media";
}
var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString());
// Number of bytes sent to the caller's stream.
long bytesReturned = 0;
try
{
// Signal SendAsync to return as soon as the response headers are read.
// We'll stream the content ourselves as it becomes available.
var completionOption = HttpCompletionOption.ResponseHeadersRead;
using (var response = await service.HttpClient.SendAsync(request, completionOption, cancellationToken).ConfigureAwait(false))
{
if (!response.IsSuccessStatusCode)
{
throw await MediaApiErrorHandling.ExceptionForResponseAsync(service, response).ConfigureAwait(false);
}
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
{
// We send ChunkSize bytes at a time to the caller, but we keep ChunkSize + 1 bytes
// buffered. That way we can tell when we've reached the end of the response, even if the
// response length is evenly divisible by ChunkSize, and we can avoid sending a Downloading
// event followed by a Completed event with no bytes downloaded in between.
//
// This maintains the client-visible behavior of a previous implementation.
var buffer = new CountedBuffer(ChunkSize + 1);
while (true)
{
await buffer.Fill(responseStream, cancellationToken).ConfigureAwait(false);
// Send one chunk to the caller's stream.
int bytesToReturn = Math.Min(ChunkSize, buffer.Count);
await stream.WriteAsync(buffer.Data, 0, bytesToReturn, cancellationToken).ConfigureAwait(false);
bytesReturned += bytesToReturn;
buffer.RemoveFromFront(ChunkSize);
if (buffer.IsEmpty)
{
// We had <= ChunkSize bytes buffered, so we've read and returned the entire response.
// Skip sending a Downloading event. We'll send Completed instead.
break;
}
UpdateProgress(new DownloadProgress(DownloadStatus.Downloading, bytesReturned));
}
}
var finalProgress = new DownloadProgress(DownloadStatus.Completed, bytesReturned);
UpdateProgress(finalProgress);
return finalProgress;
}
}
catch (TaskCanceledException ex)
{
Logger.Error(ex, "Download media was canceled");
UpdateProgress(new DownloadProgress(ex, bytesReturned));
throw;
}
catch (Exception ex)
{
Logger.Error(ex, "Exception occurred while downloading media");
var progress = new DownloadProgress(ex, bytesReturned);
UpdateProgress(progress);
//.........这里部分代码省略.........
示例8: NpkReader
internal NpkReader(Stream npkStream, bool disposeStream, Action<object, ErrorDetectedEventArgs> extraErrorHandler)
{
if (extraErrorHandler != null)
{
DoExtraErrorChecks = true;
ErrorDetected += extraErrorHandler;
}
npkStream.ThrowIfNull("npkStream");
m_npkStream = npkStream;
m_disposeStream = disposeStream;
Initialize();
}
示例9: Publish
/// <summary>
/// Publishes the image data provided by the specified stream as the user's
/// avatar.
/// </summary>
/// <param name="stream">A stream containing the image data to publish as
/// the user's avatar.</param>
/// <exception cref="ArgumentNullException">The stream parameter is
/// null.</exception>
/// <exception cref="ArgumentException">The stream does not have a valid
/// image format.</exception>
/// <exception cref="NotSupportedException">The server does not support
/// the 'Personal Eventing Protocol' extension.</exception>
/// <exception cref="XmppErrorException">The server returned an XMPP error code.
/// Use the Error property of the XmppErrorException to obtain the specific
/// error condition.</exception>
/// <exception cref="XmppException">The server returned invalid data or another
/// unspecified XMPP error occurred.</exception>
public void Publish(Stream stream) {
stream.ThrowIfNull("stream");
using (Image image = Image.FromStream(stream)) {
string mimeType = GetMimeType(image);
int width = image.Width;
int height = image.Height;
long size = 0;
string hash = String.Empty, base64Data = String.Empty;
using (var ms = new MemoryStream()) {
image.Save(ms, image.RawFormat);
size = ms.Length;
// Calculate the SHA-1 hash of the image data.
byte[] data = ms.ToArray();
hash = Hash(data);
// Convert the binary data into a BASE64-string.
base64Data = Convert.ToBase64String(data);
}
// Publish the image- and meta data.
pep.Publish("urn:xmpp:avatar:data", hash,
Xml.Element("data", "urn:xmpp:avatar:data").Text(base64Data));
pep.Publish("urn:xmpp:avatar:metadata", hash,
Xml.Element("metadata", "urn:xmpp:avatar:metadata").Child(
Xml.Element("info")
.Attr("bytes", size.ToString())
.Attr("height", height.ToString())
.Attr("width", width.ToString())
.Attr("id", hash)
.Attr("type", mimeType))
);
}
}
示例10: UploadNewVersionAsync
/// <summary>
/// This method is used to upload a new version of an existing file in a user’s account. Similar to regular file uploads,
/// these are performed as multipart form uploads. An optional If-Match header can be included to ensure that client only
/// overwrites the file if it knows about the latest version. The filename on Box will remain the same as the previous version.
/// To update the file’s name, you can specify a new name for the file using the fileName parameter.
/// A proper timeout should be provided for large uploads.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="fileId">Id of the file to upload a new version to.</param>
/// <param name="stream">Stream of the uploading file.</param>
/// <param name="etag">This ‘etag’ field of the file, which will be set in the If-Match header.</param>
/// <param name="fields">Fields which shall be returned in result.</param>
/// <param name="timeout">Optional timeout for response.</param>
/// <param name="contentMD5">The SHA1 hash of the file.</param>
/// <param name="setStreamPositionToZero">Set position for input stream to 0.</param>
/// <param name="uploadUri">Optional url for uploading file.</param>
/// <returns>A full file object is returned.</returns>
public async Task<BoxFile> UploadNewVersionAsync(string fileName, string fileId, Stream stream,
string etag = null, List<string> fields = null,
TimeSpan? timeout = null, byte[] contentMD5 = null,
bool setStreamPositionToZero = true,
Uri uploadUri = null)
{
fileName.ThrowIfNullOrWhiteSpace("fileName");
fileId.ThrowIfNullOrWhiteSpace("fileId");
stream.ThrowIfNull("stream");
if (setStreamPositionToZero)
stream.Position = 0;
uploadUri = uploadUri == null ? new Uri(string.Format(Constants.FilesNewVersionEndpointString, fileId)) : uploadUri;
BoxMultiPartRequest request = new BoxMultiPartRequest(uploadUri) { Timeout = timeout }
.Header(Constants.RequestParameters.IfMatch, etag)
.Param(ParamFields, fields)
.FormPart(new BoxFileFormPart()
{
Name = "filename",
Value = stream,
FileName = fileName
});
if (contentMD5 != null)
request.Header(Constants.RequestParameters.ContentMD5, HexStringFromBytes(contentMD5));
IBoxResponse<BoxCollection<BoxFile>> response = await ToResponseAsync<BoxCollection<BoxFile>>(request).ConfigureAwait(false);
// We can only upload one file at a time, so return the first entry
return response.ResponseObject.Entries.FirstOrDefault();
}
示例11: UploadAsync
/// <summary>
/// Uploads a provided file to the target parent folder.
/// If the file already exists, an error will be thrown.
/// A proper timeout should be provided for large uploads.
/// </summary>
/// <param name="fileRequest">BoxFileRequest object.</param>
/// <param name="stream">Stream of uploading file.</param>
/// <param name="fields">Fields which shall be returned in result.</param>
/// <param name="timeout">Timeout for response.</param>
/// <param name="contentMD5">The SHA1 hash of the file.</param>
/// <param name="setStreamPositionToZero">Set position for input stream to 0.</param>
/// <param name="uploadUri">Uri to use for upload. Default upload endpoint URI is used if not specified.</param>
/// <returns>A full file object is returned inside of a collection if the ID is valid and if the update is successful.</returns>
public async Task<BoxFile> UploadAsync(BoxFileRequest fileRequest, Stream stream, List<string> fields = null,
TimeSpan? timeout = null, byte[] contentMD5 = null,
bool setStreamPositionToZero = true,
Uri uploadUri = null)
{
stream.ThrowIfNull("stream");
fileRequest.ThrowIfNull("fileRequest")
.Name.ThrowIfNullOrWhiteSpace("filedRequest.Name");
fileRequest.Parent.ThrowIfNull("fileRequest.Parent")
.Id.ThrowIfNullOrWhiteSpace("fileRequest.Parent.Id");
if (setStreamPositionToZero)
stream.Position = 0;
uploadUri = uploadUri == null ? _config.FilesUploadEndpointUri : uploadUri;
BoxMultiPartRequest request = new BoxMultiPartRequest(uploadUri) { Timeout = timeout }
.Param(ParamFields, fields)
.FormPart(new BoxStringFormPart()
{
Name = "attributes",
Value = _converter.Serialize(fileRequest)
})
.FormPart(new BoxFileFormPart()
{
Name = "file",
Value = stream,
FileName = fileRequest.Name
});
if (contentMD5 != null)
request.Header(Constants.RequestParameters.ContentMD5, HexStringFromBytes(contentMD5));
IBoxResponse<BoxCollection<BoxFile>> response = await ToResponseAsync<BoxCollection<BoxFile>>(request).ConfigureAwait(false);
// We can only upload one file at a time, so return the first entry
return response.ResponseObject.Entries.FirstOrDefault();
}
示例12: CopyTo
/// <summary>
/// Copies the input stream to the output stream.
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <exception cref="System.IO.IOException"></exception>
/// <exception cref="System.NotSupportedException"></exception>
/// <exception cref="System.ObjectDisposedException"></exception>
/// <exception cref="System.ArgumentNullException"></exception>
public static void CopyTo(this Stream input, Stream output)
{
output.ThrowIfNull("output");
const int bufferSize = 8192;
byte[] buffer = new byte[bufferSize];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
示例13: CopyToPartially
/// <summary>
/// Copies <paramref name="numBytes"/> bytes from <paramref name="input"/> to <paramref name="output"/>.
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="numBytes"></param>
public static void CopyToPartially(this Stream input, Stream output, int numBytes)
{
if (numBytes < 0)
{
throw new ArgumentOutOfRangeException("numBytes", numBytes, "Cannot copy a negative number of bytes ({0}).".F(numBytes));
}
input.ThrowIfNull("input");
output.ThrowIfNull("output");
const int bufferSize = 4096;
byte[] buffer = new byte[bufferSize];
int numBytesCopied = 0;
while (numBytesCopied < numBytes)
{
int numBytesToRead = bufferSize;
if (numBytes - numBytesCopied < bufferSize)
{
numBytesToRead = numBytes - numBytesCopied;
}
input.ReadOrDie(buffer, numBytesToRead);
output.Write(buffer, 0, numBytesToRead);
numBytesCopied += numBytesToRead;
}
}
示例14: CreateServiceFactory
/// <summary>
/// Creates a service factory for the discovery version requested, with the given parameters
/// </summary>
/// <param name="discovery">A stream which contains information about the service to construct</param>
/// <param name="version">The discovery version to use</param>
/// <param name="parameters">
/// A set of (optional) factory parameters used to construct the service.
/// If this parameter is null, then a default set of FactoryParameters is created
/// </param>
public static IServiceFactory CreateServiceFactory(Stream discovery,
DiscoveryVersion version,
IFactoryParameter parameters)
{
discovery.ThrowIfNull("discovery");
version.ThrowIfNull("version");
JsonDictionary information = JsonReader.Parse(discovery) as JsonDictionary;
switch (version)
{
case DiscoveryVersion.Version_0_3:
return new ServiceFactoryDiscoveryV0_3(
information, (FactoryParameterV0_3) (parameters ?? new FactoryParameterV0_3()));
case DiscoveryVersion.Version_1_0:
return new ServiceFactoryDiscoveryV1_0(
information, (FactoryParameterV1_0) (parameters ?? new FactoryParameterV1_0()));
default:
throw new NotSupportedException("The Version " + version + " is not supported");
}
}