小编SLI*_*SLI的帖子

如何使用动态编译的自定义类

我有一个动态编译的表单,我有一个样式类.当我将这个样式类复制到我的表单源并编译它时,一切正常.但是我如何使用这个样式类而不将其复制到我的表单源.我编译此表单的主程序有这个类,我该如何使用它?也许我可以将样式类传递给它,因为我编译它,就像一个var?

节目来源:

using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Microsoft.CSharp;

namespace dynamic
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new Thread(newForm).Start();
        }

        public void newForm()
        {
            using (CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<string, string>
                {
                    {"CompilerVersion", "v4.0"}
                }))
            {

                var parameters = new CompilerParameters
                {
                    GenerateExecutable = false, // Create a dll
                    GenerateInMemory = true, // Create it in memory
                    WarningLevel = 3, // Default warning level
                    CompilerOptions = …
Run Code Online (Sandbox Code Playgroud)

c# compilation dynamic

7
推荐指数
1
解决办法
328
查看次数

Graphql,react-apollo如何在加载组件状态时将变量传递给查询

我有一个简单的react组件,当用户提出请求时,必须从服务器加载数据.问题是我不知道如何传输动态变量speakerUrl并在组件加载状态之前访问它.当然我可以从中访问它this.props.params,但组件未加载,当我进行graphql查询时我无法访问它.查询 - QuerySpeaker当我手动设置url变量时工作正常.

路由器

<Route path="/speaker/:speakerUrl" component={SpeakerPage} />
Run Code Online (Sandbox Code Playgroud)

组件 - SpeakerPage

import React from 'react';
import { graphql } from 'react-apollo';

import { QuerySpeaker } from '../redux/graphql/querys';

class SpeakerPage extends React.Component {
    render( ) {
        console.log( this.props );
        return (
            <div className="ui container">
                <div className="ui grid">
                    <div className="row">
                        Hello
                    </div>
                </div>
            </div>
        )
    }
}

export default graphql(QuerySpeaker, {
     options: ({ url }) => ({ variables: { url } }) <- here is my problem, how can …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-router graphql react-apollo

6
推荐指数
1
解决办法
5298
查看次数

Angularjs无法在html中显示对象

我无法在我的html中显示对象数据,只是得到空白字段.我可以看到Angularjs Batarang的数据,但是无法在html中显示它.谢谢你的回答.

的index.html

<!DOCTYPE html>
<html lang="en" ng-app="Idle">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.11.2/angular-material.min.css">
    <link rel="stylesheet" href="css/style.css">

    <title>Test</title>
</head>
<body ng-controller="IdleCtrl">
    <pre>{{ myData.length }}</pre>
    <pre>{{ myData | json}}</pre>

    <!-- Angular Material Dependencies -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
    <script src="js/angular-animate.min.js"></script>
    <script src="js/angular-aria.min.js"></script>
    <script src="js/angular-messages.min.js"></script>

    <!-- Angular Material Javascript now available via Google CDN; version 0.11.2 used here -->
    <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.11.2/angular-material.min.js"></script>

    <script src="js/myapp/app.js"></script>
    <script src="js/myapp/filters.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

app.js

var app = angular.module('Idle', ['ngMaterial']);
app.controller('IdleCtrl', ['$scope', '$http', function($scope, $http){
    $http.defaults.headers.common["X-Custom-Header"] = "Angular";

    $http.get('data/currentUser').then(function(request) {
        $scope.myData …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

C#以与我在php中相同的方式从数组中获取数据

怎样才能以相同的方式从数组中获取数据?

$arr = array(
    '123' => 'abc',
    '456' => 'def'
);
echo $arr['123']; // abc
Run Code Online (Sandbox Code Playgroud)

我如何在C#中使用数组?

c# arrays

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