Esempio n. 1
0
        public TObject Create <TObject>(params object [] parameters)
        {
            Type[] types = Type.EmptyTypes;
            if (parameters != null && parameters.Length > 0)
            {
                types = new Type[parameters.Length];
                for (int i = 0; i < parameters.Length; i++)
                {
                    types[i] = parameters[i].GetType();
                }
            }

            if (Types.ContainsKey(typeof(TObject)))
            {
                Type            type        = Types[typeof(TObject)];
                ConstructorInfo constructor = type.GetConstructor(types);
                if (constructor != null)
                {
                    TObject result = (TObject)constructor.Invoke(parameters);
                    return(result);
                }
            }

            return(default(TObject));
        }
Esempio n. 2
0
        //procedure IISButtonOnClick(Sender: TObject);
        //var
        //    IIS, WebSite, WebServer, WebRoot, VDir: Variant;
        //    ErrorCode: Integer;
        //begin
        //    if MsgBox('Setup will now connect to Microsoft IIS Server ''' + IISServerName + ''' and create a virtual directory. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
        //        Exit;

        //    { Create the main IIS COM Automation object }

        //    try
        //        IIS := CreateOleObject('IISNamespace');
        //    except
        //        RaiseException('Please install Microsoft IIS first.'#13#13'(Error ''' + GetExceptionMessage + ''' occurred)');
        //    end;

        //    { Connect to the IIS server }

        //    WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
        //    WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
        //    WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');

        //    { (Re) create a virtual dir }

        //    try
        //        WebRoot.Delete('IIsWebVirtualDir', 'innosetup');
        //        WebRoot.SetInfo();
        //    except
        //    end;

        //    VDir := WebRoot.Create('IIsWebVirtualDir', 'innosetup');
        //    VDir.AccessRead := True;
        //    VDir.AppFriendlyName := 'Inno Setup';
        //    VDir.Path := 'C:\inetpub\innosetup';
        //    VDir.AppCreate(True);
        //    VDir.SetInfo();

        //    MsgBox('Created virtual directory ''' + VDir.Path + '''.', mbInformation, mb_Ok);

        //    { Write some html and display it }

        //    if MsgBox('Setup will now write some HTML and display the virtual directory. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
        //        Exit;

        //    ForceDirectories(VDir.Path);
        //    SaveStringToFile(VDir.Path + '/index.htm', '<html><body>Inno Setup rocks!</body></html>', False);
        //    if not ShellExecAsOriginalUser('open', IISURL + '/innosetup/index.htm', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode) then
        //        MsgBox('Can''t display the created virtual directory: ''' + SysErrorMessage(ErrorCode) + '''.', mbError, mb_Ok);
        //end;
        private void IISButtonOnClick(TObject Sender)
        {
            if (MsgBox("Setup will now connect to Microsoft IIS Server '" + IISServerName + "' and create a virtual directory. Do you want to continue?", TMsgBoxType.Information, MB.YesNo) == MsgBoxResult.No)
            {
                return;
            }

            dynamic IIS;

            // Create the main IIS COM Automation object
            try
            {
                IIS = CreateOleObject("IISNamespace");
            }
            catch
            {
                throw new Exception("Please install Microsoft IIS first.\r\r(Error '" + GetExceptionMessage() + "' occurred)");
            }

            // Connect to the IIS server
            var WebSite   = IIS.GetObject("IIsWebService", IISServerName + "/w3svc");
            var WebServer = WebSite.GetObject("IIsWebServer", IISServerNumber);
            var WebRoot   = WebServer.GetObject("IIsWebVirtualDir", "Root");

            // (Re) create a virtual dir
            try
            {
                WebRoot.Delete("IIsWebVirtualDir", "innosetup");
                WebRoot.SetInfo();
            }
            catch
            {
            }

            var VDir = WebRoot.Create("IIsWebVirtualDir", "innosetup");

            VDir.AccessRead      = true;
            VDir.AppFriendlyName = "Inno Setup";
            VDir.Path            = "C:\\inetpub\\innosetup";
            VDir.AppCreate(true);
            VDir.SetInfo();

            MsgBox("Created virtual directory '" + VDir.Path + "'.", TMsgBoxType.Information, MB.Ok);

            // Write some html and display it
            if (MsgBox("Setup will now write some HTML and display the virtual directory. Do you want to continue?", TMsgBoxType.Information, MB.YesNo) == MsgBoxResult.No)
            {
                return;
            }

            ForceDirectories(VDir.Path);
            SaveStringToFile(VDir.Path + "/index.htm", "<html><body>Inno Setup rocks!</body></html>", false);

            int ErrorCode = 0;

            if (!ShellExecAsOriginalUser("open", IISURL + "/innosetup/index.htm", "", "", ShowWindow.Normal, TExecWait.NoWait, ref ErrorCode))
            {
                MsgBox("Can't display the created virtual directory: '" + SysErrorMessage(ErrorCode) + "'.", TMsgBoxType.Error, MB.Ok);
            }
        }
