本文整理汇总了C#中IOMode类的典型用法代码示例。如果您正苦于以下问题:C# IOMode类的具体用法?C# IOMode怎么用?C# IOMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOMode类属于命名空间,在下文中一共展示了IOMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RubyIO
// TODO: hack
public RubyIO(RubyContext/*!*/ context, StreamReader reader, StreamWriter writer, string/*!*/ modeString)
: this(context) {
_mode = ParseIOMode(modeString, out _preserveEndOfLines);
_stream = new DuplexStream(reader, writer);
ResetLineNumbersForReadOnlyFiles(context);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:RubyIO.cs
示例2: Parameter
/// <summary>
/// Constructor for a parameter
/// </summary>
/// <param name="mode"></param>
/// <param name="variableType"></param>
public Parameter(string name,IOMode mode, VariableType variableType,int size)
{
this.mode = mode;
this.variableType = variableType;
this.name = name;
this.size = size;
}
开发者ID:mikeabrahamsen,项目名称:uPascalCompiler,代码行数:12,代码来源:Parameter.cs
示例3: OpenFileStream
public static Stream/*!*/ OpenFileStream(RubyContext/*!*/ context, string/*!*/ path, IOMode mode) {
ContractUtils.RequiresNotNull(path, "path");
FileAccess access = mode.ToFileAccess();
FileMode fileMode;
if ((mode & IOMode.CreateIfNotExists) != 0) {
if ((mode & IOMode.ErrorIfExists) != 0) {
access |= FileAccess.Write;
fileMode = FileMode.CreateNew;
} else {
fileMode = FileMode.OpenOrCreate;
}
} else {
fileMode = FileMode.Open;
}
if ((mode & IOMode.Truncate) != 0 && (access & FileAccess.Write) == 0) {
throw RubyExceptions.CreateEINVAL("cannot truncate a file opened for reading only");
}
if ((mode & IOMode.WriteAppends) != 0 && (access & FileAccess.Write) == 0) {
throw RubyExceptions.CreateEINVAL("cannot append to a file opened for reading only");
}
if (String.IsNullOrEmpty(path)) {
throw RubyExceptions.CreateEINVAL();
}
Stream stream;
if (path == "NUL") {
stream = Stream.Null;
} else {
try {
stream = context.DomainManager.Platform.OpenInputFileStream(path, fileMode, access, FileShare.ReadWrite);
} catch (FileNotFoundException) {
throw RubyExceptions.CreateENOENT(String.Format("No such file or directory - {0}", path));
} catch (DirectoryNotFoundException e) {
throw RubyExceptions.CreateENOENT(e.Message, e);
} catch (PathTooLongException e) {
throw RubyExceptions.CreateENOENT(e.Message, e);
} catch (IOException) {
if ((mode & IOMode.ErrorIfExists) != 0) {
throw RubyExceptions.CreateEEXIST(path);
} else {
throw;
}
} catch (ArgumentException e) {
throw RubyExceptions.CreateEINVAL(e.Message, e);
}
}
if ((mode & IOMode.Truncate) != 0) {
stream.SetLength(0);
}
return stream;
}
开发者ID:andreakn,项目名称:ironruby,代码行数:58,代码来源:RubyFile.cs
示例4: RubyIO
public RubyIO(RubyContext/*!*/ context, Stream/*!*/ stream, int descriptor, IOMode mode)
: this(context)
{
ContractUtils.RequiresNotNull(context, "context");
ContractUtils.RequiresNotNull(stream, "stream");
SetStream(stream);
_mode = mode;
_fileDescriptor = descriptor;
}
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:RubyIO.cs
示例5: CheckContent
private static MutableString/*!*/ CheckContent(MutableString/*!*/ content, IOMode mode) {
if (content.IsFrozen && mode.CanWrite()) {
throw Errno.CreateEACCES("Permission denied");
}
if ((mode & IOMode.Truncate) != 0) {
content.Clear();
}
return content;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:10,代码来源:StringIO.cs
示例6: RubyInputProvider
internal RubyInputProvider(RubyContext/*!*/ context, ICollection<string>/*!*/ arguments, RubyEncoding/*!*/ encoding) {
Assert.NotNull(context, encoding);
Assert.NotNullItems(arguments);
_context = context;
var args = new RubyArray();
foreach (var arg in arguments) {
ExpandArgument(args, arg, encoding);
}
_commandLineArguments = args;
_lastInputLineNumber = 1;
_currentFileIndex = -1;
_singleton = new object();
_defaultMode = IOMode.ReadOnly;
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:16,代码来源:RubyInputProvider.cs
示例7: RubyFile
public RubyFile(RubyContext/*!*/ context, Stream/*!*/ stream, int descriptor, IOMode mode)
: base(context, stream, descriptor, mode) {
_path = null;
}
开发者ID:andreakn,项目名称:ironruby,代码行数:4,代码来源:RubyFile.cs
示例8: Reset
public void Reset(Stream/*!*/ stream, IOMode mode) {
_mode = mode;
SetStream(stream);
SetFileDescriptor(Context.AllocateFileDescriptor(stream));
}
开发者ID:rpattabi,项目名称:ironruby,代码行数:5,代码来源:RubyIO.cs
示例9: BuildParameterList
private List<Parameter> BuildParameterList(List<string> identifierList, TypeRecord variableType,
IOMode ioMode,List<Parameter> parameterList)
{
foreach (string name in identifierList)
{
parameterList.Add(new Parameter(name,ioMode, variableType.variableType,1));
}
return parameterList;
}
开发者ID:mikeabrahamsen,项目名称:uPascalCompiler,代码行数:9,代码来源:Parser.cs
示例10: OpenPipe
public static RubyIO/*!*/ OpenPipe(
RubyContext/*!*/ context,
MutableString/*!*/ command,
IOMode mode) {
bool redirectStandardInput = mode.CanWrite();
bool redirectStandardOutput = mode.CanRead();
Process process = RubyProcess.CreateProcess(context, command, redirectStandardInput, redirectStandardOutput, false);
StreamReader reader = null;
StreamWriter writer = null;
if (redirectStandardOutput) {
reader = process.StandardOutput;
}
if (redirectStandardInput) {
writer = process.StandardInput;
}
return new RubyIO(context, reader, writer, mode);
}
开发者ID:ghouston,项目名称:ironlanguages,代码行数:22,代码来源:IoOps.cs
示例11: CheckOpenPipe
private static RubyIO CheckOpenPipe(RubyContext/*!*/ context, MutableString path, IOMode mode) {
string fileName = path.ConvertToString();
if (fileName.Length > 0 && fileName[0] == '|') {
#if SILVERLIGHT
throw new NotSupportedException("open cannot create a subprocess");
#else
if (fileName.Length > 1 && fileName[1] == '-') {
throw new NotImplementedError("forking a process is not supported");
}
return RubyIOOps.OpenPipe(context, path.GetSlice(1), (IOMode)mode);
#endif
}
return null;
}
开发者ID:yarrow2,项目名称:ironruby,代码行数:14,代码来源:KernelOps.cs
示例12: StringIO
public StringIO(MutableString/*!*/ content, IOMode mode) {
ContractUtils.RequiresNotNull(content, "content");
_content = content;
_mode = mode;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:5,代码来源:StringIO.cs
示例13: IsReadable
public static bool IsReadable(IOMode mode) {
return (mode == IOMode.ReadOnlyFromStart ||
mode == IOMode.ReadWriteAppend ||
mode == IOMode.ReadWriteFromStart ||
mode == IOMode.ReadWriteTruncate);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:6,代码来源:RubyIO.cs
示例14: RubyFile
public RubyFile(RubyContext/*!*/ context, MutableString/*!*/ path, IOMode mode)
: this(context, context.DecodePath(path), mode) {
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:3,代码来源:RubyFile.cs
示例15: Write
public override void Write(bool state)
{
Mode = IOMode.Output;
_port.Write(state);
}
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:6,代码来源:NativeDigitalIO.cs
示例16: setIOConfiguration
/**
* Sets the configuration of the given IO line of this XBee device.
*
* @param ioLine The IO line to configure.
* @param ioMode The IO mode to set to the IO line.
*
* @throws InterfaceNotOpenException if this device connection is not open.
* @throws ArgumentNullException if {@code ioLine == null} or
* if {@code ioMode == null}.
* @throws TimeoutException if there is a timeout sending the set
* configuration command.
* @throws XBeeException if there is any other XBee related exception.
*
* @see #getIOConfiguration(IOLine)
* @see com.digi.xbee.api.io.IOLine
* @see com.digi.xbee.api.io.IOMode
*/
public void setIOConfiguration(IOLine ioLine, IOMode ioMode)/*throws TimeoutException, XBeeException */{
// Check IO line.
if (ioLine == null)
throw new ArgumentNullException("IO line cannot be null.");
if (ioMode == null)
throw new ArgumentNullException("IO mode cannot be null.");
// Check connection.
if (!connectionInterface.SerialPort.IsOpen)
throw new InterfaceNotOpenException();
SetParameter(ioLine.GetConfigurationATCommand(), new byte[] { (byte)ioMode.GetId() });
}
开发者ID:LordVeovis,项目名称:xbee-csharp-library,代码行数:29,代码来源:AbstractXBeeDevice.cs
示例17: RubyIO
public RubyIO(RubyContext/*!*/ context, Stream/*!*/ stream, IOMode mode)
: this(context, stream, context.AllocateFileDescriptor(stream), mode) {
}
开发者ID:rpattabi,项目名称:ironruby,代码行数:3,代码来源:RubyIO.cs
示例18: ResetIOMode
public void ResetIOMode(string/*!*/ modeString) {
_mode = ParseIOMode(modeString, out _preserveEndOfLines);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:3,代码来源:RubyIO.cs
示例19: Read
public override bool Read()
{
Mode = IOMode.Input;
return _port.Read();
}
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:6,代码来源:NativeDigitalIO.cs
示例20: Close
private void Close() {
_mode = _mode.Close();
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:StringIO.cs
注:本文中的IOMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论