Example #1
1
        private void btnSaveAsNew_Click(object sender, EventArgs e)
        {
            try
            {
                string query;
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("@Name", txtName.Text);
                parameters.Add("@StartTime", dtpStart.Value.TimeOfDay);
                parameters.Add("@EndTime", dtpEnd.Value.TimeOfDay);
                query = @"INSERT INTO Periods (Name, StartTime, EndTime) VALUES (@Name, @StartTime, @EndTime);";

                _PeriodID = SqlHelper.ExecteNonQuery(query, parameters);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Close();
            Central.MainForm.Focus();
            foreach (DockContent item in Central.MainForm.Contents)
            {
                if (item is Periods)
                {
                    ((Periods)item).RefreshPeriods();
                    continue;
                }
            }

            this.TabText = txtName.Text + " Details";
        }
Example #2
1
     void Start ()
    {
        player = transform.root.GetComponent<Player>();
        SetCursorState(CursorState.Default);

        resourceValues = new Dictionary<ResourceType, int>();
        resourceLimits = new Dictionary<ResourceType, int>();

        resourceValues.Add(ResourceType.Gold, 0);
        resourceLimits.Add(ResourceType.Gold, 0);
        resourceValues.Add(ResourceType.Nelther, 0);
        resourceLimits.Add(ResourceType.Nelther, 0);
        resourceValues.Add(ResourceType.Elynium, 0);
        resourceLimits.Add(ResourceType.Elynium, 0);
        resourceValues.Add(ResourceType.Population, 0);
        resourceLimits.Add(ResourceType.Population, 0);

        posBar = transform.FindChild("Frame1").FindChild("Frame").FindChild("BackGround").FindChild("Production").gameObject.transform.position;

        transform.FindChild("Frame1").FindChild("UnitNameProduct").GetComponent<Text>().text = "";
        transform.FindChild("Frame1").FindChild("HitText").GetComponent<Text>().text = "";
        transform.FindChild("Frame1").FindChild("Object").gameObject.SetActive(false);

        transform.FindChild("Frame1").FindChild("Frame").gameObject.SetActive(false);
        transform.FindChild("Frame1").FindChild("UnitNameProduct").gameObject.SetActive(false);
        for (int j = 1; j < 6; j++)
        {
            transform.FindChild("Frame1").FindChild("FrameUnit" + j.ToString()).gameObject.SetActive(false);
        }
    }
        public static IncomingTransportMessage Deserialize(string messageId, Stream inputStream)
        {
            var headers = new Dictionary<string, string>();
            var serializedMessageData = "";
            using (var reader = new XmlTextReader(inputStream))
            {
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.Read(); // read <root>
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        var elementName = reader.Name;
                        reader.Read(); // read the child;
                        while (reader.NodeType == XmlNodeType.Element)
                        {
                            // likely an empty header element node
                            headers.Add(elementName, reader.Value);

                            elementName = reader.Name;
                            reader.Read(); // read the child;
                        }
                        if (string.Equals(elementName, "body", StringComparison.InvariantCultureIgnoreCase) && reader.NodeType == XmlNodeType.CDATA)
                        {
                            serializedMessageData = reader.Value;
                        }
                        else if (reader.NodeType == XmlNodeType.Text)
                        {
                            headers.Add(elementName, reader.Value);
                        }
                    }
                }
            }
            return new IncomingTransportMessage(messageId, headers, serializedMessageData);
        }
        internal DatabaseGenerationAssemblyLoader(Project project, string vsInstallPath)
        {
            _assembliesInstalledUnderVisualStudio = new Dictionary<string, string>();
            // For these DLLs we should use the version pre-installed under the VS directory,
            // not whatever reference the project may have
            _assembliesInstalledUnderVisualStudio.Add(
                "ENTITYFRAMEWORK", Path.Combine(vsInstallPath, "EntityFramework.dll"));
            _assembliesInstalledUnderVisualStudio.Add(
                "ENTITYFRAMEWORK.SQLSERVER", Path.Combine(vsInstallPath, "EntityFramework.SqlServer.dll"));
            _assembliesInstalledUnderVisualStudio.Add(
                "ENTITYFRAMEWORK.SQLSERVERCOMPACT", Path.Combine(vsInstallPath, "EntityFramework.SqlServerCompact.dll"));

            _projectReferenceLookup = new Dictionary<string, Reference3>();
            _websiteReferenceLookup = new Dictionary<string, AssemblyReference>();
            if (project != null)
            {
                var vsProject = project.Object as VSProject2;
                var vsWebSite = project.Object as VSWebSite;
                if (vsProject != null)
                {
                    _isWebsite = false;
                    CacheProjectReferences(vsProject);
                }
                else if (vsWebSite != null)
                {
                    _isWebsite = true;
                    CacheWebsiteReferences(vsWebSite);
                }
            }
        }
        /// <summary>
        /// 11、	添加指标
        /// </summary>
        /// <param name="name">指标名称</param>
        /// <param name="itype">输入方式</param>
        /// <param name="vtype">值类型</param>
        /// <param name="editbypat">是否可由病人编辑</param>
        /// <param name="hospitalid">医院id</param>
        /// <param name="cateid">病例分类id</param>
        /// <param name="val">值序列,以数组形式传递,可为空</param>
        /// <returns></returns>
        /// Jack Ding
        public TermAddResponse Add(string name, int itype, int vtype, int editbypat, int hospitalid, int cateid, double[] val)
        {
            string strResponse = string.Empty;
            TermAddResponse response = new TermAddResponse();

            try
            {
                Dictionary<string, string> sPara = new Dictionary<string, string>();

                sPara.Add("name", name);
                sPara.Add("itype", itype.ToString());
                sPara.Add("vtype", vtype.ToString());
                sPara.Add("editbypat", editbypat.ToString());
                sPara.Add("hospitalid", hospitalid.ToString());
                //val参数不知道如何添加

                strResponse = F8YLSubmit.BuildRequest(sPara, "term/add");

                response = JsonHelper.DeserializeJsonToObject<TermAddResponse>(strResponse);

                return response;
            }
            catch
            {
                throw;
            }
        }
