private void Awake()
 {
     isFiring       = G.Engine.El(false);
     isManualFiring = G.Engine.El(false);
     currentDelay   = G.Engine.El(0f);
     fire           = G.Engine.Op <Empty>();
 }
示例#2
0
        public State(IEngine engine)
        {
            UserName   = engine.El(string.Empty);
            UserId     = engine.El <int?>(null);
            RepoCount  = engine.El <int?>(null);
            HttpUserId = new HttpOp <string, int>(engine,
                                                  "https://api.github.com/users/__USER_NAME__",
                                                  pipe: HttpPipe.SingleLast
                                                  ).WithUrlTransformer((url, name) => url.Replace("__USER_NAME__", name)
                                                                       ).WithResponseParser(json => {
                UnityEngine.Profiling.Profiler.BeginSample("JsonUtility");
                var user = JsonUtility.FromJson <GitHubUser>(json);
                UnityEngine.Profiling.Profiler.EndSample();
                return(user.id);
            });
            HttpRepoCount = new HttpOp <string, int?>(engine,
                                                      "https://api.github.com/users/__USER_NAME__/repos",
                                                      pipe: HttpPipe.SingleLast
                                                      ).WithUrlTransformer((url, name) => url.Replace("__USER_NAME__", name)
                                                                           ).WithWorkerResponseParser(json => {
                var arr = JsonHelper.GetJsonArray <GitHubRepo>(json);
                return(arr != null ? arr.Length : (int?)null);
            });

            IsBusy = engine.El(false);
        }
示例#3
0
        //---Метод: Удаляет подключение из Config файла----------------------------------------------------------------------
        public static void DeleteConnection(string ConnectionName)
        {
            try
            {
                //DeSelectAllConnections();
                XmlDocument document = new XmlDocument();
                document.Load(path);
                XmlElement RootElement = document.DocumentElement;

                foreach (XmlElement El in RootElement) // Пробежимся по Элементам Корневого элемента
                {
                    if (El.Name == "Connections")      // Если имя элемента "Connections"
                    {
                        foreach (XmlNode childnode in El.ChildNodes)
                        {
                            if (childnode.Name == "Connection")
                            {
                                XmlNode атрибут = childnode.Attributes.GetNamedItem("Name");

                                if (Cryption.Decrypt(атрибут.Value) == ConnectionName) // Если "Название" равно "Осень"
                                {
                                    El.RemoveChild(childnode);
                                }
                            }
                        }
                    }
                }
                document.Save(path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "XmlClass.DeleteConnection(string ConnectionName)");
            }
        }
示例#4
0
        public void TemplateChunkGenerate(string ArrayName)
        {
            if (InTemplateChunk)
            {
                throw new Exception("Exit template chunk before generating");
            }

            if (Data.GetObject(ArrayName, null, out object Obj) != DataType.Array)
            {
                throw new Exception(string.Format("Object '{0}' is not array", ArrayName));
            }

            JArray ObjArray = (JArray)Obj;
            int    Length   = NodeCount = ObjArray.Count;

            Data.UseSpecialObjectHook(GetSpecialObject, () => {
                for (int i = 0; i < Length; i++)
                {
                    NodeIndex = i;

                    JObject IndexedObj = (JObject)ObjArray[i];
                    Data.UseRootObject(IndexedObj, () => {
                        foreach (var El in TemplateChunk)
                        {
                            OpenXmlElement Clone = (OpenXmlElement)El.Clone();
                            Clone = TemplateChunkBody.AppendChild(Clone);

                            Processor.Process(TemplateChunkBody, Clone);
                        }
                    });
                }
            });
        }
示例#5
0
        public List <string> GetSelectOptions(string Name)
        {
            List <string> Fields = new List <string>();

            foreach (Element El in SelectElements)
            {
                if (El.HasName && El.Name.Equals(Name))
                {
                    HtmlNodeCollection OptionColl = El.SelectNodes(".//option");
                    if (OptionColl != null)
                    {
                        for (int i = 0; i < OptionColl.Count; i++)
                        {
                            try
                            {
                                Fields.Add((new Element(OptionColl[i], i)).Attributes.Get("value").Value);
                            }
                            catch
                            {
                                //Exception thrown probably because there was not attribute named 'value'
                            }
                        }
                    }
                }
            }
            return(Fields);
        }
