public void parseMSBuildUnloopingTest5()
        {
            var env     = new StubEnv();
            var uvar    = new UserVariable();
            var msbuild = new vsCE.MSBuild.Parser(env, uvar);
            var sbe     = new Script(env, uvar);

            msbuild.parse(sbe.parse("#[var test = $$(test)]#[var test = 1 $(test) 2]", true));

            uvar.unsetAll();
            msbuild.parse(sbe.parse("#[var test = $$(test)]#[var test = 1 $(test.Replace('1', '2')) 2]", true));

            uvar.unsetAll();
            msbuild.parse(sbe.parse("#[var test = $(test)]#[var test = 1 $(test) 2]", true));
        }
Example #2
0
 public void UpdateUserVar(UserVariable userVar, bool fromReplay = false)
 {
     if (userVar.Name == "spd")
     {
         UpdateSpeed(userVar);
     }
     else if (userVar.Name == "ptype")
     {
         UpdateType(userVar);
     }
     else if (userVar.Name == "modelAnimation")
     {
         UpdateAnimState(userVar);
     }
     else if (userVar.Name == "op")
     {
         ApplyAvatarOptions(userVar.GetStringValue());
     }
     else if (userVar.Name == "parseId")
     {
         string postfix = fromReplay ? ">" : "";
         ParseId = userVar.GetStringValue() + postfix;
     }
     else if (userVar.Name == "displayName")
     {
         DisplayName = userVar.GetStringValue();
     }
     else if (userVar.Name == "team")
     {
         teamID = userVar.GetIntValue();
     }
     else if (userVar.Name == "gt" || userVar.Name == "gp")
     {
         UpdateGaze(userVar.Name, (float)userVar.GetDoubleValue());
     }
     else if (userVar.Name == "sit")
     {
         UpdateSit(userVar.GetBoolValue());
     }
     else if (userVar.Name == "scl")
     {
         UpdateScale((float)userVar.GetDoubleValue());
     }
     else
     {
         Debug.LogError("Unsupported userVar: " + userVar.Name);
     }
 }
        public void vtSignTest5()
        {
            var uvar   = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(i = 1)"));
            Assert.AreEqual(String.Empty, target.parse("$(i += $(i))"));
            Assert.AreEqual("2", uvar.get("i"));

            //TODO: currently std. exception:
            try {
                Assert.AreEqual(String.Empty, target.parse("$(i += 'test')"));
                Assert.Fail("1");
            }
            catch (Exception ex) { Assert.IsTrue(true /*ex.GetType() == typeof(NotFoundException)*/, ex.GetType().ToString()); }
        }
Example #4
0
        public void parseMSBuildUnloopingTest6()
        {
            var env     = new StubEnv();
            var uvar    = new UserVariable();
            var msbuild = new vsSBE.MSBuild.Parser(env, uvar);
            var sbe     = new Script(env, uvar);

            string data = "#[var test = #[($(test) == \"" + vsSBE.MSBuild.Parser.PROP_VALUE_DEFAULT + "\"){0}else{$(test)}]]#[var test]";

            Assert.AreEqual("0", msbuild.parse(sbe.parse(data, true)));
            Assert.AreEqual("0", msbuild.parse(sbe.parse(data, true)));

            uvar.set("test", null, "7");
            uvar.evaluate("test", null, new EvaluatorBlank(), true);
            Assert.AreEqual("7", msbuild.parse(sbe.parse(data, true)));
        }
 public void SetDefaultUserVariable(string key, object value)
 {
     if (userVariables.ContainsKey(key))
     {
         userVariables[key] = new UserVariable {
             value = value, defaultValue = value
         };
     }
     else
     {
         userVariables.Add(key, new UserVariable {
             value = value, defaultValue = value
         });
         OnUserVariablesModified.Invoke();
     }
 }
        public void stDataTest1()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            uvar.set("p1", null, "v1");
            uvar.evaluate("p1", null, new EvaluatorBlank(), true);

            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test1\", false): $(p1)#[Box operators.sleep(10)] ]"));
            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test2\", true): $(p1) #[Box operators.sleep(10)] ]"));

            Assert.AreEqual("$(p1)#[Box operators.sleep(10)]", target.parse("#[Box data.get(\"test1\", false)]").Trim());
            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test1\", true)]", target));

            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test2\", false)]", target));
            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test2\", true)]", target));
        }
        public void setTest3()
        {
            UserVariable target = new UserVariable();

            target.set("name", null, "unevaluated");
            Assert.AreEqual(1, target.Variables.Count());

            foreach (TUserVariable v in target.Variables)
            {
                Assert.AreEqual(v.evaluated, null);
                Assert.AreEqual(v.ident, "name");
                Assert.AreEqual(v.persistence, false);
                Assert.AreEqual(v.prev, new TUserVariable());
                Assert.AreEqual(v.status, TUserVariable.StatusType.Unevaluated);
                Assert.AreEqual(v.unevaluated, "unevaluated");
            }
        }
        public void disclosureTest4()
        {
            IUserVariable uv = new UserVariable();

            uv.set("test", null, "data(str)");
            uv.set("test2", null, "true");
            uv.set("test3", null, "4");

            ConditionComponent target = new ConditionComponent((new Mock <IEnvironment>()).Object, uv);

            target.PostProcessingMSBuild = true;

            Assert.AreEqual("yes", target.parse("[(  $(test) == \"data(str)\" ){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  $(test) == \"data(str)\" && 1 < 2){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  #[var test] == \"data(str)\" && #[var test2] || #[var test3] == 4){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  #[var test] == \"data(str)\" && !#[var test2] || #[var test3] == 4){yes}else{no}]"));
            Assert.AreEqual("no", target.parse("[(  #[var test] == \"data(str)\" && !#[var test2] && #[var test3] == 4){yes}else{no}]"));
        }
