コード例 #1
0
ファイル: SimpleJSON.cs プロジェクト: DDReaper/VSCode
		public static JSONNode Deserialize (System.IO.BinaryReader aReader)
		{
			JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte ();
			switch (type) {
				case JSONBinaryTag.Array:
					{
						int count = aReader.ReadInt32 ();
						JSONArray tmp = new JSONArray ();
						for (int i = 0; i < count; i++)
							tmp.Add (Deserialize (aReader));
						return tmp;
					}
				case JSONBinaryTag.Class:
					{
						int count = aReader.ReadInt32 ();                
						JSONClass tmp = new JSONClass ();
						for (int i = 0; i < count; i++) {
							string key = aReader.ReadString ();
							var val = Deserialize (aReader);
							tmp.Add (key, val);
						}
						return tmp;
					}
				case JSONBinaryTag.Value:
					{
						return new JSONData (aReader.ReadString ());
					}
				case JSONBinaryTag.IntValue:
					{
						return new JSONData (aReader.ReadInt32 ());
					}
				case JSONBinaryTag.DoubleValue:
					{
						return new JSONData (aReader.ReadDouble ());
					}
				case JSONBinaryTag.BoolValue:
					{
						return new JSONData (aReader.ReadBoolean ());
					}
				case JSONBinaryTag.FloatValue:
					{
						return new JSONData (aReader.ReadSingle ());
					}
 
				default:
					{
						throw new Exception ("Error deserializing JSON. Unknown tag: " + type);
					}
			}
		}
コード例 #2
0
ファイル: SimpleJSON.cs プロジェクト: DDReaper/VSCode
		public override JSONNode this [string aKey]
		{
			get {
				return new JSONLazyCreator (this, aKey);
			}
			set {
				var tmp = new JSONClass ();
				tmp.Add (aKey, value);
				Set (tmp);
			}
		}
コード例 #3
0
ファイル: SimpleJSON.cs プロジェクト: DDReaper/VSCode
		public override void Add (string aKey, JSONNode aItem)
		{
			var tmp = new JSONClass ();
			tmp.Add (aKey, aItem);
			Set (tmp);
		}
コード例 #4
0
ファイル: VSCode.cs プロジェクト: Brandon9721/Unity-Practice
        /// <summary>
        /// Updte Visual Studio Code Launch file
        /// </summary>
        static void UpdateLaunchFile(int port)
        {
            //TODO Eventually all this JSON can be replaced with intragrated JSON

            // Create Default Config
            SimpleJSON.JSONClass defaultClass = new SimpleJSON.JSONClass();
            defaultClass ["name"]              = "Unity";
            defaultClass ["type"]              = "mono";
            defaultClass ["address"]           = "localhost";
            defaultClass ["port"].AsInt        = port;
            defaultClass ["sourceMaps"].AsBool = false;

            // Create Default Node
            SimpleJSON.JSONNode defaultNode = new SimpleJSON.JSONClass();
            defaultNode ["version"]             = "0.1.0";
            defaultNode ["configurations"] [-1] = defaultClass;

            if (!Directory.Exists(VSCode.LaunchFolder))
            {
                System.IO.Directory.CreateDirectory(VSCode.LaunchFolder);
            }

            if (!File.Exists(VSCode.LaunchPath))
            {
                File.WriteAllText(VSCode.LaunchPath, defaultNode.ToString());
            }
            else
            {
                string rawContent = File.ReadAllText(VSCode.LaunchPath);
                SimpleJSON.JSONNode existingNode = SimpleJSON.JSON.Parse(rawContent);

                bool found = false;

                if (existingNode != null && existingNode ["configurations"] != null)
                {
                    int index = 0;

                    foreach (SimpleJSON.JSONNode conf in existingNode["configurations"].AsArray)
                    {
                        if (conf ["name"].Value == "Unity")
                        {
                            found = true;
                            break;
                        }
                        index++;
                    }

                    if (found)
                    {
                        existingNode ["configurations"] [index] = defaultClass;
                    }
                }

                if (found)
                {
                    File.WriteAllText(VSCode.LaunchPath, existingNode.ToString());
                }
                else
                {
                    File.WriteAllText(VSCode.LaunchPath, defaultNode.ToString());
                }
            }
        }
