public object GetService(Type serviceType)
        {
            _log.Debug("VerboseDependencyResolver.GetService(Type serviceType), serviceType: " + serviceType.ToString());

            if(serviceType.Equals(typeof(IControllerFactory)))
            {
                // Cannot return controller here, as it is also set via
                // ControllerBuilder.Current.SetControllerFactory.
                //return new VerboseControllerFactory();
                _log.Debug("VerboseDependencyResolver.GetService(Type serviceType) returning null.");
                return null;
            }

            if (serviceType.Equals(typeof(IControllerActivator)))
            {
                _log.Debug("VerboseDependencyResolver.GetService(Type serviceType) returning null.");
                return null;
            }

            if (typeof(IController).IsAssignableFrom(serviceType))
            {
                _log.Debug("VerboseDependencyResolver.GetService(Type serviceType) returning instance of HomeController.");
                return new HomeController();
            }

            _log.Debug("VerboseDependencyResolver.GetService(Type serviceType) returning null.");
            return null;
        }
示例#2
0
    IEnumerator Load()
    {
        using (WWW www = new WWW(url))
        {
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                yield return(null);

                dispatcher.Dispatch(ServiceEvent.FAILURE_TO_LOAD);
            }

            if (type.Equals(typeof(Texture2D)))
            {
                var tex = www.texture;
                dispatcher.Dispatch(ServiceEvent.SUCCESS_TO_LOAD, tex);
            }
            else if (type.Equals(typeof(string)))
            {
                var text = www.text;
                dispatcher.Dispatch(ServiceEvent.SUCCESS_TO_LOAD, text);
            }
        }

        yield return(null);
    }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is BinomialNonInferiorityTesting == false)
            {
                throw new NotImplementedException();
            }

            if (targetType.Equals(typeof(IEnumerable)))
            {
                var values = new List<string>
                             {
                             	Superiority,
                                SuperiorityWithMargin,
                             };

                return values;
            }

            if (targetType.Equals(typeof(object)) || targetType.Equals(typeof(string)))
            {
                var binomialTesting = (BinomialNonInferiorityTesting)value;
                switch (binomialTesting)
                {
                    case BinomialNonInferiorityTesting.Superiority:
                        return Superiority;

                    case BinomialNonInferiorityTesting.SuperiorityWithMargin:
                        return SuperiorityWithMargin;
                }

                return binomialTesting.ToString();
            }

            throw new NotImplementedException("Unhandled targetType: " + targetType);
        }
        private static object GetObjectValue (string value, Type type)
        {
            if (type.IsEnum)
            {
                return GetEnumValue (type, value);
            }

            if (type.Equals ((typeof(bool))))
            {
                return GetBooleanValue (value);
            }

            if (type.Equals (typeof(DateTime)))
            {
                return GetDateTimeValue (value);
            }

            if (typeof(IConvertible).IsAssignableFrom (type))
            {
                return GetConvertibleValue (type, value);
            }

            string message = String.Format ("Unsupported type being used with NullableResolver: [{0}]", type.Name);
            throw new Exception(message);
        }
示例#5
0
文件: ArrayBit.cs 项目: Easun/RiftEMU
 public override void ApplyToFieldInfo(FieldInfo Info, ISerializablePacket Packet, Type Field)
 {
     if (Field.Equals(typeof(byte[])))
         Info.SetValue(Packet, val);
     else if(Field.Equals(typeof(string)))
         Info.SetValue(Packet,Marshal.ConvertToString((byte[])val));
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TimeToEventSpecification == false)
            {
                throw new NotImplementedException();
            }

            if (targetType.Equals(typeof(IEnumerable)))
            {
                var values = new List<string>
                             {
                             	EventRate,
                                MedianTime,
                             };

                return values;
            }

            if (targetType.Equals(typeof(object)) || targetType.Equals(typeof(string)))
            {
                var specification = (TimeToEventSpecification)value;
                switch (specification)
                {
                    case TimeToEventSpecification.EventRate:
                        return EventRate;

                    case TimeToEventSpecification.MedianTime:
                        return MedianTime;
                }

                return specification.ToString();
            }

            throw new NotImplementedException("Unhandled targetType: " + targetType);
        }
示例#7
0
    void Save(System.Type type)
    {
        saveData          = new QuestionBoxSaveData();
        saveData.unlocked = unlocked;
        saveData.index    = index;
        saveData.dialogueSequenceIndex = dialogueSystem.currSequenceIndex;
        saveData.corretAnswers         = correctAnswers;
        //saveData.itemsExpecting = new string[itemsExpecting.Count];
        //for(int i = 0; i < itemsExpecting.Count; i++)
        //{
        //    saveData.itemsExpecting[i] = itemsExpecting[i].GetItemType().ToString();
        //}

        Debug.Log("Added to the save object list successfully");

        if (type.Equals(typeof(SaveManager)))
        {
            SaveManager.saveObject.AddObject(saveData);
        }

        else if (type.Equals(typeof(CheckPointManager)))
        {
            CheckPointManager.checkPointData.AddObject(saveData);
        }
    }
示例#8
0
        public static Func<string, object> GetConverter(Type valueType)
        {
            if(valueType.Equals(typeof(string)))
            {
                return (s) => s;
            }
            if(valueType.Equals(typeof(int)))
            {
                return (s) => int.Parse(s);
            }
            else if(valueType.Equals(typeof(float)))
            {
                return (s) => float.Parse(s, CultureInfo.InvariantCulture.NumberFormat);
            }
            else if (valueType.Equals(typeof(double)))
            {
                return (s) => double.Parse(s, CultureInfo.InvariantCulture.NumberFormat);
            }
            else if(valueType.Equals(typeof(bool)))
            {
                return (s) => "true".Equals(s);
            }
            else if(valueType.IsEnum)
            {
                return (s) => Enum.Parse(valueType, s);
            }

            throw new NotImplementedException("Cannot create converter for " + valueType);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TimeToEventHypothesis == false)
            {
                throw new NotImplementedException();
            }

            if (targetType.Equals(typeof(IEnumerable)))
            {
                var values = new List<string>
                             {
                             	RiskRatio,
                                RiskDifference,
                             };

                return values;
            }

            if (targetType.Equals(typeof(object)) || targetType.Equals(typeof(string)))
            {
                var binomialTesting = (TimeToEventHypothesis)value;
                switch (binomialTesting)
                {
                    case TimeToEventHypothesis.RiskRatio:
                        return RiskRatio;

                    case TimeToEventHypothesis.RiskDifference:
                        return RiskDifference;
                }

                return binomialTesting.ToString();
            }

            throw new NotImplementedException("Unhandled targetType: " + targetType);
        }
