~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/monomac/docs/en/MonoMac.Foundation/NSInputStream.xml

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
  </Attributes>
17
17
  <Docs>
18
18
    <summary>A read-only input NSStream.</summary>
19
 
    <remarks>To be added.</remarks>
 
19
    <remarks>
 
20
      <para>
 
21
        <format type="text/html">
 
22
          <h3>Subclassing NSInputStream.</h3>
 
23
        </format>
 
24
                
 
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
 
33
                                        actually written.
 
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>
 
42
      </format>
 
43
      <para>
 
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>
 
47
        </format>
 
48
      </para>
 
49
      <para>
 
50
 
 
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
 
59
                                        in.
 
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.
 
67
                                </term></item></list>
 
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.
 
71
        </para>
 
72
    </remarks>
20
73
  </Docs>
21
74
  <Members>
22
75
    <Member MemberName=".ctor">
30
83
        <Attribute>
31
84
          <AttributeName>MonoMac.Foundation.Export("init")</AttributeName>
32
85
        </Attribute>
 
86
        <Attribute>
 
87
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
88
        </Attribute>
33
89
      </Attributes>
34
90
      <Parameters />
35
91
      <Docs>
49
105
        <Attribute>
50
106
          <AttributeName>MonoMac.Foundation.Export("initWithCoder:")</AttributeName>
51
107
        </Attribute>
 
108
        <Attribute>
 
109
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
110
        </Attribute>
52
111
      </Attributes>
53
112
      <Parameters>
54
113
        <Parameter Name="coder" Type="MonoMac.Foundation.NSCoder" />
66
125
      <AssemblyInfo>
67
126
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
68
127
      </AssemblyInfo>
 
128
      <Attributes>
 
129
        <Attribute>
 
130
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
131
        </Attribute>
 
132
      </Attributes>
69
133
      <Parameters>
70
134
        <Parameter Name="t" Type="MonoMac.Foundation.NSObjectFlag" />
71
135
      </Parameters>
72
136
      <Docs>
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>
75
139
        <remarks>
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>
81
141
          <example>
82
142
            <code lang="C#">
83
 
//
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
87
 
//
88
 
// This is taken from MonoMac's source code:
89
 
//
90
 
[Export ("initWithFrame:")]
91
 
public UIView (System.Drawing.RectangleF frame) : base (NSObjectFlag.Empty)
92
 
{
93
 
// Invoke the init method now.
94
 
        var initWithFrame = new Selector ("initWithFrame:").Handle;
95
 
        if (IsDirectBinding)
96
 
                Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_RectangleF (this.Handle, initWithFrame, frame);
97
 
        else
98
 
                Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_RectangleF (this.SuperHandle, initWithFrame, frame);
99
 
}
 
