示例#1
0
        public void AuthenticationFailure()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            IWampCraProcedures proceduresProxy = channel.GetRpcProxy<IWampCraProcedures>();

            WampRpcCallException callException =
                Assert.Throws<WampRpcCallException>
                    (() => proceduresProxy.Authenticate(formatter, "foobar", null, "secret2"));
        }
示例#2
0
        public void AuthenticationSuccess()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            channel.GetRpcProxy<IWampCraProcedures>().
                    Authenticate(formatter, "foobar", null, "secret");

            string result = channel.GetRpcProxy<ISample>()
                                   .Hello("Foobar");

            Assert.IsNotNullOrEmpty(result);
        }
示例#3
0
        static void Main(string[] args)
        {
            //Sample modeled and compatible with Autobahn Python https://github.com/tavendo/AutobahnPython [examples/twisted/wamp1/authentication/client.py]

            JsonFormatter formatter = new JsonFormatter();
            DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory(formatter);
            IWampChannel<JToken> channel = channelFactory.CreateChannel("ws://localhost:9000/");

            channel.Open();

            try
            {
                IWampCraProcedures proxy = channel.GetRpcProxy<IWampCraProcedures>();

                //TODO: This can authenticates as a user, or as anonymous based on conditional.
                WampCraPermissions permissions;
                if (true)
                {
                    permissions = Authenticate(proxy, formatter, "foobar", null, "secret");
                }
                else
                {
                    permissions = Authenticate(proxy, formatter, null, null, null);
                }

                Console.WriteLine("permissions: {0}", formatter.Serialize(permissions));
            }
            catch (WampRpcCallException ex)
            {
                Console.Out.WriteLine("Authenticate WampRpcCallException: '{0}' to uri '{1}'", ex.Message,
                                      ex.ProcUri);
            }

            try
            {
                //Expect failure if running against default server sample and anonymous.

                ISample proxy = channel.GetRpcProxy<ISample>();
                string result = proxy.Hello("Foobar");
                Console.WriteLine(result);
            }
            catch (WampRpcCallException ex)
            {
                Console.Out.WriteLine("Hello WampRpcCallException: '{0}' to uri '{1}'", ex.Message,
                                      ex.ProcUri);
            }

            //server sample allows for subscribe for anon and foobar user.
            ISubject<string> subject = channel.GetSubject<string>("http://example.com/topics/mytopic1");
            IDisposable cancelation = subject.Subscribe(x => Console.WriteLine("mytopic1: " + x));

            //server sample does not allow for publish if anon.  Therefore, if logged in, expect to see
            // this in console, otherwise it will silently fail to publish (Wamp1 makes it silent).
            subject.OnNext("Hello World From Client!");

            Console.ReadLine();
            channel.Close();
        }
        public ActionResult Search(SearchOptionsSD json)
        {
            new PersonRepository().GetAll().Where(_facetedSearch.GetQueryExpression(json));
            //((TextSearchOptionsParam) searchOptions.GetParams()[0]).Text = "new text";

            string resultJson = new JsonFormatter().GetJson(GetSearchOptions(), "result", "result");

            return Content(resultJson);
        }
		public void FormatAnimeSearchResponseToJsonString()
		{
			var formatter = new JsonFormatter<AnimeSearchResponse>();

			AnimeSearchResponse animeSearchResponse = new SearchResponseDeserializer<AnimeSearchResponse>().Deserialize(RESPONSE_TEXT);
			string jsonText = formatter.Format(animeSearchResponse);
			_output.WriteLine(jsonText);

			Assert.True(IsParsableJson(jsonText));
		}
示例#6
0
        public void Analysis_ToAndFromJson_AnalysisIsProperlyDeserialized(string firstName, string lastName,
            string middleName, string birthDate)
        {
            var template = new Template("имя шаблона", "содержимое");
            var person = new Person(firstName, lastName, middleName, DateTime.Parse(birthDate));
            var jsonFormatter = new JsonFormatter();
            var expectedAnalysis = new Analysis(template, person);
            var actualAnalysis = jsonFormatter.FromJson<Analysis>(jsonFormatter.ToJson(expectedAnalysis));

            Assert.True(AnalyzesAreEqual(expectedAnalysis, actualAnalysis));
        }
