Example #1
0
        public void Func()
        {
            var enity = CreateObject <CompanySetting> .Build();

            enity.Should().BeEquivalentTo(new Company[]
            {
                new Company
                {
                    Id         = Guid.Parse("68f1de41-8fd4-4fdc-afe7-3f74051ecfaf"),
                    Name       = "A",
                    Address    = "Taiwan",
                    Disable    = false,
                    CreateDate = DateTime.Parse("2020/07/23 16:00")
                },
                new Company
                {
                    Id         = Guid.Parse("7edf30de-ce7c-493e-9f82-a4478f1b7089"),
                    Name       = "B",
                    Address    = "Janpan",
                    Disable    = false,
                    CreateDate = DateTime.Parse("2020/07/22 16:00")
                },
                new Company
                {
                    Id         = Guid.Parse("6f39946d-7b1c-4603-8590-5a01d41413b6"),
                    Name       = "C",
                    Address    = "China",
                    Disable    = true,
                    CreateDate = DateTime.Parse("2020/07/21 16:00")
                },
            });
        }
Example #2
0
    /// <summary>
    /// Tells the client handler to send a CreateObject event to the client that just connected
    /// </summary>
    /// <param name="handler"></param>
    public void SpawnObjects(ClientHandler handler)
    {
        ConnectPlayer connectPlayer = new ConnectPlayer(handler.GetClientNetworkID());

        handler.SendPacket(connectPlayer.Serialize(), 0);

        int i        = 0;
        int prefabID = 0;

        foreach (NetworkingObject netObj in _networkingObjects)
        {
            if (i < 2)
            {
                prefabID = 1;
            }
            else
            {
                prefabID = 0;
            }
            CreateObject createObject = new CreateObject(prefabID, netObj.transform.position.x, netObj.transform.position.z, netObj.GetNetworkID(), netObj.GetPlayerNetworkID());
            i++;
            byte[] createObjectBytes = createObject.Serialize();

            handler.SendPacket(createObjectBytes, 0);
        }
    }
Example #3
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        CreateObject window = (CreateObject)EditorWindow.GetWindow(typeof(CreateObject));

        window.Show();
    }
Example #4
0
        private object FastCreateInstance(Type objtype)
        {
            try
            {
                CreateObject c = null;
                if (_constrcache.TryGetValue(objtype, out c))
                {
                    return(c());
                }
                else
                {
                    DynamicMethod dynMethod = new DynamicMethod("_", objtype, null);
                    ILGenerator   ilGen     = dynMethod.GetILGenerator();

                    ilGen.Emit(OpCodes.Newobj, objtype.GetConstructor(Type.EmptyTypes));
                    ilGen.Emit(OpCodes.Ret);
                    c = (CreateObject)dynMethod.CreateDelegate(typeof(CreateObject));
                    _constrcache.Add(objtype, c);
                    return(c());
                }
            }
            catch (Exception exc)
            {
                throw new Exception(string.Format("Failed to fast create instance for type '{0}' from assemebly '{1}'",
                                                  objtype.FullName, objtype.AssemblyQualifiedName), exc);
            }
        }