コード例 #5
0
ファイル: VSCode.cs プロジェクト: DDReaper/VSCode
        /// <summary>
        /// Write Default Workspace Settings
        /// </summary>
        static void WriteWorkspaceSettings()
        {
            SimpleJSON.JSONClass exclusions = new SimpleJSON.JSONClass ();

            // Hidden
            exclusions ["**/.DS_Store"].AsBool = true;
            exclusions ["**/.git"].AsBool = true;

            // Project Related
            exclusions ["**/*.booproj"].AsBool = true;
            //exclusions ["**/*.csproj"].AsBool = true;
            exclusions ["**/*.pidb"].AsBool = true;
            //exclusions ["**/*.sln"].AsBool = true;
            exclusions ["**/*.suo"].AsBool = true;
            exclusions ["**/*.user"].AsBool = true;
            exclusions ["**/*.userprefs"].AsBool = true;
            exclusions ["**/*.unityproj"].AsBool = true;

            // References
            exclusions ["**/*.dll"].AsBool = true;
            exclusions ["**/*.exe"].AsBool = true;

            // Media
            exclusions ["**/*.gif"].AsBool = true;
            exclusions ["**/*.ico"].AsBool = true;
            exclusions ["**/*.jpg"].AsBool = true;
            exclusions ["**/*.jpeg"].AsBool = true;
            exclusions ["**/*.mid"].AsBool = true;
            exclusions ["**/*.midi"].AsBool = true;
            exclusions ["**/*.pdf"].AsBool = true;
            exclusions ["**/*.png"].AsBool = true;
            exclusions ["**/*.psd"].AsBool = true;
            exclusions ["**/*.tga"].AsBool = true;
            exclusions ["**/*.tif"].AsBool = true;
            exclusions ["**/*.tiff"].AsBool = true;
            exclusions ["**/*.wav"].AsBool = true;

            // Unity
            exclusions ["**/*.asset"].AsBool = true;
            exclusions ["**/*.cubemap"].AsBool = true;
            exclusions ["**/*.flare"].AsBool = true;
            exclusions ["**/*.mat"].AsBool = true;
            exclusions ["**/*.meta"].AsBool = true;
            exclusions ["**/*.*.meta"].AsBool = true;
            exclusions ["**/*.pidb.meta"].AsBool = true;
            exclusions ["**/*.prefab"].AsBool = true;
            exclusions ["**/*.unity"].AsBool = true;

            // Models
            exclusions ["**/*.3ds"].AsBool = true;
            exclusions ["**/*.3DS"].AsBool = true;
            exclusions ["**/*.fbx"].AsBool = true;
            exclusions ["**/*.FBX"].AsBool = true;
            exclusions ["**/*.lxo"].AsBool = true;
            exclusions ["**/*.LXO"].AsBool = true;
            exclusions ["**/*.ma"].AsBool = true;
            exclusions ["**/*.MA"].AsBool = true;
            exclusions ["**/*.obj"].AsBool = true;
            exclusions ["**/*.OBJ"].AsBool = true;

            // Folders
            exclusions ["build/"].AsBool = true;
            exclusions ["Build/"].AsBool = true;
            exclusions ["library/"].AsBool = true;
            exclusions ["Library/"].AsBool = true;
            exclusions ["obj/"].AsBool = true;
            exclusions ["Obj/"].AsBool = true;
            exclusions ["ProjectSettings/"].AsBool = true;
            exclusions ["temp/"].AsBool = true;
            exclusions ["Temp/"].AsBool = true;

            SimpleJSON.JSONClass file = new SimpleJSON.JSONClass ();

            file ["files.exclude"] = exclusions;

            if (!Directory.Exists (VSCode.SettingsFolder)) {
                System.IO.Directory.CreateDirectory (VSCode.SettingsFolder);
            }

            // Dont like the replace but it fixes the issue with the JSON
            File.WriteAllText (VSCode.SettingsPath, file.ToString ().Replace ("\"true\"", "true"));
        }
