小编Mar*_*ijn的帖子

UML序列图调用属性

在我的应用程序中,我有一个Document类和一个DocumentFact类.DocumentFact类包含将从数据库中获取多个Documents的方法.这些文档存储在数据表或数据集中.两者(datatable,dataset)都是documentfact类的私有成员.可以通过酒店访问它们.

现在我的问题是:在序列图中,是否允许调用这样的属性:

Actor      Web interface    DocumentFact          Database
  |          |                 |                      |
  |input     |                 |                      |
  |------->  |  GetDocuments   |                      |
  |          |---------------->|                      |
  |          |                 | ExecuteSelectQuery() |
  |          |                 | -------------------->|
  |          |                 |                      |
  |          |                 |      Bool            |
  |          |                 | <--------------------|
  |          |                 |                      |
  |          |                 |   GetDataSet()       |
  |          |                 | -------------------->|
  |          |                 |                      |
  |          |                 |    DataSet           |
  |          |                 |<---------------------|
  |          |                 |                      |
Run Code Online (Sandbox Code Playgroud)

GetDataSet是一个属性.它是否正确?如果不是,那么这样做的正确方法是什么?

注意:这只是我序列图的一部分,其余部分不相关.

diagram uml properties sequence

3
推荐指数
1
解决办法
3284
查看次数

C#返回私有对象

是否有任何指南可以返回类的对象?我有一个类,它有一个List和一个方法,它对列表做了一些事情并返回该列表:

public class Foo
{
  private List<Bar> _myList = new List<Bar>();

  public List<Bar> DoSomething()
  {
    // Add items to the list
    return _myList;
  }

}
Run Code Online (Sandbox Code Playgroud)

我不认为这是返回列表的好方法,因为现在调用方法可以修改列表,从而更新对象Foo中的列表.这可能会导致意外和不需要的行为.

你是如何处理这种情况的?您是否复制了对象(在本例中为列表)并返回该对象,或者?有没有最好的做法或技巧?

c#

3
推荐指数
1
解决办法
1723
查看次数

C#子类使用相同的方法

我有一个带有两个子类的超类.这两个子类都有一个方法,用于检查章节是否包含内容.对于子类1,此方法是HasContent(int chapterID),对于子类2,这是HasContent(int chapterID,int institution).如您所见,子类2有一个额外的参数.两种方法的目的是相同的.

我想将方法​​HasContent放在超类中.你觉得我需要这样做吗?如果是这样,我该如何实现呢?或者将两个方法放在他们自己的子类中更明智?

编辑:

HasDocuments的主体如下所示:Subclass1:

Database DB = new Database();
int res = DB.ExecuteSpRetVal(chapterID, mInstitutionID);

if (res > 0)
    return true;
else
    return false;
Run Code Online (Sandbox Code Playgroud)

Subclass2:

Database DB = new Database();
int res = DB.ExecuteSpRetVal(chapterID);

if (res > 0)
    return true;
else
    return false;
Run Code Online (Sandbox Code Playgroud)

c# methods subclass

2
推荐指数
1
解决办法
8504
查看次数

PHP Session无法在PHP5中运行

我有2页:login.php和index.php.这两个页面都以

session_start();
Run Code Online (Sandbox Code Playgroud)

当我设置

$_SESSION['user'] = "name"; 
Run Code Online (Sandbox Code Playgroud)

在login.php中,而不是打开index.php,我的会话对象为空.怎么会?

编辑:

