Ejemplo n.º 1
0
    public static T CreateGO <T>(string newPath) where T : Component
    {
        if (!newPath.StartsWith("Assets/"))
        {
            newPath = "Assets/" + newPath;
        }
        T          ret = null;
        GameObject go  = new GameObject();

        try
        {
            FileAdapter.RequestFilePath(newPath);
            go.AddComponent <T>();

            if (!FileAdapter.Exists(newPath + ".prefab") || EditorUtility.DisplayDialog("Warning!", "File (" + newPath + ".prefab" + ") already exists you want to replace that file? This will delete the already existing Prefab", "Yes", "No"))
            {
                var refGo = PrefabUtility.SaveAsPrefabAsset(go, newPath + ".prefab", out var success);
                ret = refGo.GetComponent <T>();
            }
        }
        finally
        {
            GameObject.DestroyImmediate(go);
        }

        return(ret);
    }
Ejemplo n.º 2
0
        public Stream CheckNew2(string applicationId)
        {
            dynamic apps = win.core.utils.FileAdapter.GetJSONFromFile(HttpContext.Current.Server.MapPath("~/CheckNew2.json"));
            dynamic app  = null;

            foreach (dynamic theOne in apps)
            {
                if (theOne.ApplicationId == applicationId)
                {
                    app = theOne;
                    break;
                }
            }

            if (app == null)
            {
                WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
                return(new MemoryStream(Encoding.UTF8.GetBytes("无效的AppId")));
            }

            //检查主程序
            string exeFileName = app.ApplicationCode;
            string exeDir      = HttpContext.Current.Server.MapPath("~/" + applicationId);
            string exeFilePath = exeDir + @"\" + exeFileName;

            if (FileAdapter.Exists(exeFilePath))
            {
                //Assembly asm = Assembly.LoadFile(exeFilePath);会锁定
                Assembly asm     = Assembly.Load(System.IO.File.ReadAllBytes(exeFilePath));
                string   version = asm.GetName().Version.ToString();
                Product  product = new Product {
                    ApplicationId = applicationId, ApplicationName = app.ApplicationName, Version = version, Description = "更新说明"
                };
                string appRoot = GetAppRootPath();
                if (appRoot.EndsWith("/"))
                {
                    appRoot = appRoot.Substring(0, appRoot.Length - 1);
                }
                product.FileList = new UpdateFilesInfo {
                    SourcePath = appRoot + "/" + applicationId + "/"
                };

                string[] files = Directory.GetFiles(exeDir, "*", SearchOption.AllDirectories);
                product.FileList.FileItems = new List <FileItem>();
                foreach (string file in files)
                {
                    string itemName = file.Replace(exeDir + @"\", "").Replace(@"\", "/");
                    product.FileList.FileItems.Add(new FileItem {
                        Name = itemName
                    });
                }

                product.FileList.Count = product.FileList.FileItems.Count.ToString();
                byte[] resultBytes = Encoding.UTF8.GetBytes(XmlSerializeAdapter.Serialize <Product>(product));
                WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
                return(new MemoryStream(resultBytes));
            }

            return(null);
        }
Ejemplo n.º 3
0
    static T RequestResource(string resourcePath)
    {
        var t = Resources.Load <T>(resourcePath);

        if (t != null)
        {
            return(t);
        }

        var firstImport = FileAdapter.Exists($"{Application.dataPath}/{RESOURCES_DEFAULT_PATH}{resourcePath}.asset");

        if (firstImport)
        {
            return(null);
        }

        var create = UnityEditor.EditorUtility.DisplayDialog("Constant not Found", $"Did not find asset at {resourcePath}, do you want to create new one?", "Sure", "No");

        if (!create)
        {
            return(null);
        }

        t = Create(RESOURCES_DEFAULT_PATH + resourcePath);
        Debug.LogWarning("Created new Resource at " + RESOURCES_DEFAULT_PATH + resourcePath);
        return(t);
    }
Ejemplo n.º 4
0
        static void PrepareAppEnvironment()
        {
            Assembly assem = Assembly.GetExecutingAssembly();

            log4net.Config.XmlConfigurator.Configure(assem.GetManifestResourceStream("SmartLife.Client.Seat.log4net.config"));

            FileAdapter.EnsurePath(Common.SOUND_FILE_PATH);

            if (!FileAdapter.Exists(Common.DEFAULT_SOUND_NAME_OF_CALL_IN))
            {
                using (FileStream fs = new FileStream(Common.DEFAULT_SOUND_NAME_OF_CALL_IN, FileMode.Create))
                {
                    byte[] data = new byte[Properties.Resources.Callin.Length];
                    Properties.Resources.Callin.Read(data, 0, data.Length);
                    fs.Write(data, 0, data.Length);
                }
            }
            if (!FileAdapter.Exists(Common.DEFAULT_SOUND_NAME_OF_EXT_OFFLINE))
            {
                using (FileStream fs = new FileStream(Common.DEFAULT_SOUND_NAME_OF_EXT_OFFLINE, FileMode.Create))
                {
                    byte[] data = new byte[Properties.Resources.ExtOffline.Length];
                    Properties.Resources.ExtOffline.Read(data, 0, data.Length);
                    fs.Write(data, 0, data.Length);
                }
            }

            FileAdapter.EnsurePath(Common.TOOLS_FILE_PATH);
            if (!FileAdapter.Exists(Common.TOOLS_IPERF_EXE))
            {
                win.tools.Manager.ExportToFile(win.tools.ToolPackName.iperf, Common.TOOLS_FILE_PATH);
            }
        }
Ejemplo n.º 5
0
    public static T CreateSequentialGO <T>(string newPrefabPrefix) where T : Component
    {
        if (!newPrefabPrefix.StartsWith("Assets/"))
        {
            newPrefabPrefix = "Assets/" + newPrefabPrefix;
        }
        if (!FileAdapter.Exists(newPrefabPrefix + ".prefab"))
        {
            return(CreateGO <T>(newPrefabPrefix));
        }
        int id = 2;

        while (FileAdapter.Exists(newPrefabPrefix + id + ".prefab"))
        {
            id++;
        }

        return(CreateGO <T>(newPrefabPrefix + id));
    }
Ejemplo n.º 6
0
    public static ScriptableObject CreateSequential(string newPrefabPrefix, System.Type type, bool focus = false)
    {
        if (!newPrefabPrefix.StartsWith("Assets/") && !newPrefabPrefix.StartsWith("Assets\\"))
        {
            newPrefabPrefix = "Assets/" + newPrefabPrefix;
        }
        if (!FileAdapter.Exists(newPrefabPrefix + ".asset"))
        {
            return(Create(newPrefabPrefix, type, focus));
        }

        int id = 2;

        while (FileAdapter.Exists(newPrefabPrefix + id + ".asset"))
        {
            id++;
        }

        return(Create(newPrefabPrefix + id, type, focus));
    }
Ejemplo n.º 7
0
    public static T CreateSequential <T>(string newPrefabPrefix, bool focus = false) where T : ScriptableObject
    {
        if (!newPrefabPrefix.StartsWith("Assets/") && !newPrefabPrefix.StartsWith("Assets\\"))
        {
            newPrefabPrefix = "Assets/" + newPrefabPrefix;
        }
        if (!FileAdapter.Exists(newPrefabPrefix + ".asset"))
        {
            return(Create <T>(newPrefabPrefix, focus));
        }

        int id = 2;

        while (FileAdapter.Exists(newPrefabPrefix + id + ".asset"))
        {
            id++;
        }

        return(Create <T>(newPrefabPrefix + id, focus));
    }
Ejemplo n.º 8
0
        static void PrepareAppEnvironment()
        {
            Assembly assem = Assembly.GetExecutingAssembly();

            log4net.Config.XmlConfigurator.Configure(assem.GetManifestResourceStream("SmartLife.Client.Merchant.log4net.config"));


            FileAdapter.EnsurePath(Common.SOUND_FILE_PATH);

            if (!FileAdapter.Exists(Common.DEFAULT_SOUND_NAME_OF_DEALING))
            {
                using (FileStream fs = new FileStream(Common.DEFAULT_SOUND_NAME_OF_DEALING, FileMode.Create))
                {
                    byte[] data = new byte[Properties.Resources.Dealing.Length];
                    Properties.Resources.Dealing.Read(data, 0, data.Length);
                    fs.Write(data, 0, data.Length);
                }
            }
            if (!FileAdapter.Exists(Common.DEFAULT_SOUND_NAME_OF_WAIT_RESPONSE))
            {
                using (FileStream fs = new FileStream(Common.DEFAULT_SOUND_NAME_OF_WAIT_RESPONSE, FileMode.Create))
                {
                    byte[] data = new byte[Properties.Resources.WattingResponse.Length];
                    Properties.Resources.WattingResponse.Read(data, 0, data.Length);
                    fs.Write(data, 0, data.Length);
                }
            }
            if (!FileAdapter.Exists(Common.DEFAULT_SOUND_NAME_OF_WEIXING))
            {
                using (FileStream fs = new FileStream(Common.DEFAULT_SOUND_NAME_OF_WEIXING, FileMode.Create))
                {
                    byte[] data = new byte[Properties.Resources.WeiXing.Length];
                    Properties.Resources.WeiXing.Read(data, 0, data.Length);
                    fs.Write(data, 0, data.Length);
                }
            }
        }
Ejemplo n.º 9
0
        public Stream Output(string code)
        {
            string result = "";

            if (code == "apppath")
            {
                result = GetAppRootPath();
            }
            else if (code == "apppath2")
            {
                string appRoot = GetAppRootPath();
                if (appRoot.EndsWith("/"))
                {
                    appRoot = appRoot.Substring(0, appRoot.Length - 1);
                }
                result = appRoot;
            }
            else if (code == "CS002")
            {
                string exeFileName = "SmartLife.Client.Seat.exe";
                string exeFilePath = HttpContext.Current.Server.MapPath("~/" + code) + "/" + exeFileName;
                if (FileAdapter.Exists(exeFilePath))
                {
                    Assembly asm = Assembly.LoadFile(exeFilePath);
                    result = asm.GetName().Version.ToString();
                }
            }
            else if (code == "compare")
            {
                string _newsVersion = "0.1.5311.24874";
                int    ret          = _newsVersion.CompareTo("0.1.5311.16842");
                result = ret.ToString();
            }
            byte[] resultBytes = Encoding.UTF8.GetBytes(result);
            return(new MemoryStream(resultBytes));
        }
Ejemplo n.º 10
0
 public static bool Exists(string path)
 {
     return(_dict.ContainsKey(path) || FileAdapter.Exists(path));
 }
Ejemplo n.º 11
0
 public bool Exists(string path)
 {
     return(FileAdapter.Exists(_defaultPath + path));
 }