DLR Hosting

  • View
    2.665

  • Download
    4

Embed Size (px)

DESCRIPTION

Slides from 10 meeting of spb alt.net group

Text of DLR Hosting

  • 1. DLR
    hosting
    VitalyBaum
    Alt.NetSpb Group
    butaji.ru
    spbalt.net

2.
.

3. DLR WTF?
DLR ?
4. DLR - ?




5. DLR - ?
Mix07
1 2007
6. DLR - ?
7. DLR - ?
.NET

8. DLR - ?
http://msmvps.com/blogs/jon_skeet/archive/2009/06/19/os-jam-at-google-london-c-4-and-the-dlr.aspx
9. DLR - ?
.NET:
Garbage collector (GC)
Just-in-time compiler (JIT)
Sandbox Security Model ()
Tools (Visual Studio, SQL Server)
10. DLR - ?
, .NET .
http://blogs.msdn.com/blogfiles/codeplex/WindowsLiveWriter/CodePlexinDenmarkandSweden_C442/DSC03124.jpg
11. DLR - ?
http://github.com
, .
12. DLR - ?
Microsoft DLR:
IronPython open source www.codeplex.com/ironpython.
IronRuby open source http://rubyforge.org/projects/ironruby.
13. DLR - ?
May 22 2009
v0.91
http://dlr.codeplex.com/
14. DLR - ?
15. DLR - ?
CLR :
Expression trees( )
Call site caching( )
Dynamic object interoperability( )
16. DLR - ?
The One True Object
http://blogs.msdn.com/hugunin/archive/2007/05/02/the-one-true-object-part-1.aspx
17. DLR - ?
The One True Object
http://blogs.msdn.com/hugunin/archive/2007/05/02/the-one-true-object-part-1.aspx
18. DLR - ?
http://msdn.microsoft.com/en-us/library/dd233052(VS.100).aspx
19. DLR hosting
DLR .NET
http://farm3.static.flickr.com/2017/2047711131_d4ce321ca9.jpg
20. DLRHosting




21. DLRHosting
SilverLight
MerlinWeb
, ScriptRuntime
, ( live 1 )
PowerShell, C#, VB.NET
22. 23. DLRHosting
24. DLRHosting
25. DLRHosting
26. DLRHosting
27. DLRHosting
:



28. DLRHosting

app.close
29. DLRHosting

pyfunc(x)
30. DLRHosting

x
y =func(x)
y
31. DLRHosting
32. DLRHosting
REPL
Read-eval-print loop
33. DLRHosting
http://www.iunknown.com/2009/05/dynamic-languages-at-teched-2009.html
34. DLRHosting
:
Extension Methods, LINQ.
35. DLRHosting
:


36. DLRHosting
Adapt
your code
37. DLRHosting
public class ClassToBeExtended{}
public static class DemoExtensionClass
{
public static string Foo(thisClassToBeExtended c)
{
return"Bar";
}
}
http://blogs.msdn.com/saveenr/archive/2008/11/14/consuming-extension-methods-in-ironpython.aspx
38. DLRHosting
>>> c1 = ClassToBeExtended()>>> c1.Foo()Traceback (most recent call last): File "", line 1, in AttributeError: 'ClassToBeExtended' object has no attribute 'Foo'
39. DLRHosting
usingMicrosoft.Scripting;
[assembly: Microsoft.Scripting.Runtime.ExtensionType( typeof(ClassToBeExtended), typeof(DemoExtensionClass)
)]
40. DLRHosting
>>> c1 = ClassToBeExtended()>>> c1.Foo()'Bar'
41. DLRHosting
Legacy code
42. DLRHosting
Proxy,

43. Linq 2 Object vsPython
[myFunc(i) for i in numbers if i >3]
from i in numbers
where i > 3
selectmyFunc(i)
44. Linq 2 Object vsPython
Funcs
need that
45. Linq 2 Object vsPython
SelectWhereAggregate
mapfilterreduce
46. Linq 2 Object vsPython
map(myFunc,
filter(lambdax: x >3,numbers))
47. Linq 2 Object vsPython
Queryable.Select(
Queryable.Where(numbers, x => x > 3),
myFunc)
48. Linq 2 XML vs Python
head =soup.contents[0].contents[0] head.parent.name
# u'html'
soup.findAll('p', align="center")
# [

This is paragraph one.

]
Beautiful Soup
http://www.crummy.com/software/BeautifulSoup/
49. IronPythonClass != .NET Class
class Calculator(object):defadd(self, a, b): returna + b
http://stackoverflow.com/questions/579272/instantiating-a-python-class-in-c
50. IronPythonClass != .NET Class
ScriptEngine engine = Python.CreateEngine();ScriptSource source =engine.CreateScriptSourceFromFile(
"Calculator.py");ScriptScope scope = engine.CreateScope();ObjectOperationsop = engine.Operations;
51. IronPythonClass != .NET Class
//
source.Execute(scope);//
object calculator = scope.GetVariable("Calculator");
// object instance = op.Invoke(calculator);
// object method = op.GetMember(instance, "add");
//
intresult = (int)op.Call(method, 4, 5);
52. IronPythonClass != .NET Class
ScriptRuntimepy = Python.CreateRuntime();
dynamichelloworld = py.UseFile("helloworld.py");
helloworld.Calculator().Add(1, 10)
.NET 4.0
53. DLR + sharepoint
c DLR SharePoint
54. IPy 4 SPD
SharePoint Designer

3- -
?
55. IPy 4 SPD
:
Python-
56. IPy 4 SPD
57. IPy 4 SPD
__actprops__ ( . )__site__ (SPSite)__web__ ( SPWeb)__list__ ( SPList)__item__ (SPListItem)
58. IPy 4 SPD
defFindManager(userName, ldapPath):
importclr
clr.AddReference("System.DirectoryServices")
importSystem.DirectoryServices as ds
adFolder = ds.DirectoryEntry(ldapPath)
adSearcher = ds.DirectorySearcher(adFolder)
adSearcher.SearchScope = ds.SearchScope.Subtree
adSearcher.Filter = "(&(objectClass=user)(samaccountname=" + userName + "))"
adResult = ds.SearchResult
try:
adResult = adSearcher.FindOne()
returnadResult.Properties["Manager"][0].Split(",")[0].Substring(3)
except:
return
# the ldapPath structure may vary for you.
mgr = FindManager("yourusername","LDAP://yourdomaincontroller/DC=yourdomain,DC=com")
59. IPy 4 SPD
:


60. IPy 4 SPD
:

61. twimilar

62. Twimilar
:
, ().
63. Twimilar
:

Python
64. Twimilar
:

65. Gestalt - DIY
Gestalt
66. Gestalt
- Javascript
- server-side .
67. Gestalt
68. Gestalt
:
, :

deffunc():
HtmlPage.Window.Alert("Hello world!")

func()

69. Gestalt
:
Html
Script Runtime
Silverlight
70. Gestalt
:

71. Real-life dlR hosting
DLR
72. Real-life DLR hosting
73. Real-life DLR hosting
74. Real-life DLR hosting
75. IronPython Microsoft
IronPython in Action
76. Materials
http://dlr.codeplex.com/
http://blogs.msdn.com/seshadripv/default.aspx
http://blogs.msdn.com/mmaly/default.aspx
http://ironpython-urls.blogspot.com/
http://blogs.msdn.com/hugunin/
77.