Example #5
0
        /// <summary>
        /// Create a new instance from a Type
        /// </summary>
        public static object CreateInstance(Type type)
        {
            try
            {
                CreateObject c = null;

                if (_cacheCtor.TryGetValue(type, out c))
                {
                    return(c());
                }
                else
                {
                    if (type.IsClass)
                    {
                        var dynMethod = new DynamicMethod("_", type, null);
                        var il        = dynMethod.GetILGenerator();
                        il.Emit(OpCodes.Newobj, type.GetConstructor(Type.EmptyTypes));
                        il.Emit(OpCodes.Ret);
                        c = (CreateObject)dynMethod.CreateDelegate(typeof(CreateObject));
                        _cacheCtor.Add(type, c);
                    }
                    else if (type.IsInterface) // some know interfaces
                    {
                        if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IList <>))
                        {
                            return(CreateInstance(GetGenericListOfType(UnderlyingTypeOf(type))));
                        }
                        else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary <,>))
                        {
                            var k = type.GetGenericArguments()[0];
                            var v = type.GetGenericArguments()[1];
                            return(CreateInstance(GetGenericDictionaryOfType(k, v)));
                        }
                        else
                        {
                            throw LiteException.InvalidCtor(type);
                        }
                    }
                    else // structs
                    {
                        var dynMethod = new DynamicMethod("_", typeof(object), null);
                        var il        = dynMethod.GetILGenerator();
                        var lv        = il.DeclareLocal(type);
                        il.Emit(OpCodes.Ldloca_S, lv);
                        il.Emit(OpCodes.Initobj, type);
                        il.Emit(OpCodes.Ldloc_0);
                        il.Emit(OpCodes.Box, type);
                        il.Emit(OpCodes.Ret);
                        c = (CreateObject)dynMethod.CreateDelegate(typeof(CreateObject));
                        _cacheCtor.Add(type, c);
                    }

                    return(c());
                }
            }
            catch (Exception)
            {
                throw LiteException.InvalidCtor(type);
            }
        }
    private void OnCollisionEnter(Collision collision)
    {
        if (this.tag == "MovingBlock")
        {
            if (collision.transform.tag == "Block")
            {
                ControlEnvironment tmp_handler = collision.transform.parent.GetComponent <ControlEnvironment>();
                Vector3            p           = this.transform.position;

                Vector2Int id = CreateObject.GetIndex(p);

                if (id.y - 1 >= 0 && tmp_handler.tetrisMap[id.y - 1][id.x] == 1)
                {
                    handleObj.GetComponent <BlockObjProperty>().canGoDown = false;
                }
            }
            if (collision.transform.tag == "Ground")
            {
                handleObj.GetComponent <BlockObjProperty>().canGoDown = false;
            }
            if (collision.transform.tag == "LeftWall")
            {
                handleObj.GetComponent <BlockObjProperty>().canGoLeft = false;
            }
            if (collision.transform.tag == "RightWall")
            {
                handleObj.GetComponent <BlockObjProperty>().canGoRight = false;
            }
        }
    }
        public ActionResult <string> GetData(string userId, List <string> docNames)
        {
            if (userId == null || docNames.Count == 0)
            {
                return("URL don't seem to be correct");
            }
            /////
            ///Receiveng userID and List of DocNames and converting them to Client Object and a List of DocForProcess
            ///
            //Create Doc and UserObjects
            Client client = CreateObject.ClientObjMaker(userId, db);

            if (client == null)
            {
                return("User Not Found!");
            }

            logger.InfoFormat("Client {0}, with access level {1}, has added {2} tasks.", client.UserID, client.SLALevel, docNames.Count);

            List <DocForPorcess> taskObjList = CreateObject.TaskListMaker(client, db, docNames);

            ///Collectin data from appseting.json
            maxServerAllowed = confSettings.Value.ServerNumber;
            processTime      = confSettings.Value.ProcessTime;


            //All the new and remaining orders are in ProcessQue
            processQue.AddRange(taskObjList);

            ///Creating list of tasks, with limitation of number of servers for simultaneous process.
            Scheduler.CreateThreads(maxServerAllowed, processQue, processTime, activeServersCount);

            return("Processing...");
        }
        public ParticleTextureCutControl(ParticleTextureCutControlConstructionParams csParam)
            : base(csParam)
        {
            InitConstruction();

            //var cpInfos = new List<CodeGenerateSystem.Base.CustomPropertyInfo>();
            //cpInfos.Add(CodeGenerateSystem.Base.CustomPropertyInfo.GetFromParamInfo(typeof(string), "Name", new Attribute[] { new EngineNS.Rtti.MetaDataAttribute() }));
            //mTemplateClassInstance = CodeGenerateSystem.Base.PropertyClassGenerator.CreateClassInstanceFromCustomPropertys(cpInfos, this, true);

            //var clsType = mTemplateClassInstance.GetType();
            //var xNamePro = clsType.GetProperty("Name");
            //xNamePro.SetValue(mTemplateClassInstance, csParam.NodeName);

            NodeName = csParam.NodeName;

            if (string.IsNullOrEmpty(NodeName))
            {
                NodeName = "ParticleTextureCut";
            }

            IsOnlyReturnValue = true;
            AddLinkPinInfo("ParticleTextureCutControlDown", mCtrlValueLinkHandleDown, null);
            AddLinkPinInfo("ParticleTextureCutControlUp", mCtrlValueLinkHandleUp, null);

            mCtrlValueLinkHandleDown.ResetDefaultFilterBySystem("ParticleTextureCutControlUp");

            CreateObject.CreateObjectConstructionParams createobjparam = new CreateObject.CreateObjectConstructionParams();
            createobjparam.CreateType = csParam.CreateType;
            createObject = new CreateObject(createobjparam);
            createObject.CreateTemplateClas();

            createObject.SetPropertyChangedEvent(OnPropertyChanged);
        }
