Example #1
0
        /// <summary>
        /// Starts tracking the provided Popup.
        /// </summary>
        /// <param name="popup">The Popup to be tracked.</param>
        public static void Track(System.Windows.Controls.Primitives.Popup popup)
        {
            if (popup == null)
                throw new ArgumentNullException("popup");

            if (!s_popups.ContainsKey(popup.GetHashCode()))
                s_popups.Add(popup.GetHashCode(), new WeakReference(popup));
        }
        public static object Invoke(System.Windows.Forms.Control obj, string methodName, params object[] paramValues)
        {
            Delegate del = null;
            DateTime now  = DateTime.Now;
            TimeSpan ts = now - lastCleanTime;
            if(ts.TotalHours>5)
            {
                delLookup.Clear();
                lastCleanTime = now;
            }
            string delKey = obj.GetType().Name+"."+methodName+obj.GetHashCode().ToString() + obj.ToString();
            if(delLookup.ContainsKey(delKey))
            {
                del =(Delegate) delLookup[delKey];
            }
            else
            {
                string key = obj.GetType().Name + "." + methodName;
                Type tp;
                if (methodLookup.Contains(key))
                {
                    tp = (Type)methodLookup[key];
                }
                else
                {
                    Type objType = obj.GetType();
                    object[] signatures = new object[paramValues.Length + 1];
                    signatures[0] = methodName;
                    Array.Copy(paramValues, 0, signatures, 1, paramValues.Length);
                    MemberInfo[] mInfo = objType.FindMembers(MemberTypes.Method, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, methodFilter, signatures);
                    if (mInfo.Length != 1) return null;
                    MethodInfo methInfo = (MethodInfo)mInfo[0];
                    Type[] paramList = new Type[methInfo.GetParameters().Length];
                    ParameterInfo[] paramInfos = methInfo.GetParameters();
                    int n = 0;
                    foreach (ParameterInfo pi in paramInfos)
                    {
                        paramList[n++] = pi.ParameterType;
                    }
                    TypeBuilder typeB = builder.DefineType("Del_" +
                        obj.GetType().Name + "_" + methodName,
                        TypeAttributes.Class | TypeAttributes.AutoLayout | TypeAttributes.Public | TypeAttributes.Sealed,
                        typeof(MulticastDelegate), PackingSize.Unspecified);
                    ConstructorBuilder conB = typeB.DefineConstructor(MethodAttributes.HideBySig | MethodAttributes.SpecialName
                        | MethodAttributes.RTSpecialName, CallingConventions.Standard,
                        new Type[] { typeof(object), typeof(IntPtr) });
                    conB.SetImplementationFlags(MethodImplAttributes.Runtime);
                    MethodBuilder mb = typeB.DefineMethod("Invoke",
                        MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                        methInfo.ReturnType, paramList);
                    mb.SetImplementationFlags(MethodImplAttributes.Runtime);
                    tp = typeB.CreateType();
                    methodLookup.Add(key, tp);
                }
                del = MulticastDelegate.CreateDelegate(tp, obj, methodName);
                delLookup.Add(delKey, del);
            }

            return obj.Invoke(del, paramValues);
        }
	static int Main ()
	{
		var v1 = new { Name = "Scott", Age = 21 };
		var v2 = new { Age = 20, Name = "Sam" };
		var v3 = new { Name = Null (), Age = 33 };
		
		if (v1.GetType () == v2.GetType ())
			return 1;
			
		if (v1.Equals (v2))
			return 2;
			
		if (v1.GetType () != v3.GetType ())
			return 3;
			
		if (!v1.Equals (v1))
			return 4;
					
		if (v1.GetHashCode () != v1.GetHashCode ())
			return 5;
		
		Console.WriteLine (v1);
		Console.WriteLine (v3);
		
		if (v1.ToString () != "{ Name = Scott, Age = 21 }")
			return 6;
			
		if (v3.ToString () != "{ Name = , Age = 33 }")
			return 7;

		var v4 = new {};

		if (v4.ToString () != "{ }")
			return 8;

		var v5 = new { Foo = "Bar" };
		var v6 = new { Foo = Null () };

		if (v5.ToString () != "{ Foo = Bar }")
			return 9;

		if (v6.ToString () != "{ Foo =  }")
			return 10;

		return 0;
	}
 public void Add(System.Action action, string message="")
 {
     if(action != null)
     {
         int hash = action.GetHashCode();
         if(!queue.Exists(x=>x.GetHashCode()==hash))
         {
             queue.Add(new stateAction(action, message));
         }
     }
 }
 public void Add(System.Action<object> action, object state, string message="")
 {
     if(action != null)
     {
         int hash = action.GetHashCode() + (state != null ? state.GetHashCode() : 0);
         if(!queue.Exists(x=>x.GetHashCode()==hash))
         {
             queue.Add(new stateAction(action, state, message));
         }
     }
 }
