Exemplo n.º 1
0
        private void Save()
        {
            int id = 0;
            List <EffectConfig> configs = new List <EffectConfig>();

            EffectConfig config = new EffectConfig();

            config.Id        = EnumUtils.EnumToInt(EffectConfigName.THIRD_PERSON);
            config.Directory = "CameraFollowDemo/ThirdPersonCharacter/Prefabs";
            config.Names     = new List <string>()
            {
                "ThirdPersonController.prefab"
            };
            config.Delay         = false;
            config.StrategyType  = StrategyType.FixedForce;
            config.MaxSize       = 4;
            config.MinSize       = 1;
            config.LifeTime      = 2000;
            config.GoName        = "Test";
            config.Reset         = true;
            config.BehaviourName = typeof(EffectBehaviour).FullName;
            config.Mask          = EnumUtils.EnumToInt(ResourceCacheMask.Testing);
            config.Level         = DeviceLevel.High;
            config.IsTimerOn     = true;
            configs.Add(config);

            EffectConfig.CheckDuplicatedDatas("ResourceConfig", configs);
            SortById <EffectConfig> inst = new SortById <EffectConfig>();

            configs.Sort(inst);
            XmlFileUtils.SaveXML(string.Format("{0}/{1}/{2}{3}", Application.dataPath, XmlFileNameDefine.Directory, XmlFileNameDefine.ResourceCache, XmlFileNameDefine.SuffixFlag), configs);
        }
Exemplo n.º 2
0
 private void SaveXMl()
 {
     List<TestXmlData> datas = new List<TestXmlData>();
     datas.Add(new TestXmlData() { Id = 1, Age = 10, Name = "kay1"});
     datas.Add(new TestXmlData() { Id = 2, Age = 9, Name = "kay2" });
     datas.Add(new TestXmlData() { Id = 3, Age = 10, Name = "kay3" });
     datas.Add(new TestXmlData() { Id = 4, Age = 12, Name = "kay4" });
     datas.Add(new TestXmlData() { Id = 5, Age = 13, Name = "kay5" });
     XmlFileUtils.SaveXML(string.Format("{0}/{1}/{2}{3}", Application.dataPath, XmlFileNameDefine.Directory, XmlFileNameDefine.TestPerson, XmlFileNameDefine.SuffixFlag), datas);
 }
Exemplo n.º 3
0
        public static void GenerateKey()
        {
            RSACryptoServiceProvider rcp = new RSACryptoServiceProvider();
            string keyString             = rcp.ToXmlString(true);

            XmlFileUtils.SaveText("E:\\key.xml", keyString);
            //FileStream fs = File.Create("E:\\key.xml");
            //fs.Write(Encoding.UTF8.GetBytes(keyString), 0, Encoding.UTF8.GetBytes(keyString).Length);
            //fs.Flush();
            //fs.Close();
        }
Exemplo n.º 4
0
        public object FormatXMLData(string fileName, Type dicType, Type type, string fileContent = null)
        {
            object result = null;

            if (string.IsNullOrEmpty(fileName))
            {
                DebugUtils.Warning("FormatXMLData", "fileName IsNullOrEmpty");
                return(result);
            }
            try
            {
                result = dicType.GetConstructor(Type.EmptyTypes).Invoke(null);
                Dictionary <Int32, Dictionary <String, String> > map;//Int32 为 mId, string 为 属性名, string 为 属性值
                if (fileContent != null && XmlFileUtils.LoadIntMap(fileContent, out map))
                {
                    var props = type.GetProperties();//获取实体属性
                    foreach (var item in map)
                    {
                        var t = type.GetConstructor(Type.EmptyTypes).Invoke(null);//构造实体实例
                        foreach (var prop in props)
                        {
                            if (prop.Name == XmlData.mKeyFieldName)
                            {
                                prop.SetValue(t, item.Key, null);
                            }
                            else
                            {
                                if (item.Value.ContainsKey(prop.Name))
                                {
                                    var value = XmlFileUtils.GetValue(item.Value[prop.Name], prop.PropertyType);
                                    prop.SetValue(t, value, null);
                                }
                            }
                        }
                        dicType.GetMethod("Add").Invoke(result, new object[] { item.Key, t });
                    }
                    DebugUtils.Info(fileName + " Loaded ", map.Count);
                }
                else
                {
                    result = null;
                    DebugUtils.Warning(fileName + " Not Founded ", "Please Check Timestamps right");
                }
            }
            catch (Exception ex)
            {
                DebugUtils.Error("XmlData", ex.Message);
            }
            return(result);
        }
Exemplo n.º 5
0
        private string GetXmlContent(string fileName)
        {
            string content = null;

#if UNITY_EDITOR && !EDITOR_AB
            if (!fileName.EndsWith(XmlData.mXmlSuffix))
            {
                fileName = fileName + XmlData.mXmlSuffix;
            }
            fileName = string.Format("{0}/{1}/{2}", Application.dataPath, XmlFileNameDefine.Directory, fileName);
            content  = XmlFileUtils.LoadText(fileName);
#endif
            return(content);
        }