Example #9
0
        private void Populate(ListViewItem lvi, UserVariable rule, bool inherited = false)
        {
            if (!inherited)
            {
                lvi.Tag = rule;
            }
            else
            {
                lvi.Tag = new InheritedVariableContainer()
                {
                    Value = rule
                };

                lvi.ForeColor = Color.Gray;
            }

            this.PopulateListView(lvi, rule.Name, rule.Value);
        }
Example #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbName.Text))
            {
                MessageBox.Show(this, "The name must not be empty", this.Text);
                return;
            }

            if (this.includeRule == null)
            {
                this.includeRule = new UserVariable();
            }

            this.includeRule.Name  = this.tbName.Text;
            this.includeRule.Value = this.tbValue.Text;

            this.Close(DialogResult.OK);
        }
Example #11
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbName.Text))
            {
                MessageBox.Show(this, "The name must not be empty", this.Text);
                return;
            }

            if (this.includeRule == null)
            {
                this.includeRule = new UserVariable();
            }

            this.includeRule.Name = this.tbName.Text;
            this.includeRule.Value = this.tbValue.Text;

            this.Close(DialogResult.OK);
        }
Example #12
0
        public override TaskStatu Job(TfsVariable tfsVariables, UserVariable <FileControlSetting> usrVariables)
        {
            var setting = usrVariables.Config;

            if (setting == null)
            {
                return(new TaskStatu("No setting found."));
            }

            var allFiles = TFSHelper.ChangedFiles();

            if (!allFiles.Any())
            {
                return(new TaskStatu("No changed file found."));
            }

            string adName    = TFSHelper.UserDomainName;
            var    usrGroups = TFSHelper.GroupUserJoined();

            foreach (var sourceData in allFiles)
            {
                var sourceFile = sourceData.FilePath;
                var rule       = setting.Files.FirstOrDefault(x => x.FileNames.Any(y => sourceFile.EndsWith(y)));

                if (rule == null)
                {
                    continue;
                }

                if (rule.AllowedUser.Any(x => x == adName))
                {
                    continue;
                }

                if (rule.AllowedGroup.Any(x => (usrGroups.Any(y => y.EndsWith(x)))))
                {
                    continue;
                }

                return(new TaskStatu("FC01", string.Format("[{0}] file is restirected for [{1}] user.", sourceFile, adName)));
            }

            return(new TaskStatu(string.Format("All changes controlled successfully. FileCount/TotalRule = {0}/{1}.", allFiles.Count, setting.Files.Count)));
        }