Example #6
0
        protected override int getConcreteHash()
        {
            var anonomousType = new
            {
                f1 = Quality,
                f2 = this.Requirements != null ? string.Join(string.Empty, this.Requirements.Select(r => string.Concat(r.Name, r.Value)).ToArray()) : string.Empty,
                f3 = Color,
                f4 = Socket
            };

            return anonomousType.GetHashCode();
        }
Example #7
0
    /// <summary>
    /// 注册无参事件
    /// </summary>
    /// <param name="clip">动画片</param>
    /// <param name="time">事件</param>
    /// <param name="onAnimEvent">回调</param>
    public void AddAnimEvent(AnimationClip clip, float time, System.Action onAnimEvent)
    {
        AnimationEvent animEvent = new AnimationEvent();
        //固定一个事件方法,就不需要对每个事件都写一个
        animEvent.functionName = "OnAnimEvent";
        animEvent.time = time;
        animEvent.messageOptions = SendMessageOptions.RequireReceiver;
        //用hash码记录是哪一个回调函数,还没想到更好的方法
        animEvent.intParameter = onAnimEvent.GetHashCode();

        if (!onAnimEventDic.ContainsKey(animEvent.intParameter))
        {
            onAnimEventDic.Add(animEvent.intParameter, onAnimEvent);
        }

        clip.AddEvent(animEvent);
    }
Example #8
0
 /// <summary>
 /// 对 本结点(xNode) 的 Namespace 注册
 /// </summary>
 /// <param name="xNode">含有或继承有命名空间的结点</param>
 /// <param name="xNameSpaceManager">命名空间管理器</param>
 /// <returns>返回该 Namespace 的 prefix</returns>
 public static string AutoPrefix(System.Xml.XmlNode xNode, System.Xml.XmlNamespaceManager xNameSpaceManager)
 {
     string xPrefix;
     if (xNode.NamespaceURI == string.Empty)
     {
         return string.Empty;
     }
     else
     {
         xPrefix = xNameSpaceManager.LookupPrefix(xNode.NamespaceURI);
         if (xPrefix == null || xPrefix == string.Empty)
         {
             xPrefix = "x" + xNode.GetHashCode().ToString();
             xNameSpaceManager.AddNamespace(xPrefix, xNode.NamespaceURI);
         }
         return xPrefix + (xPrefix.Length > 0 ? ":" : "");
     }
 }
