Esempio n. 1
0
        /// <summary>
        /// 启动本地服务
        /// </summary>
        /// <typeparam name="domainType"></typeparam>
        /// <param name="workPath"></param>
        /// <param name="domains"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        private RegisterState start <domainType>(string workPath, Domain[] domains, ILog log) where domainType : HttpDomainServer.Server
        {
            RegisterState state = RegisterState.StartError;

#if NoAutoCSer
            throw new Exception();
#else
            TcpInternalServer tcpServer = new TcpInternalServer(null, null, this, 0, null, log);
            base.SetTcpServer(tcpServer);
            Assembly assembly = typeof(domainType).Assembly;
            LocalDomainServer = AutoCSer.Metadata.DefaultConstructor <domainType> .Constructor();

            LocalDomainServer.LoadCheckPath = getLoadCheckPath(new DirectoryInfo(workPath ?? AutoCSer.Config.ApplicationPath)).FullName;
            if (LocalDomainServer.Start(this, domains, null))
            {
                if ((state = start(domains)) == RegisterState.Success)
                {
                    AutoCSer.LogHelper.Info(@"domain success
" + domains.joinString(@"
", domain => domain.Host.Host + ":" + domain.Host.Port.toString()), LogLevel.Info | LogLevel.AutoCSer);
                    return(RegisterState.Success);
                }
            }
#endif
            return(state);
        }
Esempio n. 2
0
        /// <summary>
        /// Register the collection of processors with automatic dependency resolution.
        /// May to throw an InvalidOperationException.
        /// </summary>
        /// <param name="collectionOfProcessors">Collection of the processors.</param>
        public void Register(IEnumerable <BaseTextProcessor> collectionOfProcessors)
        {
            Queue <BaseTextProcessor> registrationQueue = new Queue <BaseTextProcessor>(collectionOfProcessors);
            int previousCount = registrationQueue.Count;

            while (registrationQueue.Count > 0)
            {
                String insolubleInput = null;
                for (int i = 0; i < previousCount; ++i)
                {
                    BaseTextProcessor processor = registrationQueue.Dequeue();
                    String            registerDetails;
                    RegisterState     result = this.RegisterProcessor(processor, out registerDetails);
                    if (result == RegisterState.OutputLayerNotUnique)
                    {
                        throw new InvalidOperationException(String.Format(@"Name ""{0}"" of output layer is not unique. Layer may be generated by one processor only!", registerDetails));
                    }
                    if (result == RegisterState.InputLayerNotFound)
                    {
                        insolubleInput = registerDetails;
                        registrationQueue.Enqueue(processor);
                    }
                }
                if (previousCount == registrationQueue.Count)
                {
                    throw new InvalidOperationException(String.Format(@"Collection of processors contains insoluble depending - ""{0}""", insolubleInput));
                }
                previousCount = registrationQueue.Count;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Used by the symbolic evaluator to obtain the symbolic value of <paramref name="id"/>.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Expression GetValue(Identifier id)
        {
            var        reg = id.Storage as RegisterStorage;
            Expression value;

            if (reg != null && RegisterState.TryGetValue(reg, out value))
            {
                return(value);
            }
            var tmp = id.Storage as TemporaryStorage;

            if (tmp != null && TemporaryState.TryGetValue(tmp, out value))
            {
                return(value);
            }
            var local = id.Storage as StackLocalStorage;

            if (local != null)
            {
                return(GetStackValue(local.StackOffset, local.DataType));
            }

            //$REVIEW: this is cheating a little; some flags could
            // actually have been set to 0 or 1. The problem is we
            // are doing "poor man's value propagation", and should
            // really be doing this after SSA transformation has been
            // done on the code.
            if (id.Storage is FlagGroupStorage)
            {
                return(Constant.Invalid);
            }
            return(id);
        }
Esempio n. 4
0
        public void Write(string hlslFilename)
        {
            hlslFile   = new FileStream(hlslFilename, FileMode.Create, FileAccess.Write);
            hlslWriter = new StreamWriter(hlslFile);

            _registers = new RegisterState(_shader);

            WriteConstantDeclarations();

            if (_registers.MethodInputRegisters.Count > 1)
            {
                WriteInputStructureDeclaration();
            }

            if (_registers.MethodOutputRegisters.Count > 1)
            {
                WriteOutputStructureDeclaration();
            }

            string methodReturnType = GetMethodReturnType();
            string methodParameters = GetMethodParameters();
            string methodSemantic   = GetMethodSemantic();

            WriteLine("{0} main({1}){2}", methodReturnType, methodParameters, methodSemantic);
            WriteLine("{");
            indent = "\t";

            WriteMethodBody();

            indent = "";
            WriteLine("}");

            hlslWriter.Dispose();
            hlslFile.Dispose();
        }
Esempio n. 5
0
        /// <summary>
        /// 启动本地服务
        /// </summary>
        /// <typeparam name="domainType"></typeparam>
        /// <param name="workPath"></param>
        /// <param name="domains"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        private RegisterState start <domainType>(string workPath, Domain[] domains, ILog log) where domainType : HttpDomainServer.Server
        {
            RegisterState state = RegisterState.StartError;

#if NoAutoCSer
            throw new Exception();
#else
            TcpInternalServer tcpServer = new TcpInternalServer(null, null, this, null, log);
            base.SetTcpServer(tcpServer);
            Assembly assembly = typeof(domainType).Assembly;
            LocalDomainServer = AutoCSer.Emit.Constructor <domainType> .New();

            LocalDomainServer.LoadCheckPath = getLoadCheckPath(new DirectoryInfo(workPath ?? AutoCSer.PubPath.ApplicationPath)).FullName;
            if (LocalDomainServer.Start(this, domains, null))
            {
                if ((state = start(domains)) == RegisterState.Success)
                {
                    AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Info, @"domain success
" + domains.joinString(@"
", domain => domain.Host.Host + ":" + domain.Host.Port.toString()), new System.Diagnostics.StackFrame(), false);
                    return(RegisterState.Success);
                }
            }
#endif
            return(state);
        }
Esempio n. 6
0
 private void UpdateRegisterState(RegisterState state)
 {
     if (currentState == RegisterState.VALIDATED)
     {
         currentState = state;
     }
 }
Esempio n. 7
0
 public void RegisterResponse(RegisterState state)
 {
     if (_registerResponse != null)
     {
         _registerResponse(state);
     }
 }
Esempio n. 8
0
 public void RunProgram()
 {
     foreach (var operation in operations)
     {
         CurrentRegisters = CurrentRegisters.PerformOperation(operation, opcodeNumbers[operation.Opcode]);
     }
 }
Esempio n. 9
0
            public RegisterState WithRegister(int index, int value)
            {
                var result = new RegisterState(this);

                result.registers[index] = value;
                return(result);
            }
Esempio n. 10
0
        public void Write(string hlslFilename)
        {
            hlslFile   = new FileStream(hlslFilename, FileMode.Create, FileAccess.Write);
            hlslWriter = new StreamWriter(hlslFile);

            _registers = new RegisterState(_shader);

            WriteConstantDeclarations();

            if (_registers.MethodInputRegisters.Count > 1)
            {
                WriteInputStructureDeclaration();
            }

            if (_registers.MethodOutputRegisters.Count > 1)
            {
                WriteOutputStructureDeclaration();
            }

            string methodReturnType = GetMethodReturnType();
            string methodParameters = GetMethodParameters();
            string methodSemantic   = GetMethodSemantic();

            WriteLine("{0} main({1}){2}", methodReturnType, methodParameters, methodSemantic);
            WriteLine("{");
            indent = "\t";

            if (_registers.MethodOutputRegisters.Count > 1)
            {
                var outputStructType = _shader.Type == ShaderType.Pixel ? "PS_OUT" : "VS_OUT";
                WriteLine($"{outputStructType} o;");
                WriteLine();
            }

            HlslAst ast = null;

            if (_doAstAnalysis)
            {
                var parser = new BytecodeParser();
                ast = parser.Parse(_shader);
                ast.ReduceTree();

                WriteAst(ast);
            }
            else
            {
                WriteLine("{0} o;", methodReturnType);
                WriteLine();

                WriteInstructionList();
            }
            indent = "";
            WriteLine("}");

            hlslWriter.Dispose();
            hlslFile.Dispose();
        }
Esempio n. 11
0
        /// <summary>
        /// 启动TCP服务
        /// </summary>
        /// <param name="domain">域名信息</param>
        /// <returns>HTTP服务启动状态</returns>
        private RegisterState startSsl(Domain domain)
        {
            RegisterState state = RegisterState.TcpError;

            Http.Server httpServer = null;
            Monitor.Enter(hostLock);
            try
            {
                if (hosts.TryGetValue(domain.SslHost, out httpServer))
                {
                    if (httpServer.IsSSL)
                    {
                        if (new AutoCSer.Net.Http.UnionType {
                            Value = httpServer
                        }.SslServer.SetCertificate(domain))
                        {
                            ++httpServer.DomainCount;
                            return(RegisterState.Success);
                        }
                        state = RegisterState.CertificateError;
                    }
                    else
                    {
                        state = RegisterState.SslMatchError;
                    }
                    httpServer = null;
                }
                else
                {
                    state = RegisterState.CreateServerError;
                    Http.SslServer server = new Http.SslServer(this, domain);
                    httpServer = server;
                    if (server.IsCertificate)
                    {
                        if (httpServer.IsStart)
                        {
                            hosts.Add(domain.SslHost, httpServer);
                            return(RegisterState.Success);
                        }
                    }
                    else
                    {
                        state = RegisterState.CertificateError;
                    }
                }
            }
            catch (Exception error)
            {
                server.Log.Add(AutoCSer.Log.LogType.Error, error);
            }
            finally { Monitor.Exit(hostLock); }
            if (httpServer != null)
            {
                httpServer.Dispose();
            }
            return(state);
        }
Esempio n. 12
0
 public bool Create(Guid companyId, string name, string email, string login, string password, string by)
 {
     Name     = name;
     Email    = email;
     Login    = login;
     Password = password;
     State    = RegisterState.Enabled;
     return(base.Create(companyId, by));
 }
Esempio n. 13
0
 public bool Update(string name, string email, string login, string password, RegisterState state, string by)
 {
     Name     = name;
     Email    = email;
     Login    = login;
     Password = password;
     State    = state;
     return(base.Update(by));
 }
Esempio n. 14
0
 /// <summary>
 /// Object to data transfer object
 /// </summary>
 /// <param name="authentication"></param>
 /// <returns></returns>
 public static RegisterStateDTO ObjectToDTO(RegisterState obj)
 {
     return(new RegisterStateDTO
     {
         description = obj.description,
         value = obj.value,
         timestamp = DataConvert.DateTimeToJsonString(obj.timestamp),
         updated = DataConvert.DateTimeToJsonString(obj.updated)
     });
 }// End of ObjectToDTO function
Esempio n. 15
0
        }// End of Constructor function

        /// <summary>
        /// Add register state
        /// </summary>
        /// <param name="register_state"></param>
        /// <param name="user_log"></param>
        /// <returns></returns>
        public RegisterState addRegisterState(RegisterState register_state, UserSystem user_log)
        {
            return(http_service.JSONHttpPettitionObject <RegisterState>(
                       HttpMethod.POST,
                       GetType().Name.ToLower().Replace(
                           TWords.SERVICE,
                           TWords.SLASH),
                       JsonConvert.SerializeObject(
                           RegisterStateAdapter.ObjectToDTO(
                               register_state))));
        }// End of addRegisterState function
Esempio n. 16
0
        public static IList <RegisterState> DTOsToObjects(IList <RegisterStateDTO> dtos)
        {
            IList <RegisterState> list = new List <RegisterState>();

            foreach (RegisterStateDTO dto in dtos)
            {
                RegisterState obj = DTOToObject(dto);
                list.Add(obj);
            }

            return(list);
        }
Esempio n. 17
0
        /// <summary>
        /// 启动TCP服务
        /// </summary>
        /// <param name="domains">域名信息集合</param>
        /// <returns>HTTP服务启动状态</returns>
        private RegisterState start(Domain[] domains)
        {
            int hostCount = 0, startCount = 0, stopCount = 0;

            foreach (Domain domain in domains)
            {
                if (!domain.IsOnlyHost)
                {
                    if (domain.Host.Host != null)
                    {
                        RegisterState state = start(ref domain.Host);
                        if (state != RegisterState.Success)
                        {
                            break;
                        }
                    }
                    if (domain.SslHost.Host != null)
                    {
                        RegisterState state = startSsl(domain);
                        if (state != RegisterState.Success)
                        {
                            if (domain.Host.Host != null)
                            {
                                ++stopCount;
                            }
                            break;
                        }
                    }
                    ++startCount;
                }
                ++hostCount;
                ++stopCount;
            }
            if (startCount != 0 && hostCount == domains.Length)
            {
                return(RegisterState.Success);
            }
            foreach (Domain domain in domains)
            {
                if (stopCount-- == 0)
                {
                    break;
                }
                if (!domain.IsOnlyHost)
                {
                    stop(ref domain.Host);
                    stop(ref domain.SslHost);
                }
            }
            return(RegisterState.TcpError);
        }
Esempio n. 18
0
        /// <summary>
        /// 域名状态检测
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        internal int CheckDomain(ref RegisterState state)
        {
            int index = 0;

            foreach (Domain domain in Register.Domains)
            {
                if ((state = RegisterServer.CheckDomain(ref Register.Domains[index], this)) != RegisterState.Success)
                {
                    return(index);
                }
                ++index;
            }
            return(index);
        }
Esempio n. 19
0
        private async void btnVerify_Clicked(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtCode.Text))
                {
                    await DisplayAlert("Error", "Error Code", "Cancel");

                    return;
                }
                CheckCode checkCode = new CheckCode
                {
                    PhoneNumber = txtPhoneNumber.Text,
                    Code        = Convert.ToInt32(txtCode.Text)
                };
                RegisterState State = CallAPI.PostObjectAndGetObject <CheckCode, RegisterState>(checkCode, "CheckCodeExists", "7");
                if (State == RegisterState.Blocked)
                {
                    await DisplayAlert("Error", "Your account has been banned", "Cancel");

                    return;
                }
                if (State == RegisterState.NoteFound)
                {
                    await DisplayAlert("Error", "Incorrect code", "Cancel");

                    return;
                }
                if (State == RegisterState.unregistered)
                {
                    await Navigation.PushModalAsync(new RegisterStudent(txtPhoneNumber.Text));

                    return;
                }
                if (State == RegisterState.AlreadyRegistered)
                {
                    Student student = CallAPI.GetObjectContent <Student, Student>("GetStudentByNumber", txtPhoneNumber.Text);
                    Settings.StudentId    = student.Id.ToString();
                    Settings.StudentPhone = student.PhoneNumber;
                    Settings.FirstName    = student.FirstName;
                    Settings.LastName     = student.LastName;
                    Settings.Location     = student.Address;
                    App.Current.MainPage  = new AppShell();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Cancel");
            }
        }