Example #13
0
        /// <summary>
        /// This is where shell script trigger. A cocoon ;)
        /// </summary>
        /// <param name="dllName"></param>
        /// <param name="className"></param>
        /// <param name="methodName"></param>
        /// <param name="tfsVarRaw"></param>
        /// <param name="usrVarRaw"></param>
        /// <returns></returns>
        public ShellStatu Initializer(string dllName, string className, string methodName, Dictionary <string, string> tfsVarRaw, Dictionary <string, string> usrVarRaw)
        {
            Stopwatch watchGeneral = Stopwatch.StartNew();
            string    taskLongName = string.Empty;

            try
            {
                taskLongName = Path.GetFileNameWithoutExtension(dllName) + " -> " + className;
                var tfsVar = new TfsVariable(tfsVarRaw);
                var usrVar = new UserVariable <Tsetting>(this.GetType().Name, usrVarRaw);
                Logger.Set(usrVar.WorkingPath);

                var bsSetting = usrVar.Config;
                if (bsSetting == null)
                {
                    return(new ShellStatu(false, string.Format("{0}.{1} tasks setting could not deserialized.", className, methodName)));
                }

                TFSHelper.Initialize(tfsVar);

                Stopwatch watchTask = Stopwatch.StartNew();
                var       tmpResult = Job(tfsVar, usrVar);
                watchTask.Stop();

                if (intrDetailContainer.Any() && !tmpResult.Detail.Any())
                {
                    tmpResult.Detail = intrDetailContainer;
                }

                var rtnData = tmpResult == null ? new ShellStatu() : tmpResult.ToShellStatu(taskLongName);
                watchGeneral.Stop();
                rtnData.Msgs.Add(string.Format("*** FINISH > [{0}] task runned/total (ms) : {1}/{2}",
                                               className, watchTask.Elapsed.TotalMilliseconds, watchGeneral.Elapsed.TotalMilliseconds));

                rtnData.Msgs.Add("---------------------------------------");

                return(rtnData);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return(new ShellStatu(false, string.Format("!!! BaseTask.Initializer failed. TaskName = [{0}]. ExDetail = [{1}].", taskLongName, ex)));
            }
        }
Example #14
0
 public static void UpdateTransformVars(UserVariable userVar, ref float rotAngle, ref Vector3 pos)
 {
     if (userVar.Name == "rot")
     {
         rotAngle = (float)userVar.GetDoubleValue();
     }
     else if (userVar.Name == "x")
     {
         pos.x = (float)userVar.GetDoubleValue();
     }
     else if (userVar.Name == "y")
     {
         pos.y = (float)userVar.GetDoubleValue();
     }
     else if (userVar.Name == "z")
     {
         pos.z = (float)userVar.GetDoubleValue();
     }
 }
Example #15
0
        /// <summary>
        /// Update UserVariable Update UserVariable
        /// </summary>
        /// <param name="id">id of UserVariable</param>
        /// <param name="body">UserVariable that should be updated</param>
        /// <returns>InlineResponse2002</returns>
        public InlineResponse2002 UserVariablesIdPut(int?id, UserVariable body)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling UserVariablesIdPut");
            }


            var path = "/userVariables/{id}";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id));


            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;



            postBody = ApiClient.Serialize(body); // http body (model) parameter


            // authentication setting, if any
            String[] authSettings = new String[] {  };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UserVariablesIdPut: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UserVariablesIdPut: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((InlineResponse2002)ApiClient.Deserialize(response.Content, typeof(InlineResponse2002), response.Headers));
        }
Example #16
0
        public override TaskStatu Job(TfsVariable tfsVariables, UserVariable <StyleCopSetting> usrVariables)
        {
            GlobalSetting    = usrVariables?.Config;
            SourceBaseFolder = tfsVariables.BuildSourceDirectory;
            if (GlobalSetting == null)
            {
                return(new TaskStatu("SCT02", "No setting loaded."));
            }

            bool isExcFilesExist    = GlobalSetting.ExcludedFiles.Any();
            bool isExcProjectsExist = GlobalSetting.ExcludedProjects.Any();

            SourceBaseFolder = tfsVariables.BuildSourceDirectory;
            WriteDetail("Source Folder : " + SourceBaseFolder);
            WriteDetail("Exclusion files : " +
                        (isExcFilesExist ? string.Join(", ", GlobalSetting.ExcludedFiles) : "None"));
            WriteDetail("Exclusion projects : " +
                        (isExcFilesExist ? string.Join(", ", GlobalSetting.ExcludedProjects) : "None"));

            var           srcFilesAll = Directory.GetFiles(SourceBaseFolder, "*.cs", SearchOption.AllDirectories).ToList();
            List <string> srcFilestoCheck;

            if (isExcFilesExist || isExcProjectsExist)
            {
                srcFilestoCheck = FilterFiles(srcFilesAll, GlobalSetting.ExcludedFiles, GlobalSetting.ExcludedProjects);
            }
            else
            {
                srcFilestoCheck = srcFilesAll;
            }

            WriteDetail(string.Format("File Count (Check/All) : {0}/{1}", srcFilestoCheck.Count, srcFilesAll.Count));

            bool isResultOk = RunStyleCopRules(srcFilestoCheck, tfsVariables, usrVariables);

            if (!IsRunned)
            {
                return(new TaskStatu("SCT03", "StyleCop engine did not runned."));
            }

            return(isResultOk ? new TaskStatu("StyleCopTask finished successfully") : new TaskStatu("SCT04", "There is too much error."));
        }
        public void catchTest3()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            Assert.AreEqual(0, uvar.Variables.Count());
            target.parse(@"
                            #[( false ){

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test1 = '123')
                                }]

                            }
                            else{

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test2 = '456')
                                    $(exErr = $(err))
                                    $(exMsg = $(msg))
                                }]

                            }] ");

            Assert.AreEqual(3, uvar.Variables.Count());
            Assert.AreEqual(null, uvar.get("test1", null));
            Assert.AreEqual("456", uvar.get("test2", null));
            Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exErr", null)));
            Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exMsg", null)));
            Assert.AreEqual(null, uvar.get("err", null));
            Assert.AreEqual(null, uvar.get("msg", null));
        }
