18
18
<summary>A read-only input NSStream.</summary>
19
<remarks>To be added.</remarks>
21
<format type="text/html">
22
<h3>Subclassing NSInputStream.</h3>
25
NSInputStream is a concrete subclass of NSStream you can use to give read-only
26
access to stream data. For most cases this is sufficient, however if you want
27
more control over the data, you can subclass NSInputStream. If you subclass NSInputStream
28
you must provide an implementation of the following methods:
29
<list type="bullet"><item><term><see cref="M:MonoMac.Foundation.NSInputStream.Read(IntPtr,uint)" />: In this
30
method you must write bytes to the provided buffer. You can use
31
<see cref="M:System.Runtime.InteropServices.Marshal.Copy(byte[],int,IntPtr,int)" />
32
to write from a byte array to the provided buffer. Return the number of bytes
34
</term></item><item><term><see cref="M:MonoMac.Foundation.NSInputStream.GetBuffer(byte,uint)" />: Return
35
a pointer to a buffer where bytes can be read. You can return false from this
36
method and just implement <see cref="M:MonoMac.Foundation.NSInputStream.Read(IntPtr,uint)" />.
37
</term></item><item><term><see cref="M:MonoMac.Foundation.NSInputStream.HasBytesAvailable()" />: Use
38
this method to indicate when your stream has data to be read.
39
</term></item></list></para>
40
<format type="text/html">
41
<h3>Providing a toll-free bridged NSInputStream subclass.</h3>
44
<format type="text/html">
45
<b>The methods required to provide a toll-free bridged NSInputStream subclass are considered private API,
46
and may cause Apple to reject your app from the App Store.</b>
51
An simple NSInputStream subclass will not work for all API that takes an NSInputStream.
52
This is the case with <see cref="T:MonoMac.Foundation.NSMutableUrlRequest" /> for
53
instance, which actually expects an instance of a CFReadStream object. For this to work
54
our NSInputStream subclass needs to be toll-free bridged to CFReadStream. This is
55
done by overriding the following methods:
56
<list type="bullet"><item><term><see cref="M:MonoMac.Foundation.NSInputStream.SetCFClientFlags(MonoMac.CoreFoundation.CFStreamEventType,IntPtr,IntPtr)" />:
57
This method is called to register a client to notify of events in your
58
stream. You must call the base implementation, with the exact arguments passed
60
</term></item><item><term><see cref="M:MonoMac.Foundation.NSInputStream.ScheduleInCFRunLoop(IntPtr,string)" />:
61
Depending on what you're doing to provide the data, you will need to schedule
62
in a run loop when this method is called. You should not call the base
63
implementation for this method.
64
</term></item><item><term><see cref="M:MonoMac.Foundation.NSInputStream.UnscheduleInCFRunLoop(IntPtr,string)" />:
65
This is called when you need to unschedule from a run loop. You should not call
66
the base implementation for this method.
68
You must call also <see cref="M:MonoMac.Foundation.NSInputStream.Notify((valuetype MonoMac.CoreFoundation.CFStreamEventType)" />
69
to inform the client when you have data available (or when you have any other relevant
70
event), otherwise your input stream won't be read from.
22
75
<Member MemberName=".ctor">
67
126
<AssemblyVersion>0.0.0.0</AssemblyVersion>
130
<AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
70
134
<Parameter Name="t" Type="MonoMac.Foundation.NSObjectFlag" />
73
137
<param name="t">Unused sentinel value, pass NSObjectFlag.Empty.</param>
74
<summary>Constructor to call on derived classes to skip initialization and merely allocate the object.</summary>
138
<summary>Constructor to call on derived classes when the derived class has an [Export] constructor.</summary>
76
<para>This constructor should be called by derived classes when they completely construct the object in managed code and merely want the runtime to allocate and initialize the NSObject. This is required to implement the two-step initialization process that Objective-C uses, the first step is to perform the object allocation, the second step is to initialize the object. When you invoke the constructor that takes the NSObjectFlag.Empty you taking advatnage of a direct path that goes all the way up to NSObject to merely allocate the object's memory and bind the Objective-C and C# objects together. The actual initialization of the object is up to you.</para>
77
<para>This constructor is typically used by the binding generator to allocate the object, but prevent the actual initialization to take place. Once the allocation has taken place, the constructor has to initialize the object. With constructors generated by the binding generator this means that it manually invokes one of the "init" methods to initialize the object.</para>
78
<para>It is your responsability to completely initialize the object if you chain up using the NSObjectFlag.Empty path.</para>
79
<para>In general, if your constructors invokes the NSObjectFlag.Empty base implementation, then it should be calling an Objective-C init method. If this is not the case, you should instead chain to the proper constructor in your class. </para>
80
<para>The argument value is ignored and merely ensures that the only code that is executed is the construction phase is the basic NSObject allocation and runtime type registration. Typically the chaining would look like this:</para>
140
<para>This constructor should be called by derived classes when they are initialized using an [Export] attribute. The argument value is ignore, typically the chaining would look like this:</para>
84
// The NSObjectFlag merely allocates the object and registers the
85
// C# class with the Objective-C runtime if necessary, but no actual
86
// initXxx method is invoked, that is done later in the constructor
88
// This is taken from MonoMac's source code:
90
[Export ("initWithFrame:")]
91
public UIView (System.Drawing.RectangleF frame) : base (NSObjectFlag.Empty)
93
// Invoke the init method now.
94
var initWithFrame = new Selector ("initWithFrame:").Handle;
96
Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_RectangleF (this.Handle, initWithFrame, frame);
98
Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_RectangleF (this.SuperHandle, initWithFrame, frame);
143
public class MyClass : BaseClass {
144
[Export ("initWithFoo:")]
145
public MyClass (string foo) : base (NSObjectFlag.Empty)
157
211
<remarks>Each MonoMac class mirrors an unmanaged Objective-C class. This value contains the pointer to the Objective-C class, it is similar to calling objc_getClass with the object name.</remarks>
214
<Member MemberName="Dispose">
215
<MemberSignature Language="C#" Value="protected override void Dispose (bool disposing);" />
216
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void Dispose(bool disposing) cil managed" />
217
<MemberType>Method</MemberType>
219
<AssemblyVersion>0.0.0.0</AssemblyVersion>
222
<ReturnType>System.Void</ReturnType>
225
<Parameter Name="disposing" Type="System.Boolean" />
228
<param name="disposing">
229
<para>If set to <see langword="true" />, the method is invoked directly and will dispose manage and unmanaged resources; If set to <see langword="false" /> the method is being called by the garbage collector finalizer and should only release unmanaged resources.</para>
231
<summary>Releases the resources used by the NSInputStream object.</summary>
233
<para>This Dispose method releases the resources used by the NSInputStream class.</para>
234
<para>This method is called by both the Dispose() method and the object finalizer (Finalize). When invoked by the Dispose method, the parameter disposting <paramref name="disposing" /> is set to <see langword="true" /> and any managed object references that this object holds are also disposed or released; when invoked by the object finalizer, on the finalizer thread the value is set to <see langword="false" />. </para>
235
<para>Calling the Dispose method when you are finished using the NSInputStream ensures that all external resources used by this managed object are released as soon as possible. Once you have invoked the Dispose method, the object is no longer useful and you should no longer make any calls to it.</para>
236
<para> For more information on how to override this method and on the Dispose/IDisposable pattern, read the ``Implementing a Dispose Method'' document at http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx</para>
160
240
<Member MemberName="FromData">
161
241
<MemberSignature Language="C#" Value="public static MonoMac.Foundation.NSInputStream FromData (MonoMac.Foundation.NSData data);" />
162
242
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class MonoMac.Foundation.NSInputStream FromData(class MonoMac.Foundation.NSData data) cil managed" />
207
287
<remarks>To be added.</remarks>
290
<Member MemberName="GetBuffer">
291
<MemberSignature Language="C#" Value="protected virtual bool GetBuffer (out IntPtr buffer, out uint len);" />
292
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool GetBuffer(native int buffer, unsigned int32 len) cil managed" />
293
<MemberType>Method</MemberType>
295
<AssemblyVersion>0.0.0.0</AssemblyVersion>
299
<AttributeName>MonoMac.Foundation.Export("getBuffer:length:")</AttributeName>
303
<ReturnType>System.Boolean</ReturnType>
306
<Parameter Name="buffer" Type="System.IntPtr&" RefType="out" />
307
<Parameter Name="len" Type="System.UInt32&" RefType="out" />
310
<param name="buffer">Upon return points to the first of an array of bytes where the caller can read bytes from. The buffer is only valid until the next stream operation.</param>
311
<param name="len">Upon return specifies how many bytes can be written to the buffer.</param>
312
<summary>This method can return a pointer to a buffer the caller can read data from.</summary>
313
<returns>A boolean value indicating whether the returned buffer is valid or not.</returns>
314
<remarks>It is recommended to just return false from this method. An implementation must ensure that the returned byte pointer is not moved or collected by the garbage collector until the next stream operation is performed. One way of accomplishing this is with a pinned byte array (pinned with a GCHandle).</remarks>
210
317
<Member MemberName="HasBytesAvailable">
211
318
<MemberSignature Language="C#" Value="public virtual bool HasBytesAvailable ();" />
212
319
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool HasBytesAvailable() cil managed" />
227
<summary>To be added.</summary>
228
<returns>To be added.</returns>
229
<remarks>To be added.</remarks>
334
<summary>Returna a boolean value indicating whether the stream has bytes available to be read.</summary>
335
<returns>A boolean value indicating whether the stream has bytes available to be read.</returns>
336
<remarks>This method should return true if it does not know if there are available bytes or not.</remarks>
339
<Member MemberName="Notify">
340
<MemberSignature Language="C#" Value="public void Notify (MonoMac.CoreFoundation.CFStreamEventType eventType);" />
341
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Notify(valuetype MonoMac.CoreFoundation.CFStreamEventType eventType) cil managed" />
342
<MemberType>Method</MemberType>
344
<AssemblyVersion>0.0.0.0</AssemblyVersion>
347
<ReturnType>System.Void</ReturnType>
350
<Parameter Name="eventType" Type="MonoMac.CoreFoundation.CFStreamEventType" />
353
<param name="eventType">The events to notify.</param>
354
<summary>Notifies consumers of events in the stream.</summary>
232
359
<Member MemberName="Read">
244
371
<Parameter Name="len" Type="System.UInt32" />
247
<param name="buffer">To be added.</param>
248
<param name="len">To be added.</param>
249
<summary>To be added.</summary>
250
<returns>To be added.</returns>
251
<remarks>To be added.</remarks>
374
<param name="buffer">The buffer where data should be put.</param>
375
<param name="len">The size of the buffer (in bytes).</param>
376
<summary>Reads data from the stream into the provided buffer.</summary>
377
<returns>The number of bytes actually written.</returns>
382
<Member MemberName="Read">
383
<MemberSignature Language="C#" Value="public virtual int Read (IntPtr buffer, uint len);" />
384
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance int32 Read(native int buffer, unsigned int32 len) cil managed" />
385
<MemberType>Method</MemberType>
387
<AssemblyVersion>0.0.0.0</AssemblyVersion>
391
<AttributeName>MonoMac.Foundation.Export("read:maxLength:")</AttributeName>
395
<ReturnType>System.Int32</ReturnType>
398
<Parameter Name="buffer" Type="System.IntPtr" />
399
<Parameter Name="len" Type="System.UInt32" />
402
<param name="buffer">The buffer where data should be put.</param>
403
<param name="len">The size of the buffer (in bytes).</param>
404
<summary>Reads data from the stream into the provided buffer. You should not call this method directly, you should call <see cref="M:MonoMac.Foundation.NSInputStream.Read(byte[],uint)" />
405
instead. This method is for NSInputStream subclasses to implement.</summary>
406
<returns>The number of bytes actually written.</returns>
407
<remarks>You can use methods in <see cref="T:System.Runtime.InteropServices.Marshal" /> to write to the buffer (for instance: <see cref="M:System.Runtime.InteropServices.Marshal.Copy(byte[],int,IntPtr,int)" /> to write from a byte array).</remarks>
410
<Member MemberName="ScheduleInCFRunLoop">
411
<MemberSignature Language="C#" Value="public virtual void ScheduleInCFRunLoop (MonoMac.CoreFoundation.CFRunLoop runloop, MonoMac.Foundation.NSString mode);" />
412
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void ScheduleInCFRunLoop(class MonoMac.CoreFoundation.CFRunLoop runloop, class MonoMac.Foundation.NSString mode) cil managed" />
413
<MemberType>Method</MemberType>
415
<AssemblyVersion>0.0.0.0</AssemblyVersion>
419
<AttributeName>MonoMac.Foundation.Export("_scheduleInCFRunLoop:forMode:")</AttributeName>
423
<ReturnType>System.Void</ReturnType>
426
<Parameter Name="runloop" Type="MonoMac.CoreFoundation.CFRunLoop" />
427
<Parameter Name="mode" Type="MonoMac.Foundation.NSString" />
430
<param name="runloop">The RunLoop to schedule in.</param>
431
<param name="mode">The RunLoop mode to schedule in.</param>
432
<summary>Schedules the stream in a RunLoop.</summary>
437
<Member MemberName="SetCFClientFlags">
438
<MemberSignature Language="C#" Value="protected virtual bool SetCFClientFlags (MonoMac.CoreFoundation.CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr);" />
439
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool SetCFClientFlags(valuetype MonoMac.CoreFoundation.CFStreamEventType inFlags, native int inCallback, native int inContextPtr) cil managed" />
440
<MemberType>Method</MemberType>
442
<AssemblyVersion>0.0.0.0</AssemblyVersion>
446
<AttributeName>MonoMac.Foundation.Export("_setCFClientFlags:callback:context:")</AttributeName>
450
<ReturnType>System.Boolean</ReturnType>
453
<Parameter Name="inFlags" Type="MonoMac.CoreFoundation.CFStreamEventType" />
454
<Parameter Name="inCallback" Type="System.IntPtr" />
455
<Parameter Name="inContextPtr" Type="System.IntPtr" />
458
<param name="inFlags">Flags.</param>
459
<param name="inCallback">The callbacks to call when events occur.</param>
460
<param name="inContextPtr">User-defined data for the callback.</param>
461
<summary>Adds a client for the stream. This method is not supposed to be called by managed code, it will be called by consumers of the straem. When overriding it make sure to call the base implementation.</summary>
468
<Member MemberName="UnscheduleInCFRunLoop">
469
<MemberSignature Language="C#" Value="public virtual void UnscheduleInCFRunLoop (MonoMac.CoreFoundation.CFRunLoop runloop, MonoMac.Foundation.NSString mode);" />
470
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void UnscheduleInCFRunLoop(class MonoMac.CoreFoundation.CFRunLoop runloop, class MonoMac.Foundation.NSString mode) cil managed" />
471
<MemberType>Method</MemberType>
473
<AssemblyVersion>0.0.0.0</AssemblyVersion>
477
<AttributeName>MonoMac.Foundation.Export("_unscheduleFromCFRunLoop:forMode:")</AttributeName>
481
<ReturnType>System.Void</ReturnType>
484
<Parameter Name="runloop" Type="MonoMac.CoreFoundation.CFRunLoop" />
485
<Parameter Name="mode" Type="MonoMac.Foundation.NSString" />
488
<param name="runloop">The RunLoop to unschedule.</param>
489
<param name="mode">The mode to unschedule.</param>
490
<summary>Unschedules the stream from a RunLoop.</summary>