Example #9
0
        /// <summary>
        /// Create a new instance of the specified type
        /// </summary>
        /// <returns></returns>
        public static CreateObject CreateObjectFactory <T>() // where T : class
        {
            Type         t = typeof(T);
            CreateObject c = CreatorCache[t] as CreateObject;

            if (c == null)
            {
                lock (CreatorCache.SyncRoot)
                {
                    c = CreatorCache[t] as CreateObject;
                    if (c != null)
                    {
                        return(c);
                    }
                    DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_" + t.Name, typeof(object), null, t);
                    ILGenerator   ilGen     = dynMethod.GetILGenerator();

                    //ilGen.Emit(OpCodes.Newobj, t.GetConstructor(Type.EmptyTypes));
                    ilGen.Emit(OpCodes.Newobj, t.GetConstructor(BindingFlags.Public |
                                                                BindingFlags.NonPublic | BindingFlags.Instance, null,
                                                                Type.EmptyTypes, null));

                    ilGen.Emit(OpCodes.Ret);
                    c = (CreateObject)dynMethod.CreateDelegate(CoType);
                    CreatorCache.Add(t, c);
                }
            }
            return(c);
        }
Example #10
0
    private void MakeLShape()
    {
        for (int i = 0; i < objSize; i++)
        {
            GameObject nObj = GameObject.CreatePrimitive(PrimitiveType.Cube);

            nObj.transform.SetParent(handleObj.transform);
            nObj.transform.localPosition = new Vector3(0.5f, i + 0.5f, 0);
            nObj.transform.tag           = CreateObject.FromBlockTagsToString(curObjTag);
            BlockCollisionHandle tmp = nObj.AddComponent <BlockCollisionHandle>();
            tmp.handleObj = handleObj;
            Rigidbody tmp_rb = nObj.AddComponent <Rigidbody>();
            tmp_rb.constraints = RigidbodyConstraints.FreezeAll;

            AllObjs.Add(nObj);
        }

        for (int i = 1; i < objSize - 1; i++)
        {
            GameObject nObj = GameObject.CreatePrimitive(PrimitiveType.Cube);

            nObj.transform.SetParent(handleObj.transform);
            nObj.transform.localPosition = new Vector3(0.5f + i, 0.5f, 0);
            nObj.transform.tag           = CreateObject.FromBlockTagsToString(curObjTag);
            BlockCollisionHandle tmp = nObj.AddComponent <BlockCollisionHandle>();
            tmp.handleObj = handleObj;
            Rigidbody tmp_rb = nObj.AddComponent <Rigidbody>();
            tmp_rb.constraints = RigidbodyConstraints.FreezeAll;

            AllObjs.Add(nObj);
        }

        return;
    }
Example #11
0
        /// <summary>
        /// Faster alternative to Activator.CreateInstance()
        /// </summary>
        /// <typeparam name="T">ResourceBase</typeparam>
        /// <param name="startPoint">start position</param>
        /// <param name="maxX">max amount along virtual X</param>
        /// <param name="maxZ">max amount along virtual Z</param>
        private void GenerateResources <T>(Point startPoint, Int16 maxX, Int16 maxZ, Int16 objectWidth,
                                           Int16 objectHeight, Int16 emptySpotsAmount, CellState type) where T : ResourceBase
        {
            Int16 emptySpot = Convert.ToInt16(this.rndRes.Next(MAX_MINE_NUMBER_X - 1));
            Int16 count     = 0;

            ConstructorInfo     ctor        = typeof(T).GetConstructors().First();
            ParameterExpression arg         = Expression.Parameter(typeof(Game), "game");
            NewExpression       expression  = Expression.New(ctor, arg);
            LambdaExpression    lambda      = Expression.Lambda(typeof(CreateObject <T>), expression, arg);
            CreateObject <T>    instantiate = (CreateObject <T>)lambda.Compile();

            for (Int16 i = 0; i < maxZ; i++)
            {
                for (Int16 j = 0; j < maxX; j++)
                {
                    Int16 X     = Convert.ToInt16(startPoint.X + j * objectHeight);
                    Int16 Z     = Convert.ToInt16(startPoint.Y + i * objectWidth);
                    Int16 lastX = Convert.ToInt16(X + objectHeight - 1);
                    Int16 lastZ = Convert.ToInt16(Z + objectWidth - 1);

                    if (count < emptySpotsAmount && j == emptySpot)
                    {
                        count++;
                        emptySpot = Convert.ToInt16(this.rndRes.Next(maxX - 1));
                        continue;
                    }

                    this.gameField.MarkAddResources(X, Z, type, lastX, lastZ, out this.currentResourceVertices);
                    this.InstantiateResourceObject(X, Z, instantiate);
                }
            }
        }
