入口函数注释,代码整理

This commit is contained in:
大石头 2018-08-19 10:54:15 +08:00
parent 8d7321581c
commit 593c929509
15 changed files with 45 additions and 71 deletions

View File

@ -9,7 +9,7 @@ namespace NewLife.Cube.Admin
[DisplayName("系统管理")]
public class AdminArea : AreaBaseX
{
public static string AreaName => nameof(AdminArea).TrimEnd("Area");
public static String AreaName => nameof(AdminArea).TrimEnd("Area");
/// <inheritdoc />
public AdminArea() : base(AreaName)

View File

@ -253,7 +253,7 @@ namespace NewLife.Cube.Admin.Controllers
var dest = di.FullName.CombinePath(file.FileName);
WriteLog("上传", dest);
byte[] fileBytes = null;
Byte[] fileBytes = null;
using (var fileStream = file.OpenReadStream())
using (var ms = new MemoryStream())
{

View File

@ -38,7 +38,7 @@ namespace NewLife.Cube
public static Type[] Areas { get; private set; }
/// <summary>实例化区域注册</summary>
public AreaBaseX(string areaName) : base(areaName)
public AreaBaseX(String areaName) : base(areaName)
{
//AreaName = GetType().Name.TrimEnd("Area");
}

View File

@ -584,7 +584,7 @@ namespace NewLife.Cube
#endregion
#region
public static string GetString(this IHtmlContent htmlContent)
public static String GetString(this IHtmlContent htmlContent)
{
var writer = new System.IO.StringWriter();
htmlContent.WriteTo(writer, HtmlEncoder.Default);

View File

@ -19,7 +19,7 @@ namespace NewLife.CubeNC.Extensions
public IHostingEnvironment Environment { get; }
public void PostConfigure(string name, StaticFileOptions options)
public void PostConfigure(String name, StaticFileOptions options)
{
name = name ?? throw new ArgumentException(nameof(name));
options = options ?? throw new ArgumentException(nameof(options));

View File

@ -27,12 +27,12 @@ namespace NewLife.CubeNC.Extensions
/// 添加自定义应用部分即添加外部引用的控制器、视图的Assemly作为本应用的一部分
/// </summary>
/// <param name="services"></param>
public static void AddCustomApplicationParts(this IServiceCollection services, Action<List<string>> addEntryAssemblyName = null)
public static void AddCustomApplicationParts(this IServiceCollection services, Action<List<String>> addEntryAssemblyName = null)
{
var manager = GetServiceFromCollection<ApplicationPartManager>(services) ?? new ApplicationPartManager();
//var entryAssemblyName = ;//"NewLife.Cube";
var entryAssemblyNameList = new List<string>(4) { typeof(Program).Assembly.FullName };
var entryAssemblyNameList = new List<String>(4) { typeof(Program).Assembly.FullName };
addEntryAssemblyName?.Invoke(entryAssemblyNameList);
@ -222,7 +222,7 @@ namespace NewLife.CubeNC.Extensions
?.ImplementationInstance;
}
private static void PopulateCustomParts(this ApplicationPartManager manager, string entryAssemblyName)
private static void PopulateCustomParts(this ApplicationPartManager manager, String entryAssemblyName)
{
var entryAssembly = Assembly.Load(new AssemblyName(entryAssemblyName));
//var assembliesProvider = new ApplicationAssembliesProvider();

View File

@ -19,7 +19,7 @@ namespace NewLife.CubeNC.Extensions
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static byte[] ToBytes(this Object obj)
public static Byte[] ToBytes(this Object obj)
{
if (obj == null) return null;
var binary = new Binary();
@ -38,7 +38,7 @@ namespace NewLife.CubeNC.Extensions
/// <param name="bytes"></param>
/// <param name="settingAction">反序列化设置,最常用的设置为设置本次反序列化需要忽略的属性</param>
/// <returns></returns>
public static T GetObject<T>(this byte[] bytes, Action<IBinary> settingAction=null) where T : class
public static T GetObject<T>(this Byte[] bytes, Action<IBinary> settingAction=null) where T : class
//, new()
{
var obj = (T)(Object)bytes.GetObject(typeof(T), settingAction);
@ -52,7 +52,7 @@ namespace NewLife.CubeNC.Extensions
/// <param name="type">反序列化的对象类型同时传了T和Type优先使用Type</param>
/// <param name="settingAction">反序列化设置,最常用的设置为设置本次反序列化需要忽略的属性</param>
/// <returns></returns>
public static Object GetObject(this byte[] bytes, Type type , Action<IBinary> settingAction = null)
public static Object GetObject(this Byte[] bytes, Type type , Action<IBinary> settingAction = null)
{
if (bytes == null)
return null;

View File

@ -15,7 +15,7 @@ namespace NewLife.CubeNC.Extensions
/// <param name="request"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetRequestValue(this HttpRequest request, String key)
public static String GetRequestValue(this HttpRequest request, String key)
{
var value = new StringValues();
@ -38,7 +38,7 @@ namespace NewLife.CubeNC.Extensions
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public static bool IsAjaxRequest(this HttpRequest request)
public static Boolean IsAjaxRequest(this HttpRequest request)
{
if (request == null)
throw new ArgumentNullException(nameof(request));

View File

@ -67,7 +67,7 @@ namespace NewLife.CubeNC.Extensions
{
var list = new List<Assembly>();
var typeList = new List<Type>();
var areaDic = new Dictionary<string, Type>();
var areaDic = new Dictionary<String, Type>();
var controllers = typeof(Controller).GetAllSubclasses(false).ToArray();
foreach (var item in controllers)

View File

@ -16,7 +16,7 @@ namespace NewLife.CubeNC.Extensions
/// <param name="key"></param>
/// <param name="type"></param>
/// <returns></returns>
public static T Get<T>(this ISession session, string key, Type type = null) where T:class
public static T Get<T>(this ISession session, String key, Type type = null) where T:class
//, new()
=> (T)(Object)session.Get(key, typeof(T));
@ -27,6 +27,6 @@ namespace NewLife.CubeNC.Extensions
/// <param name="key"></param>
/// <param name="type"></param>
/// <returns></returns>
public static Object Get(this ISession session, string key, Type type) => session.Get(key).GetObject(type);
public static Object Get(this ISession session, String key, Type type) => session.Get(key).GetObject(type);
}
}

View File

@ -21,7 +21,7 @@ namespace NewLife.Web
var nvss = new[]
{
req.Query,
req.HasFormContentType ? (IEnumerable<KeyValuePair<String, StringValues>>) req.Form : new List<KeyValuePair<string, StringValues>>()
req.HasFormContentType ? (IEnumerable<KeyValuePair<String, StringValues>>) req.Form : new List<KeyValuePair<String, StringValues>>()
};
// 这里必须用可空字典,否则直接通过索引查不到数据时会抛出异常

View File

@ -91,7 +91,7 @@ namespace NewLife.CubeNC.Membership
}
}
public override IManageUser Login(string name, string password, bool rememberme)
public override IManageUser Login(String name, String password, Boolean rememberme)
{
var user = UserX.Login(name, password, rememberme);
Current = user;

View File

@ -1,24 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace NewLife.CubeNC
{
/// <summary>应用程序</summary>
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
/// <summary>入口主函数</summary>
/// <param name="args"></param>
public static void Main(String[] args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
static IWebHostBuilder CreateWebHostBuilder(String[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
}
}
}

View File

@ -1,54 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NewLife.Cube;
using NewLife.Cube.Controllers;
using NewLife.CubeNC.Com;
using NewLife.CubeNC.Extensions;
using NewLife.CubeNC.Membership;
using NewLife.CubeNC.ViewsPreComplied;
using NewLife.CubeNC.WebMiddleware;
using NewLife.Log;
using NewLife.Web;
using XCode.Membership;
namespace NewLife.CubeNC
{
/// <summary>魔方初始化</summary>
public class Startup
{
/// <summary>初始化配置</summary>
/// <param name="configuration"></param>
/// <param name="env"></param>
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
HostingEnvironment = env;
}
/// <summary>配置</summary>
public IConfiguration Configuration { get; }
/// <summary>主机环境</summary>
public IHostingEnvironment HostingEnvironment { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCubeDefaultServices(HostingEnvironment);
}
/// <summary>添加服务到容器。运行时调用</summary>
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services) => services.AddCubeDefaultServices(HostingEnvironment);
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCubeDefaultServices(env);
}
/// <summary>配置Http请求管道。运行时调用</summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env) => app.UseCubeDefaultServices(env);
}
}
}

View File

@ -12,28 +12,28 @@ namespace NewLife.CubeNC.ViewModels
///
/// </summary>
/// <value></value>
public int ID { get; set; }
public Int32 ID { get; set; }
/// <summary>
/// 名称
/// </summary>
/// <value></value>
public string Name { get; set; }
public String Name { get; set; }
/// <summary>
/// 链接
/// </summary>
/// <value></value>
public string Url { get; set; }
public String Url { get; set; }
/// <summary>
/// 图标
/// </summary>
/// <value></value>
public string Icon { get; set; }
public String Icon { get; set; }
/// <summary>
/// 自定义样式类
/// </summary>
/// <value></value>
public string Class { get; set; }
public String Class { get; set; }
/// <summary>
/// 子菜单
/// </summary>