Clone() public method

public Clone ( ) : Object
return Object
		private Color[] SelectHighestFrecuency(Hashtable histogram)
		{
			Color[]   salida = new Color[NumColors];
			Hashtable HCopy  = (Hashtable)histogram.Clone();

			Color pixel;
			int i=0;
			while (i<NumColors)
			{
				if (HCopy.Count == 0) {break;}

				pixel = HighestFrecuency(HCopy);

				salida[i] = pixel;
				HCopy.Remove(pixel);

				i++;
			}

			while (i<NumColors)
			{
				salida[i] = Color.Empty;
				i++;
			}

			return salida;
		}
示例#2
0
        public void TestCloneShallowCopyReferenceTypes()
        {
            //[]Clone is a shallow copy, so the objects of the objets reference should be the same
            string strValue;

            var hsh1 = new Hashtable();
            for (int i = 0; i < 10; i++)
            {
                hsh1.Add(i, new Foo());
            }

            var hsh2 = (Hashtable)hsh1.Clone();
            for (int i = 0; i < 10; i++)
            {
                strValue = "Hello World";
                Assert.True(strValue.Equals(((Foo)hsh2[i]).strValue), "Error, Expected value not returned, " + strValue);
            }

            strValue = "Good Bye";
            ((Foo)hsh1[0]).strValue = strValue;
            Assert.True(strValue.Equals(((Foo)hsh1[0]).strValue), "Error, Expected value not returned, " + strValue);

            //da test
            Assert.True(strValue.Equals(((Foo)hsh2[0]).strValue), "Error, Expected value not returned, " + strValue);

            //if we change the object, of course, the previous should not happen
            hsh2[0] = new Foo();

            strValue = "Good Bye";
            Assert.True(strValue.Equals(((Foo)hsh1[0]).strValue), "Error, Expected value not returned, " + strValue);

            strValue = "Hello World";
            Assert.True(strValue.Equals(((Foo)hsh2[0]).strValue), "Error, Expected value not returned, " + strValue);
        }
示例#3
0
		public static int LinerComplex(string str)
		{
			Hashtable T = new Hashtable () ;
			Hashtable B = new Hashtable () ;
			Hashtable C = new Hashtable () ;
			C .Add (0,1) ;
			B .Add (0,1) ;
			int m = -1 , N = 0 , L = 0 ; //上述步骤完成初始化
			while (N < str.Length )
			{ //计算离差
				int d = str [N ] == '0' ? 0 : 1 ;
				int i = 1 ;
				#region
				while (i <= L ) 
				{					
					if (C .ContainsKey (i ))
					{
						if (str [N-i ] == '1') 
							d += 1 ;  //则ci = 1 
					}
				    i++ ;
				}
				d = d % 2;
				if ( d ==1 ) 
				{
					T = (Hashtable )C.Clone() ;
					foreach (DictionaryEntry k in B )
					{
						if ((int )k .Value == 1)
						{
							int temp = (int )k .Key + N - m ;
							if (C .ContainsKey (temp ))
							{
								C .Remove (temp ) ;
							}
							else
							{
								C .Add (temp ,1 ) ;
							}
						}
					}
					if (L <= (int )Math .Floor (N *0.5) )
					{
						L = N +1 -L ;
						m = N ;
						B =(Hashtable ) T.Clone() ;
					}				
				}
				#endregion
//			    Console.Write("L = {0}  ;", L);
//                foreach (DictionaryEntry j in C )
//                {
//                    Console.Write( j.Key  +" ;");
//                }
//			    Console.WriteLine();
				N ++ ;
			}
			return L ;
		}
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="columnStyles">List of <see cref="DataGridColumnStyle"/> which are associated with <see cref="IGridFilter"/>s.</param>
        /// <param name="columnStylesToGridFiltersHash">Mapping between <see cref="DataGridColumnStyle"/> and <see cref="IGridFilter"/>s.</param>
        internal GridFilterCollection(IList columnStyles, Hashtable columnStylesToGridFiltersHash)
        {
            _columnStylesToGridFiltersHash = (Hashtable)columnStylesToGridFiltersHash.Clone();

            foreach (DataGridColumnStyle columnStyle in columnStyles)
            {
                IGridFilter gridFilter = (IGridFilter)_columnStylesToGridFiltersHash[columnStyle];
                if (gridFilter != null)
                    base.InnerList.Add(gridFilter);
            }
        }
示例#5
0
        private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
        {
            Debug.Assert(null != connectionOptions, "null connectionOptions");
            switch (behavior)
            {
                case KeyRestrictionBehavior.PreventUsage:
                case KeyRestrictionBehavior.AllowOnly:
                    _behavior = behavior;
                    break;
                default:
                    throw ADP.InvalidKeyRestrictionBehavior(behavior);
            }

            // grab all the parsed details from DbConnectionOptions
            _encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
            _hasPassword = connectionOptions._hasPasswordKeyword;
            _parsetable = connectionOptions.Parsetable;
            _keychain = connectionOptions._keyChain;

            // we do not want to serialize out user password unless directed so by "persist security info=true"
            // otherwise all instances of user's password will be replaced with "*"
            if (_hasPassword && !connectionOptions.HasPersistablePassword)
            {
                if (mustCloneDictionary)
                {
                    // clone the hashtable to replace user's password/pwd value with "*"
                    // we only need to clone if coming from DbConnectionOptions and password exists
                    _parsetable = (Hashtable)_parsetable.Clone();
                }

                // different than Everett in that instead of removing password/pwd from
                // the hashtable, we replace the value with '*'.  This is okay since we
                // serialize out with '*' so already knows what we do.  Better this way
                // than to treat password specially later on which causes problems.
                const string star = "*";
                if (_parsetable.ContainsKey(KEY.Password))
                {
                    _parsetable[KEY.Password] = star;
                }
                if (_parsetable.ContainsKey(KEY.Pwd))
                {
                    _parsetable[KEY.Pwd] = star;
                }

                // replace user's password/pwd value with "*" in the linked list and build a new string
                _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
            }

            if (!string.IsNullOrEmpty(restrictions))
            {
                _restrictionValues = ParseRestrictions(restrictions, synonyms);
                _restrictions = restrictions;
            }
        }