コード例 #6
0
ファイル: VSCode.cs プロジェクト: DDReaper/VSCode
        /// <summary>
        /// Update Visual Studio Code Launch file
        /// </summary>
        static void UpdateLaunchFile(int port)
        {
            //TODO Eventually all this JSON can be replaced with intragrated JSON

            // Create Default Config
            SimpleJSON.JSONClass defaultClass = new SimpleJSON.JSONClass ();
            defaultClass ["name"] = "Unity";
            defaultClass ["type"] = "mono";
            defaultClass ["address"] = "localhost";
            defaultClass ["port"].AsInt = port;
            defaultClass ["sourceMaps"].AsBool = false;

            // Create Default Node
            SimpleJSON.JSONNode defaultNode = new SimpleJSON.JSONClass ();
            defaultNode ["version"] = "0.1.0";
            defaultNode ["configurations"] [-1] = defaultClass;

            if (!Directory.Exists (VSCode.SettingsFolder)) {
                if (VSCode.Debug) {
                    UnityEngine.Debug.Log ("[VSCode] Visual Studio Code settings not found, creating necessary folder.");
                }
                System.IO.Directory.CreateDirectory (VSCode.SettingsFolder);
            }

            if (!File.Exists (VSCode.LaunchPath)) {
                File.WriteAllText (VSCode.LaunchPath, defaultNode.ToString ());
            } else {
                string rawContent = File.ReadAllText (VSCode.LaunchPath);
                SimpleJSON.JSONNode existingNode = SimpleJSON.JSON.Parse (rawContent);

                bool found = false;

                if (existingNode != null && existingNode ["configurations"] != null) {
                    int index = 0;

                    foreach (SimpleJSON.JSONNode conf in existingNode["configurations"].AsArray) {
                        if (conf ["name"].Value == "Unity") {
                            found = true;
                            break;
                        }
                        index++;
                    }

                    if (found) {
                        existingNode ["configurations"] [index] = defaultClass;
                    }
                }

                if (found) {
                    File.WriteAllText (VSCode.LaunchPath, existingNode.ToString ());
                } else {
                    File.WriteAllText (VSCode.LaunchPath, defaultNode.ToString ());
                }
            }
        }