Example #12
0
        private static void ReadCreateObjectBlock(Packet packet, CreateObject createObject, WowGuid guid, uint map, object index)
        {
            ObjectType objType = ObjectTypeConverter.Convert(packet.ReadByteE <ObjectTypeLegacy>("Object Type", index));
            WoWObject  obj     = CoreParsers.UpdateHandler.CreateObject(objType, guid, map);

            obj.Movement            = ReadMovementUpdateBlock(packet, guid, index);
            obj.UpdateFields        = CoreParsers.UpdateHandler.ReadValuesUpdateBlockOnCreate(packet, createObject.Values.Legacy, objType, index);
            obj.DynamicUpdateFields = CoreParsers.UpdateHandler.ReadDynamicValuesUpdateBlockOnCreate(packet, objType, index);

            // If this is the second time we see the same object (same guid,
            // same position) update its phasemask
            if (Storage.Objects.ContainsKey(guid))
            {
                var existObj = Storage.Objects[guid].Item1;
                CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly
            }
            else
            {
                Storage.Objects.Add(guid, obj, packet.TimeSpan);
            }

            if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject))
            {
                packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN");
            }
        }
        public ParticleStateControl(ParticleStateControlConstructionParams csParam)
            : base(csParam)
        {
            InitConstruction();

            NodeName = csParam.NodeName;

            //csParam.SetHostNodesContainerEvent -= InitGraphEvent;
            //csParam.SetHostNodesContainerEvent += InitGraphEvent;
            //InitGraphEvent();
            if (string.IsNullOrEmpty(NodeName))
            {
                NodeName = "ParticleState";
            }

            IsOnlyReturnValue = true;
            AddLinkPinInfo("ParticleStateControlDown", mCtrlValueLinkHandleDown, null);
            AddLinkPinInfo("ParticleStateControlUp", mCtrlValueLinkHandleUp, null);

            mCtrlValueLinkHandleDown.ResetDefaultFilter();
            mCtrlValueLinkHandleDown.ResetDefaultFilterByShape("ParticleStateControlUp");
            CreateObject.CreateObjectConstructionParams createobjparam = new CreateObject.CreateObjectConstructionParams();
            createobjparam.CreateType = csParam.CreateType;
            createObject = new CreateObject(createobjparam);
            createObject.CreateTemplateClas();

            createObject.SetPropertyChangedEvent(OnPropertyChanged);
        }