Esempio n. 20
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            RegisterState registerState = RegisterMapper.Submit(Phone.Text, Pwd.Text, Pwd2.Text);

            if (registerState == RegisterState.sucess)
            {
                MessageBox.Show(StateString.GetRegisterStateString(registerState));
                TransfEvent(Phone.Text);
                this.Close();
            }
            else
            {
                MessageBox.Show(StateString.GetRegisterStateString(registerState));
            }
        }
Esempio n. 21
0
 public RegisterState RegisterEnd()
 {
     if (currentState == RegisterState.VALIDATED)
     {
         if (dbManger.AddUser(registerUser))
         {
             currentState = RegisterState.SUCCESS;
         }
         else
         {
             currentState = RegisterState.DBFAILED;
         }
     }
     registerUser = null;
     return(currentState);
 }
Esempio n. 22
0
    /// <summary>
    /// 开始
    /// </summary>
    public static void Run()
    {
        //注册游戏状态
        IState launch = new LaunchState();
        IState reg    = new RegisterState();
        IState update = new UpdateState();
        IState luavm  = new LuaVmState();

        //
        StateService.GetInstance().RegisteState("Launch", launch);
        StateService.GetInstance().RegisteState("Update", update);
        StateService.GetInstance().RegisteState("Register", reg);
        StateService.GetInstance().RegisteState("LuaVM", luavm);
        //启动
        StateService.GetInstance().ChangeState("Launch");
    }
