Example #1
0
        protected void Application_Start()
        {
            GlobalHttpClient = new HttpClient();

            XingePushClient.InitHttpClientCompatDefaultMagic();
            XgPushConfig.Register(GlobalHttpClient);

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var removeList = new List <MediaTypeFormatter>();

            foreach (var formatter in GlobalConfiguration.Configuration.Formatters)
            {
                if (!(formatter is JsonMediaTypeFormatter))
                {
                    removeList.Add(formatter);
                }
            }
            foreach (var formatter in removeList)
            {
                GlobalConfiguration.Configuration.Formatters.Remove(formatter);
            }

            MvcHandler.DisableMvcResponseHeader = true;
        }
Example #2
0
        public static void Register(HttpClient httpClient)
        {
            var app_id     = WebConfigurationManager.AppSettings["XgPushConfig:AppId"];
            var access_id  = long.Parse(WebConfigurationManager.AppSettings["XgPushConfig:AccessId"]);
            var secret_key = WebConfigurationManager.AppSettings["XgPushConfig:SecretKey"];
            var env        = WebConfigurationManager.AppSettings["XgPushConfig:Environment"];

            //Client = XingePushClient.Create(app_id, access_id, secret_key, env, httpClient);
            Client = new MonoCompat(app_id, access_id, secret_key, env, httpClient);
        }
Example #3
0
 public SampleController(XingePushClient pushClient) => this.pushClient = pushClient;
 public ValuesController(XingePushClient pushClient) => this.pushClient = pushClient;
Example #5
0
        public void TestMethod1()
        {
            XingePushClient.InitHttpClientCompatDefaultMagic();

            AudienceType type = new PushRequest <MessageiOS> .Token();

            var m = new Model
            {
                AudienceType = type,
                TimeInterval = new TimeInterval
                {
                    StartHour = 1,
                    StartMin  = 2,
                    EndHour   = 3,
                    EndMin    = 4,
                },
                Operator1         = Operator.AND,
                Operator2         = Operator.OR,
                True              = 1,
                False             = 0,
                Null              = null,
                NullableFalse     = 0U,
                NullableTrue      = 1U,
                ThreeDays         = TimeSpan.FromDays(3),
                UInt32S           = 60U,
                Int32S            = 120,
                NullableSeconds   = null,
                NullableThreeDays = TimeSpan.FromDays(3),
                NullableUInt32S   = 60U,
                NullableInt32S    = 120,
                TagTokenPair      = new TagTokenPair
                {
                    Tag   = "abc",
                    Token = "qwert"
                },
                TagTokenPairCompat = new Compat.TagTokenPair
                {
                    tag   = "abc1",
                    token = "qwert1"
                },
                Now1            = DateTime.Now,
                Now2            = DateTimeOffset.Now,
                TimeEmpty1      = null,
                TimeEmpty2      = null,
                TimeNull2       = string.Empty,
                D1              = Internal.Constants.DefaultMessageSendTime,
                D2              = Internal.Constants.DefaultMessageSendTime,
                iOSEnv1         = 1,
                iOSEnv2         = 2,
                iOSEnvNullable  = null,
                iOSEnv1Nullable = 1,
                iOSEnv2Nullable = 2,
            };

            m.iOSEnv1_V3         = m.iOSEnv1;
            m.iOSEnv2_V3         = m.iOSEnv2;
            m.iOSEnvNullable_V3  = m.iOSEnvNullable;
            m.iOSEnv1Nullable_V3 = m.iOSEnv1Nullable;
            m.iOSEnv2Nullable_V3 = m.iOSEnv2Nullable;

            var envE = m.iOSEnv1_V3 == m.iOSEnv1 &&
                       m.iOSEnv2_V3 == m.iOSEnv2 &&
                       m.iOSEnvNullable_V3 == m.iOSEnvNullable &&
                       m.iOSEnv1Nullable_V3 == m.iOSEnv1Nullable &&
                       m.iOSEnv2Nullable_V3 == m.iOSEnv2Nullable;

            Assert.IsTrue(envE, nameof(envE));

            var json  = m.Serialize();
            var obj   = json.Deserialize <Model>();
            var json2 = obj.Serialize();

            var isOK = json == json2;

            Assert.IsTrue(isOK, nameof(isOK));

            var iOSEnv = new iOSEnvironment(1);

            Assert.IsTrue(iOSEnv == iOSEnvironment.Production, nameof(iOSEnv));

            iOSEnvironmentV3 iOSEnv3 = iOSEnv;

            Assert.IsTrue(iOSEnv3 == iOSEnvironmentV3.Production, nameof(iOSEnv3));

            Console.WriteLine(json2);

            Console.WriteLine("Size of C# bool is: {0}", sizeof(bool));
            Console.WriteLine("Size of C# char is: {0}", sizeof(char));
            Console.WriteLine("Size of C# short is: {0}", sizeof(short));
            Console.WriteLine("Size of C# int is: {0}", sizeof(int));
            Console.WriteLine("Size of C# long is: {0}", sizeof(long));
            Console.WriteLine("Size of Operator: {0}", Marshal.SizeOf(typeof(Operator)));
            Console.WriteLine("Size of DigitBoolean: {0}", Marshal.SizeOf(typeof(DigitBoolean)));
            Console.WriteLine("Size of Seconds: {0}", Marshal.SizeOf(typeof(Second)));
            Console.WriteLine("Size of NullableDateTime: {0}", Marshal.SizeOf(typeof(NullableDateTime)));
            Console.WriteLine("Size of iOSEnvironment: {0}", Marshal.SizeOf(typeof(iOSEnvironment)));
            Console.WriteLine("Size of iOSEnvironmentV3: {0}", Marshal.SizeOf(typeof(iOSEnvironmentV3)));
        }
Example #6
0
 public static void Main(string[] args)
 {
     XingePushClient.InitHttpClientCompatDefaultMagic();
     CreateWebHostBuilder(args).Build().Run();
 }