当前位置: 首页>>代码示例>>C#>>正文


C# El类代码示例

本文整理汇总了C#中El的典型用法代码示例。如果您正苦于以下问题:C# El类的具体用法?C# El怎么用?C# El使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


El类属于命名空间,在下文中一共展示了El类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyNullableEnumLongToNullableUShort

        private static void VerifyNullableEnumLongToNullableUShort(El? value)
        {
            Expression<Func<ushort?>> e =
                Expression.Lambda<Func<ushort?>>(
                    Expression.Convert(Expression.Constant(value, typeof(El?)), typeof(ushort?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ushort?> f = e.Compile();

            // compute the value with the expression tree
            ushort? etResult = default(ushort?);
            Exception etException = null;
            try
            {
                etResult = f();
            }
            catch (Exception ex)
            {
                etException = ex;
            }

            // compute the value with regular IL
            ushort? csResult = default(ushort?);
            Exception csException = null;
            try
            {
                csResult = (ushort?)value;
            }
            catch (Exception ex)
            {
                csException = ex;
            }

            // either both should have failed the same way or they should both produce the same result
            if (etException != null || csException != null)
            {
                Assert.NotNull(etException);
                Assert.NotNull(csException);
                Assert.Equal(csException.GetType(), etException.GetType());
            }
            else
            {
                if (!IsFloating(typeof(El?)) || !IsIntegral(typeof(ushort?)))
                {
                    Assert.Equal(csResult, etResult);
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:47,代码来源:ConvertTests.cs

示例2: Create

 public static El Create(Action<El> self)
 {
     var s = new El();
     self(s);
     return s;
 }
开发者ID:joeriks,项目名称:DryHtml,代码行数:6,代码来源:TagCreationTests.cs

示例3: VerifyNullableEnumLongToUShort

        private static void VerifyNullableEnumLongToUShort(El? value, bool useInterpreter)
        {
            Expression<Func<ushort>> e =
                Expression.Lambda<Func<ushort>>(
                    Expression.Convert(Expression.Constant(value, typeof(El?)), typeof(ushort)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ushort> f = e.Compile(useInterpreter);

            if (value.HasValue)
                Assert.Equal((ushort)value.GetValueOrDefault(), f());
            else
                Assert.Throws<InvalidOperationException>(() => f());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:13,代码来源:ConvertTests.cs

示例4: VerifyNullableEnumLongToNullableUShort

        private static void VerifyNullableEnumLongToNullableUShort(El? value, bool useInterpreter)
        {
            Expression<Func<ushort?>> e =
                Expression.Lambda<Func<ushort?>>(
                    Expression.Convert(Expression.Constant(value, typeof(El?)), typeof(ushort?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ushort?> f = e.Compile(useInterpreter);

            Assert.Equal((ushort?)value, f());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:ConvertTests.cs

示例5: VerifyCheckedEnumLongToShort

        private static void VerifyCheckedEnumLongToShort(El value, bool useInterpreter)
        {
            Expression<Func<short>> e =
                Expression.Lambda<Func<short>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El)), typeof(short)),
                    Enumerable.Empty<ParameterExpression>());
            Func<short> f = e.Compile(useInterpreter);

            if ((long)value < short.MinValue | (long)value > short.MaxValue)
                Assert.Throws<OverflowException>(() => f());
            else
                Assert.Equal((short)value, f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:13,代码来源:ConvertCheckedTests.cs

示例6: VerifyEnumLongToULong

        private static void VerifyEnumLongToULong(El value, bool useInterpreter)
        {
            Expression<Func<ulong>> e =
                Expression.Lambda<Func<ulong>>(
                    Expression.Convert(Expression.Constant(value, typeof(El)), typeof(ulong)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ulong> f = e.Compile(useInterpreter);

            Assert.Equal((ulong)value, f());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:ConvertTests.cs

示例7: VerifyCheckedNullableEnumLongToNullableUShort

        private static void VerifyCheckedNullableEnumLongToNullableUShort(El? value, bool useInterpreter)
        {
            Expression<Func<ushort?>> e =
                Expression.Lambda<Func<ushort?>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El?)), typeof(ushort?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ushort?> f = e.Compile(useInterpreter);

            if (!value.HasValue)
                Assert.Null(f());
            else if (value < 0 | (long)value > ushort.MaxValue)
                Assert.Throws<OverflowException>(() => f());
            else
                Assert.Equal((ushort)value, f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:15,代码来源:ConvertCheckedTests.cs

示例8: CreateLmUserStart

 public static Int64 CreateLmUserStart(LMCookieJS cook, string psw) {
   var db = Lib.CreateContext();
   var el = new El(cook.EMail, cook.Login);
   psw = LowUtils.unpackStr(psw);
   var usr = db.Users.FirstOrDefault(u => u.EMail == el.email && u.Login == el.login);
   if (usr != null)
     switch ((VerifyStates)usr.VerifyStatus) {
       case VerifyStates.ok:
         if (usr.OtherType == (short)OtherType.LANGMaster || usr.OtherType == (short)OtherType.LANGMasterNoEMail)
           return -1; //user already registered
         else { //zmena z FB, Google apod. login na LM login
           usr.Password = psw;
           usr.OtherType = (short)OtherType.LANGMaster;
           usr.OtherId = null;
           usr.FirstName = cook.FirstName;
           usr.LastName = cook.LastName;
           Lib.SaveChanges(db);
           return usr.Id;
         }
       case VerifyStates.waiting:
         return usr.Id;
       case VerifyStates.prepared:
         usr.Password = psw;
         usr.VerifyStatus = (short)VerifyStates.waiting;
         Lib.SaveChanges(db);
         return usr.Id;
     }
   if (usr == null)
     db.Users.Add(usr = new Users() {
       Created = DateTime.UtcNow,
       VerifyStatus = cook.Type == OtherType.LANGMasterNoEMail ? (short)VerifyStates.ok : (short)VerifyStates.waiting,
       Password = psw,
     });
   if (el.email == masterEMail) {
     usr.Roles = (Int64)Role.Admin;
     usr.VerifyStatus = (short)VerifyStates.ok;
   }
   cookie2user(cook, usr);
   Lib.SaveChanges(db);
   return usr.Id;
 } const string masterEMail = "[email protected]";
开发者ID:PavelPZ,项目名称:NetNew,代码行数:41,代码来源:Login.cs

示例9: VerifyCheckedNullableEnumLongToSByte

        private static void VerifyCheckedNullableEnumLongToSByte(El? value, bool useInterpreter)
        {
            Expression<Func<sbyte>> e =
                Expression.Lambda<Func<sbyte>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El?)), typeof(sbyte)),
                    Enumerable.Empty<ParameterExpression>());
            Func<sbyte> f = e.Compile(useInterpreter);

            if (value.HasValue)
            {
                var unboxed = value.GetValueOrDefault();
                if ((long)unboxed < sbyte.MinValue | (long)unboxed > sbyte.MaxValue)
                    Assert.Throws<OverflowException>(() => f());
                else
                    Assert.Equal((sbyte)unboxed, f());
            }
            else
                Assert.Throws<InvalidOperationException>(() => f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:19,代码来源:ConvertCheckedTests.cs

示例10: VerifyCheckedNullableEnumLongToNullableULong

        private static void VerifyCheckedNullableEnumLongToNullableULong(El? value, bool useInterpreter)
        {
            Expression<Func<ulong?>> e =
                Expression.Lambda<Func<ulong?>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El?)), typeof(ulong?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ulong?> f = e.Compile(useInterpreter);

            if ((!value.HasValue))
                Assert.Null(f());
            else if (value.GetValueOrDefault() < 0)
                Assert.Throws<OverflowException>(() => f());
            else
                Assert.Equal((ulong?)value.GetValueOrDefault(), f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:15,代码来源:ConvertCheckedTests.cs

示例11: VerifyCheckedNullableEnumLongToInt

        private static void VerifyCheckedNullableEnumLongToInt(El? value, bool useInterpreter)
        {
            Expression<Func<int>> e =
                Expression.Lambda<Func<int>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El?)), typeof(int)),
                    Enumerable.Empty<ParameterExpression>());
            Func<int> f = e.Compile(useInterpreter);

            if (!value.HasValue)
                Assert.Throws<InvalidOperationException>(() => f());
            else if ((long)value < int.MinValue | (long)value > int.MaxValue)
                Assert.Throws<OverflowException>(() => f());
            else
                Assert.Equal((int)value, f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:15,代码来源:ConvertCheckedTests.cs

示例12: VerifyCheckedNullableEnumLongToNullableDouble

        private static void VerifyCheckedNullableEnumLongToNullableDouble(El? value, bool useInterpreter)
        {
            Expression<Func<double?>> e =
                Expression.Lambda<Func<double?>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El?)), typeof(double?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<double?> f = e.Compile(useInterpreter);

            Assert.Equal((double?)value, f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:10,代码来源:ConvertCheckedTests.cs

示例13: VerifyCheckedEnumLongToNullableULong

        private static void VerifyCheckedEnumLongToNullableULong(El value, bool useInterpreter)
        {
            Expression<Func<ulong?>> e =
                Expression.Lambda<Func<ulong?>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El)), typeof(ulong?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<ulong?> f = e.Compile(useInterpreter);

            if (value < 0)
                Assert.Throws<OverflowException>(() => f());
            else
                Assert.Equal((ulong)value, f());
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:13,代码来源:ConvertCheckedTests.cs

示例14: OnLMLogin

 public static LMCookieJS OnLMLogin(CmdLmLogin par) {
   var db = Lib.CreateContext();
   Users usr;
   if (par.ticket != null) {
     var ticketDir = Machines.rootPath + @"App_Data\tickets";
     var ticketFn = ticketDir + "\\" + par.ticket;
     if (!File.Exists(ticketFn)) return null;
     try {
       var email = XmlUtils.FileToObject<CmdLoginTicket>(ticketFn).email;
       usr = db.Users.FirstOrDefault(u => u.EMail == email);
       //vymazani nevyuzitych ticketu (5 minut zivotnosti)
       var now = DateTime.UtcNow;
       foreach (var tfn in Directory.GetFiles(ticketDir).Where(f => (now - File.GetCreationTime(f)).TotalMinutes > 5)) File.Delete(tfn);
     } finally { File.Delete(ticketFn); }
   } else {
     var psw = LowUtils.unpackStr(par.password);
     var el = new El(par.email, par.login);
     usr = db.Users.FirstOrDefault(u => u.EMail == el.email && u.Login == el.login);
     if (usr == null || usr.Password != psw) usr = null;
   }
   //Expression<Func<User, bool>> em, lg;
   //if (el.compId == null) em = u => u.compId == null; else em = u => u.compId == el.compId;
   //if (el.login == null) lg = u => u.Login == null; else lg = u => u.Login == el.login;
   //var userObj = db.Users.Where(em).Where(lg).FirstOrDefault();
   //var tp = userObj == null ? OtherType.no : (OtherType)userObj.OtherType;
   if (
     usr == null ||
     (VerifyStates)usr.VerifyStatus != VerifyStates.ok) return null;
   return user2cookie(usr);
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:30,代码来源:Login.cs

示例15: VerifyCheckedEnumLongToSByte

        private static void VerifyCheckedEnumLongToSByte(El value)
        {
            Expression<Func<sbyte>> e =
                Expression.Lambda<Func<sbyte>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El)), typeof(sbyte)),
                    Enumerable.Empty<ParameterExpression>());
            Func<sbyte> f = e.Compile();

            // compute the value with the expression tree
            sbyte etResult = default(sbyte);
            Exception etException = null;
            try
            {
                etResult = f();
            }
            catch (Exception ex)
            {
                etException = ex;
            }

            // compute the value with regular IL
            sbyte csResult = default(sbyte);
            Exception csException = null;
            try
            {
                csResult = checked((sbyte)value);
            }
            catch (Exception ex)
            {
                csException = ex;
            }

            // either both should have failed the same way or they should both produce the same result
            if (etException != null || csException != null)
            {
                Assert.NotNull(etException);
                Assert.NotNull(csException);
                Assert.Equal(csException.GetType(), etException.GetType());
            }
            else
            {
                if (!IsFloating(typeof(El)) || !IsIntegral(typeof(sbyte)))
                {
                    Assert.Equal(csResult, etResult);
                }
            }
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:47,代码来源:ConvertCheckedTests.cs


注:本文中的El类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。