示例#10
0
        public override void ApplyToFieldInfo(FieldInfo Info, ISerializablePacket Packet, Type Field)
        {
            if (Field.Equals(typeof(List<uint>)))
            {
                List<uint> Luint = new List<uint>();
                foreach (ISerializableField Value in (List<ISerializableField>)val)
                    Luint.Add(Value.GetUint());
                Info.SetValue(Packet, Luint);
            }
            else if(Field.Equals(typeof(List<ISerializablePacket>)))
            {
                List<ISerializablePacket> Packets = new List<ISerializablePacket>();
                foreach (ISerializableField Value in (List<ISerializableField>)val)
                    Packets.Add(Value.GetPacket());
                Info.SetValue(Packet, Packets);
            }
            else if (Field.Equals(typeof(List<bool>)))
            {
                List<bool> Bools = new List<bool>();
                foreach (ISerializableField Value in (List<ISerializableField>)val)
                    Bools.Add((bool)Value.val);
                Info.SetValue(Packet, Bools);
            }
            else if (Field.Equals(typeof(List<float>)))
            {
                List<float> floats = new List<float>();
                foreach (ISerializableField Value in (List<ISerializableField>)val)
                    floats.Add(Value.GetFloat());

                Info.SetValue(Packet, floats);
            }
        }
示例#11
0
    public void SetInactivePUObject(PowerUpBaseClass powerUp, GameObject obj)
    {
        System.Type powerUpType = powerUp.GetType();

        inactivePU.Add(powerUp);
        activePU.Remove(powerUp);
        obj.SetActive(false);

        //May want to keep these in order to change what happens to each type when it is deactivated
        if (powerUpType.Equals(typeof(BrightenPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(DestroyAllPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(HealthBackPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(ShieldPowerUp)))
        {
            // obj.SetActive(false);
        }
        else
        {
            Debug.LogWarning("This powerup type hasn't been added to the handler! " + powerUpType);
        }
    }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TimeToEventAccrual == false)
            {
                throw new NotImplementedException();
            }

            if (targetType.Equals(typeof(IEnumerable)))
            {
                var values = new List<string>
                             {
                             	Uniform,
                                Exponential,
                             };

                return values;
            }

            if (targetType.Equals(typeof(object)) || targetType.Equals(typeof(string)))
            {
                var binomialTesting = (TimeToEventAccrual)value;
                switch (binomialTesting)
                {
                    case TimeToEventAccrual.Uniform:
                        return Uniform;

                    case TimeToEventAccrual.Exponential:
                        return Exponential;
                }

                return binomialTesting.ToString();
            }

            throw new NotImplementedException("Unhandled targetType: " + targetType);
        }
示例#13
0
    public void GotPowerup(PowerUpBaseClass powerUp)
    {
        System.Type powerUpType = powerUp.GetType();

        if (powerUpType.Equals(typeof(BrightenPowerUp)))
        {
            InitBrighten();
        }
        else if (powerUpType.Equals(typeof(DestroyAllPowerUp)))
        {
            DestroyAllEnemies();
        }
        else if (powerUpType.Equals(typeof(HealthBackPowerUp)))
        {
            GetHealthBack();
        }
        else if (powerUpType.Equals(typeof(ShieldPowerUp)))
        {
            ActivateShield();
        }
        else
        {
            Debug.LogWarning("This powerup type hasn't been added to the handler! " + powerUpType);
        }
    }
示例#14
0
    public override void Exec(IEvent e)
    {
        Debug.Log("Executing event " + e.ToString());

        CountForJump();

        System.Type type = e.GetType();
        if (type.Equals(typeof(OnTrackingAreaEnterEvent)))
        {
            Color c = Color.red;
            cubeHologram.Invoke("SetColor", c);
        }
        if (type.Equals(typeof(OnTrackingAreaExitEvent)))
        {
            Color c = Color.blue;
            cubeHologram.Invoke("SetColor", c);
        }
        if (type.Equals(typeof(ButtonPressedEvent)))
        {
            ButtonPressedEvent bpe = (ButtonPressedEvent)e;
            if (bpe.State == 1)
            {
                cubeHologram.Invoke("SetColor", Color.yellow);
            }
            else
            {
                cubeHologram.Invoke("SetColor", Color.grey);
            }
        }
    }
示例#15
0
        /// <summary>
        /// Converts the specified value to a value that fits the target type.
        /// </summary>
        /// <param name="targetType">The target <see cref="Type"/>.</param>
        /// <param name="value">The value to convert.</param>
        /// <returns>The converted value.</returns>
        static object ConvertToType(Type targetType, object value)
        {
            if (targetType.IsAssignableFrom(value.GetType()))
                return value;

            if (targetType.IsEnum)
            {
                if (!Enum.IsDefined(targetType, value.ToString()))
                    throw new ScriptException(string.Format("The value '{0}' is not a member of {1}.", value, targetType));

                return Enum.Parse(targetType, value.ToString(), true);
            }

            if (targetType.Equals(typeof(byte)))
                return Convert.ToByte(value);
            if (targetType.Equals(typeof(sbyte)))
                return Convert.ToSByte(value);
            if (targetType.Equals(typeof(short)))
                return Convert.ToInt16(value);
            if (targetType.Equals(typeof(ushort)))
                return Convert.ToUInt16(value);
            if (targetType.Equals(typeof(int)))
                return Convert.ToInt32(value);
            if (targetType.Equals(typeof(uint)))
                return Convert.ToUInt32(value);
            if (targetType.Equals(typeof(long)))
                return Convert.ToInt64(value);
            if (targetType.Equals(typeof(ulong)))
                return Convert.ToUInt64(value);

            throw new ScriptException(string.Format("Could not convert from {0} to {1}.", value.GetType(), targetType));
        }
示例#16
0
        private static object getAppSetting(Type expectedType, string key)
        {
            string value = ConfigurationManager.AppSettings.Get(key);
            if (value == null)
            {
                Log.Fatal("Configuration.cs", string.Format("AppSetting: {0} is not configured", key));
                throw new Exception(string.Format("AppSetting: {0} is not configured.", key));
            }

            try
            {
                if (expectedType.Equals(typeof(int)))
                {
                    return int.Parse(value);
                }

                if (expectedType.Equals(typeof(string)))
                {
                    return value;
                }

                throw new Exception("Type not supported.");
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Config key:{0} was expected to be of type {1} but was not.", key, expectedType),
                                    ex);
            }
        }