我发现了问题:IE 7.我不得不访问我的域名.但是,我认为会话存储在服务器上,而不是客户端?为什么我有IE浏览器访问我的域名?(http://www.pcwindowstips.com/2007/09/04/how-to-enable-cookies-in-internet-explorer-7/)

php session

2
推荐指数
1
解决办法
2万
查看次数

C#哪里放一般方法?

在我的应用程序中,我有一个检查变量是否为数字的方法.在我的代码中多次调用此方法.从代码隐藏页面调用该方法.像这种方法我有更多的方法,我不能放在一个类(如工作人员).我应该在哪里放这种方法?

c# methods

2
推荐指数
1
解决办法
2767
查看次数

C#正则表达式替换url

我在文档中有一堆链接,必须用javascript调用替换.所有链接看起来都一样:

<a href="http://domain/ViewDocument.aspx?id=3D1&doc=form" target="_blank">Document naam 1</a>
<a href="http://domain/ViewDocument.aspx?id=3D2&doc=form" target="_blank">Document naam 2</a>
<a href="http://domain/ViewDocument.aspx?id=3D3&doc=form" target="_blank">Document naam 3</a>
Run Code Online (Sandbox Code Playgroud)

现在我希望将所有这些链接替换为:

<a href="javascript:loadDocument('1','form')">Document naam 1</a>
<a href="javascript:loadDocument('2','form')">Document naam 2</a>
<a href="javascript:loadDocument('3','form')">Document naam 3</a>
Run Code Online (Sandbox Code Playgroud)

因此,url中的Id = 3D是函数中的第一个参数,doc参数是函数调用中的第二个参数.

我想用Regex这样做,因为我认为这是最快捷的方式.但问题是我的正则表达式知识太有限了

c# regex

2
推荐指数
1
解决办法
2915
查看次数

C#MVC返回视图(对象)会产生查询字符串吗?

我有这个actionresult方法:

public ActionResult MenuItemCreated(MenuItem item)
{
    return View(item);
}
Run Code Online (Sandbox Code Playgroud)

这是我的观点:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MenuItem>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    MenuItemCreated
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>MenuItemCreated</h2>

    <%: Model.Caption %> is created succesfully
</asp:Content>
Run Code Online (Sandbox Code Playgroud)

我在页面上看到的内容是正确的(测试创建成功).但我的查询符如下所示:

http://localhost:62602/Admin/MenuItemCreated/2?Caption=test&Link=%2Fclient
Run Code Online (Sandbox Code Playgroud)

编辑:从这个方法调用ActionResult:

public ActionResult CreateMenuItem(FormCollection fc)
{
    MenuItem menuItem = CreateMenuItemFrom(fc);
    SaveMenuItem(menuItem);

    return RedirectToAction("MenuItemCreated", menuItem);
}
Run Code Online (Sandbox Code Playgroud)

编辑二:

对应观点:

<% using (Html.BeginForm("CreateMenuItem","Admin",FormMethod.Post)) {%>
    <%: Html.ValidationSummary(true) %>

    <fieldset>
        <legend>Fields</legend>

        <div class="editor-label">
            <%: Html.LabelFor(model => model.Caption) %>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.Caption) %>
            <%: Html.ValidationMessageFor(model …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

2
推荐指数
1
解决办法
1万
查看次数

Java连接到sql server

我有这个代码:

try
    {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");

        Connection conn = DriverManager.getConnection(
            "jdbc:jtds:sqlserver://myMachine:1433/myDB;instance=sql2008;user=myUserName;password=myPassword;"
        );

        System.out.println("connected");
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

这是我得到的例外:

Unable to get information from SQL Server: myMachine.
        at net.sourceforge.jtds.jdbc.MSSqlServerInfo.<init>(MSSqlServerInfo.java:97)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:276)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
        at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:207)
        at Library.MusicItem.Save(MusicItem.java:22)
        at AddMusicForm.jButton1ActionPerformed(AddMusicForm.java:86)
        at AddMusicForm.access$000(AddMusicForm.java:17)
        at AddMusicForm$1.actionPerformed(AddMusicForm.java:45)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6289)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6054)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4652)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4482)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at …
Run Code Online (Sandbox Code Playgroud)

java database-connection sql-server-2008

2
推荐指数
1
解决办法
7583
查看次数

如何将经度和纬度字符串转换为double?

我从谷歌得到我的经度和优势:

http://maps.google.com/maps/geo?q=Sliedrecht,%20Netherlands&output=csv&oe=utf8&sensor=false

我想使用此结果为地图添加标记:

        if (coordinates.Length == 4 && coordinates[0] == "200")
        {
            var overlay = new GMapOverlay(mapexplr, "overlayTwo");

            overlay.Markers.Add(new GMapMarkerGoogleGreen(new PointLatLng(Convert.ToDouble(coordinates[2]), Convert.ToDouble(coordinates[3]))));
            mapexplr.Overlays.Add(overlay);
        }
Run Code Online (Sandbox Code Playgroud)

问题是我的标记没有显示.我认为这是因为没有以正确的格式提供双打​​.以上链接的结果如下:

200,4,51.8248681,4.7731624

当我将值转换4.7731624为双倍时,我47731624没有点.

所以我的问题是,如何将字符串转换为带有正确位置点的双精度?

c# google-maps winforms

2
推荐指数
1
解决办法
9106
查看次数

为什么是范围.$ watch在Angular中通过$ parse assign设置值时不会触发?

我有两个指令.一个指令显示下拉列表,另一个指令必须在单击页面上的其他位置时隐藏下拉列表.

下拉指令:

app.directive('dropdown', function ($parse) {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            scope.$watch(attrs.ngShow, function (newVal, oldVal) {

                obj = angular.element(document.getElementById(attrs.dropdown));
                if (newVal) {

                    // hide all drodowns with this attribute                    $(document).find('[dropdown]').each(function (index) {
                    if ($(this).is(':visible')) {
                        var attrValue = $(this).attr('ng-show');
                        var model = $parse(attrValue);

                        model.assign(scope, false);
                    }
                });
            var offset = obj.offset();
            var new_top = offset.top + 30;
            var right = offset.left + obj.outerWidth() - element.width() + 10;

            element.css('left', right + 'px');
            element.css('top', new_top + 'px'); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery angularjs angularjs-directive

2
推荐指数
1
解决办法
1844
查看次数