Example #14
0
    public bool MoveDown()
    {
        if (mHandlerControlEnv == null)
        {
            mHandlerControlEnv = handleObj.transform.parent.GetComponent <ControlEnvironment>();
        }

        // check if the object can go down
        mHandleObjPropertyHandler.canGoDown = true;
        for (int i = 0; i < AllObjs.Count && mHandleObjPropertyHandler.canGoDown; i++)
        {
            Vector3 p = ((GameObject)AllObjs[i]).transform.position;

            Vector2Int id = CreateObject.GetIndex(p);

            if (id.y <= 0)
            {
                mHandleObjPropertyHandler.canGoDown = false;
                break;
            }
            if (mHandlerControlEnv.tetrisMap[id.y - 1][id.x] == 1)
            {
                mHandleObjPropertyHandler.canGoDown = false;
                break;
            }
        }

        if (mHandleObjPropertyHandler.canGoDown)
        {
            handleObj.transform.position += new Vector3(0, -1, 0);
            return(true);
        }
        return(false);
    }
    // once the block of cubes stops moving copy them to the tetris, and change the map, objects and sum row accordingly
    void CopyObjAsBlocks()
    {
        // y = 0.5 to 9.5 -> idy = 0 ... 9
        // x = -3.5 to 3.5 -> idx = 0 ... 7

        for (int o = 0; o < mObjectCreatorHandler.AllObjs.Count; o++)
        {
            Vector3 p = ((GameObject)mObjectCreatorHandler.AllObjs[o]).transform.position;

            Vector2Int id = CreateObject.GetIndex(p);

            if (id.y >= 0 && id.y < nRows && id.x >= 0 && id.x < nCols)
            {
                if (tetrisMap[id.y][id.x] == 0)
                {
                    sumRowsTetris[id.y] += 1;
                }
                else
                {
                    flag_reset_all = true;
                }
                tetrisMap[id.y][id.x] = 1;
            }
            tetrisMapGameObj[id.y][id.x] = (GameObject)mObjectCreatorHandler.AllObjs[o];

            tetrisMapGameObj[id.y][id.x].transform.SetParent(this.transform);
            tetrisMapGameObj[id.y][id.x].transform.tag = CreateObject.FromBlockTagsToString(CreateObject.BlockTags.Block);
            tetrisMapGameObj[id.y][id.x].GetComponent <Renderer>().material.color = Color.black;
        }

        mObjectCreatorHandler.ResetHandleObj();
    }
Example #16
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit = new RaycastHit();

            if (Physics.Raycast(ray, out hit))
            {
                GameObject obj = hit.collider.gameObject;
                Debug.Log("touchObject=" + obj.name);
                PluginUniv.touchObject();
            }

            //オブジェクト作るテスト
            Dictionary <string, decimal> data = new Dictionary <string, decimal>();
            data.Add("id", 5);
            data.Add("longitude", (decimal)Input.location.lastData.longitude);
            data.Add("latitude", (decimal)Input.location.lastData.latitude);
//			data.Add("longitude", 139.702762m);
//			data.Add("latitude", 35.649982m);

            CreateObject createobject = new CreateObject();

            createobject.CreateArObject(data);
        }
    }
Example #17
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            applicationDataContext = new ApplicationDataContext()
            {
                Objects         = new List <BaseObject>(),
                ComboBoxObjects = ComboBoxObjects,
            };
            applicationDataContext.ObjectCreatedEvent += applicationDataContext.AddObjectToList;
            applicationDataContext.ObjectCreatedEvent += applicationDataContext.AddObjectToComboBox;
            applicationDataContext.ObjectDeletedEvent += applicationDataContext.DeleteObjectFromList;
            applicationDataContext.ObjectDeletedEvent += applicationDataContext.DeleteObjectFromComboBox;

            IFactory[] ArrayOfFactories = new IFactory[] {
                new FlattopFactory("Авианосец"),
                new WarPlaneFactory("Военный самолет"),
                new PilotFactory("Пилот"),
            };
            ComboBoxCreate.Items.AddRange(ArrayOfFactories);

            CreateObject createObject = new CreateObject();

            createObject.CreateSomeObjects(applicationDataContext);

            SerializerFactory[] ArrayOfSerializers = new SerializerFactory[] {
                new JsonFactory("Json"),
                new BinaryFactory("Бинарная"),
                new ClientFactory("Клиентская"),
            };
            ComboBoxSerializers.Items.AddRange(ArrayOfSerializers);

            CodingPlugins codePlugins = new CodingPlugins();

            codePlugins.RefreshPlugins();
            ComboBoxCoders.Items.AddRange(codePlugins.plugins.ToArray());
        }
    void Update()
    {
        Cast = transform.GetComponentInChildren <CreateObject>();

        if (!Cast.Casting)
        {
            isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

            if (isGrounded && velocity.y < 0)
            {
                velocity.y = -2f;
            }

            float x = Input.GetAxis("Horizontal");
            float z = Input.GetAxis("Vertical");

            Vector3 move = transform.right * x + transform.forward * z;

            controller.Move(move * speed * Time.deltaTime);

            if (Input.GetButtonDown("Jump") && isGrounded)
            {
                velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
            }

            velocity.y += gravity * Time.deltaTime;

            controller.Move(velocity * Time.deltaTime);
        }
    }