示例#17
0
		private int Distance (Type type_a, Type type_b) {
			if (type_a.Equals (type_b))
				return 0;

			if (type_a.IsPrimitive && type_b.IsPrimitive &&
				 CanConvertPrimitive (type_a, type_b)) {
				return 1;
			}
			
			int class_distance = 1;
			Type base_a = type_a.BaseType;
			while (base_a != null && !(base_a.Equals (typeof (object)))) {
				if (type_b.Equals (base_a))
					break;

				// FIXME: this needs to check which interfaces bind tighter
				Type[] interfaces = base_a.GetInterfaces ();
				foreach (Type iface in interfaces) {
					if (type_b.Equals (iface))
						return 1;
				}

				class_distance++;
				base_a = base_a.BaseType;
			}

			if (base_a == null || !(type_b.Equals (base_a))) {
				class_distance = -1;
			}

			return class_distance;
		}
示例#18
0
    public void Save(System.Type type)
    {
        inventorySaveData = new InventorySaveData();


        for (int i = 0; i < slots.Count; i++)
        {
            if (slots[i].itemCount > 0 && slots[i].isActive)
            {
                SlotSaveData slotdata = new SlotSaveData();
                //slotdata.itemStored = slots[i].itemlist[0].gameObject.GetComponent<ItemsDescription>().GetType().ToString();
                slotdata.itemStored = slots[i].itemStored.itemProperties.itemDescription.GetItemType().ToString();
                slotdata.parent     = slots[i].imageSlotPrefab.transform.parent.name;

                //slotdata.position.x = slots[i].imageSlotPrefab.transform.position.x;
                //slotdata.position.y = slots[i].imageSlotPrefab.transform.position.y;

                slotdata.isActive     = slots[i].isActive;
                slotdata.siblingIndex = slots[i].imageSlotPrefab.transform.GetSiblingIndex();

                //InventorySaveData.instance.slots.Add(slotdata);
                //inventorySaveData.slots.Add(slotdata);
            }
        }

        for (int i = 0; i < inventorySaveData.slots.Count; i++)
        {
            Debug.Log(inventorySaveData.slots[i].itemStored + "Inventory slot data item stored");
            Debug.Log(inventorySaveData.slots[i].isActive + "Inventory slot data active status");
            Debug.Log(inventorySaveData.slots[i].numberOfItemsStored + "Inventory slot data number of items stored");
            Debug.Log(inventorySaveData.slots[i].siblingIndex + "Inventory sibling index");
        }

        if (activeItem != null)
        {
            inventorySaveData.activeItem = activeItem.itemProperties.itemDescription.GetType().ToString();
            //  inventorySaveData.activeItem = activeItem.itemProperties.name;
        }
        else
        {
            //  Debug.LogError("Active item is null");
            inventorySaveData.activeItem = null;
        }



        Debug.Log("Created inventory save obj>>>>>>" + inventorySaveData.activeItem);

        if (type.Equals(typeof(SaveManager)))
        {
            SaveManager.saveObject.AddObject(inventorySaveData);
        }
        else if (type.Equals(typeof(CheckPointManager)))
        {
            CheckPointManager.checkPointData.AddObject(inventorySaveData);
        }

        Debug.Log("Added to the save object list successfully");
    }
 /// <summary>
 /// Gets the service object of the specified type.
 /// </summary>
 /// <param name="serviceType">An object that specifies the type of service object to get.</param>
 /// <returns>
 /// A service object of type serviceType.-or- null if there is no service object of type serviceType.
 /// </returns>
 public override object GetService(Type serviceType) {
   if (serviceType.Equals(typeof(IMouseListener)))
     return this;
   else if (serviceType.Equals(typeof(IHoverListener)))
     return this;
   else
     return null;
 }
示例#20
0
 void GenLvlGenFunctionsUI(int mappingIndex)
 {
     EditorGUILayout.BeginVertical();
     functionIndices[mappingIndex] = EditorGUILayout.Popup("Function to Call", functionIndices[mappingIndex], methodSigs);
     ParameterInfo[] parameters = methods[functionIndices[mappingIndex]].GetParameters();
     ResizeList(functionArguments[mappingIndex], parameters.Length);
     EditorGUILayout.BeginHorizontal();
     for (int i = 0; i < parameters.Length; ++i)
     {
         System.Type type = parameters[i].ParameterType;
         if (type.IsSubclassOf(typeof(Object)))
         {
             if (functionArguments[mappingIndex][i] != null && !functionArguments[mappingIndex][i].GetType().IsSubclassOf(typeof(Object)))
             {
                 functionArguments[mappingIndex][i] = null;
             }
             functionArguments[mappingIndex][i] = EditorGUILayout.ObjectField((Object)functionArguments[mappingIndex][i], type, false);
         }
         else if (type.IsEnum)
         {
             if (functionArguments[mappingIndex][i] != null && !functionArguments[mappingIndex][i].GetType().IsEnum)
             {
                 functionArguments[mappingIndex][i] = null;
             }
             if (functionArguments[mappingIndex][i] == null)
             {
                 functionArguments[mappingIndex][i] = (System.Enum)System.Activator.CreateInstance(type);
             }
             functionArguments[mappingIndex][i] = EditorGUILayout.EnumPopup((System.Enum)functionArguments[mappingIndex][i]);
         }
         else if (type.Equals(typeof(int)))
         {
             if (functionArguments[mappingIndex][i] != null && !functionArguments[mappingIndex][i].GetType().Equals(typeof(int)))
             {
                 functionArguments[mappingIndex][i] = null;
             }
             if (functionArguments[mappingIndex][i] == null)
             {
                 functionArguments[mappingIndex][i] = 0;
             }
             functionArguments[mappingIndex][i] = EditorGUILayout.DelayedIntField((int)functionArguments[mappingIndex][i]);
         }
         else if (type.Equals(typeof(float)))
         {
             if (functionArguments[mappingIndex][i] != null && !functionArguments[mappingIndex][i].GetType().Equals(typeof(float)))
             {
                 functionArguments[mappingIndex][i] = null;
             }
             if (functionArguments[mappingIndex][i] == null)
             {
                 functionArguments[mappingIndex][i] = 0.0f;
             }
             functionArguments[mappingIndex][i] = EditorGUILayout.DelayedFloatField((float)functionArguments[mappingIndex][i]);
         }
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.EndVertical();
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return null;

            if (!value.GetType().Equals(typeof (PlotType))) throw new ArgumentException();

            if (targetType.Equals(typeof (int))) return (int) (PlotType) value;

            if (targetType.Equals(typeof (object)) || targetType.Equals(typeof (string)))
            {
                var s = (PlotType) value;
                switch (s)
                {
                    case PlotType.Boundaries:
                        return Boundaries;

                    case PlotType.Power:
                        return Power;

                    case PlotType.TreatmentEffect:
                        return TreatmentEffect;

                    case PlotType.ConditionalPower:
                        return ConditionalPower;

                    case PlotType.SpendingFunction:
                        return SpendingFunction;

                    case PlotType.ExpectedSampleSize:
                        return ExpectedSampleSize;

                    case PlotType.BValues:
                        return BValues;

                    default:
                        return s.ToString();
                }
            }

            if (targetType.Equals(typeof (IEnumerable)))
            {
                var values = new List<string>
                {
                    Boundaries,
                    Power,
                    TreatmentEffect,
                    ConditionalPower,
                    SpendingFunction,
                    ExpectedSampleSize,
                    BValues,
                };

                return values;
            }

            throw new NotImplementedException();
        }
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == null) { throw new ArgumentNullException("destinationType"); } // $NON-NLS-1
            if (destinationType.Equals(typeof(string))
                || destinationType.Equals(typeof(Uri)))
                return true;

            return base.CanConvertTo(context, destinationType);
        }