示例#7
0
        protected void Application_Start()
        {
            var pathFormat = Server.MapPath("~/App_Data") + @"\Log-{Date}.txt";
            var formatter = new JsonFormatter();
            var client = new MongoClient(WebConfigurationManager.AppSettings["MongoDB"]);
            var database = client.GetDatabase(WebConfigurationManager.AppSettings["MongoDatabase"]);
            Log.Logger = new LoggerConfiguration().MinimumLevel.Verbose()
                .WriteTo.Trace(restrictedToMinimumLevel: LogEventLevel.Verbose, levelSwitch: null)
                //.WriteTo.RollingFile(formatter, pathFormat, restrictedToMinimumLevel: LogEventLevel.Verbose, retainedFileCountLimit: 31, levelSwitch: null, buffered: false, shared: false)
                .WriteTo.MongoDBCapped(database, restrictedToMinimumLevel: LogEventLevel.Verbose, cappedMaxSizeMb: 50, collectionName: "serilog", batchPostingLimit: 10, period: TimeSpan.FromSeconds(15))
                .CreateLogger();

            // System.Data.Entity.Database.SetInitializer(
            //    new System.Data.Entity.MigrateDatabaseToLatestVersion<BigDataContext, BigDataData.Migrations.Configuration>());
            EnsureAuthIndexes.Exist();
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
示例#8
0
        static void Main(string[] args)
        {
            var simpleMessageFormatter = new SimpleMessageFormatter();
            var xmlMessageFormatter = new XMLMessageFormatter();
            var jsonMessageFormatter = new JsonFormatter();

            var fileMessageAppender = new FileMessageAppender(jsonMessageFormatter, "log.txt");
            var consoleMessageAppender = new ConsoleMessageAppender(jsonMessageFormatter);

            var messageAppenders = new IMessageAppender[]
            {
                fileMessageAppender,
                consoleMessageAppender
            };

            Logger logger = new Logger(messageAppenders);
            logger.LogCriticalError("Out of memory");
            logger.LogInfo("Unused local variable 'name'");

            fileMessageAppender.CloseWriter();
        }
示例#9
0
 public RankingsEndpoint(JsonFormatter formatter)
 {
     _formatter = formatter;
 }
示例#10
0
        private static Analysis GetAnalysis(SqlDataReader reader)
        {
            string jsonData = reader["Analysis"].ToString();
            var analysis = new JsonFormatter().FromJson<Analysis>(jsonData);

            return analysis;
        }
示例#11
0
 private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
 {
     TestAllTypes message;
     try
     {
         switch (request.PayloadCase)
         {
             case ConformanceRequest.PayloadOneofCase.JsonPayload:
                 var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry));
                 message = parser.Parse<TestAllTypes>(request.JsonPayload);
                 break;
             case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
                 message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
                 break;
             default:
                 throw new Exception("Unsupported request payload: " + request.PayloadCase);
         }
     }
     catch (InvalidProtocolBufferException e)
     {
         return new ConformanceResponse { ParseError = e.Message };
     }
     catch (InvalidJsonException e)
     {
         return new ConformanceResponse { ParseError = e.Message };
     }
     try
     {
         switch (request.RequestedOutputFormat)
         {
             case global::Conformance.WireFormat.JSON:
                 var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
                 return new ConformanceResponse { JsonPayload = formatter.Format(message) };
             case global::Conformance.WireFormat.PROTOBUF:
                 return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
             default:
                 throw new Exception("Unsupported request output format: " + request.PayloadCase);
         }
     }
     catch (InvalidOperationException e)
     {
         return new ConformanceResponse { SerializeError = e.Message };
     }
 }
示例#12
0
 public override TObject Deserialize <TObject>(string symbols)
 {
     return(JsonFormatter.DeserializeObject <TObject>(symbols));
 }
 /// <summary>
 /// Converts the object to JSON string
 /// </summary>
 public override string ConvertToJson()
 {
     return(JsonFormatter.ConvertToJson(this));
 }