Esempio n. 3
0
        //載入貼圖
        protected virtual IEnumerator ILoadTexture(string path, string texname, int index, Action <int, Texture> callback)
        {
            Texture tex = mList.GetTex(texname);

            if (tex != null)
            {
                callback.InvokeGracefully(index, tex);
                yield break;
            }

            TObject obj = new TObject();

            yield return(CoroutineMgr.Instance.StartCoroutine(DataMgr.Instance.ILoadTexture(path, texname, obj)));

            if (obj.Bundle != null)
            {
                tex = obj.Bundle.texture as Texture;
                if (tex != null)
                {
                    mList.TexPool.Add(new rTex(texname, tex));
                    callback.InvokeGracefully(index, tex);
                }

                if (obj.Bundle.assetBundle != null)
                {
                    obj.Bundle.assetBundle.Unload(false);
                }
            }
            else
            {
                callback.InvokeGracefully(index, null);
            }
            obj.Free();
        }
Esempio n. 4
0
        //procedure WordButtonOnClick(Sender: TObject);
        //var
        //    Word: Variant;
        //begin
        //    if MsgBox('Setup will now check whether Microsoft Word is running. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
        //        Exit;

        //    { Try to get an active Word COM Automation object }

        //    try
        //        Word := GetActiveOleObject('Word.Application');
        //    except
        //    end;

        //    if VarIsEmpty(Word) then
        //        MsgBox('Microsoft Word is not running.', mbInformation, mb_Ok)
        //    else
        //        MsgBox('Microsoft Word is running.', mbInformation, mb_Ok)
        //end;
        private void WordButtonOnClick(TObject Sender)
        {
            if (MsgBox("Setup will now check whether Microsoft Word is running. Do you want to continue?", TMsgBoxType.Information, MB.YesNo) == MsgBoxResult.No)
            {
                return;
            }

            dynamic Word = null;

            // Try to get an active Word COM Automation object
            try
            {
                Word = GetActiveOleObject("Word.Application");
            }
            catch
            {
            }

            if (VarIsEmpty(Word))
            {
                MsgBox("Microsoft Word is not running.", TMsgBoxType.Information, MB.Ok);
            }
            else
            {
                MsgBox("Microsoft Word is running.", TMsgBoxType.Information, MB.Ok);
            }
        }
Esempio n. 5
0
        public void DateCast(object data)
        {
            TObject obj = TObject.CreateAndCastFromObject(TType.GetDateType(SqlType.Date), data);

            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.TType.SqlType, SqlType.Date);
        }
Esempio n. 6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 public ChangeWithGroup(Change <TObject, TKey> change, Func <TObject, TGroupKey> keySelector)
 {
     _groupKey = keySelector(change.Current);
     _item     = change.Current;
     _key      = change.Key;
     _reason   = change.Reason;
 }
Esempio n. 7
0
        public void TimeStampCast(string data)
        {
            TObject obj = TObject.CreateAndCastFromObject(TType.GetDateType(SqlType.TimeStamp), data);

            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.TType.SqlType, SqlType.TimeStamp);
        }
Esempio n. 8
0
 public ItemWithGroupKey(TObject item, TGroupKey group, Optional <TGroupKey> prevousGroup, int index)
 {
     Item         = item;
     Group        = group;
     PrevousGroup = prevousGroup;
     Index        = index;
 }