示例#6
0
 static public int Clone(IntPtr l)
 {
     try {
         System.Collections.Hashtable self = (System.Collections.Hashtable)checkSelf(l);
         var ret = self.Clone();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#7
0
        /// <summary>
        /// Sort the passed list of Joints so that parent joints allways come first
        /// </summary>
        /// <param name="joints"><see cref="Joints"/></param>
        /// <param name="relmap"><see cref="LoadJointRelationMap"/></param>
        /// <returns></returns>
        public static IntArrayList SortJoints(GmdcJoints joints, System.Collections.Hashtable relmap)
        {
            int start = -1;

            foreach (int k in relmap.Keys)
            {
                if ((int)relmap[k] == -1)
                {
                    start = k;
                    break;
                }
            }

            if (start != -1)
            {
                IntArrayList l = new IntArrayList();
                SortJointsRec(start, relmap, l);

                //check if there are some Joint's that were not added so far
                System.Collections.Hashtable nrelmap = (System.Collections.Hashtable)relmap.Clone();
                foreach (int v in l)
                {
                    if (nrelmap.ContainsKey(v))
                    {
                        nrelmap.Remove(v);
                    }
                }

                //recursivley process remaing joints
                if (nrelmap.Count > 0)
                {
                    IntArrayList l2 = SortJoints(joints, nrelmap);
                    foreach (int i in l2)
                    {
                        l.Add(i);
                    }
                }

                return(l);
            }

            IntArrayList ls = new IntArrayList();

            foreach (GmdcJoint j in joints)
            {
                ls.Add(j.Index);
            }

            return(ls);
        }
示例#8
0
        public void TestCloneBasic()
        {
            Hashtable hsh1;
            Hashtable hsh2;

            string strKey;
            string strValue;

            //[] empty Hashtable clone
            hsh1 = new Hashtable();
            hsh2 = (Hashtable)hsh1.Clone();

            Assert.Equal(0, hsh2.Count);
            Assert.False(hsh2.IsReadOnly, "Error, Expected value not returned, <<" + hsh1.IsReadOnly + ">> <<" + hsh2.IsReadOnly + ">>");
            Assert.False(hsh2.IsSynchronized, "Error, Expected value not returned, <<" + hsh1.IsSynchronized + ">> <<" + hsh2.IsSynchronized + ">>");

            //[] Clone should exactly replicate a collection to another object reference
            //afterwards these 2 should not hold the same object references
            hsh1 = new Hashtable();
            for (int i = 0; i < 10; i++)
            {
                strKey = "Key_" + i;
                strValue = "string_" + i;
                hsh1.Add(strKey, strValue);
            }

            hsh2 = (Hashtable)hsh1.Clone();
            for (int i = 0; i < 10; i++)
            {
                strValue = "string_" + i;

                Assert.True(strValue.Equals((string)hsh2["Key_" + i]), "Error, Expected value not returned, " + strValue);
            }

            //now we remove an object from the original list
            hsh1.Remove("Key_9");
            Assert.Equal(hsh1["Key_9"], null);

            strValue = "string_" + 9;
            Assert.True(strValue.Equals((string)hsh2["Key_9"]), "Error, Expected value not returned, <<" + hsh1[9] + ">>");

            //[]now we try other test cases
            //are all the 'other' properties of the Hashtable the same?
            hsh1 = new Hashtable(1000);
            hsh2 = (Hashtable)hsh1.Clone();

            Assert.Equal(hsh1.Count, hsh2.Count);
            Assert.Equal(hsh1.IsReadOnly, hsh2.IsReadOnly);
            Assert.Equal(hsh1.IsSynchronized, hsh2.IsSynchronized);
        }
 static int Clone(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Hashtable obj = (System.Collections.Hashtable)ToLua.CheckObject(L, 1, typeof(System.Collections.Hashtable));
         object o = obj.Clone();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        private void LinkReferencesRecursive(ModifierProtocol item, Hashtable ancestors)
        {
            Hashtable ht = (ancestors == null) ? new Hashtable() : (Hashtable) ancestors.Clone();

            if (ht.ContainsKey(item.Name))
            {
                throw new InvalidOperationException(String.Format(@"Circular reference to item '{0}'.", item.Name));
            }

            ht.Add(item.Name, item);

            foreach (RelationProtocol relation in item.Relations)
            {
                LinkRelation(item, relation, ht);
            }

            foreach (RelationProtocol relation in item.UniqueRelations)
            {
                LinkRelation(item, relation, ht);
            }
        }
示例#11
0
        internal static RtpSender CreateInstance(IRtpSession session, string name, PayloadType pt, 
            Hashtable priExns, ushort cDataPx, ushort cFecPx)
        {
            // Validate before adding to private extensions
            if(cFecPx == 0)
            {
                throw new ArgumentOutOfRangeException("cFecPx", cFecPx, "Must be >= 1");
            }

            // Add the relevant private extension for FEC
            Hashtable fecExns = null;
            
            if(priExns != null)
            {
                fecExns = (Hashtable)priExns.Clone();
            }
            else
            {
                fecExns = new Hashtable();
            }

            fecExns[Rtcp.PEP_FEC] = cDataPx.ToString() + ":" + cFecPx.ToString();

            // Call generic class factory
            return CreateInstance(session, name, pt, fecExns, null);
        }
		private void AssignUrlTokens(MenuNodeCollection objNodes, ref Hashtable objTokens, ref ArrayList objUsedTokens)
		{
			string strLastToken;
			if (objTokens == null)
			{
				GetUrlTokens(objNodes, ref objTokens);
			}
			foreach (MenuNode objNode in objNodes) {
				//look all nodes
				strLastToken = "";
				foreach (string strToken in ((Hashtable)objTokens.Clone()).Keys) {
					//loop all tokens (have to clone so we can modify real collection
					if (!String.IsNullOrEmpty(objNode.NavigateURL) && objNode.NavigateURL.IndexOf(strToken) > -1)
					{
						//if url contains token
						objTokens[strToken] = (int)objTokens[strToken] - 1;
						//remove token from count
						if (strToken.Length > strLastToken.Length && ((int)objTokens[strToken] > 0 || objUsedTokens.Contains(strToken)))
						{
							//if token is better and not only one with match
							strLastToken = strToken;
							//use it
						}
					}
				}
				if (!String.IsNullOrEmpty(strLastToken))
				{
					if (objUsedTokens.Contains(strLastToken) == false)
					{
						objUsedTokens.Add(strLastToken);
					}
					objNode.UrlIndex = objUsedTokens.IndexOf(strLastToken);
					objNode.NavigateURL = objNode.NavigateURL.Substring(strLastToken.Length);
				}
				AssignUrlTokens(objNode.MenuNodes, ref objTokens, ref objUsedTokens);
			}
		}
示例#13
0
 /// <summary>
 /// 将线段连成长线-即完整的轨迹线(反方向)
 /// </summary>
 /// <param name="nowRoulentable"></param>
 /// <param name="strStationAddress"></param>
 /// <returns></returns>
 private Hashtable RouteAppend1(Hashtable nowRoulentable, string strStationAddress)
 {
     Hashtable htNew = new Hashtable();
     htNew = (Hashtable)nowRoulentable.Clone();
     foreach (string strKey1 in nowRoulentable.Keys)
     {
         string[] strTemp1 = strKey1.Split(',');
         if (strTemp1[1].Equals(strStationAddress))
         {
             foreach (string strKey2 in nowRoulentable.Keys)
             {
                 if (!nowRoulentable[strKey1].Equals(nowRoulentable[strKey2]))
                 {
                     string[] strTemp2 = strKey2.Split(',');
                     #region [结尾相同处理]
                     if (strTemp1[1].Equals(strTemp2[1]) && strTemp1[1].Equals(strStationAddress))
                     {
                         if (Convert.ToDouble(strTemp1[0]) < Convert.ToDouble(strTemp2[0]))
                         {
                             RouteLength rl1 = (RouteLength)nowRoulentable[strKey1];
                             RouteLength rl2 = (RouteLength)nowRoulentable[strKey2];
                             string strKey4 = strTemp1[0] + "," + strTemp2[0];
                             if (!nowRoulentable.ContainsKey(strKey4))
                             {
                                 if (!htNew.ContainsKey(strKey4))
                                 {
                                     string[] strRouteTemps = rl2.RouteList.Split('|');
                                     string strRouteTemp = string.Empty;
                                     for (int i = strRouteTemps.Length - 1; i >= 0; i--)
                                     {
                                         strRouteTemp += "|" + strRouteTemps[i];
                                     }
                                     htNew[strKey4] = new RouteLength(rl1.RouteList + strRouteTemp, rl1.Length + rl2.Length);
                                 }
                                 else
                                 {
                                     RouteLength rl4 = (RouteLength)htNew[strKey4];
                                     if (rl4.Length > (rl1.Length + rl2.Length))
                                     {
                                         string[] strRouteTemps = rl2.RouteList.Split('|');
                                         string strRouteTemp = string.Empty;
                                         for (int i = strRouteTemps.Length - 1; i >= 0; i--)
                                         {
                                             strRouteTemp += "|" + strRouteTemps[i];
                                         }
                                         htNew[strKey4] = new RouteLength(rl1.RouteList + strRouteTemp, rl1.Length + rl2.Length);
                                     }
                                 }
                             }
                             else
                             {
                                 RouteLength rl5 = (RouteLength)nowRoulentable[strKey4];
                                 if (!htNew.ContainsKey(strKey4))
                                 {
                                     if (rl5.Length > (rl1.Length + rl2.Length))
                                     {
                                         string[] strRouteTemps = rl2.RouteList.Split('|');
                                         string strRouteTemp = string.Empty;
                                         for (int i = strRouteTemps.Length - 1; i >= 0; i--)
                                         {
                                             strRouteTemp += "|" + strRouteTemps[i];
                                         }
                                         htNew[strKey4] = new RouteLength(rl1.RouteList + strRouteTemp, rl1.Length + rl2.Length);
                                     }
                                     else
                                     {
                                         htNew[strKey4] = rl5;
                                     }
                                 }
                                 else
                                 {
                                     RouteLength rl6 = (RouteLength)htNew[strKey4];
                                     if (rl6.Length > (rl1.Length + rl2.Length))
                                     {
                                         string[] strRouteTemps = rl2.RouteList.Split('|');
                                         string strRouteTemp = string.Empty;
                                         for (int i = strRouteTemps.Length - 1; i >= 0; i--)
                                         {
                                             strRouteTemp += "|" + strRouteTemps[i];
                                         }
                                         htNew[strKey4] = new RouteLength(rl1.RouteList + strRouteTemp, rl1.Length + rl2.Length);
                                     }
                                 }
                             }
                         }
                     }
                     #endregion
                 }
             }
         }
     }
     return (Hashtable)htNew.Clone();
 }
示例#14
0
	/// <summary>
	/// Changes a GameObject's color values over time with FULL customization options.  If a GUIText or GUITexture component is attached, they will become the target of the animation.
	/// </summary>
	/// <param name="color">
	/// A <see cref="Color"/> to change the GameObject's color to.
	/// </param>
	/// <param name="r">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color red.
	/// </param>
	/// <param name="g">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
	/// </param>
	/// <param name="b">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
	/// </param>
	/// <param name="a">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the alpha.
	/// </param> 
	/// <param name="namedcolorvalue">
	/// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the individual setting of the alpha.
	/// </param> 
	/// <param name="includechildren">
	/// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
	/// </param>
	/// <param name="time">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
	/// </param>
	/// <param name="delay">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
	/// </param>
	/// <param name="easetype">
	/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
	/// </param>   
	/// <param name="looptype">
	/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
	/// </param>
	/// <param name="onstart">
	/// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
	/// </param>
	/// <param name="onstarttarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
	/// </param>
	/// <param name="onstartparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
	/// </param>
	/// <param name="onupdate"> 
	/// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
	/// </param>
	/// <param name="onupdatetarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
	/// </param>
	/// <param name="onupdateparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
	/// </param> 
	/// <param name="oncomplete">
	/// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
	/// </param>
	/// <param name="oncompletetarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
	/// </param>
	/// <param name="oncompleteparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
	/// </param>
	public static void ColorTo(GameObject target, Hashtable args){	
		//clean args:
		args = iTween.CleanArgs(args);
		
		//handle children:
		if(!args.Contains("includechildren") || (bool)args["includechildren"]){
			foreach(Transform child in target.transform){
				Hashtable argsCopy = (Hashtable)args.Clone();
				argsCopy["ischild"]=true;
				ColorTo(child.gameObject,argsCopy);
			}
		}
		
		//set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable:
		if (!args.Contains("easetype")) {
			args.Add("easetype",EaseType.linear);
		}
		
		//establish iTween:
		args["type"]="color";
		args["method"]="to";
		Launch(target,args);
	}	
示例#15
0
        static private string BuildAttributes(Hashtable subProps)
        {
            StringBuilder attributes = new StringBuilder();
            string preString = " ";
           
            Hashtable tmp = subProps.Clone() as Hashtable;

            IDictionaryEnumerator ide = tmp.GetEnumerator();
            while (ide.MoveNext())
            {
                string key = ide.Key as string;
                if (!(ide.Value is Hashtable))
                {
                    attributes.Append(preString).Append(key).Append("=").Append("\"").Append(ide.Value).Append("\"");
                    subProps.Remove(key);
                }
            }
            return attributes.ToString();
        }
示例#16
0
        private Hashtable k_means()
        {
            ObjectParameters[] medians = k_means_plus_plus(); /*new ObjectParameters[clustCount];*/
            Hashtable table = new Hashtable(clustCount);

            //Random random = new Random();
            for (int i = 0; i < clustCount; i++)
            {                
                table[i] = new List<int>();
            }
            
            Hashtable prevTable = null;
            while (true)
            {
                for(int i = 0; i < table.Count; i++)
                {
                    ((List<int>)table[i]).Clear();
                }


                // Для каждого объекта считаем расстояние до центров
                for (int i = 1; i < objects.Length; i++)
                {
                    if (isBadValue(objects[i]))
                        continue;

                    double[] distances = new double[clustCount];
                    for (int j = 0; j < clustCount; j++)
                        distances[j] = calculateDistance(objects[i], medians[j]);

                    int indexOfMin = Array.IndexOf(distances, distances.Min());
                    ((List<int>)table[indexOfMin]).Add(i);
                }

                if (prevTable != null)
                {
                    bool isSame = true;
                    for (int i = 0; i < table.Count; i++)
                    {
                        isSame = ((List<int>)table[i]).SequenceEqual((List<int>)prevTable[i]);
                        if (isSame == false)
                            break;
                    }
                    if (isSame == true)
                        break;
                }

                prevTable = (Hashtable)table.Clone();

                // Пересчитываем средние (центры масс) по всем кластерам
                for (int i = 0; i < clustCount; i++)
                {
                    /*int squareSum = 0, perimSum = 0;
                    double compactSum = 0, elongationSum = 0, orientSum = 0;
                    foreach (int numberOfObject in (List<int>)table[i])
                    {
                        squareSum += objects[numberOfObject].Square;
                        perimSum += objects[numberOfObject].Perimeter;
                        compactSum += objects[numberOfObject].Compactness;
                        elongationSum += objects[numberOfObject].elongation;
                     //   orientSum += objects[numberOfObject].OrientationOfMainAxis;
                    }
                    int count = ((List<int>)table[i]).Count();
                    if (count != 0)
                    {
                        // change here average value to median value
                        medians[i].Square = squareSum / count;
                        medians[i].Perimeter = perimSum / count;
                        medians[i].Compactness = compactSum / count;
                        medians[i].elongation = elongationSum / count;
                     //   medians[i].OrientationOfMainAxis = orientSum / count;
                    }*/

                    List<int> square = new List<int>();
                    List<int> perimeter = new List<int>();
                    List<double> compactness = new List<double>();
                    List<double> elongation = new List<double>();

                    foreach(int objectNumber in (List<int>)table[i])
                    {
                        square.Add(objects[objectNumber].Square);
                        perimeter.Add(objects[i].Perimeter);
                        compactness.Add(objects[i].Compactness);
                        elongation.Add(objects[i].elongation);
                    }

                    square.Sort();
                    perimeter.Sort();
                    compactness.Sort();
                    elongation.Sort();

                    int count = ((List<int>)table[i]).Count - 1;
                    //if (count % 2 == 1)
                    {
                        medians[i].Square = square[(count + 1) / 2];
                        medians[i].Perimeter = perimeter[(count + 1) / 2];
                        medians[i].Compactness = compactness[(count + 1) / 2];
                        medians[i].elongation = elongation[(count + 1) / 2];
                    }
                    //else
                    //{
                    //    int number = count / 2;

                    //    medians[i].Square = (square[number] + square[number - 1]) / 2;
                    //    medians[i].Perimeter = (perimeter[number] + perimeter[number - 1]) / 2;
                    //    medians[i].Compactness = (compactness[number] + compactness[number - 1]) / 2;
                    //    medians[i].elongation = (elongation[number] + elongation[number - 1]) / 2;
                    //}
                    
                }
            }
            return table;
        }
示例#17
0
 /// <summary>
 /// Used to define what keys will be used
 /// for what in-game actions.
 /// </summary>
 /// <param name="NewKeyTable"></param>
 /// <param name="CurrUserId"></param>
 public void SetKeyTable(System.Collections.Hashtable NewKeyTable, uint CurrUserId)
 {
     this.KeyTable[CurrUserId - 1] = new System.Collections.Hashtable();
     this.KeyTable[CurrUserId - 1] = (System.Collections.Hashtable)NewKeyTable.Clone();
 }
示例#18
0
        public void TestClonedHashtableSameAsOriginal()
        {
            string strKey;
            string strValue;

            //1) create a HT, add elements
            //2) create another HT out of the first
            //3) Remove elements from 2) and add
            //4) Clone 3)
            var hsh1 = new Hashtable();
            for (int i = 0; i < 10; i++)
            {
                strKey = "Key_" + i;
                strValue = "string_" + i;
                hsh1.Add(strKey, strValue);
            }

            var hsh2 = new Hashtable(hsh1);
            hsh2.Remove("Key_0");
            hsh2.Remove("Key_1");
            hsh2.Remove("Key_2");

            Assert.Equal(hsh2.Count, 7);
            hsh2["Key_10"] = "string_10";
            hsh2["Key_11"] = "string_11";
            hsh2["Key_12"] = "string_12";

            var hsh3 = (Hashtable)hsh2.Clone();

            Assert.Equal(10, hsh3.Count);

            for (int i = 3; i < 13; i++)
            {
                Assert.True(hsh3.Contains("Key_" + i));
                Assert.True(hsh3.ContainsKey("Key_" + i));
                Assert.True(hsh3.ContainsValue("string_" + i));
            }
        }
 public ObjectParser(Hashtable ControlList)
 {
     m_ControlList = (Hashtable)ControlList.Clone();
 }
 private SettingsPropertyValueCollection(Hashtable indices, ArrayList values)
 {
     this._Indices = (Hashtable) indices.Clone();
     this._Values = (ArrayList) values.Clone();
 }
示例#21
0
        /// <summary>
        /// 近一步对线进行优化
        /// </summary>
        /// <param name="rolenttable"></param>
        /// <param name="routelist"></param>
        /// <param name="route"></param>
        /// <param name="length"></param>
        /// <param name="lastFrom"></param>
        /// <param name="lastTo"></param>
        /// <param name="startfrom"></param>
        /// <param name="endTo"></param>
        /// <param name="pCount"></param>
        /// <returns></returns>
        private Hashtable SerachHashRoute(Hashtable rolenttable, Hashtable routelist, string route, int length, string lastFrom, string lastTo, string startfrom, string endTo,int pCount)
        {
            string newRoute = string.Empty;
            int newLength = 0;
            if (Convert.ToDouble(lastTo) <= Convert.ToDouble(endTo))
            {
                if (routelist.ContainsKey(lastTo + "," + endTo))
                {
                    RouteLength rtFisrt = (RouteLength)routelist[lastTo + "," + endTo];
                    string strFirstKey = lastFrom + "," + endTo;
                    if (!rolenttable.ContainsKey(strFirstKey))
                    {
                        if (string.IsNullOrEmpty(route))
                            route = rtFisrt.RouteList;
                        else
                            route = route + "|" + rtFisrt.RouteList;
                        length += rtFisrt.Length;
                        rolenttable[strFirstKey] = new RouteLength(route, length);
                    }
                    else
                    {
                        RouteLength rtFirstNewTemp = (RouteLength)rolenttable[strFirstKey];

                        if (rtFirstNewTemp.Length > (length + rtFisrt.Length))
                        {
                            if (string.IsNullOrEmpty(route))
                                route = rtFisrt.RouteList;
                            else
                                route = route + "|" + rtFisrt.RouteList;
                            length = length + rtFisrt.Length;
                            rolenttable[strFirstKey] = new RouteLength(route, length);
                        }
                    }

                }
                else
                {
                    if (string.IsNullOrEmpty(route))
                    {
                        foreach (string strKey in routelist.Keys)
                        {
                            string[] skeys = strKey.Split(',');
                            //该次线段的起始位置和上次的线段的结尾一致
                            if (skeys[0].Equals(lastTo))
                            {
                                newRoute = route;
                                newLength = length;
                                //获取两点间的线段
                                RouteLength rt = (RouteLength)routelist[strKey];
                                if (Convert.ToDouble(skeys[1]) > Convert.ToDouble(startfrom))
                                {
                                    //设置该次线段的键值
                                    string strKeyTemp = startfrom + "," + skeys[1];

                                    //临时路径表中不存在该路径
                                    if (!rolenttable.ContainsKey(strKeyTemp))
                                    {
                                        if (string.IsNullOrEmpty(newRoute))
                                            newRoute = rt.RouteList;
                                        else
                                            newRoute = newRoute + "|" + rt.RouteList;
                                        newLength += rt.Length;
                                        rolenttable[strKeyTemp] = new RouteLength(newRoute, newLength);
                                    }
                                    else//临时路径表中存在该路径
                                    {
                                        RouteLength rtNewTemp = (RouteLength)rolenttable[strKeyTemp];

                                        if (rtNewTemp.Length > (newLength + rt.Length))
                                        {
                                            if (string.IsNullOrEmpty(newRoute))
                                                newRoute = rt.RouteList;
                                            else
                                                newRoute = newRoute + "|" + rt.RouteList;
                                            newLength = newLength + rt.Length;
                                            rolenttable[strKeyTemp] = new RouteLength(newRoute, newLength);
                                        }
                                        else
                                        {
                                            if (string.IsNullOrEmpty(newRoute))
                                                newRoute = rtNewTemp.RouteList;
                                            else
                                                newRoute = newRoute + "|" + rtNewTemp.RouteList;
                                            newLength = newLength + rtNewTemp.Length;
                                        }

                                    }

                                    if (skeys[1].Equals(endTo) || Convert.ToDouble(skeys[1]) > Convert.ToDouble(endTo))
                                    {
                                        continue;
                                    }

                                    if (pCount >= 10)
                                        continue;

                                    SerachHashRoute(rolenttable, routelist, newRoute, newLength, skeys[0], skeys[1], startfrom, endTo,pCount);
                                }
                            }
                        }
                    }
                }
            }
            return (Hashtable)rolenttable.Clone();
        }
示例#22
0
        /// <summary>
        /// 获取站点
        /// </summary>
        /// <param name="hashStation"></param>
        /// <param name="stationlist"></param>
        /// <returns></returns>
        private Hashtable GetHashStation(Hashtable hashStation, List<ZzhaStation> stationlist, System.Windows.Forms.Form form, System.Windows.Forms.ProgressBar pgb, float step)
        {
            float value = step;
            Hashtable hashNewStation = new Hashtable();
            Hashtable haNewStationAddress = new Hashtable();
            haNewStationAddress = (Hashtable)hashStation.Clone();
            hashNewStation = (Hashtable)haNewStationAddress.Clone();
            for (int i = stationlist.Count - 1; i >= 0; i--)
            {
                for (int j = stationlist.Count - 1; j >= 0; j--)
                {
                    if (Convert.ToDouble(stationlist[j].StationAddressNum) > Convert.ToDouble(stationlist[i].StationAddressNum))
                    {
                        //路径列表中是否存在该路径,存在则下一个读卡分站的路径
                        if (hashNewStation.ContainsKey(stationlist[i].StationAddressNum + "," + stationlist[j].StationAddressNum))
                        {
                            continue;
                        }
                        haNewStationAddress = SerachHashRoute(hashNewStation, (Hashtable)haNewStationAddress.Clone(), "", 0, "", stationlist[i].StationAddressNum, stationlist[i].StationAddressNum, stationlist[j].StationAddressNum);
                    }
                    else
                    {
                        break;
                    }
                }
                //hashNewStation = RouteAppend1(hashNewStation, stationlist[i].StationAddressNum);
                //hashNewStation = RouteAppend(hashNewStation, stationlist[i].StationAddressNum);
                haNewStationAddress = (Hashtable)hashNewStation.Clone();


                if (i < (stationlist.Count - 2))
                {
                    value += step;
                    pgb.Value = Convert.ToInt32(value);
                }

            }

            for (int m = stationlist.Count - 1; m >= 0; m--)
            {
                hashNewStation = RouteAppend1((Hashtable)hashNewStation.Clone(), stationlist[m].StationAddressNum);
            }
            for (int n = stationlist.Count - 1; n >= 0; n--)
            {
                hashNewStation = RouteAppend((Hashtable)hashNewStation.Clone(), stationlist[n].StationAddressNum);
            }

            //Hashtable hasTemp = new Hashtable();
            //while (true)
            //{
            //    hasTemp = (Hashtable)hashNewStation.Clone();
            //    for (int m = stationlist.Count - 1; m >= 0; m--)
            //    {
            //        hashNewStation = RouteAppend1((Hashtable)hashNewStation.Clone(), stationlist[m].StationAddressNum);
            //    }
            //    for (int n = stationlist.Count - 1; n >= 0; n--)
            //    {
            //        hashNewStation = RouteAppend((Hashtable)hashNewStation.Clone(), stationlist[n].StationAddressNum);
            //    }
            //    if (hashNewStation.Count == hasTemp.Count)
            //    {
            //        break;
            //    }
            //}
            return hashNewStation;
        }
        public IAsyncResult BeginProcessRequest ( HttpContext context, AsyncCallback cb, object extraData ) {

            m_stopwatch.Start();

            FileInfo fileInfo = new FileInfo(context.Request.MapPath(context.Request.CurrentExecutionFilePath));
            this.LogDebug("File Date: {0}; File Length: {1}", fileInfo.LastWriteTimeUtc, fileInfo.Length);
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = false;
            m_httpContext = context;
            m_returnOutput = true;
            m_httpMethod = m_httpContext.Request.HttpMethod;
            m_memcachedClient = (Client)context.Application["memcached"];
            m_encoding = (UTF8Encoding)context.Application["encoding"];
            m_queueClient = (QueueClient)context.Application["queueclient"];
            m_hashkey = (string)context.Application["hashkey"];
            m_xmlServiceOperationManager = (XPathServiceOperationManager)context.Application["xmlServiceOperationManager"];
            m_xslTransformationManager = (XsltTransformationManager)context.Application["xslTransformationManager"];
            m_transform = m_xslTransformationManager.Transform;
            m_xsltParams = (Hashtable)context.Application["globalXsltParams"];
            m_transformContext = new Transform.Context(context, m_hashAlgorithm, (string)context.Application["hashkey"], fileInfo, (Hashtable)m_xsltParams.Clone(), fileInfo.LastWriteTimeUtc, fileInfo.Length);
            m_namedXsltHashtable = (Hashtable)context.Application["namedXsltHashtable"];
            m_xmlSourceETagDictionary = m_xmlServiceOperationManager.XmlSourceETagDictionary;
            m_xmlReaderDictionary = m_xmlServiceOperationManager.XmlReaderDictionary;
            m_context = new Context(context, m_hashAlgorithm, m_hashkey, fileInfo, fileInfo.LastWriteTimeUtc, fileInfo.Length);
            this.LogDebug("File Date: {0}; File Length: {1}", m_context.RequestXmlFileInfo.LastWriteTimeUtc, m_context.RequestXmlFileInfo.Length);
            m_nuxleusAsyncResult = new Nuxleus.Core.NuxleusAsyncResult(cb, extraData);
            m_callback = cb;
            m_nuxleusAsyncResult.m_context = context;
            m_builder = new StringBuilder();
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = (bool)context.Application["usememcached"];
            Uri requestUri = new Uri(m_context.RequestUri);
            m_requestHashcode = m_context.GetRequestHashcode(true).ToString();
            m_lastModifiedKey = String.Format("LastModified:{0}", m_context.RequestUri.GetHashCode());
            m_lastModifiedDate = String.Empty;
            m_request = new TransformRequest();
            m_response = new TransformResponse();
            Guid requestGuid = Guid.NewGuid();
            m_request.ID = requestGuid;

            
            context.Response.ContentType = "text/xml";

            IEnumerator headers = context.Request.Headers.GetEnumerator();
            for (int i = 0; headers.MoveNext(); i++) {
                string local = context.Request.Headers.AllKeys[i].ToString();
                this.LogDebug("KeyName: {0}, KeyValue: {1}", local, context.Request.Headers[local]);
            }
            bool hasXmlSourceChanged = m_xmlServiceOperationManager.HasXmlSourceChanged(m_context.RequestXmlETag, requestUri);

            //if (m_USE_MEMCACHED) {

            //    string obj = (string)m_memcachedClient.Get(m_context.GetRequestHashcode(true).ToString());

            //    if (obj != null && !hasXmlSourceChanged) {
            //        m_response.TransformResult = (string)obj;
            //        m_CONTENT_IS_MEMCACHED = true;
            //        if ((bool)context.Application["debug"]) {
            //            context.Response.ContentType = "text";
            //        }
            //    } else {
            //        //m_writer = new StringWriter(m_builder);
            //        m_CONTENT_IS_MEMCACHED = false;
            //    }
            //} else {
            //    m_writer = new StringWriter(m_builder);
            //}

            m_writer = new StringWriter(m_builder);

            try {

                switch (m_httpMethod) {
                    case "GET":
                    case "HEAD":
                    case "POST": {                     
                            string name = String.Format("Name: {0}", context.Request.QueryString["name"]);
                            this.LogDebug("QueryString Length: {0}", context.Request.QueryString.Count);
                            this.LogDebug(name);
                            this.LogDebug("If-None-Match: {0}, RequestHashCode: {1}", context.Request.Headers["If-None-Match"], m_requestHashcode);
                            this.LogDebug(context.Request.Path);
                            if (context.Request.Headers["If-None-Match"] == m_requestHashcode) {
                                object lastModified;
                                this.LogDebug("They matched.");
                                this.LogDebug("Use memcached: {0}, KeyExists: {1}, XmlSource Changed: {2}", m_USE_MEMCACHED, m_memcachedClient.TryGet(m_lastModifiedKey, out lastModified), hasXmlSourceChanged);
                                this.LogDebug("Last Modified Key Value: {0}", m_lastModifiedKey);
                                if (m_USE_MEMCACHED && m_memcachedClient.TryGet(m_lastModifiedKey, out lastModified) && !hasXmlSourceChanged)
                                {
                                    m_lastModifiedDate = (string)m_memcachedClient.Get(m_lastModifiedKey);
                                    this.LogDebug("Last Modified Date: {0}", m_lastModifiedDate);
                                    if (context.Request.Headers["If-Modified-Since"] == m_lastModifiedDate) {

                                        context.Response.StatusCode = 304;
                                        m_returnOutput = false;
                                        goto CompleteCall;
                                    } else {
                                        goto Process;
                                    }
                                } else if (m_CONTENT_IS_MEMCACHED) {
                                    goto CompleteCall;
                                } else {
                                    goto Process;
                                }
                            } else {
                                this.LogDebug("Headers do not match.  Beginning transformation process...");
                                m_returnOutput = true;
                                goto Process;
                            }
                        }
                    case "PUT": {
                            goto CompleteCall;
                        }
                    case "DELETE": {
                            goto CompleteCall;
                        }
                    default: {
                            goto CompleteCall;
                        }
                }

            } catch (Exception ex) {
                m_exception = ex;
                WriteError();
                goto CompleteCall;
            }
        Process:
            try {
                this.LogDebug("Processing Transformation");
                this.LogDebug("Request XML ETag Value: {0}, Request URI: {1}", m_context.RequestXmlETag, requestUri);

                XPathNavigator navigator = m_xmlServiceOperationManager.GetXPathNavigator(m_context.RequestXmlETag, requestUri);
                //if (initialReader == null) {
                //    initialReader = reader;
                //} else {
                //    this.LogDebug("XmlReaders are the same object: {0}", initialReader.Equals(reader));
                //}
                //this.LogDebug("XML Reader Value: {0}", reader.ReadOuterXml());
                //this.LogDebug("XML Reader Hash: {0}", reader.GetHashCode());
                XPathServiceOperationNavigator serviceOperationReader = new XPathServiceOperationNavigator(context, m_context, m_transformContext, navigator, m_request, m_response, m_xslTransformationManager);
                m_response = serviceOperationReader.Process();

            } catch (Exception e) {
                this.LogDebug("Error: {0} in transformation.", e.Message);
                m_exception = e;
                WriteError();
            }

            goto CompleteCall;

        CompleteCall:
            this.LogDebug("CompleteCall reached");
            if (m_lastModifiedDate == String.Empty) {
                m_lastModifiedDate = DateTime.UtcNow.ToString("r");
            }
            context.Response.AppendHeader("Cache-Control", "max-age=86400");
            context.Response.AddHeader("Last-Modified", m_lastModifiedDate);
            context.Response.AddHeader("ETag", String.Format("\"{0}\"", m_requestHashcode));
            m_nuxleusAsyncResult.CompleteCall();
            return m_nuxleusAsyncResult;
        }
示例#24
0
 // waits and retries if container is being deleted
 public BlobStorageResponse CreateContainer(string containername, bool is_public, Hashtable headers)
 {
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<BlobStorageResponse, Object>(CompletedIfContainerIsNotBeingDeleted);
     return GenUtils.Actions.Retry<BlobStorageResponse>(delegate() { return MaybeCreateContainer(containername, is_public, (Hashtable)headers.Clone()); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs);
 }
示例#25
0
            // ICloneable

            public override object Clone()
            {
                lock (host.SyncRoot) {
                    return(new SyncHashtable((Hashtable)host.Clone()));
                }
            }
示例#26
0
        /**********************VALIDACION VIN*****************************************/
        /// <summary>
        /// Verifica si el NIV introducido es valido
        /// </summary>
        public bool VerificaVIN(string p_strVin)
        {
            bool isValid;

            int intValue = 0;
            int[] intWeights = { 8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2 };

            if (p_strVin == null)
            {
                return isValid = false;
            }
            else if (p_strVin.Length != 17)
            {
                return isValid = false;
            }

            p_strVin = p_strVin.ToUpper().Trim();
            int intCheckValue = 0;
            char check = p_strVin[8];
            char year = p_strVin[9];
            char third = p_strVin[2];

            if (!char.IsDigit(check) && check != 'X')
            {
                return isValid = false;
            }
            else
            {
                if (check != 'X')
                {
                    char[] d = new char[] { check };
                    intCheckValue = int.Parse(Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(d)));
                }
                else
                {
                    intCheckValue = 10;
                }
            }

            Hashtable replaceValues = new Hashtable();
            replaceValues.Add('A', 1);
            replaceValues.Add('B', 2);
            replaceValues.Add('C', 3);
            replaceValues.Add('D', 4);
            replaceValues.Add('E', 5);
            replaceValues.Add('F', 6);
            replaceValues.Add('G', 7);
            replaceValues.Add('H', 8);
            replaceValues.Add('J', 1);
            replaceValues.Add('K', 2);
            replaceValues.Add('L', 3);
            replaceValues.Add('M', 4);
            replaceValues.Add('N', 5);
            replaceValues.Add('P', 7);
            replaceValues.Add('R', 9);
            replaceValues.Add('S', 2);
            replaceValues.Add('T', 3);
            replaceValues.Add('U', 4);
            replaceValues.Add('V', 5);
            replaceValues.Add('W', 6);
            replaceValues.Add('X', 7);
            replaceValues.Add('Y', 8);
            replaceValues.Add('Z', 9);
            replaceValues.Add('1', 1);
            replaceValues.Add('2', 2);
            replaceValues.Add('3', 3);
            replaceValues.Add('4', 4);
            replaceValues.Add('5', 5);
            replaceValues.Add('6', 6);
            replaceValues.Add('7', 7);
            replaceValues.Add('8', 8);
            replaceValues.Add('9', 9);
            replaceValues.Add('0', 0);

            //Make sure it is a Valid Year - Created the next 4 lines to correct U, Z & 0 from being in the list
            Hashtable yearValues = (Hashtable)replaceValues.Clone(); //Get a shallow copy of values
            yearValues.Remove('0');
            yearValues.Remove('Z');
            yearValues.Remove('U');
            if (!yearValues.Contains(year))
            {
                return isValid = false;
            }

            //Make sure characters that are in the VIN are the ones allowed.
            for (int i = 0; i < p_strVin.Length; i++)
            {
                if (!replaceValues.Contains(p_strVin[i]))
                {
                    return isValid = false;
                }
                else if (i > 13 && !char.IsDigit(p_strVin[i]) && third == '9')
                {
                    return isValid = false;
                }
                else if (i > 11 && !char.IsDigit(p_strVin[i]) && third != '9')
                {
                    return isValid = false;
                }

                intValue += (intWeights[i] * ((int)replaceValues[p_strVin[i]]));
            }

            if ((intValue % 11) == intCheckValue)
            {
                return isValid = true;
            }

            return isValid = false;
        }
示例#27
0
	public void TestClone() {
		{
			char[] c1 = {'a', 'b', 'c'};
			char[] c2 = {'d', 'e', 'f'};
			Hashtable h1 = new Hashtable();
			for (int i = 0; i < c1.Length; i++) {
				h1[c1[i]] = c2[i];
			}
			Hashtable h2 = (Hashtable)h1.Clone();
			Assert.IsNotNull (h2, "got no clone!");
			Assert.IsNotNull (h2[c1[0]], "clone's got nothing!");
			for (int i = 0; i < c1.Length; i++) {
				Assert.AreEqual (h1[c1[i]], h2[c1[i]], "Hashtable match");
			}
		}
		{
			char[] c1 = {'a', 'b', 'c'};
			char[] c20 = {'1', '2'};
			char[] c21 = {'3', '4'};
			char[] c22 = {'5', '6'};
			char[][] c2 = {c20, c21, c22};
			Hashtable h1 = new Hashtable();
			for (int i = 0; i < c1.Length; i++) {
				h1[c1[i]] = c2[i];
			}
			Hashtable h2 = (Hashtable)h1.Clone();
			Assert.IsNotNull (h2, "got no clone!");
			Assert.IsNotNull (h2[c1[0]], "clone's got nothing!");
			for (int i = 0; i < c1.Length; i++) {
				Assert.AreEqual (h1[c1[i]], h2[c1[i]], "Hashtable match");
			}

			((char[])h1[c1[0]])[0] = 'z';
			Assert.AreEqual (h1[c1[0]], h2[c1[0]], "shallow copy");

#if NET_2_0
			// NET 2.0 stuff
			MyEqualityComparer a = new MyEqualityComparer ();
			Hashtable mh1 = new Hashtable (a);
			Hashtable mh1clone = (Hashtable) mh1.Clone ();
			
			// warning, depends on the field name.
			Assert.AreEqual (GetEqualityComparer (mh1), GetEqualityComparer (mh1clone), "EqualityComparer");
#endif
		}
	}
        internal MainTagNameToTypeMapper(BaseTemplateParser parser) {
            _parser = parser;
            
            if (parser != null) {
                PagesSection pagesConfig = parser.PagesConfig;
                if (pagesConfig != null) {
                    // Clone it so we don't modify the config settings
                    _tagNamespaceRegisterEntries = pagesConfig.TagNamespaceRegisterEntriesInternal;
                    if (_tagNamespaceRegisterEntries != null) {
                        _tagNamespaceRegisterEntries = (TagNamespaceRegisterEntryTable)_tagNamespaceRegisterEntries.Clone();
                    }

                    _userControlRegisterEntries = pagesConfig.UserControlRegisterEntriesInternal;
                    if (_userControlRegisterEntries != null) {
                        _userControlRegisterEntries = (Hashtable)_userControlRegisterEntries.Clone();
                    }
                }

                // 



                if (parser.FInDesigner && (_tagNamespaceRegisterEntries == null)) {
                    _tagNamespaceRegisterEntries = new TagNamespaceRegisterEntryTable();

                    foreach (TagNamespaceRegisterEntry entry in PagesSection.DefaultTagNamespaceRegisterEntries) {
                        _tagNamespaceRegisterEntries[entry.TagPrefix] = new ArrayList(new object[] { entry });
                    }
                }
            }
        }
示例#29
0
        /// <summary>
        /// Adds key and value pairs to the cache. If any of the specified key already exists 
        /// in the cache; it is updated, otherwise a new item is added to the cache.
        /// </summary>
        /// <param name="keys">keys of the entry.</param>
        /// <param name="cacheEntries">the cache entries.</param>
        /// <returns>list of keys that failed to be added</returns>
        /// <remarks>
        /// This method either invokes <see cref="handleInsert"/> on any cluster node or invokes 
        /// <see cref="Local_Insert"/> locally. The choice of the server node is determined by the 
        /// <see cref="LoadBalancer"/>.
        /// <see cref="Local_Insert"/> triggers either <see cref="OnItemAdded"/> or <see cref="OnItemUpdated"/>, which
        /// in turn trigger either an item-added or item-updated cluster-wide notification.
        /// </remarks>
        public Hashtable Clustered_Insert(object[] keys, CacheEntry[] cacheEntries,  bool notify, OperationContext operationContext)
        {
            /// Wait until the object enters any running status

            Hashtable pEntries = null;

            pEntries = Get(keys, operationContext); //dont remove

            Hashtable existingItems;
            Hashtable jointTable = new Hashtable();
            Hashtable failedTable = new Hashtable();
            Hashtable insertable = new Hashtable();
            Hashtable insertResults = null;
            ArrayList inserted = new ArrayList();
            ArrayList added = new ArrayList();
            object[] validKeys;
            CacheEntry[] validEnteries;
            int index = 0;
            object key;


            for (int i = 0; i < keys.Length; i++)
            {
                jointTable.Add(keys[i], cacheEntries[i]);
            }

            Hashtable keyValTable = jointTable.Clone() as Hashtable;

            //if (jointTable.Count > 0)
            //{
            //    index = 0;
            //    validKeys = new object[jointTable.Count];
            //    validEnteries = new CacheEntry[jointTable.Count];

            //    IDictionaryEnumerator ide = jointTable.GetEnumerator();
            //    while (ide.MoveNext())
            //    {
            //        key = ide.Key;
            //        validKeys[index] = key;
            //        index += 1;
            //    }
            //}

            if (jointTable.Count > 0)
            {
                index = 0;
                validKeys = new object[jointTable.Count];
                validEnteries = new CacheEntry[jointTable.Count];
                IDictionaryEnumerator ide = jointTable.GetEnumerator();
                while (ide.MoveNext())
                {
                    key = ide.Key;
                    validKeys[index] = key;
                    validEnteries[index] = (CacheEntry)ide.Value;
                    added.Add(key);
                    index += 1;
                }
                //for (int i = 0; i < validKeys.Length; i++)
                //{
                //    key = validKeys[i];
                //    if (jointTable.Contains(key))
                //        jointTable.Remove(key);
                //}
                try
                {
                    insertResults = null;
                    if (validKeys.Length>0)
                      insertResults = Clustered_Insert(Cluster.Servers, validKeys, validEnteries,  operationContext);
                }
                catch (Exception e)
                {
                    Context.NCacheLog.Error("ReplicatedServerCacheBase.Insert(Keys)", e.ToString());
                    for (int i = 0; i < validKeys.Length; i++)
                    {
                        failedTable.Add(validKeys[i], e);
                        added.Remove(validKeys[i]);
                    }

                    Clustered_Remove(validKeys, ItemRemoveReason.Removed, null, false, operationContext);
                }


            }
            if (insertResults != null)
            {
                Hashtable failed = CacheHelper.CompileInsertResult(insertResults);
                IDictionaryEnumerator Ie = failed.GetEnumerator();
                while (Ie.MoveNext())
                    failedTable[Ie.Key] = Ie.Value;
             }
            return failedTable;
        }
示例#30
0
	/// <summary>
	/// Changes a GameObject's color values instantly then returns them to the provided properties over time with FULL customization options.  If a GUIText or GUITexture component is attached, it will become the target of the animation.
	/// </summary>
	/// <param name="color">
	/// A <see cref="Color"/> to change the GameObject's color to.
	/// </param>
	/// <param name="r">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color red.
	/// </param>
	/// <param name="g">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
	/// </param>
	/// <param name="b">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
	/// </param>
	/// <param name="a">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the alpha.
	/// </param> 
	/// <param name="namedcolorvalue">
	/// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the individual setting of the alpha.
	/// </param> 
	/// <param name="includechildren">
	/// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
	/// </param>
	/// <param name="time">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
	/// </param>
	/// <param name="delay">
	/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
	/// </param>
	/// <param name="easetype">
	/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
	/// </param>   
	/// <param name="looptype">
	/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
	/// </param>
	/// <param name="onstart">
	/// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
	/// </param>
	/// <param name="onstarttarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
	/// </param>
	/// <param name="onstartparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
	/// </param>
	/// <param name="onupdate"> 
	/// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
	/// </param>
	/// <param name="onupdatetarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
	/// </param>
	/// <param name="onupdateparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
	/// </param> 
	/// <param name="oncomplete">
	/// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
	/// </param>
	/// <param name="oncompletetarget">
	/// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
	/// </param>
	/// <param name="oncompleteparams">
	/// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
	/// </param>
	public static void ColorFrom(GameObject target, Hashtable args){	
		Color fromColor = new Color();
		Color tempColor = new Color();
		
		//clean args:
		args = iTween.CleanArgs(args);
		
		//handle children:
		if(!args.Contains("includechildren") || (bool)args["includechildren"]){
			foreach(Transform child in target.transform){
				Hashtable argsCopy = (Hashtable)args.Clone();
				argsCopy["ischild"]=true;
				ColorFrom(child.gameObject,argsCopy);
			}
		}
		
		//set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable:
		if (!args.Contains("easetype")) {
			args.Add("easetype",EaseType.linear);
		}
		
		//set tempColor and base fromColor:

		if(target.GetComponent<GUITexture>()){
				tempColor=fromColor=target.GetComponent<GUITexture>().color;	
		}else if(target.GetComponent<GUIText>()){
				tempColor=fromColor=target.GetComponent<GUIText>().material.color;
			}else if(target.GetComponent<Renderer>()){
				tempColor=fromColor=target.GetComponent<Renderer>().material.color;
			}else if(target.GetComponent<Light>()){
				tempColor=fromColor=target.GetComponent<Light>().color;
		}
		
		
		//set augmented fromColor:
		if(args.Contains("color")){
			fromColor=(Color)args["color"];
		}else{
			if (args.Contains("r")) {
				fromColor.r=(float)args["r"];
			}
			if (args.Contains("g")) {
				fromColor.g=(float)args["g"];
			}
			if (args.Contains("b")) {
				fromColor.b=(float)args["b"];
			}
			if (args.Contains("a")) {
				fromColor.a=(float)args["a"];
			}
		}
		
		//alpha or amount?
		if(args.Contains("amount")){
			fromColor.a=(float)args["amount"];
			args.Remove("amount");
		}else if(args.Contains("alpha")){
			fromColor.a=(float)args["alpha"];
			args.Remove("alpha");
		}
		
		//apply fromColor:

		if(target.GetComponent<GUITexture>()){
				target.GetComponent<GUITexture>().color=fromColor;	
		}else if(target.GetComponent<GUIText>()){
				target.GetComponent<GUIText>().material.color=fromColor;
			}else if(target.GetComponent<Renderer>()){
				target.GetComponent<Renderer>().material.color=fromColor;
			}else if(target.GetComponent<Light>()){
				target.GetComponent<Light>().color=fromColor;
		}
		
		
		//set new color arg:
		args["color"]=tempColor;
		
		//establish iTween:
		args["type"]="color";
		args["method"]="to";
		Launch(target,args);
	}		
示例#31
0
		/// <summary>Called by Configurator. Removes 2 properties which are used by the Protocol directly and then
		/// calls setProperties(), which might invoke the setProperties() method of the actual protocol instance.
		/// </summary>
		public virtual bool setPropertiesInternal(Hashtable props)
		{
			this.props = (Hashtable)props.Clone();
			
			if (props.Contains("down_thread"))
			{
				down_thread = Convert.ToBoolean(props["down_thread"]);
				props.Remove("down_thread");
			}
			if (props.Contains("down_thread_prio"))
			{
				down_thread_prio = Convert.ToInt32(props["down_thread_prio"]);
				props.Remove("down_thread_prio");
			}
			if (props.Contains("up_thread"))
			{
				up_thread = Convert.ToBoolean(props["up_thread"]);
				props.Remove("up_thread");
			}
			if (props.Contains("up_thread_prio"))
			{
				up_thread_prio = Convert.ToInt32(props["up_thread_prio"]);
				props.Remove("up_thread_prio");
			}

            if (System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.EnableDebuggingCounters"] != null)
            {
                enableMonitoring = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.EnableDebuggingCounters"]);
            }

            if (System.Configuration.ConfigurationSettings.AppSettings["useAvgStats"] != null)
            {
                useAvgStats = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["useAvgStats"]);
            }

			return setProperties(props);
		}
示例#32
0
    // Get default settings from config
    internal virtual void ProcessConfigSettings() {
        if (_compConfig != null) {
            flags[useExplicit] = _compConfig.Explicit;
            flags[strict] = _compConfig.Strict;
        }

        if (PagesConfig != null) {
            _namespaceEntries = PagesConfig.Namespaces.NamespaceEntries;

            // Clone it so we don't modify the config settings
            if (_namespaceEntries != null)
                _namespaceEntries = (Hashtable) _namespaceEntries.Clone();

            if (!flags[ignoreParserFilter]) {
                // Check if a filter is registered, and if so initialize it
                _pageParserFilter = PageParserFilter.Create(PagesConfig, CurrentVirtualPath, this);
            }
        }
    }
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 private ProviderCollection(Hashtable h)
 {
     _Hashtable = (Hashtable)h.Clone();
 }
示例#34
0
 public static ConfigNode CreateIndirect(string name, Hashtable values)
 {
     ConfigNode n = new ConfigNode(name);
     n._data = (Hashtable)values.Clone();
     return n;
 }
示例#35
0
        public void TestCanCastClonedHashtableToInterfaces()
        {
            ICollection icol1;
            IDictionary idic1;
            Hashtable iclone1;

            //[]we try to cast the returned object from Clone() to different types
            var hsh1 = new Hashtable();

            icol1 = (ICollection)hsh1.Clone();
            Assert.Equal(hsh1.Count, icol1.Count);

            idic1 = (IDictionary)hsh1.Clone();
            Assert.Equal(hsh1.Count, idic1.Count);

            iclone1 = (Hashtable)hsh1.Clone();
            Assert.Equal(hsh1.Count, iclone1.Count);
        }