You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/22 09:40:29 UTC
[10/51] [abbrv] [partial] ignite git commit: IGNITE-1513: platform ->
platforms.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
deleted file mode 100644
index e8c4b4b..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Messaging
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Collections;
- using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Resource;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Messaging;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Messaging functionality.
- /// </summary>
- internal class Messaging : PlatformTarget, IMessaging
- {
- /// <summary>
- /// Opcodes.
- /// </summary>
- private enum Op
- {
- LocalListen = 1,
- RemoteListen = 2,
- Send = 3,
- SendMulti = 4,
- SendOrdered = 5,
- StopLocalListen = 6,
- StopRemoteListen = 7
- }
-
- /** Map from user (func+topic) -> id, needed for unsubscription. */
- private readonly MultiValueDictionary<KeyValuePair<object, object>, long> _funcMap =
- new MultiValueDictionary<KeyValuePair<object, object>, long>();
-
- /** Grid */
- private readonly Ignite _ignite;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Messaging" /> class.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="prj">Cluster group.</param>
- public Messaging(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup prj)
- : base(target, marsh)
- {
- Debug.Assert(prj != null);
-
- ClusterGroup = prj;
-
- _ignite = (Ignite) prj.Ignite;
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ClusterGroup { get; private set; }
-
- /** <inheritdoc /> */
- public void Send(object message, object topic = null)
- {
- IgniteArgumentCheck.NotNull(message, "message");
-
- DoOutOp((int) Op.Send, topic, message);
- }
-
- /** <inheritdoc /> */
- public void Send(IEnumerable messages, object topic = null)
- {
- IgniteArgumentCheck.NotNull(messages, "messages");
-
- DoOutOp((int) Op.SendMulti, writer =>
- {
- writer.Write(topic);
-
- WriteEnumerable(writer, messages.OfType<object>());
- });
- }
-
- /** <inheritdoc /> */
- public void SendOrdered(object message, object topic = null, TimeSpan? timeout = null)
- {
- IgniteArgumentCheck.NotNull(message, "message");
-
- DoOutOp((int) Op.SendOrdered, writer =>
- {
- writer.Write(topic);
- writer.Write(message);
-
- writer.WriteLong((long)(timeout == null ? 0 : timeout.Value.TotalMilliseconds));
- });
- }
-
- /** <inheritdoc /> */
- public void LocalListen<T>(IMessageFilter<T> filter, object topic = null)
- {
- IgniteArgumentCheck.NotNull(filter, "filter");
-
- ResourceProcessor.Inject(filter, _ignite);
-
- lock (_funcMap)
- {
- var key = GetKey(filter, topic);
-
- MessageFilterHolder filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
-
- var filterHnd = _ignite.HandleRegistry.Allocate(filter0);
-
- filter0.DestroyAction = () =>
- {
- lock (_funcMap)
- {
- _funcMap.Remove(key, filterHnd);
- }
- };
-
- try
- {
- DoOutOp((int) Op.LocalListen, writer =>
- {
- writer.WriteLong(filterHnd);
- writer.Write(topic);
- });
- }
- catch (Exception)
- {
- _ignite.HandleRegistry.Release(filterHnd);
-
- throw;
- }
-
- _funcMap.Add(key, filterHnd);
- }
- }
-
- /** <inheritdoc /> */
- public void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null)
- {
- IgniteArgumentCheck.NotNull(filter, "filter");
-
- long filterHnd;
- bool removed;
-
- lock (_funcMap)
- {
- removed = _funcMap.TryRemove(GetKey(filter, topic), out filterHnd);
- }
-
- if (removed)
- {
- DoOutOp((int) Op.StopLocalListen, writer =>
- {
- writer.WriteLong(filterHnd);
- writer.Write(topic);
- });
- }
- }
-
- /** <inheritdoc /> */
- public Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null)
- {
- IgniteArgumentCheck.NotNull(filter, "filter");
-
- var filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
- var filterHnd = _ignite.HandleRegistry.AllocateSafe(filter0);
-
- try
- {
- Guid id = Guid.Empty;
-
- DoOutInOp((int) Op.RemoteListen, writer =>
- {
- writer.Write(filter0);
- writer.WriteLong(filterHnd);
- writer.Write(topic);
- },
- input =>
- {
- var id0 = Marshaller.StartUnmarshal(input).RawReader().ReadGuid();
-
- Debug.Assert(IsAsync || id0.HasValue);
-
- if (id0.HasValue)
- id = id0.Value;
- });
-
- return id;
- }
- catch (Exception)
- {
- _ignite.HandleRegistry.Release(filterHnd);
-
- throw;
- }
- }
-
- /** <inheritdoc /> */
- public void StopRemoteListen(Guid opId)
- {
- DoOutOp((int) Op.StopRemoteListen, writer =>
- {
- writer.WriteGuid(opId);
- });
- }
-
- /** <inheritdoc /> */
- public virtual IMessaging WithAsync()
- {
- return new MessagingAsync(UU.MessagingWithASync(Target), Marshaller, ClusterGroup);
- }
-
- /** <inheritdoc /> */
- public virtual bool IsAsync
- {
- get { return false; }
- }
-
- /** <inheritdoc /> */
- public virtual IFuture GetFuture()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
-
- /** <inheritdoc /> */
- public virtual IFuture<TResult> GetFuture<TResult>()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
-
- /// <summary>
- /// Gets the key for user-provided filter and topic.
- /// </summary>
- /// <param name="filter">Filter.</param>
- /// <param name="topic">Topic.</param>
- /// <returns>Compound dictionary key.</returns>
- private static KeyValuePair<object, object> GetKey(object filter, object topic)
- {
- return new KeyValuePair<object, object>(filter, topic);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
deleted file mode 100644
index e899d4e..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Messaging
-{
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Messaging;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Async messaging implementation.
- /// </summary>
- internal class MessagingAsync : Messaging
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="MessagingAsync" /> class.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="prj">Cluster group.</param>
- public MessagingAsync(IUnmanagedTarget target, PortableMarshaller marsh,
- IClusterGroup prj) : base(target, marsh, prj)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- public override IMessaging WithAsync()
- {
- return this;
- }
-
- /** <inheritdoc /> */
- public override bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritdoc /> */
- public override IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritdoc /> */
- public override IFuture<T> GetFuture<T>()
- {
- return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
deleted file mode 100644
index 6e25e7e..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- using System;
- using System.Runtime.InteropServices;
-
- /// <summary>
- /// Native methods.
- /// </summary>
- internal static class NativeMethods
- {
- /// <summary>
- /// Load DLL with WinAPI.
- /// </summary>
- /// <param name="path">Path to dll.</param>
- /// <returns></returns>
- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr LoadLibrary(string path);
-
- /// <summary>
- /// Get procedure address with WinAPI.
- /// </summary>
- /// <param name="ptr">DLL pointer.</param>
- /// <param name="name">Procedure name.</param>
- /// <returns>Procedure address.</returns>
- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr GetProcAddress(IntPtr ptr, string name);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
deleted file mode 100644
index 67f631a..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Memory;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Portable.IO;
- using Apache.Ignite.Core.Impl.Portable.Metadata;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Portable;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Base class for interop targets.
- /// </summary>
- [SuppressMessage("ReSharper", "LocalVariableHidesMember")]
- internal abstract class PlatformTarget
- {
- /** */
- protected const int True = 1;
-
- /** */
- private const int OpMeta = -1;
-
- /** */
- public const int OpNone = -2;
-
- /** */
- private static readonly Dictionary<Type, FutureType> IgniteFutureTypeMap
- = new Dictionary<Type, FutureType>
- {
- {typeof(bool), FutureType.Bool},
- {typeof(byte), FutureType.Byte},
- {typeof(char), FutureType.Char},
- {typeof(double), FutureType.Double},
- {typeof(float), FutureType.Float},
- {typeof(int), FutureType.Int},
- {typeof(long), FutureType.Long},
- {typeof(short), FutureType.Short}
- };
-
- /** Unmanaged target. */
- private readonly IUnmanagedTarget _target;
-
- /** Marshaller. */
- private readonly PortableMarshaller _marsh;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- protected PlatformTarget(IUnmanagedTarget target, PortableMarshaller marsh)
- {
- _target = target;
- _marsh = marsh;
- }
-
- /// <summary>
- /// Unmanaged target.
- /// </summary>
- internal IUnmanagedTarget Target
- {
- get { return _target; }
- }
-
- /// <summary>
- /// Marshaller.
- /// </summary>
- internal PortableMarshaller Marshaller
- {
- get { return _marsh; }
- }
-
- #region Static Helpers
-
- /// <summary>
- /// Write collection.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
- {
- return WriteCollection<T, T>(writer, vals, null);
- }
-
- /// <summary>
- /// Write nullable collection.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteNullableCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
- {
- return WriteNullable(writer, vals, WriteCollection);
- }
-
- /// <summary>
- /// Write collection.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <param name="selector">A transform function to apply to each element.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteCollection<T1, T2>(PortableWriterImpl writer,
- ICollection<T1> vals, Func<T1, T2> selector)
- {
- writer.WriteInt(vals.Count);
-
- if (selector == null)
- {
- foreach (var val in vals)
- writer.Write(val);
- }
- else
- {
- foreach (var val in vals)
- writer.Write(selector(val));
- }
-
- return writer;
- }
-
- /// <summary>
- /// Write enumerable.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteEnumerable<T>(PortableWriterImpl writer, IEnumerable<T> vals)
- {
- return WriteEnumerable<T, T>(writer, vals, null);
- }
-
- /// <summary>
- /// Write enumerable.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <param name="selector">A transform function to apply to each element.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteEnumerable<T1, T2>(PortableWriterImpl writer,
- IEnumerable<T1> vals, Func<T1, T2> selector)
- {
- var col = vals as ICollection<T1>;
-
- if (col != null)
- return WriteCollection(writer, col, selector);
-
- var stream = writer.Stream;
-
- var pos = stream.Position;
-
- stream.Seek(4, SeekOrigin.Current);
-
- var size = 0;
-
- if (selector == null)
- {
- foreach (var val in vals)
- {
- writer.Write(val);
-
- size++;
- }
- }
- else
- {
- foreach (var val in vals)
- {
- writer.Write(selector(val));
-
- size++;
- }
- }
-
- stream.WriteInt(pos, size);
-
- return writer;
- }
-
- /// <summary>
- /// Write dictionary.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="vals">Values.</param>
- /// <returns>The same writer.</returns>
- protected static PortableWriterImpl WriteDictionary<T1, T2>(PortableWriterImpl writer,
- IDictionary<T1, T2> vals)
- {
- writer.WriteInt(vals.Count);
-
- foreach (KeyValuePair<T1, T2> pair in vals)
- {
- writer.Write(pair.Key);
- writer.Write(pair.Value);
- }
-
- return writer;
- }
-
- /// <summary>
- /// Write a nullable item.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- /// <param name="item">Item.</param>
- /// <param name="writeItem">Write action to perform on item when it is not null.</param>
- /// <returns>The same writer for chaining.</returns>
- protected static PortableWriterImpl WriteNullable<T>(PortableWriterImpl writer, T item,
- Func<PortableWriterImpl, T, PortableWriterImpl> writeItem)
- {
- if (item == null)
- {
- writer.WriteBoolean(false);
-
- return writer;
- }
-
- writer.WriteBoolean(true);
-
- return writeItem(writer, item);
- }
-
- #endregion
-
- #region OUT operations
-
- /// <summary>
- /// Perform out operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="action">Action to be performed on the stream.</param>
- /// <returns></returns>
- protected long DoOutOp(int type, Action<IPortableStream> action)
- {
- using (var stream = IgniteManager.Memory.Allocate().Stream())
- {
- action(stream);
-
- return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
- }
- }
-
- /// <summary>
- /// Perform out operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="action">Action to be performed on the stream.</param>
- /// <returns></returns>
- protected long DoOutOp(int type, Action<PortableWriterImpl> action)
- {
- using (var stream = IgniteManager.Memory.Allocate().Stream())
- {
- var writer = _marsh.StartMarshal(stream);
-
- action(writer);
-
- FinishMarshal(writer);
-
- return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
- }
- }
-
- /// <summary>
- /// Perform simple output operation accepting single argument.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="val1">Value.</param>
- /// <returns>Result.</returns>
- protected long DoOutOp<T1>(int type, T1 val1)
- {
- return DoOutOp(type, writer =>
- {
- writer.Write(val1);
- });
- }
-
- /// <summary>
- /// Perform simple output operation accepting two arguments.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="val1">Value 1.</param>
- /// <param name="val2">Value 2.</param>
- /// <returns>Result.</returns>
- protected long DoOutOp<T1, T2>(int type, T1 val1, T2 val2)
- {
- return DoOutOp(type, writer =>
- {
- writer.Write(val1);
- writer.Write(val2);
- });
- }
-
- /// <summary>
- /// Perform simple output operation accepting three arguments.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="val1">Value 1.</param>
- /// <param name="val2">Value 2.</param>
- /// <param name="val3">Value 3.</param>
- /// <returns>Result.</returns>
- protected long DoOutOp<T1, T2, T3>(int type, T1 val1, T2 val2, T3 val3)
- {
- return DoOutOp(type, writer =>
- {
- writer.Write(val1);
- writer.Write(val2);
- writer.Write(val3);
- });
- }
-
- #endregion
-
- #region IN operations
-
- /// <summary>
- /// Perform in operation.
- /// </summary>
- /// <param name="type">Type.</param>
- /// <param name="action">Action.</param>
- protected void DoInOp(int type, Action<IPortableStream> action)
- {
- using (var stream = IgniteManager.Memory.Allocate().Stream())
- {
- UU.TargetOutStream(_target, type, stream.MemoryPointer);
-
- stream.SynchronizeInput();
-
- action(stream);
- }
- }
-
- /// <summary>
- /// Perform in operation.
- /// </summary>
- /// <param name="type">Type.</param>
- /// <param name="action">Action.</param>
- /// <returns>Result.</returns>
- protected T DoInOp<T>(int type, Func<IPortableStream, T> action)
- {
- using (var stream = IgniteManager.Memory.Allocate().Stream())
- {
- UU.TargetOutStream(_target, type, stream.MemoryPointer);
-
- stream.SynchronizeInput();
-
- return action(stream);
- }
- }
-
- /// <summary>
- /// Perform simple in operation returning immediate result.
- /// </summary>
- /// <param name="type">Type.</param>
- /// <returns>Result.</returns>
- protected T DoInOp<T>(int type)
- {
- using (var stream = IgniteManager.Memory.Allocate().Stream())
- {
- UU.TargetOutStream(_target, type, stream.MemoryPointer);
-
- stream.SynchronizeInput();
-
- return Unmarshal<T>(stream);
- }
- }
-
- #endregion
-
- #region OUT-IN operations
-
- /// <summary>
- /// Perform out-in operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="outAction">Out action.</param>
- /// <param name="inAction">In action.</param>
- protected void DoOutInOp(int type, Action<PortableWriterImpl> outAction, Action<IPortableStream> inAction)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- outAction(writer);
-
- FinishMarshal(writer);
-
- UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- inAction(inStream);
- }
- }
- }
-
- /// <summary>
- /// Perform out-in operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="outAction">Out action.</param>
- /// <param name="inAction">In action.</param>
- /// <returns>Result.</returns>
- protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction, Func<IPortableStream, TR> inAction)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- outAction(writer);
-
- FinishMarshal(writer);
-
- UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- return inAction(inStream);
- }
- }
- }
-
- /// <summary>
- /// Perform out-in operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="outAction">Out action.</param>
- /// <param name="inAction">In action.</param>
- /// <param name="arg">Argument.</param>
- /// <returns>Result.</returns>
- protected unsafe TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction, Func<IPortableStream, TR> inAction, void* arg)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- outAction(writer);
-
- FinishMarshal(writer);
-
- UU.TargetInObjectStreamOutStream(_target, type, arg, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- return inAction(inStream);
- }
- }
- }
-
- /// <summary>
- /// Perform out-in operation.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="outAction">Out action.</param>
- /// <returns>Result.</returns>
- protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- outAction(writer);
-
- FinishMarshal(writer);
-
- UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- return Unmarshal<TR>(inStream);
- }
- }
- }
-
- /// <summary>
- /// Perform simple out-in operation accepting single argument.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="val">Value.</param>
- /// <returns>Result.</returns>
- protected TR DoOutInOp<T1, TR>(int type, T1 val)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- writer.WriteObject(val);
-
- FinishMarshal(writer);
-
- UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- return Unmarshal<TR>(inStream);
- }
- }
- }
-
- /// <summary>
- /// Perform simple out-in operation accepting two arguments.
- /// </summary>
- /// <param name="type">Operation type.</param>
- /// <param name="val1">Value.</param>
- /// <param name="val2">Value.</param>
- /// <returns>Result.</returns>
- protected TR DoOutInOp<T1, T2, TR>(int type, T1 val1, T2 val2)
- {
- using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
- {
- using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
- {
- PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
- writer.WriteObject(val1);
- writer.WriteObject(val2);
-
- FinishMarshal(writer);
-
- UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
- inStream.SynchronizeInput();
-
- return Unmarshal<TR>(inStream);
- }
- }
- }
-
- #endregion
-
- #region Miscelanneous
-
- /// <summary>
- /// Finish marshaling.
- /// </summary>
- /// <param name="writer">Portable writer.</param>
- internal void FinishMarshal(PortableWriterImpl writer)
- {
- _marsh.FinishMarshal(writer);
- }
-
- /// <summary>
- /// Put metadata to Grid.
- /// </summary>
- /// <param name="metas">Metadatas.</param>
- internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
- {
- DoOutOp(OpMeta, stream =>
- {
- PortableWriterImpl metaWriter = _marsh.StartMarshal(stream);
-
- metaWriter.WriteInt(metas.Count);
-
- foreach (var meta in metas.Values)
- {
- PortableMetadataImpl meta0 = (PortableMetadataImpl)meta;
-
- metaWriter.WriteInt(meta0.TypeId);
- metaWriter.WriteString(meta0.TypeName);
- metaWriter.WriteString(meta0.AffinityKeyFieldName);
-
- IDictionary<string, int> fields = meta0.FieldsMap();
-
- metaWriter.WriteInt(fields.Count);
-
- foreach (var field in fields)
- {
- metaWriter.WriteString(field.Key);
- metaWriter.WriteInt(field.Value);
- }
- }
-
- _marsh.FinishMarshal(metaWriter);
- });
-
- _marsh.OnMetadataSent(metas);
- }
-
- /// <summary>
- /// Unmarshal object using the given stream.
- /// </summary>
- /// <param name="stream">Stream.</param>
- /// <returns>Unmarshalled object.</returns>
- protected virtual T Unmarshal<T>(IPortableStream stream)
- {
- return _marsh.Unmarshal<T>(stream);
- }
-
- /// <summary>
- /// Creates a future and starts listening.
- /// </summary>
- /// <typeparam name="T">Future result type</typeparam>
- /// <param name="listenAction">The listen action.</param>
- /// <param name="keepPortable">Keep portable flag, only applicable to object futures. False by default.</param>
- /// <param name="convertFunc">The function to read future result from stream.</param>
- /// <returns>Created future.</returns>
- protected IFuture<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
- Func<PortableReaderImpl, T> convertFunc = null)
- {
- var futType = FutureType.Object;
-
- var type = typeof(T);
-
- if (type.IsPrimitive)
- IgniteFutureTypeMap.TryGetValue(type, out futType);
-
- var fut = convertFunc == null && futType != FutureType.Object
- ? new Future<T>()
- : new Future<T>(new FutureConverter<T>(_marsh, keepPortable, convertFunc));
-
- var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut);
-
- listenAction(futHnd, (int)futType);
-
- return fut;
- }
-
- #endregion
- }
-
- /// <summary>
- /// PlatformTarget with IDisposable pattern.
- /// </summary>
- internal abstract class PlatformDisposableTarget : PlatformTarget, IDisposable
- {
- /** Disposed flag. */
- private volatile bool _disposed;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- protected PlatformDisposableTarget(IUnmanagedTarget target, PortableMarshaller marsh) : base(target, marsh)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- public void Dispose()
- {
- lock (this)
- {
- if (_disposed)
- return;
-
- Dispose(true);
-
- GC.SuppressFinalize(this);
-
- _disposed = true;
- }
- }
-
- /// <summary>
- /// Releases unmanaged and - optionally - managed resources.
- /// </summary>
- /// <param name="disposing">
- /// <c>true</c> when called from Dispose; <c>false</c> when called from finalizer.
- /// </param>
- protected virtual void Dispose(bool disposing)
- {
- Target.Dispose();
- }
-
- /// <summary>
- /// Throws <see cref="ObjectDisposedException"/> if this instance has been disposed.
- /// </summary>
- protected void ThrowIfDisposed()
- {
- if (_disposed)
- throw new ObjectDisposedException(GetType().Name, "Object has been disposed.");
- }
-
- /// <summary>
- /// Gets a value indicating whether this instance is disposed.
- /// </summary>
- protected bool IsDisposed
- {
- get { return _disposed; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
deleted file mode 100644
index 3fee3ca..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Portable
-{
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Serializer for system types that can create instances directly from a stream and does not support handles.
- /// </summary>
- internal interface IPortableSystemTypeSerializer : IPortableSerializer
- {
- /// <summary>
- /// Reads the instance from a reader.
- /// </summary>
- /// <param name="reader">The reader.</param>
- /// <returns>Deserialized instance.</returns>
- object ReadInstance(PortableReaderImpl reader);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
deleted file mode 100644
index 4a4f0dc..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Portable
-{
- using System;
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Type descriptor.
- /// </summary>
- internal interface IPortableTypeDescriptor
- {
- /// <summary>
- /// Type.
- /// </summary>
- Type Type
- {
- get;
- }
-
- /// <summary>
- /// Type ID.
- /// </summary>
- int TypeId
- {
- get;
- }
-
- /// <summary>
- /// Type name.
- /// </summary>
- string TypeName
- {
- get;
- }
-
- /// <summary>
- /// User type flag.
- /// </summary>
- bool UserType
- {
- get;
- }
-
- /// <summary>
- /// Metadata enabled flag.
- /// </summary>
- bool MetadataEnabled
- {
- get;
- }
-
- /// <summary>
- /// Whether to cache deserialized value in IPortableObject
- /// </summary>
- bool KeepDeserialized
- {
- get;
- }
-
- /// <summary>
- /// Name converter.
- /// </summary>
- IPortableNameMapper NameConverter
- {
- get;
- }
-
- /// <summary>
- /// Mapper.
- /// </summary>
- IPortableIdMapper Mapper
- {
- get;
- }
-
- /// <summary>
- /// Serializer.
- /// </summary>
- IPortableSerializer Serializer
- {
- get;
- }
-
- /// <summary>
- /// Affinity key field name.
- /// </summary>
- string AffinityKeyFieldName
- {
- get;
- }
-
- /// <summary>
- /// Typed handler.
- /// </summary>
- object TypedHandler
- {
- get;
- }
-
- /// <summary>
- /// Untyped handler.
- /// </summary>
- PortableSystemWriteDelegate UntypedHandler
- {
- get;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
deleted file mode 100644
index d3c1521..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Portable
-{
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Represents an object that can write itself to a portable writer.
- /// </summary>
- internal interface IPortableWriteAware
- {
- /// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="writer">Writer.</param>
- /// <exception cref="System.IO.IOException">If write failed.</exception>
- void WritePortable(IPortableWriter writer);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcefaa24/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
deleted file mode 100644
index 8111117..0000000
--- a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-namespace Apache.Ignite.Core.Impl.Portable.IO
-{
- using System;
- using System.IO;
- using System.Text;
-
- /// <summary>
- /// Stream capable of working with portable objects.
- /// </summary>
- [CLSCompliant(false)]
- public unsafe interface IPortableStream : IDisposable
- {
- /// <summary>
- /// Write bool.
- /// </summary>
- /// <param name="val">Bool value.</param>
- void WriteBool(bool val);
-
- /// <summary>
- /// Read bool.
- /// </summary>
- /// <returns>Bool value.</returns>
- bool ReadBool();
-
- /// <summary>
- /// Write bool array.
- /// </summary>
- /// <param name="val">Bool array.</param>
- void WriteBoolArray(bool[] val);
-
- /// <summary>
- /// Read bool array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Bool array.</returns>
- bool[] ReadBoolArray(int cnt);
-
- /// <summary>
- /// Write byte.
- /// </summary>
- /// <param name="val">Byte value.</param>
- void WriteByte(byte val);
-
- /// <summary>
- /// Read byte.
- /// </summary>
- /// <returns>Byte value.</returns>
- byte ReadByte();
-
- /// <summary>
- /// Write byte array.
- /// </summary>
- /// <param name="val">Byte array.</param>
- void WriteByteArray(byte[] val);
-
- /// <summary>
- /// Read byte array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Byte array.</returns>
- byte[] ReadByteArray(int cnt);
-
- /// <summary>
- /// Write short.
- /// </summary>
- /// <param name="val">Short value.</param>
- void WriteShort(short val);
-
- /// <summary>
- /// Read short.
- /// </summary>
- /// <returns>Short value.</returns>
- short ReadShort();
-
- /// <summary>
- /// Write short array.
- /// </summary>
- /// <param name="val">Short array.</param>
- void WriteShortArray(short[] val);
-
- /// <summary>
- /// Read short array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Short array.</returns>
- short[] ReadShortArray(int cnt);
-
- /// <summary>
- /// Write char.
- /// </summary>
- /// <param name="val">Char value.</param>
- void WriteChar(char val);
-
- /// <summary>
- /// Read char.
- /// </summary>
- /// <returns>Char value.</returns>
- char ReadChar();
-
- /// <summary>
- /// Write char array.
- /// </summary>
- /// <param name="val">Char array.</param>
- void WriteCharArray(char[] val);
-
- /// <summary>
- /// Read char array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Char array.</returns>
- char[] ReadCharArray(int cnt);
-
- /// <summary>
- /// Write int.
- /// </summary>
- /// <param name="val">Int value.</param>
- void WriteInt(int val);
-
- /// <summary>
- /// Write int to specific position.
- /// </summary>
- /// <param name="writePos">Position.</param>
- /// <param name="val">Value.</param>
- void WriteInt(int writePos, int val);
-
- /// <summary>
- /// Read int.
- /// </summary>
- /// <returns>Int value.</returns>
- int ReadInt();
-
- /// <summary>
- /// Write int array.
- /// </summary>
- /// <param name="val">Int array.</param>
- void WriteIntArray(int[] val);
-
- /// <summary>
- /// Read int array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Int array.</returns>
- int[] ReadIntArray(int cnt);
-
- /// <summary>
- /// Write long.
- /// </summary>
- /// <param name="val">Long value.</param>
- void WriteLong(long val);
-
- /// <summary>
- /// Read long.
- /// </summary>
- /// <returns>Long value.</returns>
- long ReadLong();
-
- /// <summary>
- /// Write long array.
- /// </summary>
- /// <param name="val">Long array.</param>
- void WriteLongArray(long[] val);
-
- /// <summary>
- /// Read long array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Long array.</returns>
- long[] ReadLongArray(int cnt);
-
- /// <summary>
- /// Write float.
- /// </summary>
- /// <param name="val">Float value.</param>
- void WriteFloat(float val);
-
- /// <summary>
- /// Read float.
- /// </summary>
- /// <returns>Float value.</returns>
- float ReadFloat();
-
- /// <summary>
- /// Write float array.
- /// </summary>
- /// <param name="val">Float array.</param>
- void WriteFloatArray(float[] val);
-
- /// <summary>
- /// Read float array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Float array.</returns>
- float[] ReadFloatArray(int cnt);
-
- /// <summary>
- /// Write double.
- /// </summary>
- /// <param name="val">Double value.</param>
- void WriteDouble(double val);
-
- /// <summary>
- /// Read double.
- /// </summary>
- /// <returns>Double value.</returns>
- double ReadDouble();
-
- /// <summary>
- /// Write double array.
- /// </summary>
- /// <param name="val">Double array.</param>
- void WriteDoubleArray(double[] val);
-
- /// <summary>
- /// Read double array.
- /// </summary>
- /// <param name="cnt">Count.</param>
- /// <returns>Double array.</returns>
- double[] ReadDoubleArray(int cnt);
-
- /// <summary>
- /// Write string.
- /// </summary>
- /// <param name="chars">Characters.</param>
- /// <param name="charCnt">Char count.</param>
- /// <param name="byteCnt">Byte count.</param>
- /// <param name="encoding">Encoding.</param>
- /// <returns>Amounts of bytes written.</returns>
- int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding);
-
- /// <summary>
- /// Write arbitrary data.
- /// </summary>
- /// <param name="src">Source array.</param>
- /// <param name="off">Offset</param>
- /// <param name="cnt">Count.</param>
- void Write(byte[] src, int off, int cnt);
-
- /// <summary>
- /// Read arbitrary data.
- /// </summary>
- /// <param name="dest">Destination array.</param>
- /// <param name="off">Offset.</param>
- /// <param name="cnt">Count.</param>
- /// <returns>Amount of bytes read.</returns>
- void Read(byte[] dest, int off, int cnt);
-
- /// <summary>
- /// Write arbitrary data.
- /// </summary>
- /// <param name="src">Source.</param>
- /// <param name="cnt">Count.</param>
- void Write(byte* src, int cnt);
-
- /// <summary>
- /// Read arbitrary data.
- /// </summary>
- /// <param name="dest">Destination.</param>
- /// <param name="cnt">Count.</param>
- void Read(byte* dest, int cnt);
-
- /// <summary>
- /// Position.
- /// </summary>
- int Position
- {
- get;
- }
-
- /// <summary>
- /// Gets remaining bytes in the stream.
- /// </summary>
- /// <returns>Remaining bytes.</returns>
- int Remaining();
-
- /// <summary>
- /// Gets underlying array, avoiding copying if possible.
- /// </summary>
- /// <returns>Underlying array.</returns>
- byte[] Array();
-
- /// <summary>
- /// Gets underlying data in a new array.
- /// </summary>
- /// <returns>New array with data.</returns>
- byte[] ArrayCopy();
-
- /// <summary>
- /// Check whether array passed as argument is the same as the stream hosts.
- /// </summary>
- /// <param name="arr">Array.</param>
- /// <returns><c>True</c> if they are same.</returns>
- bool IsSameArray(byte[] arr);
-
- /// <summary>
- /// Seek to the given positoin.
- /// </summary>
- /// <param name="offset">Offset.</param>
- /// <param name="origin">Seek origin.</param>
- /// <returns>Position.</returns>
- int Seek(int offset, SeekOrigin origin);
- }
-}