Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilBeaver committed Oct 17, 2018
2 parents a44f302 + bb47597 commit 2bdcce5
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
11 changes: 10 additions & 1 deletion src/OneScript/Application/FormFileContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ public FormFileContext(IFormFile realObject)
);
}

/// <summary>
/// Имя поля формы, в котором был получен данный файл
/// </summary>
[ContextProperty("Имя")]
public string Name => _realObject.Name;

/// <summary>
/// Имя переданного файла, как указано в заголовке Content-Disposition
/// </summary>
[ContextProperty("ИмяФайла")]
public string FileName => _realObject.FileName;

[ContextProperty("Размер")]
public long Length => _realObject.Length;

Expand Down Expand Up @@ -67,7 +76,7 @@ public FormFileContext(IFormFile realObject)
public GenericStream OpenReadStream()
{
var stream = _realObject.OpenReadStream();
return new GenericStream(stream, true);
return new GenericStream(stream);
}
}
}
2 changes: 1 addition & 1 deletion src/OneScript/Application/ScriptedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ScriptedController(ControllerContext context, LoadedModule module) : base
RouteValues = ValueFactory.Create();

var typeClr = (Type)context.ActionDescriptor.Properties["type"];
var type = TypeManager.RegisterType(typeClr.Name, typeof(ScriptedController));
var type = TypeManager.RegisterType("Контроллер."+typeClr.Name, typeof(ScriptedController));
DefineType(type);
InitOwnData();
}
Expand Down
12 changes: 11 additions & 1 deletion src/OneScript/Infrastructure/DynamicContextWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
return false;
}

var valueArgs = args.Select(x => CustomMarshaller.ConvertReturnValue(x, x.GetType())).ToArray();
var methInfo = _context.GetMethodInfo(methIdx);
var valueArgs = new IValue[methInfo.Params.Length];
var passedArgs = args.Select(x => CustomMarshaller.ConvertReturnValue(x, x.GetType())).ToArray();
for (int i = 0; i < valueArgs.Length; i++)
{
if (i < passedArgs.Length)
valueArgs[i] = passedArgs[i];
else
valueArgs[i] = ValueFactory.CreateInvalidValueMarker();
}

IValue methResult;
_context.CallAsFunction(methIdx, valueArgs, out methResult);
result = methResult == null? null : CustomMarshaller.ConvertToDynamicCLRObject(methResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void FillContext(IEnumerable<IFileInfo> sources, ApplicationModelProvide
if (virtualPath.IsDirectory)
{
var info = FindModule(virtualPath.Name, MODULE_FILENAME)
?? FindModule(virtualPath.Name, virtualPath.Name);
?? FindModule(virtualPath.Name, virtualPath.Name+".os");

if(info == null)
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/OneScript/OneScriptWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<AssemblyName>OneScript.WebHost</AssemblyName>
<RootNamespace>OneScript.WebHost</RootNamespace>
<StartupObject>OneScript.WebHost.Program</StartupObject>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<FileVersion>0.3.0.0</FileVersion>
<AssemblyVersion>0.3.1.0</AssemblyVersion>
<FileVersion>0.3.1.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
4 changes: 3 additions & 1 deletion src/OneScript/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"lib.system": "$appBinary/oscript_modules",
"lib.additional": [ "oscript_modules" ]
},
"Environment": "Development"
"Environment": "Development",
"urls": "http://localhost:5000/"

}
2 changes: 1 addition & 1 deletion src/OneScriptWeb.Tests/ControllerCreationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void CheckIfControllerCreatedFromScript()
var activator = new ScriptedControllerActivator(appEngine);
var controller = (ScriptedController)activator.Create(cc);

Assert.Equal("test", controller.SystemType.Name);
Assert.Equal("Контроллер.test", controller.SystemType.Name);
}

[Fact]
Expand Down
23 changes: 23 additions & 0 deletions src/OneScriptWeb.Tests/DynamicContextWrapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Xunit;
using System.Dynamic;
using ScriptEngine;
using ScriptEngine.Machine.Contexts;

namespace OneScriptWeb.Tests
{
Expand Down Expand Up @@ -71,5 +72,27 @@ public void WrapStructureEnumeration()

Assert.Equal(2, cnt);
}

[Fact]
public void DefaultArgumentsArePassedCorrectly()
{
var dummy = new DummyClass();
dynamic dynStructure = new DynamicContextWrapper(dummy);

dynStructure.Установить("привет");

Assert.True(dummy.Answer);
}

private class DummyClass : AutoContext<DummyClass>
{
public bool Answer { get; private set; }

[ContextMethod("Установить")]
public void Set(string firstArg, bool secondArg = true)
{
Answer = secondArg;
}
}
}
}

0 comments on commit 2bdcce5

Please sign in to comment.