Example #1
0
        public View(ContactList contactList)
        {

            Dictionary<string, uint> Contacts = new Dictionary<string, uint>();
            Contacts.Equals(contactList);


        }
		public Dictionary<string, string> myDictionary()
		{
			Dictionary<string, string> addressBook = new Dictionary<string, string>();
			Dictionary<string, string> AddressBook = new Dictionary<string, string>();

			AddressBook.Add("Dan, Sara McManus", "Port Washington");
			AddressBook.Add("Brad, Vicki McManus", "Milwaukee");


			foreach (KeyValuePair<string, string> keyValPair in AddressBook)
			{
				Console.WriteLine(string.Format("Key: {0} ||-->|| {1}", keyValPair.Key, keyValPair.Value));
			}

			AddressBook.Equals(addressBook);
			return addressBook;







		}
        public void UpdateAccountMetadata(Dictionary<string, string> metadata, string region = null, bool useInternalUrl = false, CloudIdentity identity = null)
        {
            if (metadata.Equals(null))
            {
                throw new ArgumentNullException();
            }

            var headers = new Dictionary<string, string>();
            foreach (KeyValuePair<string, string> m in metadata)
            {
                if (m.Key.Contains(AccountMetaDataPrefix))
                {
                    headers.Add(m.Key, m.Value);
                }
                else
                {
                    headers.Add(AccountMetaDataPrefix + m.Key, m.Value);
                }
            }

            var urlPath = new Uri(string.Format("{0}", GetServiceEndpointCloudFiles(identity, region, useInternalUrl)));

            ExecuteRESTRequest(identity, urlPath, HttpMethod.POST, headers: headers);
        }
Example #4
0
        public void TestHistory()
        {
            var properties = new Dictionary<String, Object>();
            properties["testName"] = "test06_History";
            properties["tag"] = 1L;
            var db = database;

            var doc = CreateDocumentWithProperties(db, properties);
            var rev1ID = doc.CurrentRevisionId;
            Log.I(Tag, "1st revision: " + rev1ID);
            Assert.IsTrue (rev1ID.StartsWith ("1-", StringComparison.Ordinal), "1st revision looks wrong: " + rev1ID);
            Assert.AreEqual(doc.UserProperties, properties);

            properties = new Dictionary<String, Object>(doc.Properties);
            properties["tag"] = 2;
            Assert.IsNotNull(!properties.Equals(doc.Properties));
            Assert.IsNotNull(doc.PutProperties(properties));

            var rev2ID = doc.CurrentRevisionId;
            Log.I(Tag, "rev2ID" + rev2ID);
            Assert.IsTrue(rev2ID.StartsWith("2-", StringComparison.Ordinal), "2nd revision looks wrong:" + rev2ID);

            var revisions = doc.RevisionHistory.ToList();
            Log.I(Tag, "Revisions = " + revisions);
            Assert.AreEqual(revisions.Count, 2);

            var rev1 = revisions[0];
            Assert.AreEqual(rev1.Id, rev1ID);

            var gotProperties = rev1.Properties;
            Assert.AreEqual(1, gotProperties["tag"]);

            var rev2 = revisions[1];
            Assert.AreEqual(rev2.Id, rev2ID);
            Assert.AreEqual(rev2, doc.CurrentRevision);

            gotProperties = rev2.Properties;
            Assert.AreEqual(2, gotProperties["tag"]);

            var tmp = new List<SavedRevision>();
            tmp.Add(rev2);
            Assert.AreEqual(doc.ConflictingRevisions, tmp);
            Assert.AreEqual(doc.LeafRevisions, tmp);
        }
