コード例 #1
0
ファイル: DataUtil.cs プロジェクト: jiajiadelequ/XTween
    /************************************************************************
    *	                Private Variable Declaration	                    *
    ************************************************************************/


    /************************************************************************
    *	                Protected Variable Declaration	                    *
    ************************************************************************/


    /************************************************************************
    *	                Public Variable Declaration	                        *
    ************************************************************************/


    /************************************************************************
    *	                Life Cycle Method Declaration	                    *
    ************************************************************************/


    /************************************************************************
    *	                Private Method Declaration	                        *
    ************************************************************************/


    /************************************************************************
    *	                Protected Method Declaration	                    *
    ************************************************************************/


    /************************************************************************
    *	                Public Method Declaration	                        *
    ************************************************************************/
    public static T[] GetArrayFromCollection <T>(System.Collections.ICollection list)
    {
        if (list == null)
        {
            return(null);
        }
        T[] arr = new T[list.Count];
        list.CopyTo(arr, 0);
        return(arr);
    }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="context"></param>
        /// <param name="dsi"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public override StackValue Marshal(object obj, ProtoCore.Runtime.Context context, Interpreter dsi, ProtoCore.Type type)
        {
            if (obj == null)
            {
                return(StackUtils.BuildNull());
            }

            FFIObjectMarshler marshaler = null;
            StackValue        retVal;
            Type objType = obj.GetType();

            if (type.IsIndexable)
            {
                if (obj is System.Collections.ICollection)
                {
                    System.Collections.ICollection collection = obj as System.Collections.ICollection;
                    object[] array = new object[collection.Count];
                    collection.CopyTo(array, 0);
                    return(PrimitiveMarshler.ConvertCSArrayToDSArray(this, array, context, dsi, type));
                }
                else if (obj is System.Collections.IEnumerable)
                {
                    System.Collections.IEnumerable enumerable = obj as System.Collections.IEnumerable;
                    return(PrimitiveMarshler.ConvertCSArrayToDSArray(this, enumerable, context, dsi, type));
                }
            }

            Array arr = obj as Array;

            if (null != arr)
            {
                return(PrimitiveMarshler.ConvertCSArrayToDSArray(this, arr, context, dsi, type));
            }
            else if ((PrimitiveMarshler.IsPrimitiveDSType(type) || PrimitiveMarshler.IsPrimitiveObjectType(obj, type)) && mPrimitiveMarshalers.TryGetValue(objType, out marshaler))
            {
                return(marshaler.Marshal(obj, context, dsi, type));
            }
            else if (CLRObjectMap.TryGetValue(obj, out retVal))
            {
                return(retVal);
            }

            return(CreateDSObject(obj, context, dsi));
        }
コード例 #3
0
ファイル: FrmDesign.cs プロジェクト: scsi110/FormDesignerLib
        private void InitializeDesignerSurface()
        {
            this.designSurface = new System.ComponentModel.Design.DesignSurface(typeof(Form));
            Control view = this.designSurface.View as Control;

            this.tableLayoutPanel1.Controls.Add(view, 0, 0);
            this.tableLayoutPanel1.SetRowSpan(view, 2);
            view.Dock             = DockStyle.Fill;
            this.formDesignerHost = this.designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            this.formDesignerHost.AddService(typeof(INameCreationService), new MyNameService());
            ISelectionService selectionService = this.formDesignerHost.GetService(typeof(ISelectionService)) as ISelectionService;

            selectionService.SelectionChanged += delegate
            {
                System.Collections.ICollection collection = selectionService.GetSelectedComponents();
                object[] selectedObjects = new object[collection.Count];
                collection.CopyTo(selectedObjects, 0);
                this.propertyGrid1.SelectedObjects = selectedObjects;
            };
        }