Beispiel #1
0
        private static void DbTest()
        {
            StoreSet<Student> store = new StoreSet<Student>(
                typeof(SchoolContext)
            );

            Student student = store.FirstOrDefault(t => t.Id == 1, "Enrollments.Course");
            //Student student = store.FirstOrDefault(t => t.Id == 1);
            student.DumpToLog(Level.Info);

            Student stu2 = new Copier<Student>().Copy(student);
            stu2.DumpToLog(Level.Warn);
        }
 public SelectSetVariable(ScriptDom.SelectSetVariable src) : base(src)
 {
     this.Variable       = Copier.Copy <VariableReference>(src.Variable);
     this.Expression     = Copier.Copy <ScalarExpression>(src.Expression);
     this.AssignmentKind = src.AssignmentKind;
 }
    // eco is address pointing copy of unityEco
    // don't use any variables besides what's sent into the function, or created in the function (to avoid threading issues)
    void runSystem(Ecosystem eco, int Localsteps, Thread mainThread)
    {
        string localVisRes;

        lock (threadFinishedLock)
        {
            threadFinished = false;
        }
        // change data in copy
        //eco.name = eco.name + "1";
        for (int i = 0; i < bufferLength; i++)
        {
            /*
             * // terminate thread if main thread dies
             * if (!mainThread.IsAlive)
             * {
             *  Debug.Log("main thread dead, aborting simulation thread");
             *  Thread.CurrentThread.Abort();
             * }
             */

            // get whether finishChildThread is true
            bool tempFinishChildThread;
            lock (endThreadLock)
            {
                tempFinishChildThread = finishChildThread;
            }

            // if it shouldn't be ended, run simulation and add state to queue
            if (!tempFinishChildThread)
            {
                eco.runSystem(Localsteps); // run ecosystem
                //float st = System.DateTime.Now.Second;
                //Debug.Log("starting threads");


                // update visible resource in case it was changed by the user
                lock (visibleResourceLock)
                {
                    localVisRes = visibleResource;
                }

                eco.updateTexture(localVisRes);

                /*
                 * eco.startTextureThreads();
                 *
                 * while (!eco.checkThreadsFinished())
                 * {
                 *  Thread.Sleep(20);
                 * }
                 */

                //Debug.Log("threads done");
                //float et = System.DateTime.Now.Second;
                //Debug.Log(et - st);


                //Debug.Log("all threads finished");

                QueueMainThread(eco);               // queue main with ecosystem

                eco = Copier.getEcosystemCopy(eco); // make eco point to a new ecosystem object, so that each object in the queue is different

                Thread.Sleep(childThreadSleepTime); // give time for other thread to catch up
            }
            // if it should be ended
            else
            {
                // reset variable, and break out of loop
                lock (endThreadLock)
                {
                    finishChildThread = false;
                }
                break;
            }
        }


        lock (threadFinishedLock)
        {
            threadFinished = true;
        }
    }
 public HavingClause(ScriptDom.HavingClause src) : base(src)
 {
     this.SearchCondition = Copier.Copy <BooleanExpression>(src.SearchCondition);
 }
Beispiel #5
0
        public override void UnPack(byte[] data)
        {
            var obj = Deserialize(data);

            Copier <__ServerGModule__LoginService__ResetPasswordReq> .CopyTo(obj, this);
        }
 public ExecuteInsertSource(ScriptDom.ExecuteInsertSource src) : base(src)
 {
     this.Execute = Copier.Copy <ExecuteSpecification>(src.Execute);
 }