Esempio n. 9
0
 public void Set(TObject obj, object value)
 {
     if (value == null || value is DBNull)
     {
         return;
     }
     DoSet(obj, value);
 }
Esempio n. 10
0
        public void CastToBoolean(object data, bool expected)
        {
            TObject obj = TObject.CreateAndCastFromObject(TType.GetBooleanType(SqlType.Boolean), data);

            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.TType.SqlType, SqlType.Boolean);
            Assert.AreEqual(expected, obj.Object);
        }
Esempio n. 11
0
        /// <summary> Создаёт новый объект и сохраняет его в Хранилище Данных </summary>
        public TObject CreateDBObject <TObject>() where TObject : DBObject
        {
            id      ID     = this.GetID(typeof(TObject));
            TObject Result = DBObject.GetEmpty(typeof(TObject), ID) as TObject;

            this.AddDBObject(Result);
            return(Result);
        }
Esempio n. 12
0
 private void FocusObjectsAdd(TObject obj)
 {
     if (FocusObjects.Count < World.MAX_FOCUSED_OBJECTS)
     {
         FocusObjects.Add(obj);
         obj.IsFocused = true;
     }
 }
Esempio n. 13
0
 public object Get(TObject obj)
 {
     if (getter == null)
     {
         return(null);
     }
     return(getter.Invoke(obj));
 }