示例#23
0
文件: Raw8Bit.cs 项目: Easun/RiftEMU
 public override void ApplyToFieldInfo(FieldInfo Info, ISerializablePacket Packet, Type Field)
 {
     if (Field.Equals(typeof(byte[])))
         Info.SetValue(Packet, (byte[])val);
     else if (Field.Equals(typeof(long)))
     {
         //Array.Reverse((val as byte[]));
         Info.SetValue(Packet, BitConverter.ToInt64((byte[])val, 0));
     }
 }
示例#24
0
        public KeyOptionsForm(Type cipherType, int IVLength, ModeParams modeParams)
        {
            InitializeComponent();
            _mParams = modeParams;
            _iv = new byte[IVLength];
            tbPassword.Text = _mParams.TextKey;
            tbSeed.Text = _mParams.Seed.ToString();

            //128 (blow, idea, cast, AES)
            if (cipherType.Equals(typeof (BlowfishEngine))  ||  cipherType.Equals(typeof (IdeaEngine)) ||
                cipherType.Equals(typeof (Cast5Engine))     ||  cipherType.Equals(typeof (AesEngine)))
            {
                lbKeyLength.Items.Add(new KeyLengthObject(){Length = 128});
            }
            //56 (DES)
            if (cipherType.Equals(typeof (DesEngine)))
            {
                lbKeyLength.Items.Add(new KeyLengthObject() { Length = 56 });
            }
            //168 (3DES)
            if (cipherType.Equals(typeof (DesEdeEngine)))
            {
                lbKeyLength.Items.Add(new KeyLengthObject(){Length = 168});
            }
            //256 (blow,gost,AES)
            if (cipherType.Equals(typeof (Gost28147Engine)) || cipherType.Equals(typeof (BlowfishEngine)) ||
                cipherType.Equals(typeof (AesEngine)))
            {
                lbKeyLength.Items.Add(new KeyLengthObject(){Length = 256});
            }

            // select first
            lbKeyLength.SelectedIndex = 0;
        }
示例#25
0
文件: Convert.cs 项目: HTD/Woof
 /// <summary>
 /// Converts a boxed object value to SQL compatible boxed object
 /// </summary>
 /// <param name="x"></param>
 /// <param name="t"></param>
 public Convert(object x, Type t = null)
 {
     if (x == null) { Value = DBNull.Value; return; }
     if (t == null) t = x.GetType();
     if (t.IsPrimitive || t.Equals(typeof(decimal)) || t.Equals(typeof(string)) || t.Equals(typeof(DateTime))) { Value = x; return; }
     if (x is List<int>) { Value = GetDataTable(x as List<int>); return; }
     if (x is List<string>) { Value = GetDataTable(x as List<string>); return; }
     if (x is IList) { Value = GetDataTable(x as IList); return; }
     if (x is Guid) { Value = ((Guid)x).ToString(); return; }
     Value = GetDataTable(x);
 }
示例#26
0
        private object GetAppConfigValue(string configName, Type type)
        {
            string value = ConfigurationManager.AppSettings[configName];

            if (type.Equals(typeof (int)))
                return Int32.Parse(value);
            if (type.Equals(typeof (bool)))
                return Boolean.Parse(value);

            return value;
        }
 // TypeConverter' overrides.
 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
 {
     if (sourceType == null) { throw new ArgumentNullException("sourceType"); } // $NON-NLS-1
     if (sourceType.Equals(typeof(string))) {
         return true;
     } else if (sourceType.Equals(typeof(Uri))) {
         return true;
     } else {
         return base.CanConvertFrom(context, sourceType);
     }
 }
 private static bool IsSimpleType(Type type)
 {
     return type.GetTypeInfo().IsPrimitive ||
         type.Equals(typeof(decimal)) ||
         type.Equals(typeof(string)) ||
         type.Equals(typeof(DateTime)) ||
         type.Equals(typeof(Guid)) ||
         type.Equals(typeof(DateTimeOffset)) ||
         type.Equals(typeof(TimeSpan)) ||
         type.Equals(typeof(Uri));
 }
 public void Navigate(Type navigationPageType)
 {
     if (navigationPageType.Equals(typeof(PhotoDetailPage)))
     {
         IoCContainer.PhotoDetailViewModel.Photo = IoCContainer.PhotoOverviewViewModel.SelectedPhoto;
         CurrentPage = _photoDetailPage;
     }
     else if (navigationPageType.Equals(typeof(PhotoOverviewPage)))
     {
         CurrentPage = _photoOverviewPage;
     }
 }