示例#14
0
        /// <summary>
        /// User has requested the generation of a specification file for an assembly.
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="outputPath"></param>
        /// <param name="typeFilter"></param>
        /// <param name="methodFilter"></param>
        /// <param name="templatesStyle"></param>
        /// <param name="templateExportStyle"></param>
        public static void GenerateSpecification(FileInfo assembly, string outputPath = default,
                                                 string typeFilter = default, string methodFilter = default, string templatesStyle = default,
                                                 TemplateExportStyle templateExportStyle = TemplateExportStyle.Embed)
        {
            var typeStore = new TypeStore();

            typeStore.Load(Path.Join(assembly.DirectoryName, assembly.Name));

            var g = new global::Birch.Generator.Specification.Generator(Path.Join(Directory.GetCurrentDirectory(), "\\Templates"));

            Func <ITypeDefinition, bool> typeFilterFunc;

            // lets see if we can convert the type filter into something that can be used at runtime...

            if (!string.IsNullOrEmpty(typeFilter))
            {
                try
                {
                    var parameter = System.Linq.Expressions.Expression.Parameter(typeof(ITypeDefinition), "typeDefinition");

                    var expression = DynamicExpressionParser.ParseLambda(new[] { parameter }, null, typeFilter);

                    var compiled = expression.Compile();

                    typeFilterFunc = (typeDefinition) => (bool)compiled.DynamicInvoke(typeDefinition);
                }
                catch (Exception exception)
                {
                    throw new ArgumentException($"Unable to parse type filter:'{typeFilter}'", exception);
                }
            }
            else
            {
                // just pull in everything
                typeFilterFunc = (s) => true;
            }

            Func <IMethod, bool> methodFilterFunc;

            if (!string.IsNullOrEmpty(methodFilter))
            {
                try
                {
                    var parameter = System.Linq.Expressions.Expression.Parameter(typeof(IMethod), "method");

                    var expression = DynamicExpressionParser.ParseLambda(new[] { parameter }, null, methodFilter);

                    var compiled = expression.Compile();

                    methodFilterFunc = (typeDefinition) => (bool)compiled.DynamicInvoke(typeDefinition);
                }
                catch (Exception exception)
                {
                    throw new ArgumentException($"Unable to method filter:'{methodFilter}'", exception);
                }
            }
            else
            {
                // just pull in everything
                methodFilterFunc = (s) => true;
            }


            var r = g.Generate(typeStore, typeFilterFunc, methodFilterFunc, templatesStyle);

            // if the user specified they want their templates to be individually saved, then we need to do that as well...
            if (templateExportStyle == TemplateExportStyle.File)
            {
                var outputDirectory = Path.GetDirectoryName(outputPath);

                var revisedTemplates = new List <Template>();

                foreach (var template in r.Configuration.Templates)
                {
                    var fileName = $"{template.Name}.{TemplateExtension}";

                    var fullPath = Path.Join(outputDirectory, fileName);

                    File.WriteAllText(fullPath, template.Content);

                    revisedTemplates.Add(new Template(template.Name, template.Type, TemplateLocation.File)
                    {
                        Path = fileName
                    });
                }

                r.Configuration.Templates = revisedTemplates;
            }

            var f      = new JsonFormatter();
            var output = f.Format(r);

            if (outputPath != null)
            {
                File.WriteAllText(outputPath, output);
                Console.WriteLine(Resources.SpecificationFileWritten, outputPath);
            }
            else
            {
                Console.WriteLine(output);
            }
        }
 public void OnClickItem(int itemId)
 {
     _dataString = JsonFormatter.ToPrettyPrint(_logItems[itemId].jsonStr, JsonFormatter.IndentType.Space);
 }
        public override void Export(MeshExportSettings configuration)
        {
            base.Export(configuration);

            // avatar
            var animator = Copy.GetComponent <Animator>();

            if (animator != null)
            {
                var humanoid = Copy.GetComponent <VRMHumanoidDescription>();
                UniHumanoid.AvatarDescription description = null;
                var nodes = Copy.transform.Traverse().Skip(1).ToList();
                {
                    var isCreated = false;
                    if (humanoid != null)
                    {
                        description = humanoid.GetDescription(out isCreated);
                    }

                    if (description != null)
                    {
                        // use description
                        VRM.humanoid.Apply(description, nodes);
                    }

                    if (isCreated)
                    {
                        GameObject.DestroyImmediate(description);
                    }
                }

                {
                    // set humanoid bone mapping
                    var avatar = animator.avatar;
                    foreach (HumanBodyBones key in Enum.GetValues(typeof(HumanBodyBones)))
                    {
                        if (key == HumanBodyBones.LastBone)
                        {
                            break;
                        }

                        var transform = animator.GetBoneTransform(key);
                        if (transform != null)
                        {
                            VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform));
                        }
                    }
                }
            }

            // morph
            var master = Copy.GetComponent <VRMBlendShapeProxy>();

            if (master != null)
            {
                var avatar = master.BlendShapeAvatar;
                if (avatar != null)
                {
                    foreach (var x in avatar.Clips)
                    {
                        VRM.blendShapeMaster.Add(x, this);
                    }
                }
            }

            // secondary
            VRMSpringUtility.ExportSecondary(Copy.transform, Nodes,
                                             x => VRM.secondaryAnimation.colliderGroups.Add(x),
                                             x => VRM.secondaryAnimation.boneGroups.Add(x)
                                             );