Esempio n. 23
0
            public OpcodeCandidates GetCandidates(Operation operation, RegisterState targetState, OpcodeCandidates knownCandidates)
            {
                for (Opcode opcode = default; opcode < Opcode.OpcodeCount; opcode++)
                {
                    if (!knownCandidates.IncludesOpcode(opcode))
                    {
                        continue;
                    }

                    if (!MatchesTarget(operation, opcode, targetState))
                    {
                        knownCandidates.ExcludeOpcode(opcode);
                    }
                }

                return(knownCandidates);
            }
Esempio n. 24
0
    void ConfigureSocket()
    {
        socket.On("register", (e) =>
        {
            Debug.Log("[Register] Registrando PlayerLocal");

            RegisterState state = JsonConvert.DeserializeObject <RegisterState>(e.data.ToString());

            foreach (Client c in state.clients)
            {
                InstantiateClient(c);
            }
            id = state.myID;
        });

        socket.On("ddd", (e) =>
        {
            Debug.Log("[DisconectClient] Disconectando cliente: " + e.data);
        });

        socket.On("newClient", (e) =>
        {
            Client newClient = JsonConvert.DeserializeObject <Client>(e.data.ToString());

            if (clients.ContainsKey(newClient.id) == false)
            {
                Debug.Log("[NewClient] Registrando Cliente: " + newClient.id);
                InstantiateClient(newClient);
            }
        });

        socket.On("updateRemotePosition", (e) =>
        {
            SyncTransform sync = JsonConvert.DeserializeObject <SyncTransform>(e.data.ToString());
            if (sync.id != id)
            {
                GameObject syncClient            = clients[sync.id];
                syncClient.transform.position    = sync.position;
                syncClient.transform.eulerAngles = sync.rotation;
                //Debug.Log("[UpdateRemotePosition] Update Position from " + sync.id);
            }
        });
    }