Example #19
0
        public CreateObjectDefinition(CreateObject createObject)
        {
            this.CreateObject = createObject;
            if (!Enum.IsDefined(typeof(CreateObject), createObject))
            {
                throw new InvalidEnumArgumentException(nameof(createObject), (Int32)createObject, typeof(CreateObject));
            }

            var value = createObject.ToString();

            if (value.StartsWith(Constants.Wpf))
            {
                this.ProjectType = ProjectType.Wpf;
                this.ShortName   = value.Substring(3).SplitWords();
            }
            else if (value.StartsWith(Constants.Xamarin))
            {
                this.ProjectType = ProjectType.Xamarin;
                this.ShortName   = value.Substring(7).SplitWords();
            }
            else if (value.StartsWith(Constants.Silverlight))
            {
                this.ProjectType = ProjectType.Silverlight;
                this.ShortName   = value.Substring(11).SplitWords();
            }
            else
            {
                this.ProjectType = ProjectType.Uwp;
                this.ShortName   = value.Substring(3).SplitWords();
            }
        }
Example #20
0
    public void MoveLeft()
    {
        if (mHandlerControlEnv == null)
        {
            mHandlerControlEnv = handleObj.transform.parent.GetComponent <ControlEnvironment>();
        }

        // check if the object can go left
        mHandleObjPropertyHandler.canGoLeft = true;
        for (int i = 0; i < AllObjs.Count && mHandleObjPropertyHandler.canGoLeft; i++)
        {
            Vector3 p = ((GameObject)AllObjs[i]).transform.position;

            Vector2Int id = CreateObject.GetIndex(p);

            if (id.x <= 0)
            {
                mHandleObjPropertyHandler.canGoLeft = false;
                break;
            }
            if (mHandlerControlEnv.tetrisMap[id.y][id.x - 1] == 1)
            {
                mHandleObjPropertyHandler.canGoLeft = false;
                break;
            }
        }

        if (mHandleObjPropertyHandler.canGoLeft)
        {
            handleObj.transform.position += new Vector3(-1, 0, 0);
        }
        CheckForBoundaries();
    }