#pragma warning disable 0618
            // meta(obsolete)
            {
                var meta = Copy.GetComponent <VRMMetaInformation>();
                if (meta != null)
                {
                    VRM.meta.author             = meta.Author;
                    VRM.meta.contactInformation = meta.ContactInformation;
                    VRM.meta.title = meta.Title;
                    if (meta.Thumbnail != null)
                    {
                        VRM.meta.texture = TextureExporter.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
                    }

                    VRM.meta.licenseType     = meta.LicenseType;
                    VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
                    VRM.meta.reference       = meta.Reference;
                }
            }
#pragma warning restore 0618

            // meta
            {
                var _meta = Copy.GetComponent <VRMMeta>();
                if (_meta != null && _meta.Meta != null)
                {
                    var meta = _meta.Meta;

                    // info
                    VRM.meta.version            = meta.Version;
                    VRM.meta.author             = meta.Author;
                    VRM.meta.contactInformation = meta.ContactInformation;
                    VRM.meta.reference          = meta.Reference;
                    VRM.meta.title = meta.Title;
                    if (meta.Thumbnail != null)
                    {
                        VRM.meta.texture = TextureExporter.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
                    }

                    // ussage permission
                    VRM.meta.allowedUser        = meta.AllowedUser;
                    VRM.meta.violentUssage      = meta.ViolentUssage;
                    VRM.meta.sexualUssage       = meta.SexualUssage;
                    VRM.meta.commercialUssage   = meta.CommercialUssage;
                    VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl;

                    // distribution license
                    VRM.meta.licenseType = meta.LicenseType;
                    if (meta.LicenseType == LicenseType.Other)
                    {
                        VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
                    }
                }
            }

            // firstPerson
            var firstPerson = Copy.GetComponent <VRMFirstPerson>();
            if (firstPerson != null)
            {
                if (firstPerson.FirstPersonBone != null)
                {
                    VRM.firstPerson.firstPersonBone       = Nodes.IndexOf(firstPerson.FirstPersonBone);
                    VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset;
                    VRM.firstPerson.meshAnnotations       = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation
                    {
                        mesh            = Meshes.IndexOf(x.SharedMesh),
                        firstPersonFlag = x.FirstPersonFlag.ToString(),
                    }).ToList();
                }

                // lookAt
                {
                    var lookAtHead = Copy.GetComponent <VRMLookAtHead>();
                    if (lookAtHead != null)
                    {
                        var boneApplyer       = Copy.GetComponent <VRMLookAtBoneApplyer>();
                        var blendShapeApplyer = Copy.GetComponent <VRMLookAtBlendShapeApplyer>();
                        if (boneApplyer != null)
                        {
                            VRM.firstPerson.lookAtType = LookAtType.Bone;
                            VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner);
                            VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter);
                            VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown);
                            VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp);
                        }
                        else if (blendShapeApplyer != null)
                        {
                            VRM.firstPerson.lookAtType = LookAtType.BlendShape;
                            VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal);
                            VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown);
                            VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp);
                        }
                    }
                }
            }

            // materials
            foreach (var m in Materials)
            {
                VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures));
            }

            // Serialize VRM
            var f = new JsonFormatter();
            VRMSerializer.Serialize(f, VRM);
            var bytes = f.GetStoreBytes();
            glTFExtensionExport.GetOrCreate(ref glTF.extensions).Add("VRM", bytes);
        }