Esempio n. 25
0
        public void RegisterStart(UserGroup group)
        {
            currentState = RegisterState.VALIDATED;
            switch (group)
            {
            case UserGroup.ADMIN:
                registerUser       = new Admin();
                registerUser.Group = UserGroup.ADMIN;
                (registerUser as Admin).GrantUserName = user.Name;
                break;

            case UserGroup.REGULAR:
                registerUser       = new Regular();
                registerUser.Group = UserGroup.REGULAR;
                break;

            default:
                break;
            }
        }
Esempio n. 26
0
        public static int Task2(IEnumerable <string> input)
        {
            var examples     = ParseExamples(input);
            var opcodes      = DeduceOpcodes(examples);
            var instructions = ParseInstructions(input).ToList();

            var registerState = new RegisterState(new List <int>
            {
                0,
                0,
                0,
                0,
            });

            foreach (var instruction in instructions)
            {
                registerState = instruction.Execute(registerState, opcodes);
            }

            return(registerState[0]);
        }
Esempio n. 27
0
        /// <summary>
        /// 启动TCP服务
        /// </summary>
        /// <param name="host">TCP服务端口信息</param>
        /// <returns>HTTP服务启动状态</returns>
        private RegisterState start(ref HostPort host)
        {
            RegisterState state = RegisterState.TcpError;

            Http.Server httpServer = null;
            Monitor.Enter(hostLock);
            try
            {
                if (hosts.TryGetValue(host, out httpServer))
                {
                    if (!httpServer.IsSSL)
                    {
                        ++httpServer.DomainCount;
                        return(RegisterState.Success);
                    }
                    httpServer = null;
                    state      = RegisterState.SslMatchError;
                }
                else
                {
                    state      = RegisterState.CreateServerError;
                    httpServer = new Http.Server(this, ref host, false);
                    if (httpServer.IsStart)
                    {
                        hosts.Add(host, httpServer);
                        return(RegisterState.Success);
                    }
                }
            }
            catch (Exception error)
            {
                server.Log.Add(AutoCSer.Log.LogType.Error, error);
            }
            finally { Monitor.Exit(hostLock); }
            if (httpServer != null)
            {
                httpServer.Dispose();
            }
            return(state);
        }