Example #9
0
    public void AddAnimEvent(object obj, AnimationClip clip, float time, System.Action<object> onAnimEventObj)
    {
        AnimationEvent animEvent = new AnimationEvent();
        animEvent.functionName = "OnAnimEventParam";
        animEvent.time = time;
        animEvent.messageOptions = SendMessageOptions.RequireReceiver;
        //用hash码记录回调函数
        animEvent.intParameter = onAnimEventObj.GetHashCode();

        if (!onAnimEventObjDic.ContainsKey(animEvent.intParameter))
        {
            onAnimEventObjDic.Add(animEvent.intParameter, onAnimEventObj);
        }
        if (!paramDic.ContainsKey(animEvent.intParameter))
        {
            paramDic.Add(animEvent.intParameter, obj);
        }

        clip.AddEvent(animEvent);
    }
		public ProxyCacheEntry(System.Type baseType, System.Type[] interfaces)
		{
			if (baseType == null)
			{
				throw new ArgumentNullException("baseType");
			}
			BaseType = baseType;
			Interfaces = interfaces ?? new System.Type[0];

			if (Interfaces.Length == 0)
			{
				hashCode = baseType.GetHashCode();
				return;
			}

			// duplicated type exclusion
			var set = new HashSet<System.Type>(Interfaces) { baseType };
			hashCode = 59;
			foreach (System.Type type in set)
			{
				hashCode ^= type.GetHashCode();
			}
		}
	// @Override
	public override System.String Intern(System.String s)
	{
		int h = s.GetHashCode();
		// In the future, it may be worth augmenting the string hash
		// if the lower bits need better distribution.
		int slot = h & (cache.Length - 1);
		
		Entry first = this.cache[slot];
		Entry nextToLast = null;
		
		int chainLength = 0;
		
		for (Entry e = first; e != null; e = e.next)
		{
               if (e.hash == h && (ReferenceEquals(e.str, s) || String.CompareOrdinal(e.str, s) == 0))
			{
				// if (e.str == s || (e.hash == h && e.str.compareTo(s)==0)) {
				return e.str;
			}
			
			chainLength++;
			if (e.next != null)
			{
				nextToLast = e;
			}
		}
		
		// insertion-order cache: add new entry at head
		s = String.Intern(s);
		this.cache[slot] = new Entry(s, h, first);
		if (chainLength >= maxChainLength)
		{
			// prune last entry
			nextToLast.next = null;
		}
		return s;
	}
Example #12
0
	/** Unschedules all selectors and blocks for a given target.
	 This also includes the "update" selector.
	 @since v0.99.3
	 */
	public void unscheduleAllForTarget(System.Object target)
	{
		// explicit nil handling
		if( target == null )
			return;
		
		// Custom Selectors
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT(target.GetHashCode());
		
		if( element != null) {
			if(element.timers.Contains(element.currentTimer) && !element.currentTimerSalvaged ) {
				element.currentTimerSalvaged = true;
			}
			element.timers.Clear();
			if( currentTarget == element )
				currentTargetSalvaged = true;
			else
				removeHashElement(element);
		}
		
		// Update Selector
		unscheduleUpdateForTarget(target);
	}
Example #13
0
	/** Unschedules the update selector for a given target
	 @since v0.99.3
	 */
	public void unscheduleUpdateForTarget(System.Object target){
		if(target == null)
			return;
		tHashUpdateEntry element = hashForUpdates.HASH_FIND_INT (target.GetHashCode());
		if (element != null) {
			if(updateHashLocked)
				element.entry.obj.markedForDeletion = true;
			else
				removeUpdatesFromHash(element.entry);
		}
	}
Example #14
0
		/** Schedules the 'update' selector for a given target with a given priority.
		 The 'update' selector will be called every frame.
		 The lower the priority, the earlier it is called.
		 @since v0.99.3
		 */
		public void scheduleUpdate(System.Object target, int priority, bool paused){
			tHashUpdateEntry hashElement = hashForUpdates.HASH_FIND_INT(target.GetHashCode());
			if (hashElement!=null) {
				if(CCDebug.COCOS2D_DEBUG>=1)
					NSUtils.Assert(hashElement.entry.obj.markedForDeletion, "CCScheduler: You can't re-schedule an 'update' selector'. Unschedule it first");			

				// TODO : check if priority has changed!
				hashElement.entry.obj.markedForDeletion = false;
				return;
			}
			
			
			// most of the updates are going to be 0, that's way there
			// is an special list for updates with priority 0
			if (priority == 0){
				appendIn (updates0, target, paused);
			}
			else if (priority < 0)
				priorityIn (updatesNeg, target, priority, paused);
			else // priority > 0
				priorityIn (updatesPos, target, priority, paused);
		}