コード例 #7
0
ファイル: VSCode.cs プロジェクト: SimonDarksideJ/VSCode
        /// <summary>
        /// Write Default Workspace Settings
        /// </summary>
        static void WriteWorkspaceSettings()
        {
            SimpleJSON.JSONClass exclusions = new SimpleJSON.JSONClass();

            // Hidden
            exclusions ["**/.DS_Store"].AsBool = true;
            exclusions ["**/.git"].AsBool      = true;

            // Project Related
            exclusions ["**/*.booproj"].AsBool = true;
            //exclusions ["**/*.csproj"].AsBool = true;
            exclusions ["**/*.pidb"].AsBool = true;
            //exclusions ["**/*.sln"].AsBool = true;
            exclusions ["**/*.suo"].AsBool       = true;
            exclusions ["**/*.user"].AsBool      = true;
            exclusions ["**/*.userprefs"].AsBool = true;
            exclusions ["**/*.unityproj"].AsBool = true;

            // References
            exclusions ["**/*.dll"].AsBool = true;
            exclusions ["**/*.exe"].AsBool = true;

            // Media
            exclusions ["**/*.gif"].AsBool  = true;
            exclusions ["**/*.ico"].AsBool  = true;
            exclusions ["**/*.jpg"].AsBool  = true;
            exclusions ["**/*.jpeg"].AsBool = true;
            exclusions ["**/*.mid"].AsBool  = true;
            exclusions ["**/*.midi"].AsBool = true;
            exclusions ["**/*.pdf"].AsBool  = true;
            exclusions ["**/*.png"].AsBool  = true;
            exclusions ["**/*.psd"].AsBool  = true;
            exclusions ["**/*.tga"].AsBool  = true;
            exclusions ["**/*.tif"].AsBool  = true;
            exclusions ["**/*.tiff"].AsBool = true;
            exclusions ["**/*.wav"].AsBool  = true;

            // Unity
            exclusions ["**/*.asset"].AsBool     = true;
            exclusions ["**/*.cubemap"].AsBool   = true;
            exclusions ["**/*.flare"].AsBool     = true;
            exclusions ["**/*.mat"].AsBool       = true;
            exclusions ["**/*.meta"].AsBool      = true;
            exclusions ["**/*.*.meta"].AsBool    = true;
            exclusions ["**/*.pidb.meta"].AsBool = true;
            exclusions ["**/*.prefab"].AsBool    = true;
            exclusions ["**/*.unity"].AsBool     = true;

            // Models
            exclusions ["**/*.3ds"].AsBool = true;
            exclusions ["**/*.3DS"].AsBool = true;
            exclusions ["**/*.fbx"].AsBool = true;
            exclusions ["**/*.FBX"].AsBool = true;
            exclusions ["**/*.lxo"].AsBool = true;
            exclusions ["**/*.LXO"].AsBool = true;
            exclusions ["**/*.ma"].AsBool  = true;
            exclusions ["**/*.MA"].AsBool  = true;
            exclusions ["**/*.obj"].AsBool = true;
            exclusions ["**/*.OBJ"].AsBool = true;

            // Folders
            exclusions ["build/"].AsBool           = true;
            exclusions ["Build/"].AsBool           = true;
            exclusions ["library/"].AsBool         = true;
            exclusions ["Library/"].AsBool         = true;
            exclusions ["obj/"].AsBool             = true;
            exclusions ["Obj/"].AsBool             = true;
            exclusions ["ProjectSettings/"].AsBool = true;
            exclusions ["temp/"].AsBool            = true;
            exclusions ["Temp/"].AsBool            = true;

            SimpleJSON.JSONClass file = new SimpleJSON.JSONClass();

            file ["files.exclude"] = exclusions;

            if (!Directory.Exists(VSCode.SettingsFolder))
            {
                System.IO.Directory.CreateDirectory(VSCode.SettingsFolder);
            }

            // Dont like the replace but it fixes the issue with the JSON
            File.WriteAllText(VSCode.SettingsPath, file.ToString().Replace("\"true\"", "true"));
        }
コード例 #8
0
        public static JSONNode Deserialize(System.IO.BinaryReader aReader)
        {
            JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte();

            switch (type)
            {
            case JSONBinaryTag.Array:
            {
                int       count = aReader.ReadInt32();
                JSONArray tmp   = new JSONArray();
                for (int i = 0; i < count; i++)
                {
                    tmp.Add(Deserialize(aReader));
                }
                return(tmp);
            }

            case JSONBinaryTag.Class:
            {
                int       count = aReader.ReadInt32();
                JSONClass tmp   = new JSONClass();
                for (int i = 0; i < count; i++)
                {
                    string key = aReader.ReadString();
                    var    val = Deserialize(aReader);
                    tmp.Add(key, val);
                }
                return(tmp);
            }

            case JSONBinaryTag.Value:
            {
                return(new JSONData(aReader.ReadString()));
            }

            case JSONBinaryTag.IntValue:
            {
                return(new JSONData(aReader.ReadInt32()));
            }

            case JSONBinaryTag.DoubleValue:
            {
                return(new JSONData(aReader.ReadDouble()));
            }

            case JSONBinaryTag.BoolValue:
            {
                return(new JSONData(aReader.ReadBoolean()));
            }

            case JSONBinaryTag.FloatValue:
            {
                return(new JSONData(aReader.ReadSingle()));
            }

            default:
            {
                throw new Exception("Error deserializing JSON. Unknown tag: " + type);
            }
            }
        }