示例#30
0
        /// <summary>
        /// Determiens whether the specified type is a floating point number type or not.
        /// </summary>
        /// <param name="aType">The type to check.</param>
        /// <returns>True if the type is a floating point number type. Otherwise, false.</returns>
        public static bool IsFloat(Type aType)
        {
            bool isFloat = false;

            if (aType.Equals(typeof(float)) ||
                aType.Equals(typeof(double)))
            {
                isFloat = true;
            }

            return isFloat;
        }
        public virtual bool CanResolve (Type type)
        {
            // Can resolve any type which implements IConvertible, except DateTime, 
            // Boolean or Enum, which are more explicitly handled by other value 
            // resolvers
            if (type.Equals (typeof (DateTime)) || type.Equals (typeof (Boolean)) || type.IsEnum)
            {
                return false;
            }

            return typeof (IConvertible).IsAssignableFrom (type);
        }
示例#32
0
    public static T FromSaveData <T>(string saveData) where T : class, new()
    {
        System.Type typeOfInt    = typeof(int);
        System.Type typeOfFloat  = typeof(float);
        System.Type typeOfString = typeof(string);

        T resultObj = new T();

        System.Type objType = resultObj.GetType();

        string[] allLines = saveData.Split('\n');
        System.Reflection.FieldInfo[] fields = objType.GetFields();
        foreach (string line in allLines)
        {
            string[] splitLine = line.Split('=');
            if (splitLine.Length < 2)
            {
                continue;
            }
            string fieldName = splitLine[0].Trim();
            string value     = splitLine[1].Trim();

            int lastIndex = 0;
            int length    = fields.Length;
            for (int i = 0; i < length; i++)
            {
                int thisIndex = i + lastIndex;
                System.Reflection.FieldInfo thisField = fields[thisIndex];
                if (thisField.Name.Equals(fieldName))
                {
                    System.Type fieldType = thisField.FieldType;
                    if (fieldType.Equals(typeOfInt))
                    {
                        thisField.SetValue(resultObj, System.Convert.ToInt32(value));
                    }
                    else if (fieldType.Equals(typeOfFloat))
                    {
                        thisField.SetValue(resultObj, System.Convert.ToSingle(value));
                    }
                    else if (fieldType.Equals(typeOfString))
                    {
                        thisField.SetValue(resultObj, value);
                    }
                    else if (fieldType.IsEnum)
                    {
                        thisField.SetValue(resultObj, System.Enum.ToObject(fieldType, System.Convert.ToInt32(value)));
                    }
                    break;
                }
            }
        }
        return(resultObj);
    }
        public string getJavaName(Type type)
        {
            if (type.Equals(typeof (WebServiceEntry)))
                return "edu.kstate.datastore.data.WebServiceEntry";
            if (type.Equals(typeof (ValueSetEntry)))
                return "edu.kstate.datastore.data.ValueSetEntry";
            if (type.Equals(typeof (ElementSetEntry)))
                return "edu.kstate.datastore.data.ElementSetEntry";
            if (type.Equals(typeof (ValueSetRequestEntry)))
                return "edu.kstate.datastore.data.ValueSetRequestEntry";

            return null;
        }
 public override object Resolve(Type type)
 {
     if (type.Equals(typeof(ICalculator1))
         || type.Equals(typeof(ICalculator2))
         || type.Equals(typeof(ICalculator3)))
     {
         return this.containerWithLoggingInterception.Resolve(type);
     }
     else
     {
         return this.container.Resolve(type);
     }
 }
示例#35
0
		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
			if(destinationType.Equals(value.GetType())){
				return value;
			}else if(value is string){
				if(destinationType.Equals(typeof(AccessToken))){
					return ConvertFromStringInternal(value as string);
				}
			}else if(value is AccessToken){
				if(destinationType.Equals(typeof(string))){
					return ConvertToString(value as AccessToken);
				}
			}
			return null;
		}
示例#36
0
        public static TypeCode GetRuntimeTypeCode(Type type)
        {
            Debug.Assert(type != null);

            EETypePtr eeType;
            if (!type.TryGetEEType(out eeType))
            {
                // Type exists in metadata only. Aside from the enums, there is no chance a type with a TypeCode would not have an EEType,
                // so if it's not an enum, return the default.
                if (!type.IsEnum)
                    return TypeCode.Object;
                Type underlyingType = Enum.GetUnderlyingType(type);
                eeType = underlyingType.TypeHandle.EETypePtr;
            }

            // Note: Type.GetTypeCode() is expected to return the underlying type's TypeCode for enums. EETypePtr.CorElementType does the same,
            // so this one switch handles both cases.
            RhCorElementType rhType = eeType.CorElementType;
            switch (rhType)
            {
                case RhCorElementType.ELEMENT_TYPE_BOOLEAN: return TypeCode.Boolean;
                case RhCorElementType.ELEMENT_TYPE_CHAR: return TypeCode.Char;
                case RhCorElementType.ELEMENT_TYPE_I1: return TypeCode.SByte;
                case RhCorElementType.ELEMENT_TYPE_U1: return TypeCode.Byte;
                case RhCorElementType.ELEMENT_TYPE_I2: return TypeCode.Int16;
                case RhCorElementType.ELEMENT_TYPE_U2: return TypeCode.UInt16;
                case RhCorElementType.ELEMENT_TYPE_I4: return TypeCode.Int32;
                case RhCorElementType.ELEMENT_TYPE_U4: return TypeCode.UInt32;
                case RhCorElementType.ELEMENT_TYPE_I8: return TypeCode.Int64;
                case RhCorElementType.ELEMENT_TYPE_U8: return TypeCode.UInt64;
                case RhCorElementType.ELEMENT_TYPE_R4: return TypeCode.Single;
                case RhCorElementType.ELEMENT_TYPE_R8: return TypeCode.Double;
                default:
                    break;
            }

            if (type.Equals(CommonRuntimeTypes.String))
                return TypeCode.String;

            if (type.Equals(CommonRuntimeTypes.DateTime))
                return TypeCode.DateTime;

            if (type.Equals(CommonRuntimeTypes.Decimal))
                return TypeCode.Decimal;

            if (eeType == DBNull.Value.EETypePtr)
                return TypeCode.DBNull;

            return TypeCode.Object;
        }