Example #18
0
        private static TaskList GetAllTasks(List <string> dllFiles, UserVariable <RawBasicBuildSetting> setting)
        {
            var tasks      = new TaskList();
            var tmpSetting = setting.Config;

            foreach (var dll in dllFiles)
            {
                var assmbly  = Assembly.LoadFile(dll);
                var fileTyps = assmbly.GetTypes();
                var typs     = (from System.Type type in fileTyps
                                where
                                (type.BaseType != null) && type.BaseType.IsGenericType &&
                                type.BaseType.GetGenericTypeDefinition() == typeof(BaseTask <>)
                                select type).ToList();

                foreach (var item in typs)
                {
                    var tmpTsk = new TaskItem()
                    {
                        DLLName    = dll,
                        ClassName  = item.FullName,
                        MethodName = "Initializer",
                    };
                    bool isExist = false;
                    if (setting.ActionName == "PreBuild")
                    {
                        isExist = tmpSetting.PreBuildTasks.Any(x => tmpTsk.ClassName.EndsWith("." + x));
                    }
                    else if (setting.ActionName == "PostBuild")
                    {
                        isExist = tmpSetting.PostBuildTasks.Any(x => tmpTsk.ClassName.EndsWith("." + x));
                    }

                    if (isExist)
                    {
                        tasks.Add(tmpTsk);
                    }
                }
            }

            return(tasks);
        }
Example #19
0
        private void Populate(UserVariable rule, bool inherited = false)
        {
            var lvi = new ListViewItem();

            this.Populate(lvi, rule, inherited);

            if (!inherited && !this.uniqueVariables.Contains(rule.Name))
            {
                this.uniqueVariables.Add(rule.Name);
            }
            else if (inherited && this.uniqueVariables.Contains(rule.Name))
            {
                lvi = null;
            }

            if (lvi != null)
            {
                this.listView2.Items.Add(lvi);
            }
        }
        internal override XElement CreateXml()
        {
            var xRoot = new XElement(XmlConstants.Brick);

            xRoot.SetAttributeValue(XmlConstants.Type, XmlConstants.XmlChangeVariableBrickType);

            var xElement = VariableFormula.CreateXml();

            xElement.SetAttributeValue(XmlConstants.Category, XmlConstants.VariableChange);

            var xFormulalist = new XElement(XmlConstants.FormulaList);

            xFormulalist.Add(xElement);

            xRoot.Add(xFormulalist);

            xRoot.Add(UserVariable.CreateXml());

            return(xRoot);
        }
        public void stDataTest5()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            uvar.set("p1", null, "ab!");
            uvar.evaluate("p1", null, new EvaluatorBlank(), true);

            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test1\", false): $(p1) ]"));
            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test2\", true): $(p1) ]"));

            Assert.AreEqual("$(p1)$(p1)$(p1)$(p1)", noSpaces("#[Box data.clone(\"test1\", 4)]", target));
            Assert.AreEqual("$(p1)$(p1)$(p1)$(p1)", noSpaces("#[Box data.clone(\"test1\", 4, false)]", target));
            Assert.AreEqual("ab!ab!ab!ab!", noSpaces("#[Box data.clone(\"test1\", 4, true)]", target));

            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2)]", target));
            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2, false)]", target));
            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2, true)]", target));

            Assert.AreEqual(String.Empty, noSpaces("#[Box data.clone(\"test2\", 0)]", target));
        }
