This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assembly = Assembly.GetCallingAssembly(); | |
var instance = assembly.CreateInstance("MyProject.MyClass", true, | |
BindingFlags.CreateInstance, null, new object[] | |
{ monitor, action }, null, null); | |
var t = instance.GetType(); | |
// if you have a property you want to pass | |
// a value to, this is how you do it. | |
var p = t.GetProperty("MyProperty"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
namespace Monarchy | |
{ | |
public class ObjectFactory { | |
static readonly IDictionary<Type, Func<object>> Container = new Dictionary<Type, Func<object>>(); | |
static readonly MethodInfo CreateObjectMethodInfo = typeof (ObjectFactory).GetMethod("Get"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Machine.Specifications; | |
namespace Monarchy.Specs | |
{ | |
[Subject(typeof (ObjectFactory))] | |
public class when_retrieving_a_type_with_registered_dependency_factory | |
{ | |
static TestService _instance; | |
static ObjectFactory _factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
namespace Monarchy | |
{ | |
public class ObjectFactory { | |
static readonly IDictionary<Type, Func<object>> Container = new Dictionary<Type, Func<object>>(); | |
static readonly MethodInfo CreateObjectMethodInfo = typeof (ObjectFactory).GetMethod("Get"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
namespace Monarchy { | |
public class ObjectFactory { | |
static readonly IDictionary<Type, object> Container = new Dictionary<Type, object>(); | |
public static T Get<T>() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<table> | |
<tr> | |
<td>First Name:</td> | |
<td>#{txtFirstName}#</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ToolboxItemAttribute(false)] | |
public class HelloWorldWebPart : WebPart { | |
TextBox _firstName; | |
TextBox _lastName; | |
Button _sayHello; | |
Label _result; | |
protected override void CreateChildControls() { | |
_firstName = new TextBox() { ID = "txtFirstName" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void Render(HtmlTextWriter writer) { | |
var canvas = new Canvas(SPContext.Current.Web.Url + "/_layouts/HelloWorld/canvas.htm"); | |
string html = canvas.Render(this); | |
writer.Write(html); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Elijah's Brain", | |
"version": "1.2", | |
"description": "Tech tweets directly from the brain of Elijah Manor.", | |
"browser_action": { | |
"default_icon": "icon16.png", | |
"popup": "popup.html" | |
}, | |
"icons": { | |
"16": "icon16.png", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$.getJSON('https://api.twitter.com/1/statuses/user_timeline.json?screen_name=elijahmanor&count=50&exclude_replies=true&trim_user=true', function(data) { | |
console.log(data); | |
}); | |
</script> |
OlderNewer