示例#17
0
        public JsonWriter(IWritable <string> writer)
        {
            this.Writer = writer;

            this.JsonFormatter = new JsonFormatter();
        }
示例#18
0
    public static void MakeSoundPrefab()
    {
        if (File.Exists(PATH_OF_CONFIG) == false)
        {
            FileStream fs = File.Create(PATH_OF_CONFIG);
            if (null != fs)
            {
                fs.Close();
            }
            else
            {
                Debug.LogError("Filed create sound prefab configuration file");
                return;
            }
        }

        string           content = File.ReadAllText(PATH_OF_CONFIG);
        FMakePrefabParam param   = null;

        if (string.IsNullOrEmpty(content))
        {
            param                    = new FMakePrefabParam();
            param.source             = "Assets/Content/ArtWork/Sound/";
            param.dest               = "Assets/Content/Prefabs/Sound/";
            param.gameName           = "mj_cdxz";
            param.source_folder      = "xiayu";
            param.act_type           = 1;
            param.prefab_config_path = "Assets/Content/Setting/" + param.gameName + "/gamesound.txt";
            param.operation          = EMakePrefab.EMP_Sound;
            string s = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(param));
            CustomTool.FileSystem.ReplaceFile(PATH_OF_CONFIG, s);
            Debug.LogError("miss configuration file. now has create a template that is " + PATH_OF_CONFIG);
            return;
        }
        else
        {
            param = LitJson.JsonMapper.ToObject <FMakePrefabParam>(content);
        }

        bool bNeedSwitchMap = false;

        if (param.operation == EMakePrefab.EMP_Sound)
        {
            if (string.IsNullOrEmpty(param.source))
            {
                Debug.LogError("Missed source directory");
                return;
            }

            if (string.IsNullOrEmpty(param.dest))
            {
                Debug.LogError("Missed dest dirctory");
                return;
            }

            if (string.IsNullOrEmpty(param.prefab_config_path))
            {
                Debug.LogError("missed output configuration file of prefabs");
                return;
            }

            List <FOutputSoundConfig> all_config = null;
            //create output configuration file
            if (File.Exists(param.prefab_config_path) == false)
            {
                FileStream fs = File.Create(param.prefab_config_path);
                if (null != fs)
                {
                    fs.Close();
                }
                else
                {
                    Debug.LogError("Failed create file " + param.prefab_config_path);
                    return;
                }

                all_config = new List <FOutputSoundConfig>();
            }
            else
            {
                string text = File.ReadAllText(param.prefab_config_path);
                if (string.IsNullOrEmpty(text) == false)
                {
                    all_config = LitJson.JsonMapper.ToObject <List <FOutputSoundConfig> >(text);
                }
                else
                {
                    all_config = new List <FOutputSoundConfig>();
                }
            }

            string source = param.source + param.gameName + "/" + param.source_folder;

            if (Directory.Exists(source) == false)
            {
                Debug.LogError("missed source directory");
                return;
            }

            string dest = param.dest + param.gameName;

            if (Directory.Exists(dest) == false)
            {
                Directory.CreateDirectory(dest);
            }
            List <string> files = CustomTool.FileSystem.GetSubFiles(source);
            if (files.Count > 0)
            {
                UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.EmptyScene, UnityEditor.SceneManagement.NewSceneMode.Single);
                bNeedSwitchMap = true;
                FOutputSoundConfig new_config = new FOutputSoundConfig();
                new_config.act_type = param.act_type;

                foreach (string file in files)
                {
                    string extend = file.Substring(file.LastIndexOf(".") + 1, file.Length - file.LastIndexOf(".") - 1);

                    if (extend == "meta")
                    {
                        continue;
                    }
                    int    dot_idx   = file.LastIndexOf(".");
                    string file_name = file.Substring(0, dot_idx);

                    string src = source + "/" + file;
                    string to  = dest + "/" + file_name + ".prefab";
                    Debug.Log(src);
                    UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(src);
                    if (obj != null)
                    {
                        GameObject  go  = new GameObject(file_name);
                        AudioSource tmp = go.AddComponent <AudioSource>();
                        if (tmp != null)
                        {
                            tmp.clip = obj as UnityEngine.AudioClip;
                        }
                        if (go != null)
                        {
                            go.name = file_name;
                            PrefabUtility.CreatePrefab(to, go, ReplacePrefabOptions.ConnectToPrefab);
                            new_config.soundPaths.Add(to);
                            Debug.Log("Made prefab " + to);
                            GameObject.DestroyImmediate(go);
                        }
                    }
                    else
                    {
                        Debug.LogError("Failed to load " + src);
                    }
                }

                bool bExist = false;
                foreach (FOutputSoundConfig config in all_config)
                {
                    if (config.act_type == new_config.act_type)
                    {
                        config.soundPaths.Clear();
                        config.soundPaths.AddRange(new_config.soundPaths);
                        bExist = true;
                        break;
                    }
                }

                if (!bExist)
                {
                    all_config.Add(new_config);
                }

                //now save the file
                string s = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(all_config));

                CustomTool.FileSystem.ReplaceFile(param.prefab_config_path, s);
                AssetDatabase.Refresh();

                if (bNeedSwitchMap)
                {
                    if (EditorBuildSettings.scenes != null && EditorBuildSettings.scenes.Length > 0)
                    {
                        string scene = EditorBuildSettings.scenes[0].path;
                        UnityEditor.SceneManagement.EditorSceneManager.OpenScene(scene, UnityEditor.SceneManagement.OpenSceneMode.Single);
                    }
                }
            }
        }
        else
        {
            Debug.LogError("make prefab operation is not matched.which is " + param.operation.ToString() + "=" + (int)param.operation);
        }
    }
 public static MerchantPreferences GetMerchantPreferences()
 {
     return(JsonFormatter.ConvertFromJson <MerchantPreferences>(MerchantPreferencesJson));
 }