Beispiel #7
0
 public ExistsPredicate(ScriptDom.ExistsPredicate src) : base(src)
 {
     this.Subquery = Copier.Copy <ScalarSubquery>(src.Subquery);
 }
        static void Main(string[] args)
        {
            Copier copier = new Copier(new DataBaseRepository(), new KeyBoardProcess());

            copier.Copy();
        }
        /// <summary>
        /// 设置武器技能
        /// </summary>
        /// <param name="SkillStr">Excel中的技能短字符串</param>
        /// <param name="Weapon">被设置技能的武器</param>
        void SetSkillNew(String SkillStr, Weapon Weapon)
        {
            if (SkillStr == "")
            {
                return;
            }
            //不确定的技能名单
            var ineptitude = ToolsAndHelper.GetSpecialSkillList();

            try
            {
                //先用英文逗号分割技能字符串 ,提取其中的多个技能
                var SkillArray = SplitString(SkillStr, 2, IsHaveEmpty: StringSplitOptions.RemoveEmptyEntries);
                //遍历技能列表获取技能名称
                foreach (var item in SkillArray)
                {
                    //技能实体
                    WeaponSkill Skill;
                    //技能后缀
                    var SkillSuffix = "";
                    //后缀索引
                    short SkillSuffixIndex;
                    var   element = WeaponSkill.GBFElementCHSEnum.未知;

                    //判断是否为特殊技能 如果是则直接设置特殊技能
                    if (ineptitude.Exists(x => x == item))
                    {
                        Skill = SkillList.ObjStrDic[item].FirstOrDefault()?.Clone() as WeaponSkill;
                        //设置是否启用技能警告
                        Weapon.SkillWarning = true;
                        if (Skill == null)
                        {
                            throw new Exception("未知的特殊技能,请添加信息");
                        }
                        Weapon.WeaponSkill.Add(Skill);
                        continue;
                    }

                    var TempStr = SplitString(item, 3);
                    //取出技能主名称
                    var SkillMainName = TempStr.FirstOrDefault();

                    //当索引为1的字符串 不为数字(属性)时 ,寻找技能副名称,且索引为2的字符串为元素
                    if (!ToolsAndHelper.StringContentType(TempStr[1], 2))
                    {
                        var ExtraNameResult = ToolsAndHelper.FoundSkillExtraName(SkillMainName, TempStr[1], SkillList.ObjStrDic);

                        //如果返回值为空则说明字典集中不存在副名称为SkillExtraName的技能
                        if (ExtraNameResult == "")
                        {
                            Skill = SkillList.ObjStrDic["errorSkill"].FirstOrDefault();
                            Skill = Copier <WeaponSkill, WeaponSkill> .Copy(Skill);

                            Weapon.WeaponSkill.Add(Skill);
                            Weapon.SkillWarning = true;
                            continue;
                        }
                        //将返回值(主名称+副名称) 赋值给主名称
                        SkillMainName = ExtraNameResult;
                        //技能后缀的索引
                        SkillSuffixIndex = 3;
                    }
                    else
                    {
                        //否则索引为1的字符串为元素
                        //赋值元素,设置技能后缀索引
                        element = (WeaponSkill.GBFElementCHSEnum)Enum.Parse(
                            typeof(WeaponSkill.GBFElementCHSEnum), TempStr[1]);
                        SkillSuffixIndex = 2;
                    }
                    //赋值后缀
                    if (TempStr.Count >= 1 + SkillSuffixIndex)
                    {
                        SkillSuffix = TempStr[SkillSuffixIndex];
                        if (TempStr.Count > 1 + SkillSuffixIndex)
                        {
                            SkillSuffix += TempStr[1 + SkillSuffixIndex];
                        }
                        else
                        {
                            if (element == WeaponSkill.GBFElementCHSEnum.未知)
                            {
                                element = (WeaponSkill.GBFElementCHSEnum)Enum.Parse(
                                    typeof(WeaponSkill.GBFElementCHSEnum), TempStr[SkillSuffixIndex]);
                            }
                        }
                    }
                    //验证后缀
                    SkillSuffix = ToolsAndHelper.FoundSkillSuffix(SkillMainName, SkillSuffix, SkillList.ObjStrDic);

                    //如果技能字典集中有此技能
                    if (SkillList.ObjStrDic.Keys.ToList().Exists(x => x == SkillMainName))
                    {
                        //搜索并设置武器的技能
                        // ReSharper disable once AssignNullToNotNullAttribute
                        Skill = SkillList.ObjStrDic[SkillMainName].FirstOrDefault(x => x.Extra_Name == SkillSuffix);
                        Skill = Copier <WeaponSkill, WeaponSkill> .Copy(Skill);

                        if (Skill == null)
                        {
                            Skill = new WeaponSkill()
                            {
                                Main_Name        = (WeaponSkill.SkillTypeEnum)Enum.Parse(typeof(WeaponSkill.SkillTypeEnum), SkillMainName),
                                Extra_Name       = SkillSuffix,
                                Main_Description = "Excel中未读取到此后缀的技能,请添加",
                                IsCalculation    = false,
                                TheReason        = "Excel中未读取到此后缀的技能,请添加"
                            };
                            SkillList.ObjStrDic[SkillMainName].Add(Skill);
                            Weapon.SkillWarning = true;
                        }

                        Skill.SkillElement = element;
                        Weapon.WeaponSkill.Add(Skill);
                    }
                    else
                    {
                        throw new Exception("特殊技能 请添加信息");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("设置武器\"" + (string.IsNullOrEmpty(Weapon.FsName_CHS) ? Weapon.FnWeapon_ID.ToString() : Weapon.FsName_CHS) + "\"的武器技能时时发生错误:" + ex.Message);
            }
        }
 public GoToStatement(ScriptDom.GoToStatement src) : base(src)
 {
     this.LabelName = Copier.Copy <Identifier>(src.LabelName);
 }
 public ColumnReferenceExpression(ScriptDom.ColumnReferenceExpression src) : base(src)
 {
     this.ColumnType          = src.ColumnType;
     this.MultiPartIdentifier = Copier.Copy <MultiPartIdentifier>(src.MultiPartIdentifier);
 }
 public NullIfExpression(ScriptDom.NullIfExpression src) : base(src)
 {
     this.FirstExpression  = Copier.Copy <ScalarExpression>(src.FirstExpression);
     this.SecondExpression = Copier.Copy <ScalarExpression>(src.SecondExpression);
 }
 public ParenthesisExpression(ScriptDom.ParenthesisExpression src) : base(src)
 {
     this.Expression = Copier.Copy <ScalarExpression>(src.Expression);
 }
 public ScalarSubquery(ScriptDom.ScalarSubquery src) : base(src)
 {
     this.QueryExpression = Copier.Copy <QueryExpression>(src.QueryExpression);
 }
 public TryConvertCall(ScriptDom.TryConvertCall src) : base(src)
 {
     this.DataType  = Copier.Copy <DataTypeReference>(src.DataType);
     this.Parameter = Copier.Copy <ScalarExpression>(src.Parameter);
     this.Style     = Copier.Copy <ScalarExpression>(src.Style);
 }
			public static void Start (TextReader source,
						  Action<string> target)
			{
				var copier = new Copier (source, target);
				var ts = new ThreadStart (copier.Run);
				var thread = new Thread (ts);
				thread.Start ();
			}
Beispiel #17
0
 public override void ChooseDocument()
 {
     Copier.ResponseWriter($"Document chosen successfully.{Environment.NewLine}");
     Copier.CopierState = new PrintingDocument(Copier);
 }
Beispiel #18
0
 public override void ReturnChange()
 {
     Copier.CopierState = new WaitingForChange(Copier);
     Copier.ReturnChange();
 }
Beispiel #19
0
 public CursorId(ScriptDom.CursorId src) : base(src)
 {
     this.Name = Copier.Copy <IdentifierOrValueExpression>(src.Name);
 }
Beispiel #20
0
 public ChoosingDocument(Copier copier) : base(copier)
 {
 }
Beispiel #21
0
 public ComputeFunction(ScriptDom.ComputeFunction src) : base(src)
 {
     this.ComputeFunctionType = src.ComputeFunctionType;
     this.Expression          = Copier.Copy <ScalarExpression>(src.Expression);
 }
 public GroupByClause(ScriptDom.GroupByClause src) : base(src)
 {
     this.GroupByOption = src.GroupByOption;
     this.All           = src.All;
     Copier.CopyList(this.GroupingSpecifications, src.GroupingSpecifications);
 }
 public ExecuteContext(ScriptDom.ExecuteContext src) : base(src)
 {
     this.Principal = Copier.Copy <ScalarExpression>(src.Principal);
     this.Kind      = src.Kind;
 }
Beispiel #24
0
        /// <summary>
        /// 拷贝source的数据到target。适用于db.Create时候后,拷贝dto的数据到实体对象。
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void CopyTo(TSource source, TTarget target)
        {
            Copier <TSource, TTarget> .Copy(source, target);

            Utils.SetNullToEmpty(target);
        }
 public TableDefinition(ScriptDom.TableDefinition src) : base(src)
 {
     Copier.CopyList(this.ColumnDefinitions, src.ColumnDefinitions);
     Copier.CopyList(this.TableConstraints, src.TableConstraints);
 }
 public FetchCursorStatement(ScriptDom.FetchCursorStatement src) : base(src)
 {
     this.FetchType = Copier.Copy <FetchType>(src.FetchType);
     Copier.CopyList(this.IntoVariables, src.IntoVariables);
 }
    public bool updateEcoIfReady()
    {
        bool      updateOccured = false; // change to true if update occured
        Ecosystem lastEnqueued;
        bool      checkFinished;

        // check if child thread has finished (only one child thread runs at a time)
        lock (threadFinishedLock)
        {
            checkFinished = threadFinished;
        }
        // if finished, we may want to restart the thread
        if (checkFinished)
        {
            int queueLength;
            // get length of queue to see if it's short enough to run the simulation thread again
            lock (ecoQueueLock)
            {
                queueLength = ecoQueue.Count;
            }
            // if the last thread has finished and the queue length is getting short, run the simulation some more.
            if (queueLength < bufferLength)
            {
                bool emptyQueue;
                // check if queue is empty
                lock (ecoQueueLock)
                {
                    emptyQueue = (ecoQueue.Last == null);
                }
                // if it's not empty, start simulation where it left off with last ecosystem in queue
                if (!emptyQueue)
                {
                    lastEnqueued = ecoQueue.Last.Value;
                }
                // otherwise unityEco will hold the most recent ecosystem
                else
                {
                    lastEnqueued = unityEco;
                }
                // lastEnqueued.populations[cow].creatures[0].printNetworks();
                // create a copy using the latest ecosystem, then use the copy for the simulation
                Ecosystem simulationEco = Copier.getEcosystemCopy(lastEnqueued);
                // this will start the child thread, reseting checkFinished to false
                int localSteps = steps; // just in case next line causes threading error
                StartThreadedFunction(() => { runSystem(simulationEco, localSteps, Thread.CurrentThread); });
            }
        } // end checkFinished

        // if ecoQueue is not being modified by the child thread
        lock (ecoQueueLock)
        {
            // if the queue isn't empty, update ecosystem with what's on it
            if (ecoQueue.Count > 0)
            {
                updateOccured = true;
                // remove ecosystem from queue
                Ecosystem updatedEco = ecoQueue.First.Value;
                ecoQueue.RemoveFirst();

                // make unityEco reference modified copy of itself, NOTE: this won't change all references to the ecosystem, such as those used in the UI
                unityEco = updatedEco;

                statsPrinter.printStats(unityEco);
                //Debug.Log("ecosystem age:" + unityEco.count);
            }
        }

        return(updateOccured); // return whether or not the ecosystem was updated (if not we don't need to re-render it)
    }
 public XmlNamespacesAliasElement(ScriptDom.XmlNamespacesAliasElement src) : base(src)
 {
     this.Identifier = Copier.Copy <Identifier>(src.Identifier);
 }
 public SelectStarExpression(ScriptDom.SelectStarExpression src) : base(src)
 {
     this.Qualifier = Copier.Copy <MultiPartIdentifier>(src.Qualifier);
 }
 public TSEqualCall(ScriptDom.TSEqualCall src) : base(src)
 {
     this.FirstExpression  = Copier.Copy <ScalarExpression>(src.FirstExpression);
     this.SecondExpression = Copier.Copy <ScalarExpression>(src.SecondExpression);
 }
 public SelectScalarExpression(ScriptDom.SelectScalarExpression src) : base(src)
 {
     this.Expression = Copier.Copy <ScalarExpression>(src.Expression);
     this.ColumnName = Copier.Copy <IdentifierOrValueExpression>(src.ColumnName);
 }
 public SetIdentityInsertStatement(ScriptDom.SetIdentityInsertStatement src) : base(src)
 {
     this.Table = Copier.Copy <SchemaObjectName>(src.Table);
 }
Beispiel #33
0
 protected override void Act()
 {
     Sut = new Copier(FileImpl,PathImpl);
 }
Beispiel #34
0
        private static void TargetPackage(ITaskContext context)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));
            packagesDir = packagesDir.CombineWith(context.Properties.Get<string>(BuildProps.BuildDir));
            FullPath simplexPackageDir = packagesDir.CombineWith("Detergent");
            FileFullPath zipFileName = packagesDir.AddFileName(
                "Detergent-{0}.zip",
                context.Properties.Get<Version>(BuildProps.BuildVersion));

            StandardPackageDef packageDef = new StandardPackageDef("Detergent", context);
            VSSolution solution = context.Properties.Get<VSSolution>(BuildProps.Solution);

            VSProjectWithFileInfo projectInfo =
                (VSProjectWithFileInfo)solution.FindProjectByName("Detergent");
            LocalPath projectOutputPath = projectInfo.GetProjectOutputPath(
                context.Properties.Get<string>(BuildProps.BuildConfiguration));
            FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath);
            packageDef.AddFolderSource(
                "bin",
                projectTargetDir,
                false);

            ICopier copier = new Copier(context);
            CopyProcessor copyProcessor = new CopyProcessor(
                 context,
                 copier,
                 simplexPackageDir);
            copyProcessor
                .AddTransformation("bin", new LocalPath(string.Empty));

            IPackageDef copiedPackageDef = copyProcessor.Process(packageDef);

            Zipper zipper = new Zipper(context);
            ZipProcessor zipProcessor = new ZipProcessor(
                context,
                zipper,
                zipFileName,
                simplexPackageDir,
                null,
                "bin");
            zipProcessor.Process(copiedPackageDef);
        }