Example #15
0
		void appendIn(utList<tListEntry> list, System.Object target, bool paused){
			tListEntry listEntry = new tListEntry ();
			listEntry.target = target;
			listEntry.paused = paused;
			listEntry.markedForDeletion = false;
			MethodInfo method = target.GetType ().GetMethod (updateSelector);
			listEntry.impMethod = (TICK_IMP) Delegate.CreateDelegate(typeof(TICK_IMP), target, method);
			
			utNode<tListEntry> listElement = new utNode<tListEntry> ();
			listElement.next = listElement.prev = null;
			listElement.obj = listEntry;

			list.DL_APPEND(listElement);
			
			tHashUpdateEntry hashElement = new tHashUpdateEntry ();
			hashElement.target = target;
			hashElement.list = list;
			hashElement.entry = listElement;
			hashForUpdates.HASH_ADD_INT (target.GetHashCode(), hashElement);
		}
        public void CreateObject_GetHashCode_SameAsRealAnonymousObject()
        {
            var objA = AnonymousTypeUtils.CreateObject(new Dictionary<string, object>
            {
                { "a", 1 },
                { "b", "test" },
                { "c", new DateTime(2014, 1, 1) },
            });
            var objB = new {
                a = 1,
                b = "test",
                c = new DateTime(2014, 1, 1)
            };

            Assert.AreNotSame(objA, objB);
            Assert.AreEqual(objA.GetHashCode(), objB.GetHashCode());
        }
Example #17
0
 /// <summary>
 /// Adds the date time.
 /// </summary>
 /// <param name="dt">The dt.</param>
 public void AddDateTime(System.DateTime dt)
 {
     AddInt(dt.GetHashCode());
 }
Example #18
0
	/** Pauses the target.
	 All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
	 If the target is not present, nothing happens.
	 @since v0.99.3
	 */
	public void pauseTarget(System.Object target){
		NSUtils.Assert (target != null, "target must be non nil");		
		
		// Custom selectors
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT (target.GetHashCode());
		if (element != null)
			element.paused = true;
		
		// Update selector
		tHashUpdateEntry elementUpdate = hashForUpdates.HASH_FIND_INT (target.GetHashCode());
		if (elementUpdate != null) {
			NSUtils.Assert(elementUpdate.entry != null, "pauseTarget: unknown error");
			elementUpdate.entry.obj.paused = true;
		}
	}