示例#6
0
 public Item(IEngine engine, string id, string name, string image, int level)
 {
     Id    = id;
     Name  = name;
     Image = image;
     Level = engine.El(level);
 }
示例#7
0
        public bool CheckMark(string mark)
        {
            string mk = mark;

            if (!Array.Exists(simv, El => El.Equals(mk[0])) && !Array.Exists(simv, El => El.Equals(mk[4])) && !Array.Exists(simv, El => El.Equals(mk[5])))
            {
                return(false);
            }
            mk = mk.Substring(1, 3);
            if (Array.Exists(simv, El => El.Equals(int.Parse(mk))))
            {
                return(false);
            }
            mk = mark;
            mk = mk.Substring(6, 3);
            if (Array.Exists(simv, El => El.Equals(int.Parse(mk))))
            {
                return(false);
            }

            if (!(int.Parse(mk) >= 1) && !(int.Parse(mk) <= 92))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Generate an EA-Module into the defined package. It adds the EA Module reference if exists.
        /// - Component with Stereotype 'LE Modul'
        /// - <tbd>Tagged values are missing(ASIL level)</tbd>
        /// </summary>
        public void Generate(EA.Package pkg)
        {
            if (El == null)
            {
                // Create Module
                El            = (EA.Element)pkg.Elements.AddNew(Name, "Component");
                El.Stereotype = @"LE Modul";
                El.Update();
                pkg.Elements.Refresh();
            }
            //-------------------------------------------------------
            // Create Ports
            var portNames = new List <string>();

            foreach (var functionItem in RequiredFunctions)
            {
                var interfaceName = functionItem.Interface.Name;
                if (!portNames.Contains(interfaceName))
                {
                    portNames.Add(interfaceName);
                }
            }
            foreach (var functionItem in ProvidedFunctions)
            {
                var interfaceName = functionItem.Interface.Name;
                if (!portNames.Contains(interfaceName))
                {
                    portNames.Add(interfaceName);
                }
            }

            var existingPorts = EaElement.GetEmbeddedElements(El);


            // Create new ports
            var newPorts = from s in portNames
                           where existingPorts.All(i => s != i.Name)
                           select s;
            // Delete not used ports
            var deletePorts = from s in existingPorts
                              where portNames.All(i => s.Name != i)
                              orderby s.Pos descending
                              select s;

            // delete not needed ports
            foreach (var deletePort in deletePorts)
            {
                El.EmbeddedElements.Delete(deletePort.Pos);
            }
            El.EmbeddedElements.Refresh();


            // create new ports
            foreach (var portName in newPorts)
            {
                var newPort = (EA.Element)El.EmbeddedElements.AddNew(portName, "Port");
                newPort.Name = portName;
            }
        }
 void Start()
 {
     er             = GameObject.FindGameObjectWithTag("Envanter").GetComponent <Envanter>();
     el             = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <El>();
     yp             = GameObject.FindGameObjectWithTag("YanPanel").GetComponent <YanPanel>();
     BlockHighlight = GameObject.FindGameObjectWithTag("CubeHighlight");
     dataitem       = GameObject.FindGameObjectWithTag("DataItem").GetComponent <DataItem>();
 }
示例#10
0
        public bool CheckVIN(string vin)
        {
            if (vin.Length > 17 || vin.Length < 17)
            {
                return(false);
            }
            string WMI = vin.Substring(0, 3);

            if (!Array.Exists(Simv, El => El.Equals(WMI[0])) || !Array.Exists(Simv, El => El.Equals(WMI[1])) || !Array.Exists(Simv, El => El.Equals(WMI[2])))
            {
                return(false);
            }
            string VDS = vin.Substring(3, 5);

            for (int i = 0; i < VDS.Length; i++)
            {
                if (!Array.Exists(Sim, El => El.Equals(VDS[i])))
                {
                    return(false);
                }
            }

            string VIS = vin.Substring(9, 8);

            if (!Array.Exists(Simv, El => El.Equals(VIS[0])) || !Array.Exists(Simv, El => El.Equals(VIS[1])) || !Array.Exists(Simv, El => El.Equals(VIS[2])) ||
                !Array.Exists(Simv, El => El.Equals(VIS[3])))
            {
                return(false);
            }

            int ch = int.Parse(VIS.Substring(4, 4));

            if (ch < 1000 && ch > 10000)
            {
                return(false);
            }
            int sum = 0;

            for (int i = 0; i < vin.Length; i++)
            {
                if (i != 8)
                {
                    int ves = weight[i + 1];
                    int c   = countries[vin[i]];
                    sum += ves * c;
                }
            }
            int s   = sum / 11;
            int d   = s * 11;
            int CHK = sum - d;

            if (!(CHK == 10 && vin[8] == 'X') || !(int.Parse(vin[8].ToString()) >= 0 && int.Parse(vin[8].ToString()) <= 9))
            {
                return(false);
            }
            return(true);
        }
示例#11
0
 public State(IEngine engine)
 {
     Gold           = engine.El(50);
     Home           = new Home(engine);
     Inventory      = new Inventory(engine);
     SimpleLoading  = new Scene <Empty>(engine, "SimpleLoading", backAutoClose: false);
     SceneStack     = new SceneStack(engine);
     ShouldShowBack = engine.El(false);
 }
示例#12
0
        private static void VerifyEnumLongConstant(El value, bool useInterpreter)
        {
            Expression <Func <El> > e =
                Expression.Lambda <Func <El> >(
                    Expression.Constant(value, typeof(El)),
                    Enumerable.Empty <ParameterExpression>());
            Func <El> f = e.Compile(useInterpreter);

            Assert.Equal(value, f());
        }
示例#13
0
            //////////////////////////////////////////////////////////////////////////
            public void Paint(Graphics G, float Y)
            {
                float X = 0;

                foreach (TextElement El in Elements)
                {
                    El.Paint(G, X, Y);
                    X += El.Size.Width;
                }
            }
示例#14
0
 void Start()
 {
     if (!isLocalPlayer)
     {
         el       = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <El>();
         er       = GameObject.FindGameObjectWithTag("Envanter").GetComponent <Envanter>();
         yan      = GameObject.FindGameObjectWithTag("YanPanel").GetComponent <YanPanel>();
         animator = GetComponent <Animator>();
     }
 }
示例#15
0
 protected Scene(IEngine engine, string name, LoadSceneMode mode, bool backAutoClose)
 {
     Name            = name;
     Mode            = mode;
     BackAutoClose   = backAutoClose;
     State           = engine.El(SceneState.Closed);
     Root            = engine.El <GameObject>(null);
     LoadingProgress = engine.El(1f);
     Close           = engine.Op <Empty>(allowWriters: true);
     Back            = engine.Op <bool>(allowWriters: true);
 }
    private void Awake()
    {
        currentDelay   = G.Engine.El(delay);
        currentEnemies = G.Engine.El(0);
        spawn          = G.Engine.Op <Vector2>();
        spawning       = G.Engine.Li(new List <Spawning>());
        spawningCurrentDelayWatcher = G.Engine.Wa(cd, spawning, it => it.CurrentDelay);
        spawningFactory             = new Spawning.Factory();
        rand = new System.Random();

        spawningFactory.Setup(cd, G.Engine, G.Tick, spawn);
    }
示例#17
0
        public VerifyConfirmOp(IEngine engine, Func <T, string> messageFormatter, bool allowWriters = false)
        {
            this.messageFormatter = messageFormatter;

            Status   = engine.El(false);
            Current  = engine.El(default(T));
            Dialog   = new Scene <Empty>(engine, "YesNoDialog", backAutoClose: false);
            Trigger  = engine.Op <T>(allowWriters);
            Yes      = engine.Op <T>();
            No       = engine.Op <T>();
            Rejected = engine.Op <T>();
        }
示例#18
0
 public static void CheckEnumLongCoalesceTest(bool useInterpreter)
 {
     El?[] array1 = new El?[] { null, (El)0, El.A, El.B, (El)long.MaxValue, (El)long.MinValue };
     El[]  array2 = new El[] { (El)0, El.A, El.B, (El)long.MaxValue, (El)long.MinValue };
     for (int i = 0; i < array1.Length; i++)
     {
         for (int j = 0; j < array2.Length; j++)
         {
             VerifyEnumLongCoalesce(array1[i], array2[j], useInterpreter);
         }
     }
 }
示例#19
0
        private static void VerifyEnumLongCoalesce(El?a, El b, bool useInterpreter)
        {
            Expression <Func <El> > e =
                Expression.Lambda <Func <El> >(
                    Expression.Coalesce(
                        Expression.Constant(a, typeof(El?)),
                        Expression.Constant(b, typeof(El))),
                    Enumerable.Empty <ParameterExpression>());
            Func <El> f = e.Compile(useInterpreter);

            Assert.Equal(a ?? b, f());
        }
示例#20
0
        public HttpOp(IEngine engine, string url,
                      HttpPipe pipe = HttpPipe.Multiple, bool allowWriters = false)
        {
            this.engine = engine;
            this.pipe   = pipe;
            this.url    = url;

            Request    = engine.Op <TReq>(allowWriters);
            Response   = engine.Op <TRes>();
            Error      = engine.Op <HttpError>();
            Requesting = engine.El(0);
        }
示例#21
0
    void Start()
    {
        el = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <El>();
        er = GameObject.FindGameObjectWithTag("Envanter").GetComponent <Envanter>();


        if (cam == null)
        {
            Debug.Log("PlayerShoot: No Camera referenced.");
            this.enabled = false;
        }
    }
示例#22
0
        private static void VerifyEnumLong(bool condition, El a, El b, bool useInterpreter)
        {
            Expression <Func <El> > e =
                Expression.Lambda <Func <El> >(
                    Expression.Condition(
                        Expression.Constant(condition, typeof(bool)),
                        Expression.Constant(a, typeof(El)),
                        Expression.Constant(b, typeof(El))),
                    Enumerable.Empty <ParameterExpression>());
            Func <El> f = e.Compile(useInterpreter);

            Assert.Equal(condition ? a : b, f());
        }
示例#23
0
        public ObservableCollection <Entry> GetArtilleryentries()
        {
            ArtilleryEntriesList.Clear();
            ArtilleryString = EmptySelector.Artillery;

            if (ArtilleryString != "" && ArtilleryString != null)
            {
                String[] ArtilleryEntries = ArtilleryString.Split('|');

                foreach (var Entry in ArtilleryEntries)
                {
                    if (Entry != "")
                    {
                        String[] Elements = Entry.Split(';');
                        Entry    E        = new Entry();
                        bool     flag     = true;
                        bool     nameFlag = true;

                        foreach (var El in Elements)
                        {
                            if (flag == true)
                            {
                                flag = false;
                                String[] MinMax = El.Split('-');
                                E.Min = Int32.Parse(MinMax[0]);
                                E.Max = Int32.Parse(MinMax[1]);
                            }
                            else
                            {
                                String[] UnitFlag = El.Split(',');
                                if (nameFlag == true)
                                {
                                    E.Name   = UnitFlag[0] + " Artillery";
                                    nameFlag = false;
                                }

                                Unit newUnit = new Unit(Int32.Parse(UnitFlag[0]));
                                E.UnitList.Add(newUnit);

                                if (UnitFlag[1] == "true")
                                {
                                    E.ExcludingUnitList.Add(newUnit);
                                }
                            }
                        }
                        ArtilleryEntriesList.Add(E);
                    }
                }
            }
            return(ArtilleryEntriesList);
        }
示例#24
0
        public ObservableCollection <Entry> GetTransportsentries()
        {
            TransportsEntriesList.Clear();
            TransportsString = EmptySelector.Transport;

            if (TransportsString != "" && TransportsString != null)
            {
                String[] TransportsEntries = TransportsString.Split('|');

                foreach (var Entry in TransportsEntries)
                {
                    if (Entry != "")
                    {
                        String[] Elements = Entry.Split(';');
                        Entry    E        = new Entry();
                        bool     flag     = true;
                        bool     nameFlag = true;

                        foreach (var El in Elements)
                        {
                            if (flag == true)
                            {
                                flag = false;
                                String[] MinMax = El.Split('-');
                                E.Min = Int32.Parse(MinMax[0]);
                                E.Max = Int32.Parse(MinMax[1]);
                            }
                            else
                            {
                                String[] UnitFlag = El.Split(',');
                                if (nameFlag == true)
                                {
                                    E.Name   = UnitFlag[0] + " Armoured Cars";
                                    nameFlag = false;
                                }

                                Unit newUnit = new Unit(Int32.Parse(UnitFlag[0]));
                                E.UnitList.Add(newUnit);

                                if (UnitFlag[1] == "true")
                                {
                                    E.ExcludingUnitList.Add(newUnit);
                                }
                            }
                        }
                        TransportsEntriesList.Add(E);
                    }
                }
            }
            return(TransportsEntriesList);
        }
    private void Awake()
    {
        rb2d   = GetComponent <Rigidbody2D>();
        orgPos = transform.position;

        W.Mark(rb2d);
        W.Mark(transform, "position");
        W.Mark(countText, "text");
        W.Mark(winText, "text");

        Position = G.Engine.El(transform.position);
        Score    = G.Engine.El(0);
        movement = G.Engine.El(Vector2.zero);
    }
示例#26
0
 public static void CheckTernaryEnumLongTest(bool useInterpreter)
 {
     bool[] array1 = new bool[] { false, true };
     El[]   array2 = new El[] { (El)0, El.A, El.B, (El)long.MaxValue, (El)long.MinValue };
     for (int i = 0; i < array1.Length; i++)
     {
         for (int j = 0; j < array2.Length; j++)
         {
             for (int k = 0; k < array2.Length; k++)
             {
                 VerifyEnumLong(array1[i], array2[j], array2[k], useInterpreter);
             }
         }
     }
 }
        /// <summary>
        /// Generate an EA-Interface into the defined package. It adds the EA Interface reference if exists.
        /// </summary>
        public int Generate(EA.Package pkg)
        {
            int newMethods = 0;

            if (El == null)
            {
                // Create Interface
                El = (EA.Element)pkg.Elements.AddNew(Name, "Interface");
                El.Update();
            }
            // Generate operations for Interface
            foreach (FunctionItem functionItem in ProvidedFunctions)
            {
                EA.Method m        = functionItem.Op;
                bool      isUpdate = true;
                if (m == null)
                {
                    isUpdate = false;
                    // new function
                    m = (EA.Method)El.Methods.AddNew(functionItem.Name, "Operation");
                    newMethods++;
                }
                m.ReturnType = functionItem.ReturnType;
                m.Update();
                if (isUpdate)
                {
                    DeleteParameter(m);
                }
                foreach (ParameterItem par in functionItem.ParameterList)
                {
                    string       parName = par.Name;
                    EA.Parameter p       = (EA.Parameter)m.Parameters.AddNew(parName, "Parameter");
                    p.Position = par.Position;
                    p.Type     = par.Type;
                    p.IsConst  = par.IsConst;
                    p.Update();
                    m.Parameters.Refresh();
                    functionItem.Op = m;
                }
                m.Parameters.Refresh();



                functionItem.Op = m;
            }
            El.Methods.Refresh();
            return(newMethods);
        }
示例#28
0
        /// <summary>
        /// Выдаёт первую запись в виде List string
        /// </summary>
        /// <param name="QueryString"></param>
        /// <returns></returns>
        public List <string> QueryOne(string QueryString)
        {
            DataTable Table = Query(QueryString);

            if (Table.Rows.Count == 0)
            {
                return(null);
            }

            List <string> Res = new List <string>();

            foreach (var El in Table.Rows[0].ItemArray)
            {
                Res.Add(El.ToString());
            }
            return(Res);
        }
示例#29
0
        private static int[,] GrafToMatrix(Graf graf)
        {
            int[,] tomb = new int[graf.Csucsok.Count, graf.Csucsok.Count];

            for (int i = 0; i < graf.Csucsok.Count; i++)
            {
                for (int j = 0; j < graf.Csucsok.Count; j++)
                {
                    if (graf.VezetEL(graf.Csucsok[i], graf.Csucsok[j]))
                    {
                        El el = graf.GetEl(graf.Csucsok[i], graf.Csucsok[j]);

                        tomb[i, j] = (int)el.Tavolsag;
                    }
                    else
                    {
                        tomb[i, j] = 0;
                    }
                }
            }

            return(tomb);
        }
示例#30
0
        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);
                }
            }
        }
        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());
        }
