本文整理汇总了C#中JsObject类的典型用法代码示例。如果您正苦于以下问题:C# JsObject类的具体用法?C# JsObject怎么用?C# JsObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsObject类属于命名空间,在下文中一共展示了JsObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ObjectPropertiesAreEqual
public void ObjectPropertiesAreEqual()
{
var obj1 = new { prop1 = "test", prop2 = 2 };
dynamic obj2 = new JsObject();
obj2.prop1 = "test";
obj2.prop2 = 2;
AssertEx.ObjectPropertiesAreEqual(obj1, obj2);
obj2.prop2 = 5;
AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2);
obj2.prop2 = 2;
obj2.thirdProp = "some other property";
AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2);
((IDictionary<string, object>)obj2).Remove("thirdProp");
AssertEx.ObjectPropertiesAreEqual(obj1, obj2);
// make sure it fails correctly too
Assert.Throws<AssertionException>(() =>
{
AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2);
});
}
开发者ID:TheX,项目名称:CsQuery,代码行数:31,代码来源:TestTests.cs
示例2: Querystring
public void Querystring(JsString qs = null)
{ // optionally pass a querystring to parse
this.parameters = new JsObject<JsString>();
JsCode("this.get = Querystring_get");
if (qs == null)
qs = location.search.Substring(1, location.search.length);
if (qs.length == 0) return;
// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
qs = qs.Replace(new JsRegExp("\\+", "g"), " ");
JsArray<JsString> args = qs.Split('&'); // parse out name/value pairs separated via &
// split out each name=value pair
for (int i = 0; i < args.length; i++)
{
JsString value;
JsArray<JsString> pair = args[i].Split('=');
JsString name = Unescape(pair[0]);
if (pair.length == 2)
value = Unescape(pair[1]);
else
value = name;
this.parameters[name] = value;
}
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:28,代码来源:QueryString.cs
示例3: JsClrClientSerializer
public JsClrClientSerializer()
{
ObjInfos = new Dictionary<object, ObjInfo>();
IgnoreFields = new JsObject<bool>();
IgnoreFields["_type"] = true;
IgnoreFields["_hashKey"] = true;
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:7,代码来源:JsClrClientSerializer.cs
示例4: SendInternal
private void SendInternal(string httpMethod, string type, JsString url, object data,
JsAction<object, JsString, jqXHR> success,
JsAction<JsError, JsString, jqXHR> failed)
{
url = addTimeToUrl(url);
JsObject headers = new JsObject();
AjaxSettings ajaxSettings = new AjaxSettings
{
type = httpMethod,
dataType = type,
data = data,
url = jsUtils.inst.getLocation() + "/" + url,
headers = headers,
success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); },
error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); }
};
bool isString = data.As<JsObject>()["toLowerCase"] != null;
if (isString)
{
ajaxSettings.processData = true;
ajaxSettings.contentType = (type.As<JsString>().toLowerCase() == "xml")
? "application/xml"
: "application/json";
}
jQuery.ajax(
ajaxSettings);
}
开发者ID:mgerasika,项目名称:gam-gam,代码行数:29,代码来源:ajaxHlp.cs
示例5: renderTemplateClone
public jQuery renderTemplateClone(JsObject data )
{
JsString token;
JsString field;
dynamic dereferencedValue;
var keyRegex = new JsRegExp(@"\{[\w\W]+?\}", "g");
var foundKeys = templateAsString.match(keyRegex);
var output = templateAsString;
if (foundKeys != null) {
for ( int j = 0; j < foundKeys.length; j++ ) {
token = foundKeys[ j ];
field = returnFieldName( token );
if (field.indexOf(".") != -1) {
dereferencedValue = resolveComplexName(data, field);
} else if (field != "*") {
dereferencedValue = data[field];
} else {
dereferencedValue = data;
}
output = output.replace(token, dereferencedValue);
}
}
jQuery fragmentJquery = jQueryContext.J("<div></div>");
fragmentJquery.append(output);
return fragmentJquery;
}
开发者ID:griffith-computing,项目名称:Randori,代码行数:32,代码来源:TemplateBuilder.cs
示例6: filter
public override object filter(JsObject obj, JsObject arg)
{
int day = arg["day"].As<int>();
JsArray<JsArray<ngHistoryEntry>> allPropousals = obj.As<JsArray<JsArray<ngHistoryEntry>>>();
JsArray<ngHistoryEntry> res = allPropousals[day];
return res;
}
开发者ID:mgerasika,项目名称:gam-gam,代码行数:8,代码来源:ngPropousalFilter.cs
示例7: foo
void foo()
{
dynamic arrivingViewProps = new JsObject();
arrivingViewProps.left = 0;
arrivingViewProps.leaveTransforms = true;
animate(arrivingViewProps, HOW_LONG);
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:8,代码来源:Dynamics.cs
示例8: NullableDateTime
public void NullableDateTime()
{
var o = new JsObject();
o["MyDate"] = "2015-11-02T23:00:54.237".As<JsObject>();
var obj = o.FromJsonObject<NullableDateTimeClass>();
AssertEquals(54, obj.MyDate.Value.Second);
}
开发者ID:kswoll,项目名称:WootzJs,代码行数:8,代码来源:JsonTests.cs
示例9: BreakPoint
public void BreakPoint(JsObject instance)
{
if (InvokeRequired)
{
this.Invoke(new MethodInvoker(() =>
{
debugControl.InspectObject(instance);
}));
}
}
开发者ID:Diullei,项目名称:Storm,代码行数:10,代码来源:Console.cs
示例10: LocalizationProvider
public LocalizationProvider(AbstractTranslator translator )
{
this.translator = translator;
translator.translationResult += provideTranslation;
timer = new Timer( 10, 1 );
timer.timerComplete += sendTranslationRequest;
pendingTranslations = new JsObject<JsArray<Node>>();
}
开发者ID:griffith-computing,项目名称:Randori,代码行数:10,代码来源:LocalizationProvider.cs
示例11: MarshalJsFunction
public static Delegate MarshalJsFunction(JintRuntime runtime, JsObject function, JsObject that, Type delegateType)
{
if (runtime == null)
throw new ArgumentNullException("runtime");
if (function == null)
throw new ArgumentNullException("function");
if (delegateType == null)
throw new ArgumentNullException("delegateType");
if (!typeof(Delegate).IsAssignableFrom(delegateType))
throw new ArgumentException("A delegate type is required", "delegateType");
var invokeMethod = delegateType.GetMethod("Invoke");
var parameters = invokeMethod
.GetParameters()
.Select(p => Expression.Parameter(p.ParameterType, p.Name))
.ToList();
Expression call = Expression.Call(
Expression.Constant(function),
typeof(JsObject).GetMethod("Execute"),
Expression.Constant(runtime),
Expression.Constant(that),
MakeArrayInit(
parameters.Select(p => Expression.Call(
Expression.Constant(runtime.Global.Marshaller),
typeof(Marshaller).GetMethod("MarshalClrValue").MakeGenericMethod(p.Type),
p
)),
typeof(object),
false
)
);
if (invokeMethod.ReturnType != typeof(void))
{
call = Expression.Call(
Expression.Constant(runtime.Global.Marshaller),
typeof(Marshaller).GetMethod("MarshalJsValue").MakeGenericMethod(invokeMethod.ReturnType),
call
);
}
var lambda = Expression.Lambda(
delegateType,
Expression.Block(
invokeMethod.ReturnType,
call
),
parameters
);
return lambda.Compile();
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:54,代码来源:ProxyHelper.cs
示例12: FromDynamic
public void FromDynamic()
{
var div = CQ.Create("<div></div>");
dynamic dict = new JsObject();
dict.width = "10px";
dict.height = 20;
div.CssSet(dict);
Assert.AreEqual("10px", div.Css("width"));
Assert.AreEqual("20px", div.Css("height"));
}
开发者ID:xinmyname,项目名称:CsQuery,代码行数:11,代码来源:Css.cs
示例13: foo2
void foo2()
{
FakeQuery arrivingView = null;
dynamic arrivingViewProps = new JsObject();
arrivingViewProps.left = 0;
arrivingViewProps.leaveTransforms = true;
var newLeftSide = 7;
arrivingView.show();
arrivingView.css("left", newLeftSide);
arrivingView.animate(arrivingViewProps, HOW_LONG);
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:14,代码来源:Dynamics.cs
示例14: OnReady
static void OnReady()
{
var fields = new JsObject<FieldConfig>();
fields["OrderID"] = new FieldConfig { type = "number" };
fields["ShipCountry"] = new FieldConfig { type = "string" };
fields["ShipName"] = new FieldConfig { type = "string" };
fields["ShipAddress"] = new FieldConfig { type = "string" };
new jQuery("#grid").kendoGrid(new GridConfiguration
{
dataSourceObject = new DataSourceConfiguration
{
type = "odata",
transport = new DataSourceTransportConfiguration
{
readString = "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema = new DataSourceSchemaConfiguration
{
model = new ModelObjectOptions
{
fields = fields
}
},
pageSize = 10,
serverPaging = true,
serverFiltering = true,
serverSorting = true
},
height = 250,
sortableBoolean = true,
filterable = true,
columnMenu = true,
pageableBoolean = true,
columns = new JsArray<GridColumnConfiguration>
{
new GridColumnConfiguration{ field = "OrderID" },
new GridColumnConfiguration{ field = "ShipCountry" },
new GridColumnConfiguration{ field = "ShipName" },
new GridColumnConfiguration
{
field = "ShipAddress",
filterable = false
}
}
});
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:49,代码来源:ColumnMenu.cs
示例15: StaticTranslator
public StaticTranslator()
{
this.translations = new JsObject<JsObject<JsString>>();
var labels = new JsObject<JsString>();
labels["Greetings"] = "Howdy There";
labels["Whatever"] = "Blah";
var messages = new JsObject<JsString>();
labels["ERROR"] = "There has been a rather large error";
labels["LEAVE"] = "It would be best if you left now";
translations["labels"] = labels;
translations["messages"] = labels;
}
开发者ID:griffith-computing,项目名称:RandoriSampleSolution,代码行数:15,代码来源:StaticTranslator.cs
示例16: Save
public void Save()
{
try
{
JsObject data = new JsObject();
data.str["main"] = MainFormPosition;
data.str["fullscreen"] = FullscreenPosition;
data.str["monitor"] = MonitorFormPosition;
data.str["options"] = OptionsFormPosition;
data.str["hivemind_submit"] = HivemindSubmitFormPosition;
File.WriteAllText(cfgFile, data.Serialize());
}
catch (Exception)
{ }
}
开发者ID:aaronboo95,项目名称:chiitrans,代码行数:15,代码来源:WindowPosition.cs
示例17: SendGet
public void SendGet(string type, JsString url, JsAction<object, JsString, jqXHR> success,
JsAction<JsError, JsString, jqXHR> failed)
{
url = addTimeToUrl(url);
JsObject headers = new JsObject();
jQuery.ajax(new AjaxSettings
{
type = "GET",
dataType = type,
url = jsUtils.inst.getLocation() + "/" + url,
headers = headers,
success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); },
error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); }
});
}
开发者ID:mgerasika,项目名称:gam-gam,代码行数:16,代码来源:ajaxHlp.cs
示例18: ExtendPocoFromDynamic
public void ExtendPocoFromDynamic()
{
TestClass1 t1 = new TestClass1();
t1.Prop1 = "value1";
t1.Prop2 = "value2";
dynamic t2 = new JsObject();
t2.Prop2 = "class2value2";
t2.Prop3 = "class2vlaue3";
CQ.Extend(t1, t2);
Assert.AreEqual("value1", t1.Prop1, "Target prop1 unchanged");
Assert.AreEqual("class2value2", t1.Prop2, "Target prop2 updated");
}
开发者ID:emrahoner,项目名称:CsQuery,代码行数:17,代码来源:Extend.cs
示例19: filter
public override object filter(JsObject obj, JsObject arg)
{
JsArray<ngOrderEntry> res = new JsArray<ngOrderEntry>();
int day = arg["day"].As<int>();
JsArray<JsArray<ngOrderEntry>> allOrders = obj.As<JsArray<JsArray<ngOrderEntry>>>();
JsArray<ngOrderEntry> tmp = allOrders[day];
if (tmp != null && tmp.length > 0) {
foreach (ngOrderEntry order in tmp) {
ngFoodItem foodItem = ngFoodController.inst.findFoodById(order.FoodId);
if (null != foodItem && !foodItem.isContainer) {
res.Add(order);
}
}
}
return res;
}
开发者ID:mgerasika,项目名称:gam-gam,代码行数:17,代码来源:ngOrderFilter.cs
示例20: runEffect
// run the currently selected effect
static void runEffect()
{
// get effect type from
var selectedEffect = new jQuery("#effectTypes").val().As<EffectType>();
// most effect types need no options passed by default
var options = new JsObject { };
if (selectedEffect.ExactEquals("scale"))
{
options = new { percent = 0 }.As<JsObject>();
}
else if (selectedEffect.ExactEquals("size"))
{
options = new { to = new { width = 200, height = 60 } }.As<JsObject>();
}
// run the effect
new jQuery("#effect").hide(selectedEffect, options, 1000, callback);
}
开发者ID:fjgandrade,项目名称:sharpkit,代码行数:18,代码来源:Default.cs
注:本文中的JsObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论