Example #22
0
    public Vector3 GetPosition()
    {
        float   newRotAngle       = 0;
        Vector3 newPos            = Vector3.zero;
        int     transformMsgCount = 0;

        for (int i = 0; changedVars != null && i < changedVars.Count; ++i)
        {
            UserVariable userVar = changedVars[i];
            if (userVar.Name == "x" || userVar.Name == "y" || userVar.Name == "z" || userVar.Name == "rot")
            {
                ReplayManager.UpdateTransformVars(userVar, ref newRotAngle, ref newPos);
                transformMsgCount++;
                if (transformMsgCount == 4)
                {
                    return(newPos);
                }
            }
        }
        Debug.LogError("Didn\'t find position");
        return(newPos);
    }
        public void catchTest4()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            Assert.AreEqual(0, uvar.Variables.Count());
            target.parse(@"
                            #[( false ){

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch
                                {
                                    $(test1 = '123')
                                }]

                            }
                            else{

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch
                                {
                                    $(test2 = '456')
                                }]

                            }] ");

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual(null, uvar.get("test1", null));
            Assert.AreEqual("456", uvar.get("test2", null));
            Assert.AreEqual(null, uvar.get("err", null));
            Assert.AreEqual(null, uvar.get("msg", null));
        }
Example #24
0
        private string CheckSetting(UserVariable <AnalyzerEnforcerSetting> usrVariables)
        {
            var setting = usrVariables?.Config;

            if (setting == null)
            {
                return("Settings is missing.");
            }

            if ((setting.References == null) || (!setting.References.Any()))
            {
                return("No outside library found in setting.");
            }

            foreach (var item in setting.References)
            {
                if (!File.Exists(item.DLLPath))
                {
                    return(string.Format("Could not find the \"{0}\" library from [{1}].", item.DLLName, item.DLLPath));
                }
            }

            return(null);
        }
Example #25
0
        public override TaskStatu Job(TfsVariable tfsVariables, UserVariable <AnalyzerEnforcerSetting> usrVariables)
        {
            string settingOkMsg = CheckSetting(usrVariables);
            var    setting      = usrVariables.Config;

            if (!string.IsNullOrEmpty(settingOkMsg))
            {
                return(new TaskStatu("RET01", settingOkMsg));
            }
            string buildPath = tfsVariables.BuildSourceDirectory;

            string[] slnFiles = SolutionHelper.FindSolutionFiles(buildPath);
            slnFiles = !string.IsNullOrEmpty(tfsVariables.SolutiontoBuild) ?
                       slnFiles.Where(x => x.Contains(tfsVariables.SolutiontoBuild)).ToArray()
                : slnFiles;

            if ((slnFiles == null) || (!slnFiles.Any()))
            {
                return(new TaskStatu("RET02", "No solution file found."));
            }

            var workspace = MSBuildWorkspace.Create();

            foreach (var slnItem in slnFiles)
            {
                var slnName = Path.GetFileNameWithoutExtension(slnItem);
                if (IsSolutionExcluded(setting, slnName))
                {
                    continue;
                }

                var solution = workspace.OpenSolutionAsync(slnItem).Result;


                foreach (var libItem in setting.References)
                {
                    var analyzer = new AnalyzerFileReference(libItem.DLLPath, FromFileLoader.Instance);

                    foreach (var project in solution.Projects)
                    {
                        if (IsProjectExcluded(setting, project.Name))
                        {
                            continue;
                        }

                        bool analyzerExists = false;
                        foreach (var analyzerReference in project.AnalyzerReferences)
                        {
                            if (analyzerReference.FullPath.EndsWith(libItem.DLLName))
                            {
                                analyzerExists = true;
                                break;
                            }
                        }

                        if (!analyzerExists)
                        {
                            WriteDetail(string.Format("{0} project is missing {1} library. Adding...", project.Name, libItem.DLLName));
                            solution = solution.AddAnalyzerReference(project.Id, analyzer);
                        }
                    }
                }

                workspace.TryApplyChanges(solution);
            }

            return(new TaskStatu("Enforce finished successfully."));
        }