示例#32
0
 public static El Create(Action<El> self)
 {
     var s = new El();
     self(s);
     return s;
 }
        private static void VerifyCheckedEnumLongToNullableFloat(El value, bool useInterpreter)
        {
            Expression<Func<float?>> e =
                Expression.Lambda<Func<float?>>(
                    Expression.ConvertChecked(Expression.Constant(value, typeof(El)), typeof(float?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<float?> f = e.Compile(useInterpreter);

            Assert.Equal((float)value, f());
        }
        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());
        }
        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());
        }
        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());
        }
示例#37
0
        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());
        }
        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());
        }
示例#39
0
文件: Login.cs 项目: PavelPZ/NetNew
 static void cookie2user(LMCookieJS cook, Users usr) {
   var el = new El(cook.EMail, cook.Login);
   usr.EMail = el.email;
   usr.FirstName = cook.FirstName;
   usr.LastName = cook.LastName;
   usr.Login = el.login;
   usr.LoginEMail = cook.LoginEMail;
   usr.OtherType = (short)cook.Type;
   usr.OtherId = cook.TypeId;
   usr.OtherData = cook.OtherData;
 }
示例#40
0
文件: Login.cs 项目: PavelPZ/NetNew
 public static LMCookieJS OnOtherLogin(OtherType otherType, string otherId, string email, string firstName, string lastName) {
   var db = Lib.CreateContext();
   var el = new El(email, null);
   var usr = db.Users.FirstOrDefault(u => u.EMail == el.email && u.Login == null);
   if (usr == null) db.Users.Add(usr = new Users() { EMail = email, Created = DateTime.UtcNow });
   usr.VerifyStatus = (short)VerifyStates.ok;
   usr.OtherType = (short)otherType; usr.OtherId = otherId; usr.FirstName = firstName; usr.LastName = lastName;
   Lib.SaveChanges(db);
   return user2cookie(usr);
 }
    private void Awake()
    {
        W.Mark(transform, "rotation");

        rotation = G.Engine.El(transform.rotation);
    }
示例#42
0
        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);
                }
            }
        }
        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());
        }
示例#44
0
文件: Login.cs 项目: PavelPZ/NetNew
 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);
 }
示例#45
0
        private static void VerifyEnumLongToNullableSByte(El value, bool useInterpreter)
        {
            Expression<Func<sbyte?>> e =
                Expression.Lambda<Func<sbyte?>>(
                    Expression.Convert(Expression.Constant(value, typeof(El)), typeof(sbyte?)),
                    Enumerable.Empty<ParameterExpression>());
            Func<sbyte?> f = e.Compile(useInterpreter);

            Assert.Equal((sbyte)value, f());
        }
示例#46
0
文件: Login.cs 项目: PavelPZ/NetNew
 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 = "*****@*****.**";
示例#47
0
        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());
        }
        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());
        }
示例#49
0
        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());
        }