示例#20
0
 public static Measurement GetMeasurement()
 {
     return(JsonFormatter.ConvertFromJson <Measurement>(MeasurementJson));
 }
示例#21
0
 public override Catalog GetObject()
 {
     return(JsonFormatter.DeserializeObject <Catalog>(File.ReadAllText(@"..\..\..\..\Swifter.Test\Resources\catalog.json")));
 }
示例#22
0
        public static void __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Tail(JsonFormatter f, float[] value)
        {
            f.BeginList();

            foreach (var item in value)
            {
                f.Value(item);
            }
            f.EndList();
        }
示例#23
0
        //----------------------------------------------------------------------------------------------------
        // return message format

        void Send(string id, string msg, string data)
        {
            mSocket.SendAsync(JsonFormatter.ResponseMessage(id, msg, data));
        }
示例#24
0
 public static PayoutBatch GetPayoutBatch()
 {
     return(JsonFormatter.ConvertFromJson <PayoutBatch>(PayoutBatchJson));
 }
示例#25
0
 public static VerifyWebhookSignatureResponse GetVerifyWebhookResponseSignature()
 {
     return(JsonFormatter.ConvertFromJson <VerifyWebhookSignatureResponse>(VerifyWebhookSignatureResponseJson));
 }
 /// <summary>
 /// Converts the object to JSON string
 /// </summary>
 public virtual string ConvertToJson()
 {
     return(JsonFormatter.ConvertToJson(this));
 }
 public static WebhookEventType GetWebhookEventType()
 {
     return(JsonFormatter.ConvertFromJson <WebhookEventType>(WebhookEventTypeJsonCreated));
 }
 public override string ToString()
 {
     return(JsonFormatter.ToDiagnosticString(this));
 }
 public static Capture GetCapture()
 {
     return(JsonFormatter.ConvertFromJson <Capture>(CaptureJson));
 }