Example #26
0
        private void broadcastUserVariables(User user, ArrayList changedVars = null)
        {
            bool flag = getSessionId(user) == mt.ClubPenguinClient.PlayerSessionId;

            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.PROTOTYPE.GetKey())) && user.ContainsVariable(SocketUserVars.PROTOTYPE.GetKey()))
            {
                PrototypeState prototypeState = default(PrototypeState);
                prototypeState.id   = getSessionId(user);
                prototypeState.data = JsonMapper.ToObject(user.GetVariable(SocketUserVars.PROTOTYPE.GetKey()).GetStringValue());
                mt.triggerEvent(GameServerEvent.PROTOTYPE_STATE, prototypeState);
            }
            if (changedVars == null || changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT.GetKey()))
            {
                UserVariable variable  = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                UserVariable variable2 = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey());
                if (variable == null)
                {
                    if (changedVars != null && changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()) && variable2 == null)
                    {
                        mt.triggerEvent(GameServerEvent.SERVER_ITEM_REMOVED, new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER));
                    }
                    else
                    {
                        mt.triggerEvent(GameServerEvent.HELD_OBJECT_DEQUIPPED, getSessionId(user));
                    }
                }
                else
                {
                    EquippedObject equippedObject = EquippedObject.FromSFSData(variable.GetSFSObjectValue());
                    if (variable2 != null)
                    {
                        PlayerHeldItem playerHeldItem = new PlayerHeldItem();
                        playerHeldItem.Id         = new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER);
                        playerHeldItem.CreatorId  = playerHeldItem.Id.Id;
                        playerHeldItem.Type       = equippedObject.EquippedObjectId;
                        playerHeldItem.Properties = variable2.GetStringValue();
                        mt.triggerEvent(GameServerEvent.SERVER_ITEM_ADDED, playerHeldItem);
                    }
                    else if (!flag || (flag && equippedObject.isPartyGame()))
                    {
                        HeldObjectEvent heldObjectEvent = default(HeldObjectEvent);
                        heldObjectEvent.SessionId = getSessionId(user);
                        heldObjectEvent.Type      = equippedObject.EquippedObjectId;
                        if (equippedObject.IsConsumable())
                        {
                            mt.triggerEvent(GameServerEvent.CONSUMABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.IsDispensable())
                        {
                            mt.triggerEvent(GameServerEvent.DISPENSABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.IsDurable())
                        {
                            mt.triggerEvent(GameServerEvent.DURABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.isPartyGame())
                        {
                            mt.triggerEvent(GameServerEvent.PARTYGAME_EQUIPPED, heldObjectEvent);
                        }
                    }
                }
            }
            else if (changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()))
            {
                UserVariable variable3 = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                if (variable3 != null && variable3.Type == VariableType.OBJECT)
                {
                    PlayerHeldItem playerHeldItem = new PlayerHeldItem();
                    playerHeldItem.Id         = new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER);
                    playerHeldItem.CreatorId  = playerHeldItem.Id.Id;
                    playerHeldItem.Type       = EquippedObject.FromSFSData(variable3.GetSFSObjectValue()).EquippedObjectId;
                    playerHeldItem.Properties = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()).GetStringValue();
                    mt.triggerEvent(GameServerEvent.SERVER_ITEM_CHANGED, playerHeldItem);
                }
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.LOCOMOTION_STATE.GetKey())))
            {
                UserVariable variable4 = user.GetVariable(SocketUserVars.LOCOMOTION_STATE.GetKey());
                PlayerLocomotionStateEvent playerLocomotionStateEvent = default(PlayerLocomotionStateEvent);
                playerLocomotionStateEvent.SessionId = getSessionId(user);
                if (variable4 == null || variable4.IsNull())
                {
                    playerLocomotionStateEvent.State = LocomotionState.Default;
                }
                else
                {
                    playerLocomotionStateEvent.State = (LocomotionState)variable4.GetIntValue();
                }
                mt.triggerEvent(GameServerEvent.USER_LOCO_STATE_CHANGED, playerLocomotionStateEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.OUTFIT.GetKey())) && user.ContainsVariable(SocketUserVars.OUTFIT.GetKey()))
            {
                PlayerOutfitDetails playerOutfitDetails = mt.JsonService.Deserialize <PlayerOutfitDetails>(user.GetVariable(SocketUserVars.OUTFIT.GetKey()).GetStringValue());
                playerOutfitDetails.sessionId = getSessionId(user);
                mt.triggerEvent(GameServerEvent.USER_OUTFIT_CHANGED, playerOutfitDetails);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.PROFILE.GetKey())) && user.ContainsVariable(SocketUserVars.PROFILE.GetKey()))
            {
                ProfileEvent profileEvent = default(ProfileEvent);
                profileEvent.SessionId      = getSessionId(user);
                profileEvent.Profile        = new Profile();
                profileEvent.Profile.colour = user.GetVariable(SocketUserVars.PROFILE.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.USER_PROFILE_CHANGED, profileEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.AIR_BUBBLE.GetKey())))
            {
                UserVariable         variable5            = user.GetVariable(SocketUserVars.AIR_BUBBLE.GetKey());
                PlayerAirBubbleEvent playerAirBubbleEvent = default(PlayerAirBubbleEvent);
                playerAirBubbleEvent.SessionId = getSessionId(user);
                if (variable5 == null || variable5.IsNull())
                {
                    playerAirBubbleEvent.AirBubble = new AirBubble();
                }
                else
                {
                    playerAirBubbleEvent.AirBubble = AirBubble.FromSFSData(variable5.GetSFSObjectValue());
                }
                mt.triggerEvent(GameServerEvent.AIR_BUBBLE_UPDATE, playerAirBubbleEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.ON_QUEST.GetKey())))
            {
                UserVariable variable4    = user.GetVariable(SocketUserVars.ON_QUEST.GetKey());
                OnQuestState onQuestState = default(OnQuestState);
                onQuestState.SessionId = getSessionId(user);
                if (!(variable4?.IsNull() ?? true))
                {
                    onQuestState.MascotName = variable4.GetStringValue();
                }
                mt.triggerEvent(GameServerEvent.ON_QUEST, onQuestState);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.SELECTED_TUBE.GetKey())) && user.ContainsVariable(SocketUserVars.SELECTED_TUBE.GetKey()))
            {
                SelectedTubeEvent selectedTubeEvent = default(SelectedTubeEvent);
                selectedTubeEvent.SessionId = getSessionId(user);
                selectedTubeEvent.TubeId    = user.GetVariable(SocketUserVars.SELECTED_TUBE.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.SELECTED_TUBE_CHANGED, selectedTubeEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey())) && user.ContainsVariable(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey()))
            {
                TemporaryHeadStatusEvent temporaryHeadStatusEvent = default(TemporaryHeadStatusEvent);
                temporaryHeadStatusEvent.SessionId = getSessionId(user);
                temporaryHeadStatusEvent.Type      = user.GetVariable(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.TEMPORARY_HEAD_STATUS_CHANGED, temporaryHeadStatusEvent);
            }
            if (flag || (changedVars != null && !changedVars.Contains(SocketUserVars.AWAY_FROM_KEYBOARD.GetKey())))
            {
                return;
            }
            UserVariable variable6 = user.GetVariable(SocketUserVars.AWAY_FROM_KEYBOARD.GetKey());

            if (variable6 == null || variable6.IsNull())
            {
                EquippedObject equippedObject2 = null;
                UserVariable   variable7       = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                if (variable7 != null)
                {
                    equippedObject2 = EquippedObject.FromSFSData(variable7.GetSFSObjectValue());
                }
                mt.triggerEvent(GameServerEvent.AWAY_FROM_KEYBOARD_STATE_CHANGED, new AFKEvent(getSessionId(user), 0, equippedObject2));
            }
            else
            {
                mt.triggerEvent(GameServerEvent.AWAY_FROM_KEYBOARD_STATE_CHANGED, new AFKEvent(getSessionId(user), variable6.GetIntValue(), null));
            }
        }