Example #5
0
        //初始化两个面板层 根据ChampionList表循环生成
        void InitPanels(Panel parent,Dictionary<int,Panel> PanelList,MouseEventHandler pp_MouseClick,MouseEventHandler item_MouseDoubleClick)
        {
            int id = 0;
            foreach (KeyValuePair<string, Models.Champion> pair in CHAMPION_LIST)
            {
                int modNum = 9;
                int spacing = 1;

                Panel pp = new Panel();
                //pp.Name = "Champion_" + pair.Key + "_Panel";
                pp.Parent = parent;
                pp.Width = 70;
                pp.Height = 100;
                pp.BackColor = Color.Transparent;
                pp.MouseClick+=pp_MouseClick;

                Panel panel = new Panel();
                panel.Width = 60;
                panel.Height = 60;
                panel.Parent = pp;
                //这里判断一下是哪个面板层 如果是结果集列表的话就先把item的背景图片置空 在其他地方处理
                panel.BackgroundImage = PanelList.Equals(panelList) ? Image.FromFile(pair.Value.Portrait) : null ;
                panel.BackgroundImageLayout = ImageLayout.Stretch;
                panel.TabIndex = 2;
                panel.Tag = pair.Key;
                panel.Top = 5;
                panel.Left = 5;
                panel.MouseClick +=pp_MouseClick;
                panel.MouseDoubleClick+=item_MouseDoubleClick;

                Label label = new Label();
                label.Text = pair.Value.DefaultName;
                label.Parent = pp;
                label.Width = 70;
                label.Height = 25;
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Font = new Font("微软雅黑", 7, FontStyle.Bold);
                label.Top = 70;
                label.Left = 0;
                label.MouseClick+=pp_MouseClick;
                label.MouseDoubleClick+=item_MouseDoubleClick;

                if (id % modNum != 0 && id > modNum)
                {
                    pp.Top = Convert.ToInt32(pp.Height * (Math.Floor(Convert.ToDouble(id / modNum))) + spacing * (Math.Floor(Convert.ToDouble(id / modNum)) + 1));
                    pp.Left = pp.Width * (id % modNum) + spacing * (id % modNum + 1);
                }
                else if (id % modNum == 0 && id >= modNum)
                {
                    pp.Left = spacing;
                    pp.Top = Convert.ToInt32(pp.Height * (Math.Floor(Convert.ToDouble(id / modNum))) + spacing * (Math.Floor(Convert.ToDouble(id / modNum)) + 1));
                }
                else if (id % modNum != 0 && id <= modNum)
                {
                    pp.Top = spacing;
                    pp.Left = pp.Width * id + spacing * (id + 1);
                }
                else if (id == 0)
                {
                    pp.Top = spacing;
                    pp.Left = spacing;
                }
                if (!PanelList.ContainsKey(id))
                {
                    PanelList.Add(id, pp);
                }
                id += 1;
            }
        }
 /// <summary>
 /// Adds the metadata.
 /// </summary>
 /// <param name='metadata'>
 /// Metadata.
 /// </param>
 /// <exception cref='ArgumentNullException'>
 /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
 /// </exception>
 public void AddMetadata(Dictionary<string, string> metadata)
 {
     if (metadata.Equals(null))
     {
         throw new ArgumentNullException();
     }
     var headers = new Dictionary<string, string>();
     foreach (KeyValuePair<string, string> m in metadata)
     {
         if (m.Key.Contains(Constants.Headers.ContainerMetaDataPrefix))
         {
             headers.Add(m.Key, m.Value);
         }
         else
         {
             headers.Add(Constants.Headers.ContainerMetaDataPrefix + m.Key, m.Value);
         }
     }
     AddHeaders(headers);
 }
 /// <summary>
 /// Saves log message into the dictionary that has been passed. It can be used at the end of the script to create a log asset.
 /// </summary>
 public static void SaveLog(Dictionary<string, string> dicLog, string logMessage)
 {
     if (!dicLog.Equals(null))
     {
         if (dicLog.Count > 0)
         {
             int nNextKey = Convert.ToInt32(dicLog.Last().Key) + 1;
             dicLog.Add(nNextKey.ToString("00000"), logMessage);
         }
         else
         {
             string szLogRender = @"
                             <%@ Page Language=""C#"" Inherits=""CrownPeak.Internal.Debug.OutputInit"" %>
                             <%@ Import Namespace=""CrownPeak.CMSAPI"" %>
                             <%@ Import Namespace=""CrownPeak.CMSAPI.Services"" %>
                             <%@ Import Namespace=""CrownPeak.CMSAPI.CustomLibrary"" %>
                             <!--DO NOT MODIFY CODE ABOVE THIS LINE-->
                             <%//This plugin uses OutputContext as its context class type%>
                             <%
                                 Dictionary<string, string> dicContents = asset.GetContent();
                                 dicContents.Remove(""body"");
                                 foreach (KeyValuePair<string, string> kvpContent in dicContents.OrderBy(c => c.Key))
                                 {
                                     Out.WriteLine(""{0} - {1}<br>"", kvpContent.Key, kvpContent.Value);
                                 }
                             %>
                             ";
             dicLog.Add("body", szLogRender);
             int nZero = 0;
             dicLog.Add(nZero.ToString("00000"), logMessage);
         }
     }
 }