Example #19
0
        /*
        /// <summary>
        /// Returns localized week number
        /// </summary>
        /// <param name="dayOfWeek"></param>
        /// <returns></returns>
        internal static int LocalizedDayOfWeek(System.DayOfWeek dayOfWeek)
        {
            // Old way with auto detect based on localization
             int day = dayOfWeek.GetHashCode() - System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek.GetHashCode();
            // New settings based on setting selected for control
            // int day = dayOfWeek.GetHashCode() - System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek.GetHashCode();

            if(day<0)
                day+=7;

            return day;
        }
        */
        /// <summary>
        /// Returns localized week number
        /// </summary>
        /// <param name="dayOfWeek"></param>
        /// <returns></returns>
        public static int LocalizedDayOfWeek(System.DayOfWeek dayOfWeek, CalendarDayOfWeek firstDayOfWeek)
        {
            // New settings based on setting selected for control
            int day = dayOfWeek.GetHashCode() - GetDayOfWeek(firstDayOfWeek).GetHashCode();

            if(day<0)
                day+=7;

            return day;
        }
 private string ResolveConflict(string name, System.Type returnType, out bool fOverride, out bool fUseNew)
 {
     fOverride = false;
     fUseNew = false;
     string str = "";
     try
     {
         if (axHostPropDescs == null)
         {
             axHostPropDescs = new Hashtable();
             foreach (PropertyInfo info in typeof(AxHost).GetProperties())
             {
                 string key = info.Name + info.PropertyType.GetHashCode();
                 if (!axHostPropDescs.Contains(key))
                 {
                     axHostPropDescs.Add(key, info);
                 }
             }
         }
         PropertyInfo info2 = (PropertyInfo) axHostPropDescs[name + returnType.GetHashCode()];
         if (info2 != null)
         {
             if (returnType.Equals(info2.PropertyType))
             {
                 if (info2.CanRead ? info2.GetGetMethod().IsVirtual : false)
                 {
                     fOverride = true;
                     return str;
                 }
                 fUseNew = true;
                 return str;
             }
             return "Ctl";
         }
         if (this.AxHostMembers.Contains(name) || this.ConflictableThings.Contains(name))
         {
             return "Ctl";
         }
         if (!name.StartsWith("get_") && !name.StartsWith("set_"))
         {
             return str;
         }
         if (TypeDescriptor.GetProperties(typeof(AxHost))[name.Substring(4)] != null)
         {
             str = "Ctl";
         }
     }
     catch (AmbiguousMatchException)
     {
         str = "Ctl";
     }
     return str;
 }
Example #21
0
	/** Returns whether or not the target is paused
	 @since v1.0.0
	 */
	public bool isTargetPaused(System.Object target){
		NSUtils.Assert( target != null, "target must be non nil" );
		
		// Custom selectors
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT(target.GetHashCode());
		if( element != null)
			return element.paused;
		
		// We should check update selectors if target does not have custom selectors
		tHashUpdateEntry elementUpdate = hashForUpdates.HASH_FIND_INT(target.GetHashCode());
		if ( elementUpdate != null)
			return elementUpdate.entry.obj.paused;
		
		return false;  // should never get here
	}
Example #22
0
		/** The scheduled method will be called every 'interval' seconds.
		 If paused is YES, then it won't be called until it is resumed.
		 If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
		 If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
		 repeat lets the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously
		 delay is the amount of time the action will wait before it'll start

		 @since v0.99.3, repeat and delay added in v1.1
		 */
		public void schedule(TICK_IMP selector, System.Object target, float interval, uint repeat, bool paused, float delay=0){
			NSUtils.Assert( selector != null, "Argument selector must be non-nil");
			NSUtils.Assert( target != null, "Argument target must be non-nil");

			tHashTimerEntry element = hashForTimers.HASH_FIND_INT(target.GetHashCode());
			if (element == null) {
				element = new tHashTimerEntry ();
				element.target = target;
				hashForTimers.HASH_ADD_INT(target.GetHashCode(), element);

				// Is this the 1st element ? Then set the pause level to all the selectors of this target
				element.paused = paused;
			} else 
				NSUtils.Assert( element.paused == paused, "CCScheduler. Trying to schedule a selector with a pause value different than the target");


			if (element.timers == null)
				element.timers = new List<CCTimer> (10);
			else {
				var enumerator = element.timers.GetEnumerator();
				while (enumerator.MoveNext()) {
					CCTimer timer = enumerator.Current;
					if(timer is CCTimerTargetSelector && selector == ((CCTimerTargetSelector)timer).selector){
						CCDebug.Log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: {0:0.0000} to {1:0.0000}", timer.interval, interval);
						timer.interval = interval;
						return;
					}
				}
			}
			CCTimerTargetSelector timerSelector = new CCTimerTargetSelector(target, selector, interval, repeat, delay);
			element.timers.Add(timerSelector);
		}