Esempio n. 14
0
        /// <summary>
        /// Обработчик события клика по UI панели
        /// </summary>
        private void panel_UIPanelClick(object sender, UnitsLib.Events.UIPanelEventArgs e)
        {
            Point index = e.Index;

            if (FocusObjects.Count == 1)
            {
                TObject fo = FocusObjects[0];
                if (index == new Point(0, 0) && fo is TCityCenter)
                {
                    (fo as TCityCenter).ToQueue(UnitNames.Worker);
                    return;
                }
                if (index == new Point(3, 0) && fo is TCityCenter)
                {
                    State = MouseStates.BuildingMesh;
                    BuildingRectangle.SetRectangle(BuildingNames.Farm);
                    fo.IsFocused = false;
                    return;
                }
                if (index == new Point(3, 1) && fo is TCityCenter)
                {
                    State = MouseStates.BuildingMesh;
                    BuildingRectangle.SetRectangle(BuildingNames.Baracks);
                    fo.IsFocused = false;
                    return;
                }
                if (index == new Point(0, 1) && fo is TFarm)
                {
                    (fo as TFarm).ToQueue(UnitNames.Peasant);
                    return;
                }
                if (index == new Point(0, 2) && fo is TBaracks)
                {
                    (fo as TBaracks).ToQueue(UnitNames.Swordman);
                    return;
                }
                if (index == new Point(1, 0) && fo is TCUnit)
                {
                    TCUnit unit = fo as TCUnit;
                    unit.Stop();
                    unit.Center = unit.Center.Round();
                    unit.Aim    = Aims.Stand;
                    return;
                }
                if (index == new Point(1, 1) && fo is TCUnit)
                {
                    TCUnit unit = fo as TCUnit;
                    unit.HP = 0;
                    return;
                }
                if (index == new Point(2, 0) && fo is IQueue && fo is ISide && (fo as ISide).Side)
                {
                    (fo as IQueue).Clear();
                    return;
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes <see cref="FormItemMetadata"/> with given properties.
        /// </summary>
        /// <param name="properties">Properties list.</param>
        public void Init(IEnumerable <string> properties)
        {
            var schema = new TObject();

            MessageContainers = properties.ToDictionary(
                property => property,
                property => new MessageContainer(schema.Add <TObject>(property)));
            Template = schema;
        }
Esempio n. 16
0
        //procedure FormButtonOnClick(Sender: TObject);
        //var
        //    Form: TSetupForm;
        //    Edit: TNewEdit;
        //    OKButton, CancelButton: TNewButton;
        //begin
        //    Form := CreateCustomForm();
        //    try
        //        Form.ClientWidth := ScaleX(256);
        //        Form.ClientHeight := ScaleY(128);
        //        Form.Caption := 'TSetupForm';

        //        Edit := TNewEdit.Create(Form);
        //        Edit.Top := ScaleY(10);
        //        Edit.Left := ScaleX(10);
        //        Edit.Width := Form.ClientWidth - ScaleX(2 * 10);
        //        Edit.Height := ScaleY(23);
        //        Edit.Anchors := [akLeft, akTop, akRight];
        //        Edit.Text := 'TNewEdit';
        //        Edit.Parent := Form;

        //        OKButton := TNewButton.Create(Form);
        //        OKButton.Parent := Form;
        //        OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
        //        OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
        //        OKButton.Width := ScaleX(75);
        //        OKButton.Height := ScaleY(23);
        //        OKButton.Anchors := [akRight, akBottom]
        //        OKButton.Caption := 'OK';
        //        OKButton.ModalResult := mrOk;
        //        OKButton.Default := True;

        //        CancelButton := TNewButton.Create(Form);
        //        CancelButton.Parent := Form;
        //        CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
        //        CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
        //        CancelButton.Width := ScaleX(75);
        //        CancelButton.Height := ScaleY(23);
        //        CancelButton.Anchors := [akRight, akBottom]
        //        CancelButton.Caption := 'Cancel';
        //        CancelButton.ModalResult := mrCancel;
        //        CancelButton.Cancel := True;

        //        Form.ActiveControl := Edit;
        //        { Keep the form from sizing vertically since we don't have any controls which can size vertically }
        //        Form.KeepSizeY := True;
        //        { Center on WizardForm.Without this call it will still automatically center, but on the screen }
        //        Form.FlipSizeAndCenterIfNeeded(True, WizardForm, False);

        //        if Form.ShowModal() = mrOk then
        //          MsgBox('You clicked OK.', mbInformation, MB_OK);
        //    finally
        //        Form.Free();
        //    end;
        //end;
        void FormButtonOnClick(TObject Sender)
        {
            var Form = CreateCustomForm();

            try
            {
                Form.ClientWidth  = ScaleX(256);
                Form.ClientHeight = ScaleY(128);
                Form.Caption      = "TSetupForm";

                var Edit = new TNewEdit(Form);
                Edit.Top     = ScaleY(10);
                Edit.Left    = ScaleX(10);
                Edit.Width   = Form.ClientWidth - ScaleX(2 * 10);
                Edit.Height  = ScaleY(23);
                Edit.Anchors = new[] { TAnchorKind.Left, TAnchorKind.Top, TAnchorKind.Right };
                Edit.Text    = "TNewEdit";
                Edit.Parent  = Form;

                var OKButton = new TNewButton(Form);
                OKButton.Parent      = Form;
                OKButton.Left        = Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
                OKButton.Top         = Form.ClientHeight - ScaleY(23 + 10);
                OKButton.Width       = ScaleX(75);
                OKButton.Height      = ScaleY(23);
                OKButton.Anchors     = new[] { TAnchorKind.Right, TAnchorKind.Bottom };
                OKButton.Caption     = "OK";
                OKButton.ModalResult = TModalResult.Ok;
                OKButton.Default     = true;

                var CancelButton = new TNewButton(Form);
                CancelButton.Parent      = Form;
                CancelButton.Left        = Form.ClientWidth - ScaleX(75 + 10);
                CancelButton.Top         = Form.ClientHeight - ScaleY(23 + 10);
                CancelButton.Width       = ScaleX(75);
                CancelButton.Height      = ScaleY(23);
                CancelButton.Anchors     = new[] { TAnchorKind.Right, TAnchorKind.Bottom };
                CancelButton.Caption     = "Cancel";
                CancelButton.ModalResult = TModalResult.Cancel;
                CancelButton.Cancel      = true;

                Form.ActiveControl = Edit;
                // Keep the form from sizing vertically since we don't have any controls which can size vertically
                Form.KeepSizeY = true;
                // Center on WizardForm.Without this call it will still automatically center, but on the screen
                Form.FlipSizeAndCenterIfNeeded(true, WizardForm, false);

                if (Form.ShowModal() == TModalResult.Ok)
                {
                    MsgBox("You clicked OK.", TMsgBoxType.Information, MB.Ok);
                }
            }
            finally
            {
                Form.Free();
            }
        }
Esempio n. 17
0
            public static FileContent Create(TObject objectToStore, string jsonContent)
            {
                var objectType = objectToStore.GetType().GetTypeInfo();

                return(new FileContent {
                    Type = $"{objectType.FullName}, {objectType.Assembly.FullName}",
                    Content = jsonContent.ToBase64()
                });
            }
Esempio n. 18
0
        //procedure MSXMLButtonOnClick(Sender: TObject);
        //var
        //    XMLHTTP, XMLDoc, NewNode, RootNode: Variant;
        //    Path: String;
        //begin
        //    if MsgBox('Setup will now use MSXML to download XML file ''' + XMLURL + ''' and save it to disk.'#13#13'Setup will then load, modify and save this XML file. Do you want to continue?', mbInformation, mb_YesNo) = idNo then
        //    Exit;

        //    { Create the main MSXML COM Automation object }

        //    try
        //    XMLHTTP := CreateOleObject('MSXML2.ServerXMLHTTP');
        //    except
        //    RaiseException('Please install MSXML first.'#13#13'(Error ''' + GetExceptionMessage + ''' occurred)');
        //    end;

        //    { Download the XML file }

        //    XMLHTTP.Open('GET', XMLURL, False);
        //    XMLHTTP.Send();

        //    Path := ExpandConstant('{src}\');
        //    XMLHTTP.responseXML.Save(Path + XMLFileName);

        //    MsgBox('Downloaded the XML file and saved it as ''' + XMLFileName + '''.', mbInformation, mb_Ok);

        //    { Load the XML File }

        //    XMLDoc := CreateOleObject('MSXML2.DOMDocument');
        //    XMLDoc.async := False;
        //    XMLDoc.resolveExternals := False;
        //    XMLDoc.load(Path + XMLFileName);
        //    if XMLDoc.parseError.errorCode<> 0 then
        //    RaiseException('Error on line ' + IntToStr(XMLDoc.parseError.line) + ', position ' + IntToStr(XMLDoc.parseError.linepos) + ': ' + XMLDoc.parseError.reason);

        //    MsgBox('Loaded the XML file.', mbInformation, mb_Ok);

        //    { Modify the XML document }

        //    NewNode := XMLDoc.createElement('isxdemo');
        //    RootNode := XMLDoc.documentElement;
        //    RootNode.appendChild(NewNode);
        //    RootNode.lastChild.text := 'Hello, World';

        //    { Save the XML document }

        //    XMLDoc.Save(Path + XMLFileName2);

        //    MsgBox('Saved the modified XML as ''' + XMLFileName2 + '''.', mbInformation, mb_Ok);
        //end;

        private void MSXMLButtonOnClick(TObject Sender)
        {
            if (MsgBox("Setup will now use MSXML to download XML file '" + XMLURL + "' and save it to disk.\r\rSetup will then load, modify and save this XML file. Do you want to continue?",
                       TMsgBoxType.Information,
                       MB.YesNo) == MsgBoxResult.No)
            {
                return;
            }

            dynamic XMLHTTP;

            // Create the main MSXML COM Automation object
            try
            {
                XMLHTTP = CreateOleObject("MSXML2.ServerXMLHTTP");
            }
            catch
            {
                throw new Exception("Please install MSXML first.\r\r(Error '" + GetExceptionMessage() + "' occurred)");
            }

            // Download the XML file
            XMLHTTP.Open("GET", XMLURL, false);
            XMLHTTP.Send();

            var Path = ExpandConstant("{src}\\");

            XMLHTTP.responseXML.Save(Path + XMLFileName);

            MsgBox("Downloaded the XML file and saved it as '" + XMLFileName + "'.", TMsgBoxType.Information, MB.Ok);

            // Load the XML File

            var XMLDoc = CreateOleObject("MSXML2.DOMDocument");

            XMLDoc.async            = false;
            XMLDoc.resolveExternals = false;
            XMLDoc.load(Path + XMLFileName);
            if (XMLDoc.parseError.errorCode != 0)
            {
                throw new Exception("Error on line " + IntToStr(XMLDoc.parseError.line) + ", position " + IntToStr(XMLDoc.parseError.linepos) + ": " + XMLDoc.parseError.reason);
            }

            MsgBox("Loaded the XML file.", TMsgBoxType.Information, MB.Ok);

            // Modify the XML document
            var NewNode  = XMLDoc.createElement("isxdemo");
            var RootNode = XMLDoc.documentElement;

            RootNode.appendChild(NewNode);
            RootNode.lastChild.text = "Hello, World";

            // Save the XML document
            XMLDoc.Save(Path + XMLFileName2);
            MsgBox("Saved the modified XML as '" + XMLFileName2 + "'.", TMsgBoxType.Information, MB.Ok);
        }
        public IList <int> RegexSearch(Table table, int column, string regularExpression, string expressionOps)
        {
            // Get the ordered column,
            IList <int> row_list = table.SelectAll(column);
            // The result matched rows,
            List <int> result_list = new List <int>();

            // Make into a new list that matches the pattern,
            Regex regex;

            try {
                RegexOptions options = RegexOptions.None;
                if (expressionOps != null)
                {
                    if (expressionOps.IndexOf('i') != -1)
                    {
                        options |= RegexOptions.IgnoreCase;
                    }
                    if (expressionOps.IndexOf('s') != -1)
                    {
                        options |= RegexOptions.Singleline;
                    }
                    if (expressionOps.IndexOf('m') != -1)
                    {
                        options |= RegexOptions.Multiline;
                    }
                }

                regex = new Regex(regularExpression, options);
            } catch (Exception) {
                // Incorrect syntax means we always match to an empty list,
                return(result_list);
            }

            // For each row in the column, test it against the regular expression.
            int size = row_list.Count;

            for (int i = 0; i < size; ++i)
            {
                int     row_index = row_list[i];
                TObject cell      = table.GetCell(column, row_index);
                // Only try and match against non-null cells.
                if (!cell.IsNull)
                {
                    Object ob  = cell.Object;
                    String str = ob.ToString();
                    // If the column matches the regular expression then return it,
                    if (regex.IsMatch(str))
                    {
                        result_list.Add(row_index);
                    }
                }
            }

            return(result_list);
        }
        protected QueryResultPart GetResultPart(int resultId, int startRow, int countRows)
        {
            AssertNotDisposed();

            QueryResult table = GetResult(resultId);

            if (table == null)
            {
                throw new DatabaseException("'resultId' invalid.");
            }

            int rowEnd = startRow + countRows;

            if (startRow < 0 || startRow >= table.RowCount ||
                rowEnd > table.RowCount)
            {
                throw new DatabaseException("Result part out of range.");
            }

            try {
                int colCount = table.ColumnCount;
                var block    = new QueryResultPart(colCount);
                for (int r = startRow; r < rowEnd; ++r)
                {
                    var row = new object[colCount];
                    for (int c = 0; c < colCount; ++c)
                    {
                        TObject value = table.GetCellContents(c, r);

                        // If this is a IRef, we must assign it a streamable object
                        // id that the client can use to access the large object.
                        object clientOb;
                        if (value.Object is IRef)
                        {
                            var reference = (IRef)value.Object;
                            clientOb = new StreamableObject(reference.Type, reference.RawSize, reference.Id);
                        }
                        else
                        {
                            clientOb = value.Object;
                        }

                        row[c] = clientOb;
                    }

                    block.AddRow(row);
                }
                return(block);
            } catch (Exception e) {
                Logger.Warning(this, e);
                // If an exception was generated while getting the cell contents, then
                // throw an DataException.
                throw new DatabaseException("Exception while reading results: " + e.Message, e);
            }
        }
Esempio n. 21
0
 protected override void DoSet(TObject obj, object value)
 {
     if (value is bool)
     {
         setter(obj, (bool)value);
     }
     else
     {
         setter(obj, Convert.ToUInt16(value) > 0);
     }
 }
Esempio n. 22
0
 protected override void DoSet(TObject obj, object value)
 {
     if (value is byte)
     {
         setter(obj, (byte)value);
     }
     else
     {
         setter(obj, Convert.ToByte(value));
     }
 }
Esempio n. 23
0
 protected override void DoSet(TObject obj, object value)
 {
     try
     {
         setter(obj, (int)value);
     }
     catch
     {
         setter(obj, Convert.ToInt32(value));
     }
 }
Esempio n. 24
0
            // public void Set(TObject obj, object value)
            // {
            //     if (value == null || value is DBNull || !CanSet)
            //     {
            //         return;
            //     }
            //     try
            //     {
            //         setter(obj, value);
            //     }
            //     catch
            //     {
            //         throw new Exception(string.Format("将{0}类型的值{1}赋给{2}.{3}时失败", value.GetType().FullName, value, obj.GetType().FullName, prop.Name));
            //     }
            // }

            public object Get(TObject obj)
            {
                if (CanGet)
                {
                    return(getter(obj));
                }
                else
                {
                    throw new Exception("获取属性失败");
                }
            }
Esempio n. 25
0
 public void ChangeButtonClick(TObject Sender)
 {
     if (fProgress.Style == TProgressBarStyle.Marquee)
     {
         fProgress.Style = TProgressBarStyle.Normal;
     }
     else
     {
         fProgress.Style = TProgressBarStyle.Marquee;
     }
 }
Esempio n. 26
0
        public bool CheckSelect(TObject obj)
        {
            bool result = false;

            try
            {
                result = selectable[selection] == obj;
            }
            catch (Exception) { return(false); }
            return(result);
        }
Esempio n. 27
0
 /// <summary>
 /// Возвращает объект под точкой (x,y)
 /// </summary>
 /// <param name="x">Координата по оси X (мировые)</param>
 /// <param name="y">Координата по оси Y (мировые)</param>
 /// <returns>Объект под точкой (x,y)</returns>
 private TObject TObjectUnderPoint(int x, int y)
 {
     for (int i = World.TObjects.Count - 1; i >= 0; i--)
     {
         TObject g = World.TObjects[i];
         if (g.PtInside(x + scene.Rect.X, y + scene.Rect.Y))
         {
             return(g);
         }
     }
     return(null);
 }
Esempio n. 28
0
        public void StringEqual()
        {
            TObject obj1 = (TObject) "test1";
            TObject obj2 = (TObject) "test2";
            Assert.IsTrue(obj1 != obj2);

            obj1 = (TObject) "test_a";
            obj2 = (TObject) "test_a";
            Assert.IsTrue(obj1 != null);
            Assert.IsTrue(obj1 == obj2);

            obj2 = new TObject(new TStringType(SqlType.Char, 20, "enUS"), "test_b");
            Assert.IsTrue(obj1 != obj2);
        }
Esempio n. 29
0
 public static List <TObject> GetModels <TObject>() where TObject : class, IEntityObject <TObject>, new()
 {
     using (var context = new ModelsDbContext())
     {
         try
         {
             var obj = new TObject();
             return((obj.HasAssociation?obj.GetAssociaton(context.Set <TObject>()) : context.Set <TObject>()).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("Failed To Get Models " + typeof(TObject), ex);
         }
     }
 }
Esempio n. 30
0
 public void Set(TObject obj, object value)
 {
     if (value == null || value is DBNull)
     {
         return;
     }
     try
     {
         DoSet(obj, value);
     }
     catch (Exception ero)
     {
         throw new CRLException(string.Format("将值 {0} 赋值给类型{1}.{2}时失败,请检查对象类型和数据表字段类型是否一致", value + " " + value.GetType(), obj.GetType(), _prop));
     }
 }
Esempio n. 31
0
 public void Set(TObject obj, object value)
 {
     if (value == null || value is DBNull || !CanSet)
     {
         return;
     }
     try
     {
         setter(obj, value);
     }
     catch
     {
         throw new Exception(string.Format("将{0}类型的值{1}赋给{2}.{3}时失败", value.GetType().FullName, value, obj.GetType().FullName, prop.Name));
     }
 }