Example #27
0
        private void Populate(UserVariable rule, bool inherited = false)
        {
            var lvi = new ListViewItem();

            this.Populate(lvi, rule, inherited);

            if (!inherited && !this.uniqueVariables.Contains(rule.Name))
            {
                this.uniqueVariables.Add(rule.Name);
            }
            else if (inherited && this.uniqueVariables.Contains(rule.Name))
            {
                lvi = null;
            }

            if (lvi != null)
            {
                this.listView2.Items.Add(lvi);
            }
        }
        /// <summary>
        /// Store UserVariable Store UserVariable
        /// </summary>
        /// <param name="body">UserVariable that should be stored</param> 
        /// <returns>InlineResponse20022</returns>            
        public InlineResponse20022 UserVariablesPost(UserVariable body)
        {
            var path = "/userVariables";
            path = path.Replace("{format}", "json");

            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            postBody = ApiClient.Serialize(body); // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] {  };

            // make the HTTP request
            IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling UserVariablesPost: " + response.Content, response.Content);
            else if (((int)response.StatusCode) == 0)
                throw new ApiException ((int)response.StatusCode, "Error calling UserVariablesPost: " + response.ErrorMessage, response.ErrorMessage);

            return (InlineResponse20022) ApiClient.Deserialize(response.Content, typeof(InlineResponse20022), response.Headers);
        }