Example #23
0
        protected int getHash()
        {
            var anonomousType = new
            {
                f = this.IconURL,
                f1 = this.League,
                f2 = this.Name,
                f3 = this.TypeLine,
                f4 = this.DescrText,
                f5 = this.Explicitmods != null ? string.Join(string.Empty, this.Explicitmods.ToArray()) : string.Empty,
                f6 = this.Properties != null ? string.Join(string.Empty, this.Properties.Select(p => string.Concat(p.DisplayMode, p.Name, string.Join(string.Empty, p.Values.Select(t => string.Concat(t.Item1, t.Item2)).ToArray()))).ToArray()) : string.Empty,
                f7 = getConcreteHash()
            };

            return anonomousType.GetHashCode();
        }
Example #24
0
	public void scheduleBlockForKey(string key, System.Object owner, float interval, uint repeat, float delay, bool paused, TICK_IMP block)
	{
		NSUtils.Assert( block != null, "Argument block must be non-nil");
		NSUtils.Assert( owner != null, "Argument owner must be non-nil");
		
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT(owner.GetHashCode());
		
		if (element == null) {
			element = new tHashTimerEntry ();
			element.target = owner;
			hashForTimers.HASH_ADD_INT(owner.GetHashCode(), element);
			
			// Is this the 1st element ? Then set the pause level to all the selectors of this target
			element.paused = paused;
			
		} else
			NSUtils.Assert( element.paused == paused, "CCScheduler. Trying to schedule a block with a pause value different than the target");
		
		
		if (element.timers == null)
			element.timers = new List<CCTimer> (10);
		else
		{
			var enumerator = element.timers.GetEnumerator();
			while (enumerator.MoveNext()) {
				CCTimer timer = enumerator.Current;
				if(timer is CCTimerBlock  && key == ((CCTimerBlock)timer).key) {
					CCDebug.Log("CCScheduler#scheduleBlock. Block already scheduled. Updating interval from: {0:0.0000} to {1:0.0000}", timer.interval, interval);
					timer.interval = interval;
					return;
				}
			}
		}
		
		CCTimerBlock timerBlock = new CCTimerBlock(owner, interval, key, block, repeat, delay);
		element.timers.Add(timerBlock);
	}
        public void GetHashCode_ForEqualObjects_ReturnsTheSame()
        {
            CoolMatrix matrixA = new[,]
            {
                {1, 2},
                {3, 4}
            };

            CoolMatrix matrixB = new[,]
            {
                {1, 2},
                {3, 4}
            };

            Assert.AreEqual(matrixA, matrixB);
            Assert.AreEqual(matrixA.GetHashCode(), matrixB.GetHashCode());
        }
Example #26
0
	/** Unshedules a selector for a given target.
	 If you want to unschedule the "update", use unscheudleUpdateForTarget.
	 @since v0.99.3
	 */
	public void unscheduleSelector(TICK_IMP selector, System.Object target){
		if (target==null && selector == null) {
			return;			
		}
		
		NSUtils.Assert( target != null, "Target MUST not be nil");
		NSUtils.Assert( selector != null, "Selector MUST not be NULL");
		
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT (target.GetHashCode());
		if (element != null) {
			int timersCount = element.timers.Count;
			for(int i=0; i< timersCount; i++ ) {
				CCTimer timer = element.timers[i];
				if(timer is CCTimerTargetSelector && selector == ((CCTimerTargetSelector)timer).selector){
					if(timer == element.currentTimer && !element.currentTimerSalvaged){
						element.currentTimerSalvaged = true;
					}
					element.timers.RemoveAt(i);
					if(element.timerIndex >= i)
						element.timerIndex --;
					if(element.timers.Count == 0){
						if(currentTarget == element)
							currentTargetSalvaged = true;
						else 
							removeHashElement(element);
					}
					return;
				}
			}
		}
		
		// Not Found
		//	NSLog(@"CCScheduler#unscheduleSelector:forTarget: selector not found: %@", selString);
	}