Example #21
0
    public static List <T> ReadFile <T>(string filename, bool hasheader, char delimiter, ToOBJ <T> mapper) //where T : new()
    {
        COLUMNS.MGSpan[] cols;
        List <T>         list = new List <T>(10000);

        int          linenum = 0;
        CreateObject co      = FastCreateInstance <T>();
        var          br      = new BufReader(File.OpenText(filename), 64 * 1024);
        var          line    = br.ReadLine();

        if (line.Count == 0)
        {
            return(list);
        }

        if (hasheader)
        {
            // actual col count
            int cc = CountOccurence(line, delimiter);
            if (cc == 0)
            {
                throw new Exception("File does not have '" + delimiter + "' as a delimiter");
            }
            cols = new COLUMNS.MGSpan[cc + 1];
        }
        else
        {
            cols = new COLUMNS.MGSpan[_COLCOUNT];
        }

        while (true)
        {
            try
            {
                line = br.ReadLine();
                linenum++;
                if (line.Count == 0)
                {
                    break;
                }

                var c = ParseLine(line, delimiter, cols);

                T o = (T)co();
                //new T();
                var b = mapper(o, new COLUMNS(c));
                if (b)
                {
                    list.Add(o);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("error on line " + linenum + "\r\n" + line, ex);
            }
        }

        return(list);
    }
Example #22
0
        /// <summary>
        /// Initialises a new instance of the <see cref="SlimObjectPool{T}" /> class.
        /// </summary>
        /// <param name="create">
        /// The delegate method to use to create new pooled object instances.
        /// </param>
        /// <param name="reset">
        /// The delegate method to use to reset used pooled object instances.
        /// </param>
        /// <param name="destroy">
        /// The delegate method to use to destroy pooled object instances that cannot be reused.
        /// </param>
        internal SlimObjectPool(CreateObject create, ResetObject reset, DestroyObject destroy)
        {
            createObject  = create;
            resetObject   = reset;
            destroyObject = destroy;

            objectBuffer = new ConcurrentBag <T>();
        }
Example #23
0
        public static CreateObject CreateClass(Type type)
        {
            var          newType = Expression.New(type);
            var          lambda  = Expression.Lambda <CreateObject>(newType);
            CreateObject c       = lambda.Compile();

            return(c);
        }
Example #24
0
        public Pool(CreateObject createObject, EnableObject enableObject, DisableObject disableObject)
        {
            _availableObjects = new List <T>();

            _createObject  = createObject;
            _enableObject  = enableObject;
            _disableObject = disableObject;
        }
 void Start()
 {
     m_createobj         = this.GetComponent <CreateObject>();
     mTrackableBehaviour = GetComponent <TrackableBehaviour>();
     if (mTrackableBehaviour)
     {
         mTrackableBehaviour.RegisterTrackableEventHandler(this);
     }
 }
Example #26
0
        public GenericPool(CreateObject createAction, int startSize = 128, int pageSize = 128)
        {
            this.createAction = createAction;

            this.startSize = startSize;
            this.pageSize  = pageSize;

            Initialize();
        }
Example #27
0
        private static void ReadCreateObjectBlock(Packet packet, CreateObject createObject, WowGuid guid, uint map, object index)
        {
            ObjectType objType        = ObjectTypeConverter.Convert(packet.ReadByteE <ObjectTypeLegacy>("Object Type", index));
            var        moves          = ReadMovementUpdateBlock(packet, createObject, guid, index);
            var        updates        = CoreParsers.UpdateHandler.ReadValuesUpdateBlockOnCreate(packet, createObject.Values, objType, index);
            var        dynamicUpdates = CoreParsers.UpdateHandler.ReadDynamicValuesUpdateBlockOnCreate(packet, objType, index);

            WoWObject obj;

            switch (objType)
            {
            case ObjectType.Unit:
                obj = new Unit();
                break;

            case ObjectType.GameObject:
                obj = new GameObject();
                break;

            case ObjectType.Player:
                obj = new Player();
                break;

            default:
                obj = new WoWObject();
                break;
            }

            obj.Type                = objType;
            obj.Movement            = moves;
            obj.UpdateFields        = updates;
            obj.DynamicUpdateFields = dynamicUpdates;
            obj.Map          = map;
            obj.Area         = CoreParsers.WorldStateHandler.CurrentAreaId;
            obj.Zone         = CoreParsers.WorldStateHandler.CurrentZoneId;
            obj.PhaseMask    = (uint)CoreParsers.MovementHandler.CurrentPhaseMask;
            obj.Phases       = new HashSet <ushort>(CoreParsers.MovementHandler.ActivePhases.Keys);
            obj.DifficultyID = CoreParsers.MovementHandler.CurrentDifficultyID;

            // If this is the second time we see the same object (same guid,
            // same position) update its phasemask
            if (Storage.Objects.ContainsKey(guid))
            {
                var existObj = Storage.Objects[guid].Item1;
                CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly
            }
            else
            {
                Storage.Objects.Add(guid, obj, packet.TimeSpan);
            }

            if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject))
            {
                packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN");
            }
        }
        public static CreateObject read(BinaryReader binaryReader)
        {
            CreateObject newObj = new CreateObject();

            newObj.object_id   = binaryReader.ReadUInt32();
            newObj.objdesc     = ObjDesc.read(binaryReader);
            newObj.physicsdesc = PhysicsDesc.read(binaryReader);
            newObj.wdesc       = PublicWeenieDesc.read(binaryReader);
            return(newObj);
        }
Example #29
0
        public CreateObjectResponse CreateObject(CreateObjectRequest request)
        {
            EnsureAbsoluteUri(request);
            var command = new CreateObject(_userId, _secret, _builder, _authenticator)
            {
                Parameters = request
            };

            return((CreateObjectResponse)((ICommandExecutor)this).Execute(command));
        }
Example #30
0
    public TheGoodStuff(int abilityIndex) : base(abilityIndex)
    {
        cost = abilityCost;

        FriendlyHitChanceSkillcheck = CharacterStatType.NONE;
        HostileHitChanceSkillcheck  = CharacterStatType.NONE;

        specialEffect = new CreateObject(0);
        targeting     = new SingleTargetAdjacent(false);
        base.SetDescriptionFromEffects();
    }