Example #8
0
		//TODO issue: deleteLocalDocument should return error.code( see ios)
		// HISTORY
		/// <exception cref="System.Exception"></exception>
		public virtual void TestHistory()
		{
			IDictionary<string, object> properties = new Dictionary<string, object>();
			properties.Put("testName", "test06_History");
			properties.Put("tag", 1);
			Database db = StartDatabase();
			Document doc = CreateDocumentWithProperties(db, properties);
			string rev1ID = doc.GetCurrentRevisionId();
			Log.I(Tag, "1st revision: " + rev1ID);
			NUnit.Framework.Assert.IsNotNull("1st revision looks wrong: " + rev1ID, rev1ID.StartsWith
				("1-"));
			NUnit.Framework.Assert.AreEqual(doc.GetUserProperties(), properties);
			properties = new Dictionary<string, object>();
			properties.PutAll(doc.GetProperties());
			properties.Put("tag", 2);
			NUnit.Framework.Assert.IsNotNull(!properties.Equals(doc.GetProperties()));
			NUnit.Framework.Assert.IsNotNull(doc.PutProperties(properties));
			string rev2ID = doc.GetCurrentRevisionId();
			Log.I(Tag, "rev2ID" + rev2ID);
			NUnit.Framework.Assert.IsNotNull("2nd revision looks wrong:" + rev2ID, rev2ID.StartsWith
				("2-"));
			IList<SavedRevision> revisions = doc.GetRevisionHistory();
			Log.I(Tag, "Revisions = " + revisions);
			NUnit.Framework.Assert.AreEqual(revisions.Count, 2);
			SavedRevision rev1 = revisions[0];
			NUnit.Framework.Assert.AreEqual(rev1.GetId(), rev1ID);
			IDictionary<string, object> gotProperties = rev1.GetProperties();
			NUnit.Framework.Assert.AreEqual(1, gotProperties.Get("tag"));
			SavedRevision rev2 = revisions[1];
			NUnit.Framework.Assert.AreEqual(rev2.GetId(), rev2ID);
			NUnit.Framework.Assert.AreEqual(rev2, doc.GetCurrentRevision());
			gotProperties = rev2.GetProperties();
			NUnit.Framework.Assert.AreEqual(2, gotProperties.Get("tag"));
			IList<SavedRevision> tmp = new AList<SavedRevision>();
			tmp.AddItem(rev2);
			NUnit.Framework.Assert.AreEqual(doc.GetConflictingRevisions(), tmp);
			NUnit.Framework.Assert.AreEqual(doc.GetLeafRevisions(), tmp);
		}
Example #9
0
        /// <summary>
        /// This helper removes dependencies, was added to reduce code reuse
        /// </summary>
        /// <param name="s">key</param>
        /// <param name="t">value</param>
        /// <param name="dict">dictoinary</param>
        private void RemoveFromDependencyDic(string s, string t, Dictionary<string, HashSet<string>> dict)
        {
            if (dict.ContainsKey(s) && dict[s].Contains(t))
            {
                // if dictonary only has one value reomve the whole kvp
                if (dict[s].Count() == 1)
                    dict.Remove(s);
                //just remove t from the hash set
                else
                    dict[s].Remove(t);

                if (dict.Equals(dependentDict))
                {
                    _size--;
                }

                //!!!! this could potentaily be a problem down the road!!!!!!
                //implies t has dependents not sure if I need to check this
                //probaly will for at least size
                //if (dict.ContainsKey(t) && dict[t].Count() > 0)
                //{ }
                //need to do this to keep track of _size
            }
        }
        private static void comparePermissions(int currentID, Dictionary<string, HashSet<string>> oldPermissions, Dictionary<string, HashSet<string>> newPermissions, List<Task> tasklist, bool AccessValue)
        {
            if (!oldPermissions.Equals(newPermissions))
            {
                UserControlPermission ucp = new UserControlPermission();
                UserPermission up = new UserPermission();
                HashSet<string> deletedControls = new HashSet<string>();
                //added permissions
                foreach(var delPerms in oldPermissions)
                {
                    if (!newPermissions.Keys.Contains(delPerms.Key))
                    {
                        deletedControls.Add(delPerms.Key);
                        tasklist.Add(Task.Factory.StartNew(() => DeleteControlAccess(currentID, delPerms.Key)));
                    }
                }
                foreach (var permission in newPermissions)
                {
                    if (!deletedControls.Contains(permission.Key) && oldPermissions.ContainsKey(permission.Key))
                    {
                        //delete all permissions from control
                        if (!(permission.Value.Count > 0))
                            tasklist.Add(Task.Factory.StartNew(() => DeleteControlPermissions(currentID, permission.Key)));

                        HashSet<string> DeletePermissions = new HashSet<string>();
                        HashSet<string> AddPermissions = oldPermissions[permission.Key];

                        if (AddPermissions != null)
                        {
                            DeletePermissions.AddRange(oldPermissions[permission.Key]);
                            foreach (string s in permission.Value)
                            {
                                if (!DeletePermissions.Remove(s))
                                {
                                    up.Control = permission.Key;
                                    up.Permission = s;
                                    up.AccessValue = AccessValue;
                                    //add permission
                                    tasklist.Add(Task.Factory.StartNew(() => SetPermissionByUserID(currentID, up)));
                                }
                            }
                        }
                        else { throw new Exception("addpermission = null"); }
                        if (DeletePermissions.Count > 0)
                        {
                            foreach (string s in DeletePermissions)
                            {
                                up.Control = permission.Key;
                                up.Permission = s;
                                tasklist.Add(Task.Factory.StartNew(() => DeleteControlPermissionAccess(currentID, up)));
                            }
                        }
                    }
                    else
                    {
                        ucp.Control = permission.Key;
                        ucp.AccessValue = true;
                        tasklist.Add(Task.Factory.StartNew(() => SetPermissionByUserID(currentID, ucp)));
                        
                        foreach (string s in permission.Value)
                        {
                            up.AccessValue = AccessValue;
                            up.Control = permission.Key;
                            up.Permission = s;
                            tasklist.Add(Task.Factory.StartNew(() => SetPermissionByUserID(currentID, ucp)));
                        }
                    }

                }
            }
        }