Example #27
0
 /// <summary>
 /// Construct a group from a set of image capabilities for your device
 /// </summary>
 /// <param name="width">The width of the device</param>
 /// <param name="height">The height of the device</param>
 /// <param name="depth">The depth of the device</param>
 /// <param name="fmt">The format of the device</param>
 public Group( int width, int height, int depth, System.Drawing.Imaging.ImageFormat fmt )
 {
     byte[] data = new byte[16];
     data[0] = 0x0A;
     data[1] = 0x01;
     BitConverter.GetBytes( (short)depth.GetHashCode() ).CopyTo( data, 2 );
     BitConverter.GetBytes( width.GetHashCode() ).CopyTo( data, 4 );
     BitConverter.GetBytes( height.GetHashCode() ).CopyTo( data, 8 );
     BitConverter.GetBytes( fmt.GetHashCode() ).CopyTo( data, 12 );
     this.m_id = new Guid( data );
     this.m_friendlyName = fmt.ToString() +
         " W:" + width +
         " H:" + height +
         " D:" + depth;
 }
Example #28
0
	public void unscheduleBlockForKey(string key, System.Object target)
	{
		// explicity handle nil arguments when removing an object
		if( target==null && key==null)
			return;
		
		NSUtils.Assert( target != null, "Target MUST not be nil");
		NSUtils.Assert( key != null, "key MUST not be NULL");
		
		tHashTimerEntry element = hashForTimers.HASH_FIND_INT (target.GetHashCode());
		if (element != null) {
			
			for(int i=0; i< element.timers.Count; i++ ) {
				CCTimer timer = element.timers[i];
				
				
				if( timer is CCTimerBlock &&  key == ((CCTimerBlock)timer).key ) {
					
					if( timer == element.currentTimer && !element.currentTimerSalvaged ) {
						element.currentTimerSalvaged = true;
					}
					
					element.timers.RemoveAt(i);
					
					// update timerIndex in case we are in tick:, looping over the actions
					if( element.timerIndex >= i )
						element.timerIndex--;
					
					if(element.timers.Count == 0){
						if( currentTarget == element )
							currentTargetSalvaged = true;
						else
							removeHashElement(element);
					}
					return;
				}
			}
		}
		// Not Found
		//	NSLog(@"CCScheduler#unscheduleSelector:forTarget: selector not found: %@", selString);
	}
 public static int GetPathAndTypeID(string path, System.Type type)
 {
   return path.GetHashCode() * 27 ^ type.GetHashCode();
 }
Example #30
0
		void priorityIn(utList<tListEntry> list, System.Object target, int priority, bool paused){
			tListEntry listEntry = new tListEntry ();
			listEntry.target = target;
			listEntry.priority = priority;
			listEntry.paused = paused;
			MethodInfo method = target.GetType ().GetMethod (updateSelector);
			listEntry.impMethod = (TICK_IMP) Delegate.CreateDelegate(typeof(TICK_IMP), target, method);
			listEntry.markedForDeletion = false;
			
			utNode<tListEntry> listElement = new utNode<tListEntry> ();
			listElement.next = listElement.prev = null;
			listElement.obj = listEntry;

			
			if (list.head == null) {
				list.DL_APPEND(listElement);
			} else {
				bool added = false;
				for( utNode<tListEntry> elem = list.head; elem != null ; elem = elem.next ) {
					if(priority < elem.obj.priority){
						
						if( elem == list.head )
							list.DL_PREPEND(listElement);
						else {
							listElement.next = elem;
							listElement.prev = elem.prev;
							
							elem.prev.next = listElement;
							elem.prev = listElement;
						}
						added = true;
						break;
					}
				}

				if(!added)
					list.DL_APPEND(listElement);
			}
			tHashUpdateEntry hashElement = new tHashUpdateEntry ();
			hashElement.target = target;
			hashElement.list = list;
			hashElement.entry = listElement;
			hashForUpdates.HASH_ADD_INT (target.GetHashCode(), hashElement);
		}