Example #31
0
        public ObjectPool(CreateObject<PooledObject> createObject, int initalSize = 0, int maxBuffer = 0)
        {
            if (createObject == null)
            {
                throw new ArgumentNullException("createObject");
            }

            _initialSize = initalSize;
            _maxBuffer = maxBuffer;

            _objects = new ConcurrentQueue<PooledObject>();
            _createObject = createObject;

            for (int i = 0; i < _initialSize; i++)
            {
                PooledObject item = _createObject();
                item.Init(new ReturnObject<PooledObject>(PutObject));

                _objects.Enqueue(item);
            }
        }
Example #32
0
        internal ReflectionCache(Type type)
        {
            Type = type;
            TypeName = type.FullName;
            AssemblyName = type.AssemblyQualifiedName;

            JsonDataType = Reflection.GetJsonDataType (type);
            SerializeMethod = JsonSerializer.GetWriteJsonMethod (type);
            DeserializeMethod = JsonDeserializer.GetReadJsonMethod (type);

            if (JsonDataType == JsonDataType.Enum) {
                IsFlaggedEnum = AttributeHelper.HasAttribute<FlagsAttribute> (type, false);
                return;
            }

            if (type.IsArray) {
                ArgumentTypes = new Type[] { type.GetElementType () };
                CommonType = type.GetArrayRank () == 1 ? ComplexType.Array : ComplexType.MultiDimensionalArray;
            }
            else {
                var t = type;
                if (t.IsGenericType == false) {
                    while ((t = t.BaseType) != null) {
                        if (t.IsGenericType) {
                            break;
                        }
                    }
                }
                if (t != null) {
                    ArgumentTypes = t.GetGenericArguments ();
                    var gt = t.GetGenericTypeDefinition ();
                    if (gt.Equals (typeof (Dictionary<,>))) {
                        CommonType = ComplexType.Dictionary;
                    }
                    else if (gt.Equals (typeof (List<>))) {
                        CommonType = ComplexType.List;
                    }
                    else if (gt.Equals (typeof (Nullable<>))) {
                        CommonType = ComplexType.Nullable;
                        SerializeMethod = JsonSerializer.GetWriteJsonMethod (ArgumentTypes[0]);
                    }
                }
            }
            if (typeof(IEnumerable).IsAssignableFrom (type)) {
                if (typeof(Array).IsAssignableFrom (type) == false) {
                    AppendItem = Reflection.CreateWrapperMethod<AddCollectionItem> (Reflection.FindMethod (type, "Add", new Type[1] { null }));
                }
                if (ArgumentTypes != null && ArgumentTypes.Length == 1) {
                    ItemSerializer = JsonSerializer.GetWriteJsonMethod (ArgumentTypes[0]);
                    ItemDeserializer = JsonDeserializer.GetReadJsonMethod (ArgumentTypes[0]);
                }
            }
            if (ArgumentTypes != null) {
                ArgumentReflections = new ReflectionCache[ArgumentTypes.Length];
            }
            if (CommonType != ComplexType.Array
                && CommonType != ComplexType.MultiDimensionalArray
                && CommonType != ComplexType.Nullable) {
                var t = type;
                if (type.IsNested == false && type.IsPublic == false) {
                    ConstructorInfo |= ConstructorTypes.NonPublic;
                }
                else {
                    while (t != null && t.IsNested) {
                        if (t.IsNestedPublic == false) {
                            ConstructorInfo |= ConstructorTypes.NonPublic;
                        }
                        t = t.DeclaringType;
                    }
                }
                if (type.IsClass || type.IsValueType) {
                    Constructor = Reflection.CreateConstructorMethod (type, type.IsVisible == false || typeof (DatasetSchema).Equals (type));
                    if (Constructor != null && Constructor.Method.IsPublic == false) {
                        ConstructorInfo |= ConstructorTypes.NonPublic;
                    }
                    if (Constructor == null) {
                        var c = type.GetConstructors (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                        if (c != null && c.Length > 0) {
                            ConstructorInfo |= ConstructorTypes.Parametric;
                        }
                    }

                    Members = Reflection.GetMembers (type);
                }
            }
            //if (typeof (IEnumerable).IsAssignableFrom (type)) {
            //	return;
            //}
            //if (JsonDataType != JsonDataType.Undefined) {
            //	return;
            //}
        }