示例#30
0
        /// <summary>
        /// Emit a batch of log events, running to completion synchronously.
        /// </summary>
        /// <param name="events">The events to emit.</param>
        /// <remarks>Override either <see cref="PeriodicBatchingSink.EmitBatch"/> or <see cref="PeriodicBatchingSink.EmitBatchAsync"/>,
        /// not both.</remarks>
        protected override void EmitBatch(IEnumerable<LogEvent> events)
        {
            var payload = new StringWriter();
            payload.Write("{\"d\":[");

            var formatter = new JsonFormatter(
                omitEnclosingObject: true,
                renderMessage: true,
                formatProvider: _formatProvider);

            var delimStart = "{";
            foreach (var logEvent in events)
            {
                payload.Write(delimStart);
                formatter.Format(logEvent, payload);
                payload.Write(",\"UtcTimestamp\":\"{0:u}\"}}",
                              logEvent.Timestamp.ToUniversalTime().DateTime);
                delimStart = ",{";
            }

            payload.Write("]}");

            var bson = BsonDocument.Parse(payload.ToString());
            var docs = bson["d"].AsBsonArray;
            GetLogCollection().InsertBatch(docs);
        }
示例#31
0
 /// <summary>
 /// Initialize parametrized serializer.
 /// </summary>
 internal PhpJsonSerializer(JsonFormatter.EncodeOptions encodeOptions, JsonFormatter.DecodeOptions decodeOptions)
 {
     // options
     this.encodeOptions = encodeOptions;
     this.decodeOptions = decodeOptions;
 }
示例#32
0
 public static CreditCard GetCreditCard()
 {
     return(JsonFormatter.ConvertFromJson <CreditCard>(CreditCardJson));
 }
示例#33
0
        public static void __colliderGroups_ITEM__colliders_ITEM__shape_Serialize_Capsule(JsonFormatter f, ColliderShapeCapsule value)
        {
            f.BeginMap();


            if (value.Offset != null && value.Offset.Count() >= 3)
            {
                f.Key("offset");
                __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Offset(f, value.Offset);
            }

            if (value.Radius.HasValue)
            {
                f.Key("radius");
                f.Value(value.Radius.GetValueOrDefault());
            }

            if (value.Tail != null && value.Tail.Count() >= 3)
            {
                f.Key("tail");
                __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Tail(f, value.Tail);
            }

            f.EndMap();
        }
示例#34
0
 public static Agreement GetAgreement()
 {
     return(JsonFormatter.ConvertFromJson <Agreement>(AgreementJson));
 }
示例#35
0
 /// <summary>
 /// Card constructor.
 /// </summary>
 /// <param name="data">string</param>
 public Card(string data) : this(JsonFormatter.ParseJObject(data))
 {
 }
示例#36
0
        public void NoAuthenticationThrowsException()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            Task<string> result =
                channel.GetRpcProxy<ISampleAsync>()
                   .Hello("Foobar");

            AggregateException aggregateException = result.Exception;
            Exception exception = aggregateException.InnerException;
            WampRpcCallException casted = exception as WampRpcCallException;

            Assert.IsNotNull(casted);
        }
        /// <summary>
        /// Filter json data.
        /// </summary>
        /// <param name="data">JObject</param>
        /// <returns>JObject</returns>
        public static JObject JObjectFilter(JObject data)
        {
            string json = JsonFormatter.RemoveNullOrEmpty(data).ToString();

            return(JsonFormatter.ParseJObject(json));
        }
示例#38
0
 public static PaymentDefinition GetPaymentDefinition()
 {
     return(JsonFormatter.ConvertFromJson <PaymentDefinition>(PaymentDefinitionJson));
 }
示例#39
0
 public static Invoice GetInvoice()
 {
     return(JsonFormatter.ConvertFromJson <Invoice>(InvoiceJson));
 }
示例#40
0
 public override string ToString()
 {
     return(JsonFormatter.prettyPrint(ToJson(this)) ?? string.Empty);
 }
 public static InputFields GetInputFields()
 {
     return(JsonFormatter.ConvertFromJson <InputFields>(InputFieldsJson));
 }
示例#42
0
 public static Sale GetSale()
 {
     return(JsonFormatter.ConvertFromJson <Sale>(SaleJson));
 }
 /// <summary>
 /// Instrument constructor.
 /// </summary>
 /// <param name="data">string</param>
 public Instrument(string data) : this(JsonFormatter.ParseJObject(data))
 {
 }