本文整理汇总了C#中JsObject类的典型用法代码示例。如果您正苦于以下问题:C# JsObject类的具体用法?C# JsObject怎么用?C# JsObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsObject类属于命名空间,在下文中一共展示了JsObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
});
}
示例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;
}
}
示例3: JsClrClientSerializer
public JsClrClientSerializer()
{
ObjInfos = new Dictionary<object, ObjInfo>();
IgnoreFields = new JsObject<bool>();
IgnoreFields["_type"] = true;
IgnoreFields["_hashKey"] = true;
}
示例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);
}
示例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;
}
示例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;
}
示例7: foo
void foo()
{
dynamic arrivingViewProps = new JsObject();
arrivingViewProps.left = 0;
arrivingViewProps.leaveTransforms = true;
animate(arrivingViewProps, HOW_LONG);
}
示例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);
}
示例9: BreakPoint
public void BreakPoint(JsObject instance)
{
if (InvokeRequired)
{
this.Invoke(new MethodInvoker(() =>
{
debugControl.InspectObject(instance);
}));
}
}
示例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>>();
}
示例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();
}
示例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"));
}
示例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);
}
示例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
}
}
});
}
示例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;
}