Example #29
0
    Player GetPlayer(ref MsgData msg)
    {
        Player replayPlayer = null;

        if (!replayPlayers.TryGetValue(msg.id, out replayPlayer))
        {
            User         user = new ReplayUser(msg);
            UserVariable playerTypeOverride = null;
            if (msg.changedVars != null)
            {
                for (int i = 0; i < msg.changedVars.Count && playerTypeOverride == null; ++i)
                {
                    if (msg.changedVars[i].Name == "ptype")
                    {
                        playerTypeOverride = msg.changedVars[i];
                    }
                }
            }
            string      jsonRequest = "{\"displayname\":\"" + msg.name + "\"}";
            UserProfile userProfile = new UserProfile();
            userProfile.InitFromColumnValue(jsonRequest);

            if (!userProfile.Initialized)
            {
                Debug.LogError("Didn't get the user " + msg.name + " they may have changed their display name");
            }
            else
            {
                int        modelIdx = PlayerManager.GetModelIdx(userProfile.Model);
                GameObject go       = GameManager.Inst.playerManager.CreateRemotePlayerGO(modelIdx);
                replayPlayer = new Player(user, go, userProfile);
                if (playerTypeOverride != null)
                {
                    replayPlayer.UpdateType(playerTypeOverride);
                }
                replayPlayers[msg.id] = replayPlayer;
            }
            if (replayClicks)
            {
                SetPlayerMouseToReplayMode(replayPlayer);
            }
        }
        if (replayPlayer == null)
        {
            // save parse requests and use our best guess for now.
            Debug.LogError("Creating user: "******" as a stealth user");
            int        modelIdx = 0;
            GameObject go       = GameManager.Inst.playerManager.CreateRemotePlayerGO(modelIdx);
            User       user     = new ReplayUser(msg);
            replayPlayer          = new Player(user, go, modelIdx, PlayerType.STEALTH, "", msg.name, 0);
            replayPlayers[msg.id] = replayPlayer;

            if (replayClicks)
            {
                SetPlayerMouseToReplayMode(replayPlayer);
            }
        }
        if (!replayPlayer.Visible)
        {
            replayPlayer.Visible = true;
        }
        return(replayPlayer);
    }
Example #30
0
        private void Populate(ListViewItem lvi, UserVariable rule, bool inherited = false)
        {
            if (!inherited)
            {
                lvi.Tag = rule;
            }
            else
            {
                lvi.Tag = new InheritedVariableContainer()
                {
                    Value = rule
                };

                lvi.ForeColor = Color.Gray;
            }

            this.PopulateListView(lvi, rule.Name, rule.Value);
        }
Example #31
0
        private void Add(UserVariable rule)
        {
            this.collection.Add(rule);

            this.Items = this.Items;
        }
        public void VariablesTest()
        {
            UserVariable target = new UserVariable();

            Assert.AreEqual(target.Variables.Count(), 0);
        }
        public void evaluateTest2()
        {
            UserVariable target = new UserVariable();

            target.evaluate("name", new Evaluator1(), true);
        }
        public void DefinitionsTest()
        {
            UserVariable target = new UserVariable();

            Assert.AreEqual(target.Definitions.Count(), 0);
        }
Example #35
0
 public virtual QsiQualifiedIdentifier VisitUserVariable(UserVariable variable)
 {
     return(new(new QsiIdentifier(variable.toString(), false)));
 }
Example #36
0
 private void UpdateControls(UserVariable value)
 {
     if (value != null)
     {
         this.tbName.Text = value.Name;
         this.tbValue.Text = value.Value;
     }
     else
     {
         this.tbName.Text = string.Empty;
         this.tbValue.Text = string.Empty;
     }
 }
        /// <summary>
        /// Update UserVariable Update UserVariable
        /// </summary>
        /// <param name="id">id of UserVariable</param> 
        /// <param name="body">UserVariable that should be updated</param> 
        /// <returns>InlineResponse2002</returns>            
        public InlineResponse2002 UserVariablesIdPut(int? id, UserVariable body)
        {
            // verify the required parameter 'id' is set
            if (id == null) throw new ApiException(400, "Missing required parameter 'id' when calling UserVariablesIdPut");

            var path = "/userVariables/{id}";
            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id));

            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            postBody = ApiClient.Serialize(body); // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] {  };

            // make the HTTP request
            IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling UserVariablesIdPut: " + response.Content, response.Content);
            else if (((int)response.StatusCode) == 0)
                throw new ApiException ((int)response.StatusCode, "Error calling UserVariablesIdPut: " + response.ErrorMessage, response.ErrorMessage);

            return (InlineResponse2002) ApiClient.Deserialize(response.Content, typeof(InlineResponse2002), response.Headers);
        }