示例#37
0
        public static Form CreateFacebookForm(Type i_TypeOfForm, User i_LoggedUser)
        {
            Form requestedForm = null;         
            if (i_TypeOfForm.Equals(typeof(LikeAnalyzerForm)))
            {
                requestedForm = new LikeAnalyzerForm(i_LoggedUser);
            }
            else if (i_TypeOfForm.Equals(typeof(FormMusic)))
            {
                requestedForm = new FormMusic(i_LoggedUser);
            }

            return requestedForm;
        }
示例#38
0
        public override void ApplyToFieldInfo(FieldInfo Info, ISerializablePacket Packet, Type Field)
        {
            byte[] Data = val as byte[];
            object Result = Data;

            if(Field.Equals(typeof(UInt32)))
                Result = Marshal.ConvertToUInt32(Data[3], Data[2], Data[1], Data[0]);
            else if(Field.Equals(typeof(Int32)))
                Result = BitConverter.ToInt32(Data, 0);
            else if(Field.Equals(typeof(long)))
                Result = (long)BitConverter.ToUInt32(Data,0);

            Info.SetValue(Packet, Result);
        }
示例#39
0
    void Update()
    {
        timeSinceLastSpawn += Time.deltaTime;

        if (!GameController.Instance.GameOver && timeSinceLastSpawn > spawnRate)
        {
            timeSinceLastSpawn = 0;
            float ySpawnPosition = Random.Range(yAxisPositionRange.x, yAxisPositionRange.y);
            objects[currentObject].transform.position = new Vector2(xAxisSpawnPosition, ySpawnPosition);

            if (isAPickup)
            {
                if (pickupType.Equals(typeof(Coin)))
                {
                    ((Coin)pickupComponents[currentObject]).ShowCoinAgain();
                }
                //'else if' for more pickup types!
            }

            if (++currentObject >= objectPoolSize)
            {
                currentObject = 0;
            }
        }
    }