143
public class MyClass : BaseClass {
 
144
    [Export ("initWithFoo:")]
 
145
    public MyClass (string foo) : base (NSObjectFlag.Empty)
 
146
    {
 
147
        ...
 
148
    }
100
149
</code>
101
150
          </example>
102
151
        </remarks>
109
158
      <AssemblyInfo>
110
159
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
111
160
      </AssemblyInfo>
 
161
      <Attributes>
 
162
        <Attribute>
 
163
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
164
        </Attribute>
 
165
      </Attributes>
112
166
      <Parameters>
113
167
        <Parameter Name="handle" Type="System.IntPtr" />
114
168
      </Parameters>
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>
158
212
      </Docs>
159
213
    </Member>
 
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>
 
218
      <AssemblyInfo>
 
219
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
220
      </AssemblyInfo>
 
221
      <ReturnValue>
 
222
        <ReturnType>System.Void</ReturnType>
 
223
      </ReturnValue>
 
224
      <Parameters>
 
225
        <Parameter Name="disposing" Type="System.Boolean" />
 
226
      </Parameters>
 
227
      <Docs>
 
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>
 
230
        </param>
 
231
        <summary>Releases the resources used by the NSInputStream object.</summary>
 
232
        <remarks>
 
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>
 
237
        </remarks>
 
238
      </Docs>
 
239
    </Member>
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>
208
288
      </Docs>
209
289
    </Member>
 
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>
 
294
      <AssemblyInfo>
 
295
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
296
      </AssemblyInfo>
 
297
      <Attributes>
 
298
        <Attribute>
 
299
          <AttributeName>MonoMac.Foundation.Export("getBuffer:length:")</AttributeName>
 
300
        </Attribute>
 
301
      </Attributes>
 
302
      <ReturnValue>
 
303
        <ReturnType>System.Boolean</ReturnType>
 
304
      </ReturnValue>
 
305
      <Parameters>
 
306
        <Parameter Name="buffer" Type="System.IntPtr&amp;" RefType="out" />
 
307
        <Parameter Name="len" Type="System.UInt32&amp;" RefType="out" />
 
308
      </Parameters>
 
309
      <Docs>
 
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>
 
315
      </Docs>
 
316
    </Member>
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" />
224
331
      </ReturnValue>
225
332
      <Parameters />
226
333
      <Docs>
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>
 
337
      </Docs>
 
338
    </Member>
 
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>
 
343
      <AssemblyInfo>
 
344
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
345
      </AssemblyInfo>
 
346
      <ReturnValue>
 
347
        <ReturnType>System.Void</ReturnType>
 
348
      </ReturnValue>
 
349
      <Parameters>
 
350
        <Parameter Name="eventType" Type="MonoMac.CoreFoundation.CFStreamEventType" />
 
351
      </Parameters>
 
352
      <Docs>
 
353
        <param name="eventType">The events to notify.</param>
 
354
        <summary>Notifies consumers of events in the stream.</summary>
 
355
        <remarks>
 
356
        </remarks>
230
357
      </Docs>
231
358
    </Member>
232
359
    <Member MemberName="Read">
244
371
        <Parameter Name="len" Type="System.UInt32" />
245
372
      </Parameters>
246
373
      <Docs>
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>
 
378
        <remarks>
 
379
        </remarks>
 
380
      </Docs>
 
381
    </Member>
 
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>
 
386
      <AssemblyInfo>
 
387
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
388
      </AssemblyInfo>
 
389
      <Attributes>
 
390
        <Attribute>
 
391
          <AttributeName>MonoMac.Foundation.Export("read:maxLength:")</AttributeName>
 
392
        </Attribute>
 
393
      </Attributes>
 
394
      <ReturnValue>
 
395
        <ReturnType>System.Int32</ReturnType>
 
396
      </ReturnValue>
 
397
      <Parameters>
 
398
        <Parameter Name="buffer" Type="System.IntPtr" />
 
399
        <Parameter Name="len" Type="System.UInt32" />
 
400
      </Parameters>
 
401
      <Docs>
 
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>
 
408
      </Docs>
 
409
    </Member>
 
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>
 
414
      <AssemblyInfo>
 
415
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
416
      </AssemblyInfo>
 
417
      <Attributes>
 
418
        <Attribute>
 
419
          <AttributeName>MonoMac.Foundation.Export("_scheduleInCFRunLoop:forMode:")</AttributeName>
 
420
        </Attribute>
 
421
      </Attributes>
 
422
      <ReturnValue>
 
423
        <ReturnType>System.Void</ReturnType>
 
424
      </ReturnValue>
 
425
      <Parameters>
 
426
        <Parameter Name="runloop" Type="MonoMac.CoreFoundation.CFRunLoop" />
 
427
        <Parameter Name="mode" Type="MonoMac.Foundation.NSString" />
 
428
      </Parameters>
 
429
      <Docs>
 
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>
 
433
        <remarks>
 
434
        </remarks>
 
435
      </Docs>
 
436
    </Member>
 
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>
 
441
      <AssemblyInfo>
 
442
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
443
      </AssemblyInfo>
 
444
      <Attributes>
 
445
        <Attribute>
 
446
          <AttributeName>MonoMac.Foundation.Export("_setCFClientFlags:callback:context:")</AttributeName>
 
447
        </Attribute>
 
448
      </Attributes>
 
449
      <ReturnValue>
 
450
        <ReturnType>System.Boolean</ReturnType>
 
451
      </ReturnValue>
 
452
      <Parameters>
 
453
        <Parameter Name="inFlags" Type="MonoMac.CoreFoundation.CFStreamEventType" />
 
454
        <Parameter Name="inCallback" Type="System.IntPtr" />
 
455
        <Parameter Name="inContextPtr" Type="System.IntPtr" />
 
456
      </Parameters>
 
457
      <Docs>
 
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>
 
462
        <returns>
 
463
        </returns>
 
464
        <remarks>
 
465
        </remarks>
 
466
      </Docs>
 
467
    </Member>
 
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>
 
472
      <AssemblyInfo>
 
473
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
 
474
      </AssemblyInfo>
 
475
      <Attributes>
 
476
        <Attribute>
 
477
          <AttributeName>MonoMac.Foundation.Export("_unscheduleFromCFRunLoop:forMode:")</AttributeName>
 
478
        </Attribute>
 
479
      </Attributes>
 
480
      <ReturnValue>
 
481
        <ReturnType>System.Void</ReturnType>
 
482
      </ReturnValue>
 
483
      <Parameters>
 
484
        <Parameter Name="runloop" Type="MonoMac.CoreFoundation.CFRunLoop" />
 
485
        <Parameter Name="mode" Type="MonoMac.Foundation.NSString" />
 
486
      </Parameters>
 
487
      <Docs>
 
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>
 
491
        <remarks>
 
492
        </remarks>
252
493
      </Docs>
253
494
    </Member>
254
495
  </Members>