Exemple #1
0
        public void CamelCaseConversPascalCaseToCamelCase()
        {
            // Act
            string name = JsonUtility.CamelCase("SomeMethod");

            // Assert
            Assert.Equal("someMethod", name);
        }
        private static void GenerateClientRxStuff(StringBuilder sb, HubDescriptor descriptor)
        {
            var hubName = JsonUtility.CamelCase(descriptor.Name);

            sb.AppendFormat("").AppendLine();
            sb.AppendFormat("            subject : $.extend(new Rx.Subject(), {{toJSON: function() {{}}}}),").AppendLine();
            sb.AppendFormat("            subjectOnNext: function(value) {{").AppendLine();
            sb.AppendFormat("                                           signalR.{0}.client.subject.onNext(value);", hubName).AppendLine();
            sb.AppendFormat("                       }}").AppendLine();
        }
Exemple #3
0
        private static string GetDescriptorName(Descriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }

            string name = descriptor.Name;

            // If the name was not specified then do not camel case
            if (!descriptor.NameSpecified)
            {
                name = JsonUtility.CamelCase(name);
            }

            return(name);
        }
        private static void GenerateServerRxSubject(StringBuilder sb, HubDescriptor descriptor)
        {
            var hubName = JsonUtility.CamelCase(descriptor.Name);

            sb.AppendFormat(",").AppendLine();
            sb.AppendFormat("            observe: function (eventName) {{ ").AppendLine();
            sb.AppendFormat("                                return Rx.Observable.createWithDisposable(function (obs) {{ ").AppendLine();
            sb.AppendFormat("                                                var disposable = signalR.{0}.client.subject ", hubName).AppendLine();
            sb.AppendFormat("                                                    .asObservable() ").AppendLine();
            sb.AppendFormat("                                                    .where(function (x) {{ return x.EventName.toLowerCase() === eventName.toLowerCase(); }}) ").AppendLine();
            sb.AppendFormat("                                                    .subscribe(function (x) {{ ").AppendLine();
            sb.AppendFormat("                                                        if (x.Type === 'onNext') obs.onNext(x.Data); ").AppendLine();
            sb.AppendFormat("                                                        if (x.Type === 'onError') obs.onError(x.Data); ").AppendLine();
            sb.AppendFormat("                                                        if (x.Type === 'onCompleted') obs.onCompleted(); ").AppendLine();
            sb.AppendFormat("                                                    }}); ").AppendLine();
            sb.AppendFormat("                                                return disposable; ").AppendLine();
            sb.AppendFormat("                                 }}); ").AppendLine();
            sb.AppendFormat("                             }} ").AppendLine();
        }