示例#40
0
    public override bool ShouldContinueAI()
    {
        if (b_has_attacked &&
            ent_main.GetAnimator().GetCurrentAnimatorStateInfo(0).normalizedTime > ent_main.F_totalAnimationLength ||
            !ent_main.B_isGrounded)
        {
            return(false);
        }

        if (ent_target == null)
        {
            foreach (var list in ObjectPool.GetInstance().GetAllEntity())
            {
                foreach (GameObject l_go in list)
                {
                    if (type_target.Equals(l_go.GetComponent <EntityLivingBase>().GetType()))
                    {
                        if (!l_go.GetComponent <EntityLivingBase>().IsDead())
                        {
                            if (ent_target == null)
                            {
                                if (Vector3.Distance(ent_main.GetPosition(), l_go.transform.position) < f_range)
                                {
                                    ent_target = l_go.GetComponent <EntityLivingBase>();
                                }
                            }
                            else
                            {
                                if (Vector3.Distance(ent_main.GetPosition(), ent_target.transform.position) > Vector3.Distance(ent_main.GetPosition(), l_go.transform.position))
                                {
                                    ent_target = l_go.GetComponent <EntityLivingBase>();
                                }
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }

        if (ent_target != null && ent_target.IsDead())
        {
            ent_target = null;
        }

        if (ent_target == null)
        {
            return(false);
        }

        ent_main.B_isAttacking = true;
        ent_main.GetAnimator().SetBool("PunchTrigger", true);
        ent_main.GetAnimator().speed = ent_main.F_attack_speed;
        return(true);
    }
    protected virtual GameObject GetPrefabFromType(System.Type _type)
    {
        if (_type.Equals(typeof(ScreenBaseHandler)))
        {
            return(Resources.Load("Prefabs/ExampleUI") as GameObject);
        }

        return(null);
    }
示例#42
0
    void Load(System.Type type)
    {
        //Debug.Log(CheckPointManager.checkPointData.types.Count + "check point data count");

        //Get the appropriate value from the save data
        //TODO: This part might need a little tweaking

        InventorySaveData saveData = new InventorySaveData();

        if (type.Equals(typeof(SaveManager)))
        {
            Debug.Log("Loading");
            for (int i = 0; i < SaveManager.saveObject.types.Count; i++)
            {
                if (SaveManager.saveObject.types[i].type == typeof(InventorySaveData).ToString())
                {
                    saveData = (InventorySaveData)SaveManager.saveObject.types[i].values[0];
                    break;
                }
            }
        }
        else
        {
            if (type.Equals(typeof(CheckPointManager)))
            {
                Debug.Log("Loading the checkpoint");

                Debug.Log(CheckPointManager.checkPointData.types.Count + "check point data count");

                for (int i = 0; i < CheckPointManager.checkPointData.types.Count; i++)
                {
                    if (CheckPointManager.checkPointData.types[i].type == typeof(InventorySaveData).ToString())
                    {
                        Debug.Log((InventorySaveData)CheckPointManager.checkPointData.types[i].values[0] + "value of check point");
                        saveData = (InventorySaveData)CheckPointManager.checkPointData.types[i].values[0];

                        break;
                    }
                }

                LoadData(saveData);
            }
        }
    }
示例#43
0
        void UpdateParameterValue()
        {
            System.Type t = System.Type.GetType(type);
            _currentValue = null;

            if (t == null)
            {
                return;
            }
            isSwitch = t.Equals(typeof(bool)) && isSwitch;
            if (t.IsSubclassOf(typeof(Object)) | type.Equals(typeof(Object)))
            {
                _currentValue = objectParameter;
            }
            else if (t.Equals(typeof(Vector3)))
            {
                _currentValue = vectorParameter;
            }
            else if (t.Equals(typeof(Vector2)))
            {
                _currentValue = (Vector2)vectorParameter;
            }
            else if (t.Equals(typeof(Color)))
            {
                _currentValue = colorParameter;
            }
            else if (t.Equals(typeof(bool)))
            {
                _currentValue = boolParameter;
            }
            else if (t.Equals(typeof(string)))
            {
                _currentValue = stringParameter;
            }
            else if (t.Equals(typeof(float)))
            {
                _currentValue = floatParameter;
            }
            else if (t.Equals(typeof(double)))
            {
                _currentValue = doubleParameter;
            }
            else if (t.Equals(typeof(int)))
            {
                _currentValue = intParameter;
            }
        }
示例#44
0
 public void ChangeState(System.Type t)
 {
     for (int i = 0; i < StatesList.Count; i++)
     {
         if (t.Equals(StatesList[i]))
         {
             Current.Exit(MyTeam, MyPaddle);
             Current = StatesList[i];
             Current.Enter(MyTeam, MyPaddle);
         }
     }
 }
示例#45
0
 /// <summary>Enable or Disable Specific PlayerComponent on Player</summary>
 public void EnableComponent <T> (bool enable) where T : PlayerComponent
 {
     System.Type tmp = typeof(T);
     foreach (PlayerComponent component in components)
     {
         System.Type tem = component.GetType( );
         if (tmp.Equals(tem))
         {
             component.enabled = enable;
         }
     }
 }
示例#46
0
 public static void BadBallHit(BadBall bb)
 {
     System.Type ballType = bb.GetType();
     if (ballType.Equals(typeof(Delinker)))
     {
         DelinkersHit += 1;
     }
     else if (ballType.Equals(typeof(Ejector)))
     {
         EjectorsHit += 1;
     }
     else if (ballType.Equals(typeof(Freezer)))
     {
         FreezersHit += 1;
     }
     else if (ballType.Equals(typeof(Shocker)))
     {
         ShockersHit += 1;
     }
     else if (ballType.Equals(typeof(Infector)))
     {
         InfectorsHit += 1;
     }
     else if (ballType.Equals(typeof(Glooper)))
     {
         GloopersHit += 1;
     }
 }
示例#47
0
    public void Send(RPCOption mode, MessageInformation message, bool reliable = true)
    {
        string outdata = "";

        System.Type t = message.value.GetType();
        //CODIFICA IN BASE AL TIPO DI INPUT
        if (t.Equals(typeof(string)))
        {
            outdata = "string:" + message.name + ":" + message.value;
        }
        else if (t.Equals(typeof(int)))
        {
            outdata = "int:" + message.name + ":" + message.value.ToString();
        }
        else if (t.Equals(typeof(float)))
        {
            outdata = "float:" + message.name + ":" + message.value.ToString();
        }
        else if (t.Equals(typeof(Vector2)))
        {
            outdata = "Vector2:" + message.name + ":" + ((Vector2)message.value).x + ":" + ((Vector2)message.value).y;
        }
        else if (t.Equals(typeof(Vector3)))
        {
            outdata = "Vector3:" + message.name + ":" + ((Vector3)message.value).x + ":" + ((Vector3)message.value).y + ":" + ((Vector3)message.value).z;
        }
        else if (t.Equals(typeof(bool)))
        {
            outdata = "bool:" + message.name + ":" + message.value.ToString();
        }
        else if (t.Equals(typeof(Texture2D)))
        {
            Texture2D te = ((Texture2D)message.value);
            outdata = "Texture2D:" + message.name + ":";
            byte[] pixelsdata = te.EncodeToJPG();
            outdata += System.Convert.ToBase64String(pixelsdata);
        }
        else
        {
            Debug.LogError("data type not supported");
            return;
        }

        byte[] dataBYTE = System.Text.ASCIIEncoding.Default.GetBytes(outdata);
        Debug.LogWarning("Sent data of " + dataBYTE.Length + "bytes");

        switch (mode)
        {
        case RPCOption.Everyone:
            MC.PgamePlatform_instance.RealTime.SendMessageToAll(reliable, dataBYTE);
            break;
        }
    }
示例#48
0
    static public Dictionary <KEY, COMPONENT> GetComponentInChildren <KEY, COMPONENT>(this Component pTarget)
        where COMPONENT : UnityEngine.Component
    {
        Dictionary <KEY, COMPONENT> mapInitTarget = new Dictionary <KEY, COMPONENT>();

        System.Type pType    = typeof(KEY);
        EKeyType    eKeyType = EKeyType.None;

        if (pType.Equals(typeof(string)))
        {
            eKeyType = EKeyType.String;
        }
        else if (pType.IsEnum)
        {
            eKeyType = EKeyType.Enum;
        }

        if (eKeyType == EKeyType.None)
        {
            Debug.LogWarning(pTarget.name + " GetComponentInChildren_InitEnumerator eKeyType == EKeyType.None", pTarget);
            return(null);
        }

        COMPONENT[] arrComponent = pTarget.GetComponentsInChildren <COMPONENT>(true);
        for (int i = 0; i < arrComponent.Length; i++)
        {
            KEY Key = default(KEY);
            switch (eKeyType)
            {
            case EKeyType.CustomKey: break;

            case EKeyType.String: Key = (KEY)(object)arrComponent[i].name; break;

            case EKeyType.Enum:
                try
                {
                    Key = (KEY)System.Enum.Parse(typeof(KEY), arrComponent[i].name);
                }
                catch
                {
                    Debug.LogWarning(pTarget.name + " GetComponentInChildren_InitEnumerator Enum Parsing Error - " + arrComponent[i].name, pTarget);
                    continue;
                }
                break;
            }
            mapInitTarget.Add(Key, arrComponent[i]);
        }

        return(mapInitTarget);
    }
 void ApplyGroundEffects()
 {
     foreach (var specialGround in groundTypes)
     {
         System.Type type = specialGround.GetType();
         // Icy ground
         if (type.Equals(typeof(IcyGround)))
         {
             finalAccel = accel * ((IcyGround)specialGround).accelerationRate;
         }
         // Bouncy ground
         else if (type.Equals(typeof(BouncyGround)))
         {
             if (state.moveState.Missing(PlayerState.Movement.Landing))
             {
                 finalJumpSpeed = jumpSpeed * ((BouncyGround)specialGround).bounceJumpRate;
                 velocity       = new Vector2(velocity.x, jumpSpeed * ((BouncyGround)specialGround).bounceRate);
                 canDoubleJump  = ((BouncyGround)specialGround).doubleJumpEnabled;
                 //prevJumpDownTime = 0f;
             }
         }
     }
 }
示例#50
0
    protected override GameObject GetPrefabFromType(System.Type _type)
    {
        string key = _type.ToString();

        if (_resScreens.ContainsKey(key))
        {
            return(_resScreens[key]);
        }
        if (_type.Equals(typeof(ScreenEntry)))
        {
            return(Resources.Load("UIEntry") as GameObject);
        }

        if (_type.Equals(typeof(ScreenMainMenu)))
        {
            return(Resources.Load("UIMainMenu") as GameObject);
        }

        if (_type.Equals(typeof(ScreenWaitingBoard)))
        {
            return(Resources.Load("UIWaitingBoard") as GameObject);
        }
        return(null);
    }
示例#51
0
文件: buf.cs 项目: diakopter/csmeta
        static buffer()
        {
            System.Type t        = type = typeof(T);
            int         numbytes = t.Equals(typeof(ulong)) || t.Equals(typeof(long))
                ? 8
                : t.Equals(typeof(uint)) || t.Equals(typeof(int))
                    ? 4
                    : t.Equals(typeof(ushort)) || t.Equals(typeof(short))
                        ? 2
                        : t.Equals(typeof(byte))
                            ? 1
                            : 0;

            bits  = 8 * numbytes;
            bytes = numbytes;
        }
示例#52
0
        private static bool IsMatchingImplementor(string entityOrClassName, System.Type entityClass, IQueryable implementor)
        {
            var implementorClass = implementor.GetMappedClass(EntityMode.Poco);

            if (implementorClass == null)
            {
                return(false);
            }
            if (entityClass.Equals(implementorClass))
            {
                // It is possible to have multiple mappings for the same entity class, but with different entity names.
                // When querying for a specific entity name, we should only return entities for the requested entity name
                // and not return entities for any other entity names that may map to the same entity class.
                bool isEntityName = !entityOrClassName.Equals(entityClass.FullName);
                return(!isEntityName || entityOrClassName.Equals(implementor.EntityName));
            }
            return(entityClass.IsAssignableFrom(implementorClass));
        }
    public void UpdateMultiplier(System.Type newMultiplier)
    {
        if (newMultiplier.Equals(GetComponent <BasicMultiplier>()))
        {
            return;
        }
        try
        {
            Destroy(GetComponent <BasicMultiplier>());
        }
        catch (System.Exception e)
        {
            Debug.Log("No Basic Multiplier Attached");
            throw;
        }

        this.gameObject.AddComponent(newMultiplier);
    }
示例#54
0
 public override bool Recycle(object obj, System.Type type)
 {
     if (type.Equals(typeof(T)))
     {
         foreach (var o in objects)
         {
             if (System.Object.ReferenceEquals(obj, o))
             {
                 return(Recycle(o));
             }
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
示例#55
0
    /**
     * Get a random InventoryItem that has the given type of ItemAttribute
     */
    public InventoryItem GetRandomMatchingItem(System.Type attributeType)
    {
        // make a list to hold all the InventoryItem objects we find that match our criteria
        List <InventoryItem> matchingItems = new List <InventoryItem>();

        // look through every inventory item we know about
        foreach (InventoryItem item in Items)
        {
            foreach (ItemAttribute attrib in item.attributes)
            {
                if (attrib != null && attributeType.Equals(attrib.GetType()))
                {
                    matchingItems.Add(item);
                }
            }
        }

        return(matchingItems[Random.Range(0, matchingItems.Count)]);
    }
示例#56
0
 public static object ConvertObject(object value, System.Type type)
 {
     if (value == null)
     {
         if (type.IsGenericType)
         {
             return(System.Activator.CreateInstance(type));
         }
         return(null);
     }
     else
     {
         if (type.Equals(value.GetType()))
         {
             return(value);
         }
         else
         {
             if (type.IsUnityObject() || type.IsClass)
             {
                 return(StringToObject(value.ToString(), type));
             }
             else
             {
                 if (type.IsEnum)
                 {
                     if (value is string)
                     {
                         return(System.Enum.Parse(type, value.ToString()));
                     }
                     else
                     {
                         return(System.Enum.ToObject(type, value));
                     }
                 }
                 else
                 {
                     return(System.Convert.ChangeType(value, type));
                 }
             }
         }
     }
 }
示例#57
0
 public override DecodedObject <object> decodeInteger(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Integer, elementInfo))
     {
         return(null);
     }
     if (objectClass.Equals(typeof(int)))
     {
         DecodedObject <object> result = decodeIntegerValue(stream);
         CoderUtils.checkConstraints((int)result.Value, elementInfo);
         return(result);
     }
     else
     {
         DecodedObject <object> result = decodeLongValue(stream);
         CoderUtils.checkConstraints((long)result.Value, elementInfo);
         return(result);
     }
 }
        /// <summary>
        /// Roll back to the Loaded state
        /// </summary>
        public virtual void RollBack()
        {
            if (_originalItem != null)
            {
                Replace(_originalItem);
            }
            else
            {
                //We get the array of fields for the new type instance.
                FieldInfo[] fields = this.GetType().GetFields(BINDINGS_PRIVATE_INSTANCES);

                foreach (FieldInfo fi in fields)
                {
                    if (fi.FieldType.IsGenericType)
                    {
                        System.Type genericType = fi.FieldType.GetGenericTypeDefinition();

                        if (genericType.Equals(typeof(EntityList <>)))
                        {
                            System.Collections.IList entityList = fi.GetValue(this) as System.Collections.IList;

                            if (entityList != null)
                            {
                                foreach (EntityBase entity in entityList)
                                {
                                    entity.RollBack();
                                }
                            }
                        }
                    }
                    else if (fi.FieldType.IsSubclassOf(typeof(EntityBase)))
                    {
                        // then replace the entity using it's own .Replace method if it is not null
                        EntityBase entityBase = fi.GetValue(this) as EntityBase;
                        if (entityBase != null)
                        {
                            entityBase.RollBack();
                        }
                    }
                }
            }
        }
示例#59
0
        /// <summary>
        /// Change from UI Window
        /// </summary>
        /// <param name="type">UIWindow class to change to</param>
        /// <param name="OnWindowChanged">Callback when window has been changed, returning the newly changed window</param>
        public void GoToWindow(System.Type type, Action <UIWindow> OnWindowChanged = null)
        {
            this.activeWindow.DisableWindow();

            int windowsLength = this.windows.Count;

            for (int i = 0; i < windowsLength; i++)
            {
                UIWindow currentWindow = this.windows[i];
                if (!type.Equals(currentWindow.GetType()))
                {
                    continue;
                }

                this.activeWindow = currentWindow;
            }

            this.activeWindow.EnableWindow();
            OnWindowChanged?.Invoke(this.activeWindow);
        }
示例#60
0
        static StackObject *Equals_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Type @o = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Type instance_of_this_method = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Equals(@o);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }