IronPython
Changes
.gitignore 9(+9 -0)
TryIronPython/TryIronPython.sln 25(+25 -0)
TryIronPython/TryIronPython/Program.cs 136(+136 -0)
Details
.gitignore 9(+9 -0)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c63d1c4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+
+TryIronPython/.vs/TryIronPython/
+TryIronPython/packages/
+
+
+TryIronPython/TryIronPython/bin/
+TryIronPython/TryIronPython/obj/
+
+
TryIronPython/TryIronPython.sln 25(+25 -0)
diff --git a/TryIronPython/TryIronPython.sln b/TryIronPython/TryIronPython.sln
new file mode 100644
index 0000000..8b55dee
--- /dev/null
+++ b/TryIronPython/TryIronPython.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.136
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TryIronPython", "TryIronPython\TryIronPython.csproj", "{AAAFC6FF-7969-4CEE-B596-F46B2CE70388}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AAAFC6FF-7969-4CEE-B596-F46B2CE70388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AAAFC6FF-7969-4CEE-B596-F46B2CE70388}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AAAFC6FF-7969-4CEE-B596-F46B2CE70388}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AAAFC6FF-7969-4CEE-B596-F46B2CE70388}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {3E03AE93-B54E-4709-B112-70DB26250D68}
+ EndGlobalSection
+EndGlobal
diff --git a/TryIronPython/TryIronPython/App.config b/TryIronPython/TryIronPython/App.config
new file mode 100644
index 0000000..8e15646
--- /dev/null
+++ b/TryIronPython/TryIronPython/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+</configuration>
\ No newline at end of file
diff --git a/TryIronPython/TryIronPython/packages.config b/TryIronPython/TryIronPython/packages.config
new file mode 100644
index 0000000..6f82a01
--- /dev/null
+++ b/TryIronPython/TryIronPython/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="DynamicLanguageRuntime" version="1.2.2" targetFramework="net45" />
+ <package id="IronPython" version="2.7.9" targetFramework="net45" />
+</packages>
\ No newline at end of file
TryIronPython/TryIronPython/Program.cs 136(+136 -0)
diff --git a/TryIronPython/TryIronPython/Program.cs b/TryIronPython/TryIronPython/Program.cs
new file mode 100644
index 0000000..dda3080
--- /dev/null
+++ b/TryIronPython/TryIronPython/Program.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using IronPython.Hosting;
+using Microsoft.Scripting.Hosting;
+
+using System.IO;
+
+namespace TryIronPython
+{
+ class Program
+ {
+
+
+ /// <summary>
+ /// Выпонение из строки
+ /// </summary>
+ static void Example1()
+ {
+ ScriptEngine engine = Python.CreateEngine();
+ engine.Execute("print 'hello, world'");
+ }
+
+ /// <summary>
+ /// ВЫполнение из файла
+ /// </summary>
+ static void Example2()
+ {
+ ScriptEngine engine = Python.CreateEngine();
+ engine.ExecuteFile(@"Python\Example2.py");
+ }
+
+
+ /// <summary>
+ /// Выполнение из файла
+ /// Получение и задание переменных скрипта
+ /// </summary>
+ static void Example3()
+ {
+ int yNumber = 22;
+
+ ScriptEngine engine = Python.CreateEngine();
+ ScriptScope scope = engine.CreateScope();
+
+ scope.SetVariable("y", yNumber);
+ engine.ExecuteFile(@"Python\Example3.py", scope);
+
+ dynamic xNumber = scope.GetVariable("x");
+ dynamic zNumber = scope.GetVariable("z");
+
+ Console.WriteLine("Сумма {0} и {1} равна: {2}", xNumber, yNumber, zNumber);
+ }
+
+
+ /// <summary>
+ /// Выполнение из файла
+ /// Получение и вызов функции
+ /// </summary>
+ static void Example4()
+ {
+ int x = 5;
+
+ ScriptEngine engine = Python.CreateEngine();
+ ScriptScope scope = engine.CreateScope();
+
+ engine.ExecuteFile(@"Python\Example4.py", scope);
+ dynamic function = scope.GetVariable("factorial");
+
+ // вызываем функцию и получаем результат
+ dynamic result = function(x);
+ Console.WriteLine(string.Format("Факторил({0}) = {1}", x, result));
+ }
+
+
+ /// <summary>
+ /// Выполнение из файла
+ /// Работа с модулями
+ ///
+ /// Насколько понял нужны полные пути
+ /// Подпапки не учитываются
+ /// </summary>
+ static void Example5()
+ {
+ DirectoryInfo LibDir =
+ new DirectoryInfo(@"Python\Lib");
+
+ var LibsDir = new List<string>
+ (
+ //LibDir.GetDirectories().
+ //Select(e => e.FullName).
+ //Concat(new string[] { LibDir.FullName})
+ )
+ { @".\Python\Lib"};
+
+ ScriptEngine engine = Python.CreateEngine();
+ //engine.SetSearchPaths(LibsDir);
+
+ engine.ExecuteFile(@"Python\Example5.py");
+ }
+
+
+
+ /// <summary>
+ /// Попытка использовать сторонние модули
+ /// Стандартный модули IronPython.Std
+ ///
+ /// </summary>
+ static void Example6()
+ {
+ ScriptEngine engine = Python.CreateEngine();
+ var l = engine.GetSearchPaths();
+
+ DirectoryInfo LibDir =
+ new DirectoryInfo(@"Python\Lib");
+
+ var LibsDir = new List<string>
+ (
+ LibDir.GetDirectories("*", SearchOption.AllDirectories).
+ Select(e => e.FullName).
+ Concat(new string[] { LibDir.FullName })
+ );
+ engine.SetSearchPaths(LibsDir);
+ engine.ExecuteFile(@"Python\Example6.py");
+ }
+
+ static void Main(string[] args)
+ {
+ Example5();
+
+ Console.ReadKey();
+ }
+ }
+}
diff --git a/TryIronPython/TryIronPython/Properties/AssemblyInfo.cs b/TryIronPython/TryIronPython/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fda8b7f
--- /dev/null
+++ b/TryIronPython/TryIronPython/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Общие сведения об этой сборке предоставляются следующим набором
+// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
+// связанные со сборкой.
+[assembly: AssemblyTitle("TryIronPython")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TryIronPython")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
+// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
+// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
+[assembly: ComVisible(false)]
+
+// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
+[assembly: Guid("aaafc6ff-7969-4cee-b596-f46b2ce70388")]
+
+// Сведения о версии сборки состоят из следующих четырех значений:
+//
+// Основной номер версии
+// Дополнительный номер версии
+// Номер сборки
+// Редакция
+//
+// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
+// используя "*", как показано ниже:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TryIronPython/TryIronPython/Python/Example2.py b/TryIronPython/TryIronPython/Python/Example2.py
new file mode 100644
index 0000000..0bf1911
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Example2.py
@@ -0,0 +1,2 @@
+
+print 'hello, world'
diff --git a/TryIronPython/TryIronPython/Python/Example3.py b/TryIronPython/TryIronPython/Python/Example3.py
new file mode 100644
index 0000000..9665d8d
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Example3.py
@@ -0,0 +1,9 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+# Переменная Y будет задана из среды .Net
+
+x = 10
+z = x + y
+print z
diff --git a/TryIronPython/TryIronPython/Python/Example4.py b/TryIronPython/TryIronPython/Python/Example4.py
new file mode 100644
index 0000000..cd1ce38
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Example4.py
@@ -0,0 +1,7 @@
+
+
+def factorial(number):
+ result = 1
+ for i in xrange(2, number + 1):
+ result *= i
+ return result
diff --git a/TryIronPython/TryIronPython/Python/Example5.py b/TryIronPython/TryIronPython/Python/Example5.py
new file mode 100644
index 0000000..6088c6a
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Example5.py
@@ -0,0 +1,7 @@
+
+
+import ExampleModule
+
+ExampleModule.SayHello()
+print(ExampleModule.Summ(5, 10))
+
diff --git a/TryIronPython/TryIronPython/Python/Example6.py b/TryIronPython/TryIronPython/Python/Example6.py
new file mode 100644
index 0000000..640dc14
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Example6.py
@@ -0,0 +1,3 @@
+
+import urllib.request
+
diff --git a/TryIronPython/TryIronPython/Python/Lib/ExampleLib/ExampleModule.py b/TryIronPython/TryIronPython/Python/Lib/ExampleLib/ExampleModule.py
new file mode 100644
index 0000000..940647a
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Lib/ExampleLib/ExampleModule.py
@@ -0,0 +1,9 @@
+
+def SayHello():
+ print('Hello, world!')
+
+def Summ(a,b):
+ z = a + b
+ return z
+
+
diff --git a/TryIronPython/TryIronPython/Python/Lib/ExampleModule.py b/TryIronPython/TryIronPython/Python/Lib/ExampleModule.py
new file mode 100644
index 0000000..940647a
--- /dev/null
+++ b/TryIronPython/TryIronPython/Python/Lib/ExampleModule.py
@@ -0,0 +1,9 @@
+
+def SayHello():
+ print('Hello, world!')
+
+def Summ(a,b):
+ z = a + b
+ return z
+
+
diff --git a/TryIronPython/TryIronPython/TryIronPython.csproj b/TryIronPython/TryIronPython/TryIronPython.csproj
new file mode 100644
index 0000000..be50ca0
--- /dev/null
+++ b/TryIronPython/TryIronPython/TryIronPython.csproj
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{AAAFC6FF-7969-4CEE-B596-F46B2CE70388}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>TryIronPython</RootNamespace>
+ <AssemblyName>TryIronPython</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <Deterministic>true</Deterministic>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="IronPython, Version=2.7.9.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\IronPython.2.7.9\lib\net45\IronPython.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.Modules, Version=2.7.9.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\IronPython.2.7.9\lib\net45\IronPython.Modules.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.SQLite, Version=2.7.9.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\IronPython.2.7.9\lib\net45\IronPython.SQLite.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.Wpf, Version=2.7.9.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\IronPython.2.7.9\lib\net45\IronPython.Wpf.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Dynamic, Version=1.2.2.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\DynamicLanguageRuntime.1.2.2\lib\net45\Microsoft.Dynamic.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Scripting, Version=1.2.2.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\DynamicLanguageRuntime.1.2.2\lib\net45\Microsoft.Scripting.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Scripting.Metadata, Version=1.2.2.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
+ <HintPath>..\packages\DynamicLanguageRuntime.1.2.2\lib\net45\Microsoft.Scripting.Metadata.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <ItemGroup>
+ <Content Include="Python\Example6.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Lib\ExampleLib\ExampleModule.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Example5.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Example4.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Example3.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Example2.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Python\Lib\ExampleModule.py">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git "a/\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265 IronPython _ C# \320\270 .NET.pdf" "b/\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265 IronPython _ C# \320\270 .NET.pdf"
new file mode 100644
index 0000000..10d3904
Binary files /dev/null and "b/\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265 IronPython _ C# \320\270 .NET.pdf" differ