Example #6
0
        public static void Test_Serialize_Dictionary_02(DictionaryRepresentation dictionaryRepresentation)
        {
            // json Dictionary
            // DictionaryRepresentation.Dynamic or DictionaryRepresentation.Document
            // { "toto1" : "tata1", "toto2" : "tata2" }
            // DictionaryRepresentation.ArrayOfArrays
            // [["toto1", "tata1"], ["toto2", "tata2"]]
            // DictionaryRepresentation.ArrayOfDocuments
            // [{ "k" : "toto1", "v" : "tata1" }, { "k" : "toto2", "v" : "tata2" }]
            Trace.WriteLine();
            Trace.WriteLine("Test_Serialize_Dictionary_02");
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            dictionary.Add("toto1", "tata1");
            dictionary.Add("toto2", "tata2");
            //DictionaryRepresentation dictionaryRepresentation = DictionaryRepresentation.ArrayOfDocuments;
            Trace.WriteLine("DictionaryRepresentation : {0}", dictionaryRepresentation);
            Trace.WriteLine("Dictionary json :");
            string json = dictionary.ToJson(new DictionarySerializationOptions(dictionaryRepresentation));
            Trace.WriteLine(json);

            Trace.WriteLine("Deserialize json :");
            Dictionary<string, string> dictionary2 = BsonSerializer.Deserialize<Dictionary<string, string>>(json);
            string json2 = dictionary2.ToJson(new DictionarySerializationOptions(dictionaryRepresentation));
            Trace.WriteLine(json2);
            Trace.WriteLine("comparison of Dictionary json and Deserialize json : {0}", json == json2 ? "identical" : "different");
        }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method GetEnumerator in ValueCollection Generic IEnumerable 1");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("str1", "Test1");
         dic.Add("str2", "Test2");
         IEnumerable<string> ienumer = (IEnumerable<string>)new Dictionary<string, string>.ValueCollection(dic);
         IEnumerator<string> ienumerator = ienumer.GetEnumerator();
         Dictionary<string, string>.Enumerator dicEnumer = dic.GetEnumerator();
         while (ienumerator.MoveNext() && dicEnumer.MoveNext())
         {
             if (!ienumerator.Current.Equals(dicEnumer.Current.Value))
             {
                 TestLibrary.TestFramework.LogError("001", "the ExpecResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #8
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            var beneficiaries = _unitOfWork.Beneficiaries.GetAll();

            Dictionary<string, decimal> totals = new Dictionary<string, decimal>();
            const decimal TARGET = 600000;
            totals.Add("Target", TARGET);

            List<Payment> payments = _unitOfWork.Payments.GetPaymentWithCurrency().ToList();

            var posted = payments.Where(p => p.Locked).Sum(p => p.Amount * p.Currency.ExchangeRate);

            totals.Add("Posted", posted);

            var total = payments.Sum(p => p.Amount * p.Currency.ExchangeRate);

            totals.Add("Total", total);

            ViewBag.Posted = totals["Posted"];
            ViewBag.Total = totals["Total"];
            ViewBag.Target = totals["Target"];
            ViewBag.Percentage = Convert.ToInt32((ViewBag.Total / ViewBag.Target) * 100);

            return View(beneficiaries);
        }
        private void CreateMenu()
        {
            Sites = new Dictionary<string, string>();
            var root = "../Form/";
            Sites.Add(root + "Start.aspx", Resources.Default.home);
            Sites.Add(root + "Uebersicht.aspx", Resources.Default.accountMovements);
            Sites.Add(root + "Kategorie.aspx", Resources.Default.Overview);

            if (SessionManager.CurrentUser.ISADMIN == true)
            {
                Sites.Add(root + "Admin/Admin.aspx", Resources.Default.admin);
            }

            var script = string.Empty;
            foreach (var str in Sites)
            {
                script = string.Concat(script,
                    "haushaltsRechner.client.menuPoint('",
                    str.Key,
                    "','",
                    str.Value,
                    "','",
                    MainMenu.ClientID,
                    "');");
            }

            ScriptManager.RegisterStartupScript(this, GetType(), "STARTUPSCRIPTCONTENTMASTER_" + ClientID, script, true);
        }
Example #10
0
        public void SendLetter(UpdateLetter updateLetter)
        {
            var letter = updateLetter.CreateLetter();
            letter.ReplyTime = SqlDateTime.MinValue.Value;
            using (var content = new DefaultContext())
            {
                content.Letters.Add(letter);
                content.SaveChanges();
            }
            var dic = new Dictionary<string, string>();
            dic.Add("ActionName", "Reply");
            dic.Add("letter", letter.ToJson());

            var resString = HttpWebResponseUtility.CreatePostHttpResponse("http://second.eagle.com/api/Message", dic.ToJson(), 30000);
            if (string.IsNullOrEmpty(resString) || resString == "0")
            {
                Flag = false;
                Message = "消息无响应";
                return;
            }
            var result = resString.ToDeserialize<Cells>();
            if (!result.Flag)
            {
                Flag = false;
                Message = result.Message;
                return;
            }
            Flag = true;
        }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method CopyTo in the ValueCollection 2");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("str1", "Test1");
         dic.Add("str2", "Test2");
         Dictionary<string, string>.ValueCollection values = new Dictionary<string, string>.ValueCollection(dic);
         string[] TVals = new string[SIZE];
         values.CopyTo(TVals, 5);
         string strVals = null;
         for (int i = 0; i < TVals.Length; i++)
         {
             if (TVals[i] != null)
             {
                 strVals += TVals[i].ToString();
             }
         }
         if (TVals[5].ToString() != "Test1" || TVals[6].ToString() != "Test2" || strVals != "Test1Test2")
         {
             TestLibrary.TestFramework.LogError("003", "the ExpecResult is not the ActualResult");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #12
0
        public bool GetAccessToken(string code)
        {
            Dictionary<string, string> args = new Dictionary<string, string>();
            args.Add("code", code);
            args.Add("client_id", AuthInfo.Client_ID);
            args.Add("client_secret", AuthInfo.Client_Secret);
            args.Add("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
            args.Add("grant_type", "authorization_code");

            string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);

            if (!string.IsNullOrEmpty(response))
            {
                OAuth2Token token = JsonConvert.DeserializeObject<OAuth2Token>(response);

                if (token != null && !string.IsNullOrEmpty(token.access_token))
                {
                    token.UpdateExpireDate();
                    AuthInfo.Token = token;
                    return true;
                }
            }

            return false;
        }
		/// <summary>
		/// A simple construtor that initializes the object with the given dependencies.
		/// </summary>
		/// <param name="p_msfFunctions">The object that proxies the script function calls
		/// out of the sandbox.</param>
		public ModScriptInterpreterContext(ModScriptFunctionProxy p_msfFunctions)
		{
			Variables = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
			FunctionProxy = p_msfFunctions;
			Variables.Add("NewLine", Environment.NewLine);
			Variables.Add("Tab", "\t");
		}
 public override Dictionary<string, object> feed(
     Dictionary<string, object> data)
 {
     data.Add("text", Text);
     data.Add("link", Link);
     return data;
 }
        //// GET api/<controller>
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}
        //// GET api/<controller>/5
        //public string Get(int id)
        //{
        //    return "value";
        //}
        //// POST api/<controller>
        //public void Post([FromBody]string value)
        //{
        //}
        //// PUT api/<controller>/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}
        //// DELETE api/<controller>/5
        //public void Delete(int id)
        //{
        //}
        public Dictionary<string, Boolean> Get()
        {
            Dictionary<string, Boolean> perms = new Dictionary<string, Boolean>();

            using (ServerApplicationContext ctx = ServerApplicationContext.CreateContext())
            {
                var currentUser = ctx.Application.User;
                if (currentUser.IsAuthenticated)
                {
                    perms.Add(Permissions.SecurityAdministration,
                        currentUser.HasPermission(Permissions.SecurityAdministration));

                    currentUser.AddPermissions(Permissions.SecurityAdministration);

                    foreach (Permission perm in ctx.DataWorkspace.SecurityData.Permissions)
                    {
                        if (perm.Id != Permissions.SecurityAdministration)
                        {
                            perms.Add(perm.Id, currentUser.HasPermission(perm.Id));
                        }
                    }
                }
            }
            return perms;
        }
Example #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string query;
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("@Name", txtName.Text);
                parameters.Add("@StartTime", dtpStart.Value.TimeOfDay);
                parameters.Add("@EndTime", dtpEnd.Value.TimeOfDay);
                parameters.Add("@PeriodID", _PeriodID);
                if (_PeriodID < 0)
                    query = @"INSERT INTO Periods (Name, StartTime, EndTime) VALUES (@Name, @StartTime, @EndTime);";
                else
                    query = @"UPDATE Periods SET Name = @Name, StartTime = @StartTime, EndTime = @EndTime WHERE PeriodID = @PeriodID";

                _PeriodID = SqlHelper.ExecteNonQuery(query, parameters);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Close();
            Central.MainForm.Focus();
            foreach (DockContent item in Central.MainForm.Contents)
            {
                if (item is Periods)
                    ((Periods)item).RefreshPeriods();
            }
        }
Example #17
0
        public DetectorsStatusManager(DetectorsDataAccess dataAccess, EventLoggerAccess logger) :
            base(dataAccess, logger)
        {
            _logger = logger;
            Dictionary<int, string> ConnectionValueMapping = new Dictionary<int, string>();
            ConnectionValueMapping.Add(0, TagValueTypes.Error);
            ConnectionValueMapping.Add(1, TagValueTypes.Clear);

            StatusElement detectorConnect = new StatusElement(_DetectorConnectTag, 0, TagTypes.Status, ConnectionValueMapping);
            //detectorConnect.Value = 
            _Statuses.Add(detectorConnect);


            StatusElement apcsConnect = new StatusElement(_APCSConnectTag, 0, TagTypes.Status, ConnectionValueMapping);
            _Statuses.Add(apcsConnect);

            dataAccess.DetectorConnectionStateUpdate +=
                    new ConnectionStateChangeHandler(OnDetectorsConnectionChange);
            dataAccess.APCSConnectionStateUpdate +=
                    new ConnectionStateChangeHandler(OnApcsConnectionChange);

            Dictionary<int, string> DetectorsValueMapping = new Dictionary<int, string>();
            DetectorsValueMapping.Add(0, TagValueTypes.Clear);
            DetectorsValueMapping.Add(1, TagValueTypes.Warning);
            DetectorsValueMapping.Add(2, TagValueTypes.Error);
            DetectorsValueMapping.Add(3, TagValueTypes.Warning);

            StatusElement detectorStatus = new StatusElement(_DetectorStatusTag, 0, TagTypes.Status, DetectorsValueMapping);
            _Statuses.Add(detectorStatus);
        }
Example #18
0
        /// <summary>
        /// Creates a DotLiquid compatible dictionary that represents the current store model.
        /// </summary>
        /// <param name="debug">if set to <c>true</c> the entire object tree will be parsed immediately.</param>
        /// <returns>
        /// DotLiquid compatible dictionary.
        /// </returns>
        public virtual object ToLiquid( bool debug )
        {
            var dictionary = new Dictionary<string, object>();

            Type entityType = this.GetType();

            foreach ( var propInfo in entityType.GetProperties() )
            {

                object propValue = propInfo.GetValue( this, null );

                if ( propValue is Guid )
                {
                    propValue = ((Guid)propValue).ToString();
                }

                if ( debug && propValue is DotLiquid.ILiquidizable )
                {
                    dictionary.Add( propInfo.Name, ((DotLiquid.ILiquidizable)propValue).ToLiquid() );
                }
                else
                {
                    dictionary.Add( propInfo.Name, propValue );
                }

            }

            return dictionary;
        }
Example #19
0
        public async Task<bool> RegisterDevice(string token, string deviceModel = null, string systemVersion = null, bool noText = false, string subscribe = null)
        {
            if (_vkontakte.AccessToken == null || string.IsNullOrEmpty(_vkontakte.AccessToken.Token) || _vkontakte.AccessToken.HasExpired)
                throw new Exception("Access token is not valid.");

            var parametres = new Dictionary<string, string>();

            parametres.Add("token", token);

            if (!string.IsNullOrEmpty(deviceModel))
                parametres.Add("device_model", deviceModel);

            if (!string.IsNullOrEmpty(systemVersion))
                parametres.Add("system_version", systemVersion);

            if (noText)
                parametres.Add("no_text", "1");

            _vkontakte.SignMethod(parametres);

            var response = await new VkRequest(new Uri(VkConst.MethodBase + "account.registerDevice"), parametres).Execute();

            VkErrorProcessor.ProcessError(response);

            if (response["response"] != null)
            {
                return response["response"].Value<int>() == 1;
            }

            return false;
        }
Example #20
0
        public static Dictionary<MarkerType, IMarkerDrawer> CreateDefaultMarkerDrawers()
        {
            Dictionary<MarkerType, IMarkerDrawer> markerDrawers = new Dictionary<MarkerType, IMarkerDrawer>();
              markerDrawers.Add(
            MarkerType.Start,
            new CircleDrawer(Color.FromArgb(192, 255, 0, 64), 12, 3)
              );
              markerDrawers.Add(
            MarkerType.Lap,
            new CircleDrawer(Color.FromArgb(192, 255, 0, 64), 12, 3)
              );
              markerDrawers.Add(
            MarkerType.Stop,
            new CircleDrawer(Color.FromArgb(192, 255, 0, 64), 12, 3)
              );
              markerDrawers.Add(
            MarkerType.MouseHover,
            new DiscAndCircleDrawer(Color.FromArgb(192, Color.Red), 4, Color.FromArgb(192,Color.Black), 6, 2)
              );
              markerDrawers.Add(
            MarkerType.Handle,
            new DiscDrawer(Color.FromArgb(192, Color.Blue), 6)
              );
              markerDrawers.Add(
            MarkerType.ActiveHandle,
            new DiscAndCircleDrawer(Color.FromArgb(192, Color.Blue), 6, Color.FromArgb(192, Color.Blue), 12, 3)
              );
              markerDrawers.Add(
            MarkerType.MovingActiveHandle,
            new CircleDrawer(Color.FromArgb(192, Color.Blue), 12, 3)
              );

              return markerDrawers;
        }
Example #21
0
        public override UploadResult ShortenURL(string url)
        {
            UploadResult result = new UploadResult { URL = url };

            if (string.IsNullOrEmpty(API_HOST))
            {
                API_HOST = "https://polr.me/publicapi.php";
                API_KEY = null;
            }
            else
            {
                API_HOST = URLHelpers.FixPrefix(API_HOST);
            }

            Dictionary<string, string> args = new Dictionary<string, string>();

            if (!string.IsNullOrEmpty(API_KEY))
            {
                args.Add("apikey", API_KEY);
            }

            args.Add("action", "shorten");
            args.Add("url", url);

            string response = SendRequest(HttpMethod.GET, API_HOST, args);

            if (!string.IsNullOrEmpty(response))
            {
                result.ShortenedURL = response;
            }

            return result;
        }
    /// <summary>
    /// Start is called once on object creation
    /// </summary>
    protected override void Start()
    {
        instance = this;
        previewObjects = new Dictionary<CharacterType, GameObject>();
        previewObjects.Add(CharacterType.Ranger, ranger);
        previewObjects.Add(CharacterType.Mage, mage);
        previewObjects.Add(CharacterType.Warrior, warrior);
        abilityTexts = new Dictionary<InputType, Text[]>();
        abilityTexts.Add(InputType.Main, mainTexts);
        abilityTexts.Add(InputType.Secondary, secondTexts);
        abilityTexts.Add(InputType.Power, powerTexts);
        abilityTexts.Add(InputType.Special, specialTexts);
        classNames = new Dictionary<CharacterType, string>();
        classNames.Add(CharacterType.Ranger, "RANGER");
        classNames.Add(CharacterType.Mage, "MAGE");
        classNames.Add(CharacterType.Warrior, "WARRIOR");
        UpdateMapping();

        if (autoShow)
        {
            previewObjects[GameManager.Instance.CurrentSave.PlayerType].SetActive(true);
            title.text = classNames[GameManager.Instance.CurrentSave.PlayerType];
        }
        base.Start();
    }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method GetEnumerator in ValueCollection Generic IEnumerable 2");
     try
     {
         Dictionary<TestClass, TestClass> dic = new Dictionary<TestClass, TestClass>();
         TestClass TKey1 = new TestClass();
         TestClass TVal1 = new TestClass();
         TestClass TKey2 = new TestClass();
         TestClass TVal2 = new TestClass();
         dic.Add(TKey1, TVal1);
         dic.Add(TKey2, TVal2);
         IEnumerable<TestClass> ienumer = (IEnumerable<TestClass>)new Dictionary<TestClass, TestClass>.ValueCollection(dic);
         IEnumerator<TestClass> ienumerator = ienumer.GetEnumerator();
         Dictionary<TestClass, TestClass>.Enumerator dicEnumer = dic.GetEnumerator();
         while (ienumerator.MoveNext() && dicEnumer.MoveNext())
         {
             if (!ienumerator.Current.Equals(dicEnumer.Current.Value))
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpecResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
        public PartialCountBolt(Context ctx)
        {
            this.ctx = ctx;

            // set input schemas
            Dictionary<string, List<Type>> inputSchema = new Dictionary<string, List<Type>>();
            inputSchema.Add(Constants.DEFAULT_STREAM_ID, new List<Type>() { typeof(string) });

            //Add the Tick tuple Stream in input streams - A tick tuple has only one field of type long
            inputSchema.Add(Constants.SYSTEM_TICK_STREAM_ID, new List<Type>() { typeof(long) });

            // set output schemas
            Dictionary<string, List<Type>> outputSchema = new Dictionary<string, List<Type>>();
            outputSchema.Add(Constants.DEFAULT_STREAM_ID, new List<Type>() { typeof(long) });

            // Declare input and output schemas
            this.ctx.DeclareComponentSchema(new ComponentStreamSchema(inputSchema, outputSchema));

            this.ctx.DeclareCustomizedDeserializer(new CustomizedInteropJSONDeserializer());

            if (Context.Config.pluginConf.ContainsKey(Constants.NONTRANSACTIONAL_ENABLE_ACK))
            {
                enableAck = (bool)(Context.Config.pluginConf[Constants.NONTRANSACTIONAL_ENABLE_ACK]);
            }

            partialCount = 0L;
            totalCount = 0L;
        }
    public ObjectFactory()
    {
        instance = this;

        creationTable = new Dictionary<string, System.Func<GameObject>>();
        creationTable.Add("factory", createFactory);
        creationTable.Add ("city", createCity);
        creationTable.Add ("fort", createFort);
        creationTable.Add ("barracks", createBarracks);
        creationTable.Add ("tree", createTree);

        team1 = new Dictionary<string, string>();
        team2 = new Dictionary<string, string>();

        team1.Add ("scout", "lambo");
        team1.Add ("ranged", "archer");
        team1.Add ("healer", "healer");
        team1.Add ("medium", "construction");
        team1.Add ("heavy", "predator");

        team2.Add ("scout", "normandy");
        team2.Add ("ranged", "wizard");
        team2.Add ("healer", "healer");
        team2.Add ("medium", "construction");
        team2.Add ("heavy", "centurion");
    }
		private static void SetCellDictionaries()
		{
			var bottomDict = new Dictionary<int, Edge>();
			bottomDict.Add((int)CellBitmask.RightBottom, Edge.Right);
			bottomDict.Add(Edge.Left,
				CellBitmask.LeftTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom | CellBitmask.RightTop,
				CellBitmask.LeftTop | CellBitmask.RightBottom | CellBitmask.RightTop,
				CellBitmask.LeftBottom);
			bottomDict.Add(Edge.Right,
				CellBitmask.RightTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom | CellBitmask.LeftTop,
				CellBitmask.LeftBottom | CellBitmask.LeftTop | CellBitmask.RightTop);
			bottomDict.Add(Edge.Top,
				CellBitmask.RightBottom | CellBitmask.RightTop,
				CellBitmask.LeftBottom | CellBitmask.LeftTop);

			var leftDict = new Dictionary<int, Edge>();
			leftDict.Add(Edge.Top,
				CellBitmask.LeftTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom | CellBitmask.RightTop);
			leftDict.Add(Edge.Right,
				CellBitmask.LeftTop | CellBitmask.RightTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom);
			leftDict.Add(Edge.Bottom,
				CellBitmask.RightBottom | CellBitmask.RightTop | CellBitmask.LeftTop,
				CellBitmask.LeftBottom);

			var topDict = new Dictionary<int, Edge>();
			topDict.Add(Edge.Right,
				CellBitmask.RightTop,
				CellBitmask.LeftTop | CellBitmask.LeftBottom | CellBitmask.RightBottom);
			topDict.Add(Edge.Right,
				CellBitmask.RightBottom,
				CellBitmask.LeftTop | CellBitmask.LeftBottom | CellBitmask.RightTop);
			topDict.Add(Edge.Left,
				CellBitmask.RightBottom | CellBitmask.RightTop | CellBitmask.LeftTop,
				CellBitmask.LeftBottom,
				CellBitmask.LeftTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom | CellBitmask.RightTop);
			topDict.Add(Edge.Bottom,
				CellBitmask.RightBottom | CellBitmask.RightTop,
				CellBitmask.LeftTop | CellBitmask.LeftBottom);

			var rightDict = new Dictionary<int, Edge>();
			rightDict.Add(Edge.Top,
				CellBitmask.RightTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom | CellBitmask.LeftTop);
			rightDict.Add(Edge.Left,
				CellBitmask.LeftTop | CellBitmask.RightTop,
				CellBitmask.LeftBottom | CellBitmask.RightBottom);
			rightDict.Add(Edge.Bottom,
				CellBitmask.RightBottom,
				CellBitmask.LeftTop | CellBitmask.LeftBottom | CellBitmask.RightTop);

			dictChooser.Add((int)Edge.Left, leftDict);
			dictChooser.Add((int)Edge.Right, rightDict);
			dictChooser.Add((int)Edge.Bottom, bottomDict);
			dictChooser.Add((int)Edge.Top, topDict);
		}
    void Test_diclist()
    {
        Dictionary <string, List<string>> myDic
            = new Dictionary<string, List<string>> ();
        string keystr;

        // command 1
        keystr = "hello";
        var res1ls = new List<string> ();
        res1ls.Add ("hello, Mike");
        res1ls.Add ("tadano shikabane no youda");
        res1ls.Add ("This number is not currently registered");
        myDic.Add (keystr, res1ls);

        // command 2
        keystr = "Ca va bien?";
        var res2ls = new List<string> ();
        res2ls.Add ("Merci, beaucoup");
        res2ls.Add ("honjitsu wa sentenn nari");
        res2ls.Add ("Je nous peut pas parler Francaise.");
        myDic.Add (keystr, res2ls);

        //		displayAllElementWithKey (ref myDic, /* searchKey=*/"hello");
        for (int loop=0; loop<10; loop++) {
            findElementWithKey (ref myDic, /* searchKey=*/"hello");
        }
    }
 public void Claims_Roundtrip()
 {
     Dictionary<string, string> claims = new Dictionary<string, string>();
     claims.Add("foo", "value1");
     claims.Add("bar", "value2");
     PropertyAssert.Roundtrips(this.creds, c => c.Claims, PropertySetter.NullRoundtrips, roundtripValue: claims);
 }
Example #29
0
 /// <summary>
 /// 取得临时的Access Token
 /// </summary>
 /// <param name="code">临时Authorization Code,官方提示10分钟过期</param>
 /// <param name="state">防止CSRF攻击,成功授权后回调时会原样带回</param>
 /// <returns>Dictionary</returns>
 public static Dictionary<string, object> get_access_token(string code, string state)
 {
     //获得配置信息
     oauth_config config = oauth_helper.get_config("qq");
     string send_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=" + config.oauth_app_id + "&client_secret=" + config.oauth_app_key + "&code=" + code + "&state=" + state + "&redirect_uri=" + Utils.UrlEncode(config.return_uri);
     //发送并接受返回值
     string result = Utils.HttpGet(send_url);
     if (result.Contains("error"))
     {
         return null;
     }
     try
     {
         string[] parm = result.Split('&');
         string access_token = parm[0].Split('=')[1];    //取得access_token
         string expires_in = parm[1].Split('=')[1];      //Access Token的有效期,单位为秒
         Dictionary<string, object> dic = new Dictionary<string, object>();
         dic.Add("access_token", access_token);
         dic.Add("expires_in", expires_in);
         return dic;
     }
     catch
     {
         return null;
     }
 }
Example #30
0
        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
            ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();
            if (requestParameters.ContainsKey("Submit"))
            {
                string title = requestParameters["NewsTitle"].ToString();
                string text = requestParameters["NewsText"].ToString();
                IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector>();
                GridNewsItem item = new GridNewsItem {Text = text, Time = DateTime.Now, Title = title};
                item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1;
                connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD());
                response = "<h3>News item added successfully, redirecting to main page</h3>" +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" +
                           "</script>";
                return null;
            }

            vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle"));
            vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText"));
            vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return vars;
        }