本文整理汇总了C#中TransferMode类的典型用法代码示例。如果您正苦于以下问题:C# TransferMode类的具体用法?C# TransferMode怎么用?C# TransferMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransferMode类属于命名空间,在下文中一共展示了TransferMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
public static void Validate(TransferMode value)
{
if (!IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int) value, typeof(TransferMode)));
}
}
示例2: Validate
public static void Validate(TransferMode value)
{
if (!IsDefined(value))
{
throw Fx.Exception.AsError(new InvalidEnumArgumentException("value", (int)value, typeof(TransferMode)));
}
}
示例3: ServiceConfigurationAttribute
public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, TransferMode transferMode, params string[] bindingConfiguration)
{
CustomErrorHandler = customErrorHandler;
TransferMode = transferMode;
BehaviorConfiguration = behaviorConfiguration;
BindingConfiguration = bindingConfiguration;
}
示例4: Validate
public static void Validate(TransferMode value, string parameterValue)
{
if (!IsDefined(value))
{
throw Error.InvalidEnumArgument(parameterValue, (int)value, typeof(TransferMode));
}
}
示例5: IsDefined
public static bool IsDefined(TransferMode transferMode)
{
return transferMode == TransferMode.Buffered ||
transferMode == TransferMode.Streamed ||
transferMode == TransferMode.StreamedRequest ||
transferMode == TransferMode.StreamedResponse;
}
示例6: TransferFolder
public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode, bool verified = true)
{
Ensure.That(sourcePath, () => sourcePath).IsValidPath();
Ensure.That(targetPath, () => targetPath).IsValidPath();
if (!_diskProvider.FolderExists(targetPath))
{
_diskProvider.CreateFolder(targetPath);
}
var result = mode;
foreach (var subDir in _diskProvider.GetDirectoryInfos(sourcePath))
{
result &= TransferFolder(subDir.FullName, Path.Combine(targetPath, subDir.Name), mode, verified);
}
foreach (var sourceFile in _diskProvider.GetFileInfos(sourcePath))
{
var destFile = Path.Combine(targetPath, sourceFile.Name);
result &= TransferFile(sourceFile.FullName, destFile, mode, true, verified);
}
if (mode.HasFlag(TransferMode.Move))
{
_diskProvider.DeleteFolder(sourcePath, true);
}
return result;
}
示例7: Init
public override bool Init(ControlChannel controlClient, TransferMode mode)
{
var command = "LIST" + (string.IsNullOrWhiteSpace(infoTargetName) ? string.Empty : " " + infoTargetName);
_dataClient = PrepareDataChannel(controlClient, mode, command);
return true;
}
示例8: IsDefined
public static bool IsDefined(TransferMode v)
{
if (((v != TransferMode.Buffered) && (v != TransferMode.Streamed)) && (v != TransferMode.StreamedRequest))
{
return (v == TransferMode.StreamedResponse);
}
return true;
}
示例9: IsResponseStreamed
public static bool IsResponseStreamed(TransferMode v)
{
if (v != TransferMode.StreamedResponse)
{
return (v == TransferMode.Streamed);
}
return true;
}
示例10: ControlChannel
internal ControlChannel(Session host)
{
m_connection = new TcpClient();
m_server = "localhost";
m_port = 21;
m_sessionHost = host;
m_currentTransferMode = TransferMode.Unknown;
}
示例11: IsRequestStreamed
public static bool IsRequestStreamed(TransferMode v)
{
if (v != TransferMode.StreamedRequest)
{
return (v == TransferMode.Streamed);
}
return true;
}
示例12: WcfConstantSettingConfig
/// <summary>
/// wcf服务端常量设置文件
/// </summary>
/// <param name="doc"></param>
public WcfConstantSettingConfig(XmlDocument doc)
{
try
{
foreach (XmlNode elem in XmlHelper.Children(doc.DocumentElement, "NetTcpBinding"))
{
XmlElement xe = XmlHelper.Child(elem, "readerQuotas");
int.TryParse(xe.GetAttribute("maxDepth"), out _maxDepth);
int.TryParse(xe.GetAttribute("maxStringContentLength"), out _maxStringContentLength);
int.TryParse(xe.GetAttribute("maxArrayLength"), out _maxArrayLength);
int.TryParse(xe.GetAttribute("maxBytesPerRead"), out _maxBytesPerRead);
int.TryParse(xe.GetAttribute("maxNameTableCharCount"), out _maxNameTableCharCount);
XmlElement xea = XmlHelper.Child(elem, "reliableSession");
Boolean.TryParse(xea.GetAttribute("enabled"), out _reliableSessionEnabled);
Boolean.TryParse(xea.GetAttribute("ordered"), out _reliableSessionOrdered);
TimeSpan.TryParse(xea.GetAttribute("inactivityTimeout"), out _reliableSessionInactivityTimeout);
XmlElement xe1 = XmlHelper.Child(elem, "host");
_addres = new Uri(xe1.GetAttribute("baseAddress"));
_binding = new NetTcpBinding();
XmlElement xe2 = XmlHelper.Child(elem, "behaviors");
TimeSpan.TryParse(xe2.GetAttribute("closeTimeout"), out _closeTimeout);
TimeSpan.TryParse(xe2.GetAttribute("openTimeout"), out _openTimeout);
TimeSpan.TryParse(xe2.GetAttribute("receiveTimeout"), out _receiveTimeout);
TimeSpan.TryParse(xe2.GetAttribute("sendTimeout"), out _sendTimeout);
Boolean.TryParse(xe2.GetAttribute("transactionFlow"), out _transactionFlow);
_transferMode = (TransferMode)Enum.Parse(typeof(TransferMode), xe2.GetAttribute("transferMode"));
_transactionProtocol = xe2.GetAttribute("transactionProtocol");
_hostNameComparisonMode = (HostNameComparisonMode)Enum.Parse(typeof(HostNameComparisonMode), xe2.GetAttribute("hostNameComparisonMode"));
int.TryParse(xe2.GetAttribute("listenBacklog"), out _listenBacklog);
int.TryParse(xe2.GetAttribute("maxBufferPoolSize"), out _maxBufferPoolSize);
int.TryParse(xe2.GetAttribute("maxBufferSize"), out _maxBufferSize);
int.TryParse(xe2.GetAttribute("maxConnections"), out _maxConnections);
int.TryParse(xe2.GetAttribute("maxReceivedMessageSize"), out _maxReceivedMessageSize);
bool.TryParse(xe2.GetAttribute("portSharingEnabled"), out _portSharingEnabled);
_securitymode = (SecurityMode)Enum.Parse(typeof(SecurityMode), xe2.GetAttribute("securitymode"));
_clientCredentialType = (MessageCredentialType)Enum.Parse(typeof(MessageCredentialType), xe2.GetAttribute("clientCredentialType"));
//_enableBinaryFormatterBehavior = bool.Parse(xe2.GetAttribute("enableBinaryFormatterBehavior"));
XmlElement xe3 = XmlHelper.Child(elem, "serviceDebug");
Boolean.TryParse(xe3.GetAttribute("includeExceptionDetailInFaults"), out _includeExceptionDetailInFaults);
XmlElement xe4 = XmlHelper.Child(elem, "serviceThrottling");
int.TryParse(xe4.GetAttribute("maxConcurrentCalls"), out _maxConcurrentCalls);
int.TryParse(xe4.GetAttribute("maxConcurrentInstances"), out _maxConcurrentInstances);
int.TryParse(xe4.GetAttribute("maxConcurrentSessions"), out _maxConcurrentSessions);
//XmlElement xe5 = XmlHelper.Child(elem, "dataContractSerializer");
//int.TryParse(xe5.GetAttribute("maxItemsInObjectGraph"), out _maxItemsInObjectGraph);
}
}
catch (Exception oe)
{
throw new ArgumentException(oe.Message);
}
}
示例13: WebSocketTransportDuplexSessionChannel
public WebSocketTransportDuplexSessionChannel(HttpChannelFactory<IDuplexSessionChannel> channelFactory, EndpointAddress remoteAddresss, Uri via)
: base(channelFactory, channelFactory, EndpointAddress.AnonymousAddress, channelFactory.MessageVersion.Addressing.AnonymousUri, remoteAddresss, via)
{
Fx.Assert(channelFactory.WebSocketSettings != null, "channelFactory.WebSocketTransportSettings should not be null.");
_webSocketSettings = channelFactory.WebSocketSettings;
_transferMode = channelFactory.TransferMode;
_maxBufferSize = channelFactory.MaxBufferSize;
_transportFactorySettings = channelFactory;
}
示例14: transfer
/*Initiates a TFTP file transfer from the server to the local machine.*/
public bool transfer(IPEndPoint server, String filename, bool error, TransferMode mode)
{
if (DEBUG) { Console.WriteLine("Retrieving file " + filename + " from server at " + server.ToString() + (error ? " with errors " : " without errors ") + "using transfer mode " + (mode == TransferMode.NETASCII ? "netascii." : "octet.")); }
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
byte[] block;
byte[] message = new byte[416];
UInt16 blocknum;
Int32 msgBytes = 0;
Int32 index = 0;
BinaryWriter fileWriter;
UdpClient client = new UdpClient();
fileWriter = new BinaryWriter(File.Create(filename, 512));
requestData(client, server, filename, error, mode);
do
{
block = recieveData(client, ref sender);
if (DEBUG) { Console.WriteLine("Recieved datagram with length " + block.Length + " from " + sender.ToString() + "with op code " + HammingCode.getOpCode(block) + ":\n" + ASCII.GetString(block)); }
if (HammingCode.getOpCode(block) == 3)
{
blocknum = HammingCode.getBlockNum(block);
if (DEBUG) { Console.WriteLine("Recieved data packet with block number: " + blocknum); }
if (HammingCode.getMessage(block, block.Length, ref message, ref msgBytes))
{
fileWriter.Write(message, 0, msgBytes);
index += msgBytes;
acknowledge(client, sender, blocknum);
}
else
{
nacknowledge(client, sender, blocknum);
continue;
}
}
else if (HammingCode.getOpCode(block) == 5) //error
{
Console.WriteLine("Error encountered. Terminating file transfer.");
client.Close();
fileWriter.Close();
File.Delete(filename);
return false;
}
else //wtf?
{
Console.WriteLine("Recieved packet with unexpected op code. Terminating file transfer.");
client.Close();
fileWriter.Close();
File.Delete(filename);
return false;
}
}
while (block.Length > 515);
fileWriter.Close();
return true;
}
示例15: ServiceConfigurationAttribute
public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, TransferMode transferMode,
InstanceContextMode instanceContextMode, ConcurrencyMode concurencyMode, params string[] bindingConfiguration)
{
InstanceContextMode = instanceContextMode;
ConcurrencyMode = concurencyMode;
CustomErrorHandler = customErrorHandler;
TransferMode = transferMode;
BehaviorConfiguration = behaviorConfiguration;
BindingConfiguration = bindingConfiguration;
}