Esempio n. 28
0
        private void btnRegAcc_Click(object sender, EventArgs e)
        {
            string userCode = this.txtUserCode.Text.Trim();
            string userPwd  = this.txtUserPwd.Text.Trim();
            string userName = this.txtUserName.Text.Trim();

            #region 检查输入
            if (string.IsNullOrEmpty(userCode))
            {
                MessageBox.Show("账号不能为空");
                return;
            }
            if (string.IsNullOrEmpty(userPwd))
            {
                MessageBox.Show("密码不能为空");
                return;
            }
            if (string.IsNullOrEmpty(userName))
            {
                MessageBox.Show("昵称不能为空");
                return;
            }
            #endregion

            #region 判断注册
            RegisterState registerState = uiBll.Register(userCode, userPwd, userName);
            if (registerState == RegisterState.Success)
            {
                MessageBox.Show("注册成功\r\n你的账号为: " + this.txtUserCode.Text.Trim());
            }
            else if (registerState == RegisterState.Registed)
            {
                MessageBox.Show("已经存在此账户,请更换账户名,或则用此账户登录");
            }
            else
            {
                MessageBox.Show("注册失败,请稍后再试");
            }
            #endregion
        }
Esempio n. 29
0
        private static IEnumerable <Example> ParseExamples(IEnumerable <string> input)
        {
            var enumerator = input.GetEnumerator();

            enumerator.MoveNext();

            while (enumerator.Current != null && enumerator.Current.Length > 6 && enumerator.Current.Substring(0, 6) == "Before")
            {
                var registerValuesBefore = enumerator
                                           .Current
                                           .Substring(9, 10)
                                           .Split(", ")
                                           .Select(int.Parse);

                var before = new RegisterState(registerValuesBefore);
                enumerator.MoveNext();

                var instructionValues = enumerator
                                        .Current
                                        .Split(" ")
                                        .Select(int.Parse)
                                        .ToArray();

                var instruction = new Instruction(instructionValues[0], instructionValues[1], instructionValues[2], instructionValues[3]);
                enumerator.MoveNext();

                var registerValuesAfter = enumerator
                                          .Current
                                          .Substring(9, 10)
                                          .Split(", ")
                                          .Select(int.Parse);

                var after = new RegisterState(registerValuesAfter);
                enumerator.MoveNext();
                enumerator.MoveNext();

                yield return(new Example(before, instruction, after));
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 本地模式
        /// </summary>
        /// <typeparam name="domainServerType"></typeparam>
        /// <param name="workPath"></param>
        /// <param name="log"></param>
        /// <param name="hosts"></param>
        /// <returns></returns>
        public static Server Create <domainServerType>(string workPath, ILog log, params HostPort[] hosts) where domainServerType : HttpDomainServer.Server
        {
            Server        server = new Server();
            RegisterState state  = RegisterState.Unknown;

            try
            {
                if ((state = server.start <domainServerType>(workPath, hosts, log)) == RegisterState.Success)
                {
                    return(server);
                }
                AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Debug, "HTTP服务启动失败 " + state.ToString());
            }
            finally
            {
                if (state != RegisterState.Success)
                {
                    server.Dispose();
                }
            }
            return(null);
        }
Esempio n. 31
0
 internal void RestoreRegisterState(RegisterState[] state)
 {
     registers = state;
 }
Esempio n. 32
0
 internal RegisterState[] SaveRegisterState()
 {
     var r = new RegisterState[8];
     for (int i = 0; i < 8; ++i) r[i] = registers[i];
     return r;
 }