FromType() public static method

Creates a transfer data type from a CLR type
This is the data type to be used when transferring whole objects through drag & drop or copy & paste
public static FromType ( Type type ) : TransferDataType
type System.Type /// A type ///
return TransferDataType
Ejemplo n.º 1
0
 /// <summary>
 /// Adds a value to the data source
 /// </summary>
 /// <param name='value'>
 /// Value.
 /// </param>
 public void AddValue <T> (T value) where T : class
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     data [TransferDataType.FromType(typeof(T))] = value;
 }
Ejemplo n.º 2
0
 public static void SetData <T> (T data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     SetData(TransferDataType.FromType(data.GetType()), data);
 }
Ejemplo n.º 3
0
 public void AddValue(object value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     data [TransferDataType.FromType(value.GetType())] = value;
 }
Ejemplo n.º 4
0
        T ITransferData.GetValue <T> ()
        {
            object ob = GetValue(TransferDataType.FromType(typeof(T)));

            if (ob == null || ob.GetType() == typeof(Type))
            {
                return((T)ob);
            }
            if (ob is byte[])
            {
                T val = (T)TransferDataSource.DeserializeValue((byte[])ob);
                data[TransferDataType.FromType(typeof(T))] = val;
                return(val);
            }
            return((T)ob);
        }
Ejemplo n.º 5
0
 public static T GetData <T> ()
 {
     return((T)Backend.GetData(TransferDataType.FromType(typeof(T))));
 }
Ejemplo n.º 6
0
 public static bool ContainsData <T> ()
 {
     return(Backend.IsTypeAvailable(TransferDataType.FromType(typeof(T))));
 }
Ejemplo n.º 7
0
 public static void SetData <T> (Func <T> dataSource)
 {
     Backend.SetData(TransferDataType.FromType(typeof(T)), delegate() {
         return(dataSource());
     });
 }
Ejemplo n.º 8
0
 public static IAsyncResult BeginGetData <T> (AsyncCallback callback, object state)
 {
     return(Backend.BeginGetData(TransferDataType.FromType(typeof(T)), callback, state));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Registers that the data store contains data of the provided type
 /// </summary>
 /// <param name='type'>
 /// A type
 /// </param>
 /// <remarks>
 /// This method can be used in combination with DataRequestCallback to
 /// generate the data on demand. In some scenarios, the drop/paste
 /// side of a drag&amp;drop or clipboard operation can decide if a drop/paste
 /// is allowed or not by checking the available data type in this
 /// data source. Once the operation is accepted, the DataRequestCallback
 /// callback will be invoked to get the data for the type.
 /// </remarks>
 public void AddType(Type type)
 {
     data [TransferDataType.FromType(type)] = null;
 }
Ejemplo n.º 10
0
 public void SetDragSource(DragDropAction dragAction, params Type[] types)
 {
     Backend.SetDragSource(types.Select(t => TransferDataType.FromType(t)).ToArray(), dragAction);
 }
Ejemplo n.º 11
0
 public void SetDragDropTarget(params Type[] types)
 {
     Backend.SetDragTarget(types.Select(t => TransferDataType.FromType(t)).ToArray(), DragDropAction.All);
 }