public static void Init(string applicationId) { if (!_Initilized) { Assembly assem = Assembly.GetExecutingAssembly(); log4net.Config.XmlConfigurator.Configure(assem.GetManifestResourceStream("SmartLife.Share.Behaviors.log4net.config")); if (applicationId == SmartLife_CertManage_CertServices || applicationId == SmartLife_Auth_Mobile_Services || applicationId == SmartLife_CertManage_MobileServices || applicationId == SmartLife_DataExchange_Services || applicationId == SmartLife_WeiXin || applicationId == SmartLife_Officer_CertServices || applicationId == SmartLife_Auth_CertServices || applicationId == SmartLife_CertManage_MerchantServices ) { _Initilized = true; } CurrentApplicationId = applicationId; StreamReader srForErrorMessage = new StreamReader(assem.GetManifestResourceStream("SmartLife.Share.Behaviors.ErrorCodeMessage.txt")); string[] lines = srForErrorMessage.ReadToEnd().Split('\n'); srForErrorMessage.Close(); foreach (var line in lines) { if (line.Trim() != "") { var keyValues = line.Split("=".ToCharArray()); if (!errorCodeMessages.ContainsKey(keyValues[0])) { errorCodeMessages.Add(keyValues[0], keyValues[1].Replace("\r", "")); } } } } }
public void Keys() { Assert.AreEqual(_dictionary.Count, _dictionary.Keys.Count); foreach (string key in _dictionary.Keys) { Assert.IsTrue(_dictionary.ContainsKey(key)); } }
public void SetUserLoginData(string value, string key) { if (temp.ContainsKey(key)) { temp[key] = value; } else { temp.Add(key, value); } }
protected override ScriptableObjectExtended InternalGetAsset(string key) { #if UNITY_EDITOR if (key == null || !m_DbDictionary.ContainsKey(key)) { Debug.LogWarning("No asset in DB with key equals to " + key); return(null); } #endif if (!m_DbDictionary.ContainsKey(key)) { throw new System.Exception("Asset with guid not found: " + key); } else { string path = m_DbDictionary[key]; if (path.StartsWith("Assets/")) #if UNITY_EDITOR { return(UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObjectExtended>(path)); } #else { throw new System.Exception("Trying to access to an editor-only asset"); }
/// <summary> /// /// </summary> /// <param name="deviceExtendParameters"></param> /// <returns></returns> private FluxPlace GetFluxPlace(string deviceExtendParameters) { FluxPlace p = FluxPlace.Unknown; StringStringDictionary ssd = StringStringDictionaryConverter.Parse(deviceExtendParameters); if (ssd.ContainsKey(PlaceDeviceBase.PN_FLUXPLACE)) { string place = ssd[PlaceDeviceBase.PN_FLUXPLACE]; try { p = (FluxPlace)Enum.Parse(typeof(FluxPlace), place); } catch (Exception ex) { log.Error(ex.ToString()); } } return(p); }
/// <summary> /// Restore asset paths /// </summary> public void OnAfterDeserialize() { FieldInfo[] members = GetFields(GetType()); foreach (FieldInfo member in members) { Type fieldType = GetUnderlyingType(member); if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(DatablockRef <>)) { var dbref = GetFieldValue <IDatablockRef>(member); if (dbref != null && assetPaths.ContainsKey(member.Name)) { var constructor = member.FieldType.GetConstructor(new Type[] { typeof(string) }); object val = constructor.Invoke(new object[] { assetPaths[member.Name] }); member.SetValue(this, val); } } } }
public void Update(Vector2Int mapsize, Texture2D beforeTexture) { properties = new StringNoiseValueTypeDictionary(); this.beforeTexture = beforeTexture; this.mapsize = mapsize; switch (type) { case NoiseType.Perlin: Shader = Shader.Find("Noise/Perlin"); Properties.Add("X", NoiseValueType.Float); Properties.Add("Y", NoiseValueType.Float); Properties.Add("Scale", NoiseValueType.Float); Properties.Add("Fractal", NoiseValueType.Int); Properties.Add("Mode", NoiseValueType.Mode); break; case NoiseType.Simplex: Shader = Shader.Find("Noise/Simplex"); Properties.Add("X", NoiseValueType.Float); Properties.Add("Y", NoiseValueType.Float); Properties.Add("Scale", NoiseValueType.Float); Properties.Add("Fractal", NoiseValueType.Int); Properties.Add("Mode", NoiseValueType.Mode); break; case NoiseType.Circle: Shader = Shader.Find("Noise/Circle"); Properties.Add("X", NoiseValueType.Float); Properties.Add("Y", NoiseValueType.Float); Properties.Add("Scale", NoiseValueType.Float); Properties.Add("Mode", NoiseValueType.Mode); break; case NoiseType.Box: Shader = Shader.Find("Noise/Box"); Properties.Add("X", NoiseValueType.Float); Properties.Add("Y", NoiseValueType.Float); Properties.Add("BLX", NoiseValueType.Float); Properties.Add("BLY", NoiseValueType.Float); Properties.Add("TRX", NoiseValueType.Float); Properties.Add("TRY", NoiseValueType.Float); Properties.Add("Mode", NoiseValueType.Mode); break; case NoiseType.BasicTerrain: Shader = Shader.Find("Noise/BasicTerrain"); Properties.Add("Height", NoiseValueType.Float); Properties.Add("Scale", NoiseValueType.Float); Properties.Add("Fractal", NoiseValueType.Int); Properties.Add("Mode", NoiseValueType.Mode); break; case NoiseType.Ridge: Shader = Shader.Find("Noise/Ridge"); Properties.Add("Scale", NoiseValueType.Float); Properties.Add("Grain", NoiseValueType.Float); Properties.Add("Lacunarity", NoiseValueType.Float); Properties.Add("Fractal", NoiseValueType.Int); Properties.Add("Mode", NoiseValueType.Mode); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } foreach (var pair in Properties) { if (values.ContainsKey(pair.Key)) { continue; } switch (pair.Value) { case NoiseValueType.Int: values.Add(pair.Key, "0"); break; case NoiseValueType.Float: values.Add(pair.Key, "0"); break; case NoiseValueType.String: values.Add(pair.Key, ""); break; case NoiseValueType.Mode: values.Add(pair.Key, "0"); break; default: throw new ArgumentOutOfRangeException(); } } }