internal static void Dir(FunctionObject func, CommonObject that, object value) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; ObjectDumper.Write(value, 15); Console.ResetColor(); }
public static string HttpGet(FunctionObject _, CommonObject that, FunctionObject function) { var self = that.CastTo <HttpObject>(); var wc = new WebClient(); return(wc.DownloadString(self.Url)); }
public static string EncodeCommonObjectToBase64(CommonObject src) { if (null == src) { return(null); } byte[] rc = null; try { var formatter = new BinaryFormatter(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, src); rc = stream.ToArray(); } } catch { //Debug.WriteLine(e.Message); } if (rc == null) { throw new Exception("转换失败"); } return(Convert.ToBase64String(rc)); }
IEnumerable <TreeViewItem> renderObjectProperties(CommonObject jsObject) { if (jsObject != null && !alreadyRendered.Contains(jsObject)) { if (jsObject.Prototype != null) { yield return(renderProperty("[[Prototype]]", jsObject.Prototype)); } if (jsObject is ValueObject) { var value = (jsObject as ValueObject).Value.Value.ClrBoxed; yield return(renderProperty("[[Value]]", value)); } alreadyRendered.Add(jsObject); foreach (var member in jsObject.Members) { yield return(renderProperty(member.Key, member.Value)); } if (jsObject is ArrayObject) { var arrayObject = jsObject as ArrayObject; for (var i = 0u; i < arrayObject.Length; ++i) { yield return(renderProperty("[" + i + "]", arrayObject.Get(i).ClrBoxed)); } } } }
public static CommonObject DecodeCommonObjectFromBase64(string base64) { var bytes = Convert.FromBase64String(base64); if (null == bytes || 0 == bytes.Length) { return(null); } CommonObject rc = null; try { using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); stream.Write(bytes, 0, bytes.Length); stream.Seek(0, SeekOrigin.Begin); if (formatter.Deserialize(stream) is CommonObject obj) { rc = obj; } } } catch { //Debug.WriteLine(e.Message); } return(rc); }
public static string GetCommonObjectExtension(CommonObject commonObject) { switch (commonObject) { case CommonObject.DIRECTIONAL: return(COMMON_OBECT_DIRECTIONAL); case CommonObject.POINT: return(COMMON_OBECT_POINT); case CommonObject.SPOT: return(COMMON_OBECT_SPOT); case CommonObject.SKYBOX: return(COMMON_OBECT_SKYBOX); case CommonObject.SKYSPHERE: return(COMMON_OBECT_SKYSPHERE); case CommonObject.WATER: return(COMMON_OBECT_WATER); case CommonObject.LANDSCAPE: return(COMMON_OBECT_LANDSCAPE); case CommonObject.TRIGGER: return(COMMON_OBECT_TRIGGER); default: return(string.Empty); } }
public static void Send(CommonObject c) { TinyMessengerHub.Instance.Publish(new TalkMessage() { Text = TypeConverter.ToString(c) }); }
/// <summary> /// 记录Fetal日志 /// </summary> /// <param name="message"></param> /// <param name="isEnableDbLog"></param> public static void Fatal(string message, bool isEnableDbLog = false) { if (string.IsNullOrEmpty(message)) { return; } try { Slogger.Fatal(message); if (isEnableDbLog) { LogItem item = new LogItem() { Id = GuidUtils.GetGuid32(), LogSource = "", LogType = "fatal", CreateTime = DateTime.Now, LogContent = message }; CommonObject model = new CommonObject() { TheObject = item, TheObjectType = CommonModelType.LogType }; SblockingQueueEx.Add(model); } } catch (Exception) { } }
static void AddHandler( FunctionObject func, CommonObject that, string eventName, FunctionObject handler) { EventObject self = that.CastTo<EventObject>(); self.AddHandler(eventName, handler); }
static void Main(string[] args) { var ctx = new IronJS.Hosting.CSharp.Context(); string json; using (TextReader reader = File.OpenText("array_items.txt")) { json = reader.ReadToEnd(); } CommonObject result = (CommonObject)ctx.Execute("var x=" + json); Dictionary <uint, BoxedValue> indexes = new Dictionary <uint, BoxedValue>(); result.GetAllIndexProperties(indexes, uint.MaxValue); List <Place> places = new List <Place>(); foreach (uint idx in indexes.Keys) { Place p = new Place(); p.ID = (int)idx; p.Name = (string)indexes[idx].Object.Members["Name"]; p.Latitude = (double)indexes[idx].Object.Members["Latitude"]; p.Longitude = (double)indexes[idx].Object.Members["Longitude"]; places.Add(p); } foreach (Place place in places) { Console.WriteLine("ID = {0}", place.ID); Console.WriteLine("Name = {0}", place.Name); Console.WriteLine("Latitude = {0}", place.Latitude); Console.WriteLine("Longitude = {0}", place.Longitude); } Console.ReadKey(); }
static CommonObject CommonObjectFromJToken(JToken jsonElement) { int archive3dm = (int)jsonElement["archive3dm"]; int opennurbs = (int)jsonElement["opennurbs"]; string data = (string)jsonElement["data"]; return(CommonObject.FromBase64String(archive3dm, opennurbs, data)); }
public JavaScriptApp(object app, CommonObject obj) { _objectInstance = obj; if (_objectInstance.Members.ContainsKey("initialize")) { ((FunctionObject) _objectInstance.Members["initialize"]).Call(_objectInstance, new AppJsObject(_objectInstance.Env, (ICallable)app)); } }
public JavaScriptApp(object app, CommonObject obj) { _objectInstance = obj; if (_objectInstance.Members.ContainsKey("initialize")) { ((FunctionObject)_objectInstance.Members["initialize"]).Call(_objectInstance, new AppJsObject(_objectInstance.Env, (ICallable)app)); } }
public EditorProviderObject(Env env, CommonObject prototype, IEditorProvider provider) : base(env, env.Maps.Base, prototype) { this.provider = provider; this.editorPrototype = EditorObject.CreatePrototype(env); var newEditor = Utils.CreateFunction(env, 0, (Func<FunctionObject, CommonObject, CommonObject>)NewEditor); this.Put("newEditor", newEditor, DescriptorAttrs.Immutable); }
void displayGlobalVariables(CommonObject globals) { if (!(disableGlobalsCheckbox.IsChecked ?? false)) { EnvironmentVariables.Items.Clear(); foreach (var item in renderObjectProperties(globals)) { alreadyRendered.Clear(); EnvironmentVariables.Items.Add(item); } } }
public EnvironmentJsObject(IDictionary<string, object> environment, IronJS.Environment env, CommonObject prototype) : base(env, env.Maps.Base, prototype) { foreach(var key in environment.Keys) { if (key == "rack.input") { Put(key, new JsStream(env, environment[key] as Stream)); continue; } Put(key, environment[key].ToString()); } }
internal static void Log(FunctionObject func, CommonObject that, object value) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; if(value is string) Console.WriteLine(value); else if (value is BoxedValue) { BoxedValue boxedValue = ((BoxedValue)value); Console.WriteLine(TypeConverter.ToString(boxedValue)); } Console.ResetColor(); }
public dynamic[] ConvertJavaScriptResponse(CommonObject obj) { string status = null; var headerDictionary = new Hash(); dynamic body = null; foreach (var prop in obj.Members) { if (prop.Key == "headers") { var headers = prop.Value as CommonObject; if (headers == null) { continue; } foreach (var header in headers.Members) { headerDictionary[header.Key] = header.Value.ToString(); } continue; } if (prop.Key == "status") { status = prop.Value.ToString(); continue; } if (prop.Key == "body") { body = prop.Value; if (body is ArrayObject) { var arr = (ArrayObject)prop.Value; var responseBody = new List <string>(); for (var i = 0; i < arr.Length; i++) { responseBody.Add(arr.Get(i).Object.ToString()); } body = new IterableAdapter(responseBody); } } } return(new[] { status, headerDictionary, body }); }
public dynamic[] ConvertJavaScriptResponse(CommonObject obj) { string status = null; var headerDictionary = new Hash(); dynamic body = null; foreach (var prop in obj.Members) { if (prop.Key == "headers") { var headers = prop.Value as CommonObject; if (headers == null) { continue; } foreach (var header in headers.Members) { headerDictionary[header.Key] = header.Value.ToString(); } continue; } if (prop.Key == "status") { status = prop.Value.ToString(); continue; } if (prop.Key == "body") { body = prop.Value; if (body is ArrayObject) { var arr = (ArrayObject) prop.Value; var responseBody = new List<string>(); for (var i = 0; i < arr.Length; i++) { responseBody.Add(arr.Get(i).Object.ToString()); } body = new IterableAdapter(responseBody); } } } return new[] {status, headerDictionary, body}; }
private void Execute(string file, string code, CommonObject exports) { try { // Wrap the required code in its own function. var requiredResult = this.context.Execute<FunctionObject>("function (exports) {\n" + code + "\n}"); // Call the required code, passing in the new exports function to be populated. requiredResult.Call(this.context.Globals, exports); } catch (Exception exception) { throw new RequireException(file, exception); } }
public static CommonObject CreatePrototype(Env env) { var getText = Utils.CreateFunction<GetStr>(env, 0, GetText); var setText = Utils.CreateFunction<SetStr>(env, 1, SetText); var getTitle = Utils.CreateFunction<GetStr>(env, 0, GetTitle); var setTitle = Utils.CreateFunction<SetStr>(env, 1, SetTitle); var prototype = new CommonObject(env, env.Maps.Base, env.Prototypes.Object); prototype.Put("getText", getText, DescriptorAttrs.Immutable); prototype.Put("setText", setText, DescriptorAttrs.Immutable); prototype.Put("getTitle", getTitle, DescriptorAttrs.Immutable); prototype.Put("setTitle", setTitle, DescriptorAttrs.Immutable); return prototype; }
public override List <SpeckleObjectProperties> getObjectProperties(IEnumerable <object> objects) { var propertiesList = new List <SpeckleObjectProperties>(); var simpleProps = new List <ArchivableDictionary>(); int k = 0; foreach (object o in objects) { CommonObject myObj = null; GH_Brep brep = o as GH_Brep; if (brep != null) { myObj = brep.Value; } GH_Surface srf = o as GH_Surface; if (srf != null) { myObj = srf.Value; } GH_Mesh mesh = o as GH_Mesh; if (mesh != null) { myObj = mesh.Value; } GH_Curve crv = o as GH_Curve; if (crv != null) { myObj = crv.Value; } if (myObj != null) { if (myObj.UserDictionary.Keys.Length > 0) { propertiesList.Add(new SpeckleObjectProperties(k, myObj.UserDictionary)); } } k++; } return(propertiesList); }
/// <summary> /// Serializes the Tuple<T1,T2> into a object which doensn't include the types from the external assemblies /// and is hereby known by the applications AppDomain /// </summary> /// <param name="obj">The object which holds the type information</param> /// <returns>A `CommonObject` where information from `obj` is retrieved</returns> public static CommonObject Serialize(this Tuple<Type, System.Reflection.PropertyInfo[]> obj) { var returnVal = new CommonObject { TypeFullName = obj.Item1.FullName, Properties = new List<Util.CommonProperty>() }; foreach (var pi in obj.Item2) { var prop = new Util.CommonProperty { Name = pi.Name, PropertyType = pi.PropertyType.FullName != null ? pi.PropertyType.FullName.GetTypeInfo().Pretify() : "UnknownType" }; returnVal.Properties.Add(prop); } return returnVal; }
static object ToObjectHelper(JToken jsonElement, Type objectType, JsonSerializer serializer) { if (typeof(CommonObject).IsAssignableFrom(objectType)) { int archive3dm = (int)jsonElement["archive3dm"]; int opennurbs = (int)jsonElement["opennurbs"]; string data = (string)jsonElement["data"]; CommonObject rc = CommonObject.FromBase64String(archive3dm, opennurbs, data); // Steve: I'm still undecided on if we should 'magically' convert //if(objectType.Equals(typeof(Brep)) && rc is Extrusion) //{ // Extrusion extrusion = rc as Extrusion; // return extrusion.ToBrep(); //} return(rc); } if (serializer == null) { return(jsonElement.ToObject(objectType)); } return(jsonElement.ToObject(objectType, serializer)); }
private void bindingCombobox() { List <CommonObject> cboOrdinalDisplayData = new List <CommonObject>(); var obj1 = new CommonObject { Key = 1, Value = 1 }; cboOrdinalDisplayData.Add(obj1); var obj2 = new CommonObject { Key = 2, Value = 2 }; cboOrdinalDisplayData.Add(obj2); var obj3 = new CommonObject { Key = 3, Value = 3 }; cboOrdinalDisplayData.Add(obj3); var obj4 = new CommonObject { Key = 4, Value = 4 }; cboOrdinalDisplayData.Add(obj4); var obj5 = new CommonObject { Key = 5, Value = 5 }; cboOrdinalDisplayData.Add(obj5); cboOrdinalDisplay.DisplayMember = "Value"; cboOrdinalDisplay.ValueMember = "Key"; cboOrdinalDisplay.DataSource = cboOrdinalDisplayData; }
void displayGlobalVariables(CommonObject globals) { EnvironmentVariables.Items.Clear(); foreach (var item in renderObjectProperties(globals)) { alreadyRendered.Clear(); EnvironmentVariables.Items.Add(item); } }
static string GetTitle(FunctionObject func, CommonObject that) { var window = that.CastTo<WindowObject>().window; return window.Title; }
static CommonObject Construct(FunctionObject ctor, CommonObject _, double x) { var prototype = ctor.GetT<CommonObject>("prototype"); return new RobotObject(ctor.Env, prototype); }
public object BaoCaoBoPhan_DK(DK_BaoCao_BoPhan_MucDoHaiLong dieuKien) { try { List <BoPhanReport> boPhanReports = new List <BoPhanReport>(); var boPhans = _context.BoPhans.ToList(); if (dieuKien.BoPhanId != null) { boPhans = boPhans.Where(x => x.Id == dieuKien.BoPhanId).ToList(); } var boPhanView = Mapper.Map <List <BoPhan>, List <BoPhanViewModel> >(boPhans); var mucDoHaiLongs = _context.MucDoHaiLongs.ToList(); foreach (var item in boPhanView) { BoPhanReport boPhanReport = new BoPhanReport { BoPhanViewModel = item, CommonObjects = new List <CommonObject>() }; foreach (var m in mucDoHaiLongs) { CommonObject commonObject = new CommonObject(); commonObject.Name = m.NoiDung; commonObject.Value = 0; boPhanReport.CommonObjects.Add(commonObject); } boPhanReports.Add(boPhanReport); } foreach (var item in boPhanReports) { foreach (var i in item.CommonObjects) { var temp = (from b in _context.BoPhans join p in _context.PhieuDanhGias on b.Id equals p.BoPhanId join ctp in _context.ChiTietPhieuDanhGias on p.Id equals ctp.PhieuDanhGiaId join md in _context.MucDoHaiLongs on ctp.MucDoHaiLongId equals md.Id where p.BoPhanId == item.BoPhanViewModel.Id && i.Name == md.NoiDung select new { b.Id, MucDoID = md.Id, ChiTietPhieuId = ctp.Id, NgayTaoPhieu = p.NgayTao }).ToList(); if (dieuKien.TuNgay != null && dieuKien.DenNgay != null) { temp = temp.Where(x => x.NgayTaoPhieu.Value.Date >= dieuKien.TuNgay.Value.Date && x.NgayTaoPhieu.Value.Date <= dieuKien.DenNgay.Value.Date).ToList(); } i.Value = temp.Count; } } return(boPhanReports); } catch (DbUpdateConcurrencyException) { return(BadRequest("Lỗi không xác định!")); } }
public ConfigJsObject(IronJS.Environment env, ConfigBase config, CommonObject prototype) : base(env, prototype) { configBase = config; }
public static void Use(FunctionObject _, CommonObject that, CommonObject obj) { var configObj = that.CastTo<ConfigJsObject>(); configObj.configBase.Use(typeof(JavaScriptApp), obj); }
static CommonObject Construct(FunctionObject ctor, CommonObject that) { return new EventObject(ctor.Env, ctor.GetT<CommonObject>("prototype")); }
public HttpObject(string url, Environment env, CommonObject prototype) : base(env, env.Maps.Base, prototype) { Put("url", url, DescriptorAttrs.Immutable); Url = url; }
private void UpdateForm(CommonObject args) { rotationPeriod.Value = args.RotationPeriod; strobePeriod.Value = args.StrobePeriod; strobeOnTime.Value = args.StrobeOnTime; }
public static void Map(FunctionObject _, CommonObject that, string str, BoxedValue func) { var configObj = that.CastTo <ConfigJsObject>(); configObj.configBase.Map(str, BuilderJsObject.MapBuilder(func.Func)); }
private CommonObject Require(string file) { if (String.IsNullOrEmpty(file)) throw new ArgumentNullException("file"); file = Normalize(file); CommonObject exports; this.cacheLock.EnterReadLock(); try { // Check for existence so we can return fast without write-locking. if (this.requireCache.TryGetValue(file, out exports)) return exports; } finally { this.cacheLock.ExitReadLock(); } this.cacheLock.EnterWriteLock(); try { // Check for existence again after locking. if (this.requireCache.TryGetValue(file, out exports)) return exports; string fileName = String.Concat(file, ".js"); string code = this.resourceHelper.Get(fileName); // Allocate a new object for the exports of the require, and add it preemptively, to allow for reentrancy. exports = new CommonObject(this.context.Environment, this.context.Environment.Prototypes.Object); this.requireCache.Add(file, exports); // Populate the exports object. Execute(file, code, exports); return exports; } finally { this.cacheLock.ExitWriteLock(); } }
string HandlePostHelper(Newtonsoft.Json.Linq.JArray ja, Dictionary <string, string> returnModifiers) { int tokenCount = ja == null ? 0 : ja.Count; if (_methods != null) { JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new ArchivableDictionaryResolver()); int methodIndex = -1; foreach (var method in _methods) { methodIndex++; int paramCount = method.GetParameters().Length; if (!method.IsStatic) { paramCount++; } foreach (var parameter in method.GetParameters()) { if (parameter.IsOut) { paramCount--; } } if (paramCount == tokenCount) { var methodParameters = method.GetParameters(); object invokeObj = null; object[] invokeParameters = new object[methodParameters.Length]; int currentJa = 0; if (!method.IsStatic) { invokeObj = ja[currentJa++].ToObject(_classType); } int outParamCount = 0; try { for (int i = 0; i < methodParameters.Length; i++) { if (!methodParameters[i].IsOut) { var jsonobject = ja[currentJa++]; var generics = methodParameters[i].ParameterType.GetGenericArguments(); Type objectType = null; bool useSerializer = true; if (generics == null || generics.Length != 1) { objectType = methodParameters[i].ParameterType; useSerializer = true; } else { objectType = generics[0].MakeArrayType(); useSerializer = false; } invokeParameters[i] = DataCache.GetCachedItem(jsonobject, objectType, useSerializer ? serializer : null); if (invokeParameters[i] == null) { if (useSerializer) { invokeParameters[i] = jsonobject.ToObject(objectType, serializer); } else { if (objectType == typeof(GeometryBase[])) { // 6 Sept 2020 S. Baer // This needs to be tuned up. Json.Net is having issues creating arrays of // GeometryBase since that class is abstract. I think we need to generalize this // solution, but for now I can repeat the issue when calling // AreaMassProperties.Compute(IEnumerable<GeometryBase>) // from an endpoint GeometryBase[] items = new GeometryBase[jsonobject.Count()]; for (int itemIndex = 0; itemIndex < items.Length; itemIndex++) { var jsonElement = jsonobject[itemIndex]; int archive3dm = (int)jsonElement["archive3dm"]; int opennurbs = (int)jsonElement["opennurbs"]; string data = (string)jsonElement["data"]; items[itemIndex] = CommonObject.FromBase64String(archive3dm, opennurbs, data) as GeometryBase; } invokeParameters[i] = items; } else { invokeParameters[i] = jsonobject.ToObject(objectType); } } } } if (methodParameters[i].IsOut || methodParameters[i].ParameterType.IsByRef) { outParamCount++; } } } catch (Exception ex) { if (methodIndex < (_methods.Count() - 1)) { continue; } throw ex; } bool isConst = false; if (!method.IsStatic) { object[] methodAttrs = method.GetCustomAttributes(true); if (methodAttrs != null) { for (int i = 0; i < methodAttrs.Length; i++) { Attribute attr = methodAttrs[i] as Attribute; if (attr != null && attr.ToString().Contains("ConstOperationAttribute")) { isConst = true; break; } } } } if (method.ReturnType != typeof(void) || (!method.IsStatic && !isConst)) { outParamCount++; } var invokeResult = method.Invoke(invokeObj, invokeParameters); if (outParamCount < 1) { return(""); } object[] rc = new object[outParamCount]; int outputSlot = 0; if (method.ReturnType != typeof(void)) { rc[outputSlot++] = invokeResult; } else if (!method.IsStatic && !isConst) { rc[outputSlot++] = invokeObj; } for (int i = 0; i < methodParameters.Length; i++) { if (methodParameters[i].IsOut || methodParameters[i].ParameterType.IsByRef) { rc[outputSlot++] = invokeParameters[i]; } } if (returnModifiers != null && returnModifiers.Count > 0) { for (int i = 0; i < rc.Length; i++) { rc[i] = ProcessModifiers(rc[i], returnModifiers); } } if (rc.Length == 1) { return(Newtonsoft.Json.JsonConvert.SerializeObject(rc[0], GeometryResolver.Settings)); } return(Newtonsoft.Json.JsonConvert.SerializeObject(rc, GeometryResolver.Settings)); } } } if (_constructors != null) { for (int k = 0; k < _constructors.Length; k++) { var constructor = _constructors[k]; int paramCount = constructor.GetParameters().Length; if (paramCount == tokenCount) { object[] parameters = new object[tokenCount]; var p = constructor.GetParameters(); try { bool skipThisConstructor = false; for (int ip = 0; ip < tokenCount; ip++) { var generics = p[ip].ParameterType.GetGenericArguments(); if (generics == null || generics.Length != 1) { if (_constructors.Length > 0 && p[ip].ParameterType == typeof(Rhino.Geometry.Plane)) { if (ja[ip].Count() < 4) { skipThisConstructor = true; ip = tokenCount; continue; } } parameters[ip] = ja[ip].ToObject(p[ip].ParameterType); } else { var arrayType = generics[0].MakeArrayType(); parameters[ip] = ja[ip].ToObject(arrayType); } } if (skipThisConstructor) { continue; } } catch (Exception) { continue; } var rc = constructor.Invoke(parameters); rc = ProcessModifiers(rc, returnModifiers); return(Newtonsoft.Json.JsonConvert.SerializeObject(rc, GeometryResolver.Settings)); } } } return(""); }
public static void DoSomething(CommonObject o) { // code here }
static CommonObject NewEditor(FunctionObject func, CommonObject that) { var self = that.CastTo<EditorProviderObject>(); IEditor editor = self.provider.NewEditor(); return new EditorObject(func.Env, self.editorPrototype, editor); }
public ConsoleObject(Environment env, CommonObject prototype) : base(env, env.Maps.Base, prototype) { }
private void RunMasterCommonStatusUpdate(CommonObject args) { MessageBroker.RunActions("VisiLEDCommon", args); }
public static void Use(FunctionObject _, CommonObject that, CommonObject obj) { var configObj = that.CastTo <ConfigJsObject>(); configObj.configBase.Use(typeof(JavaScriptApp), obj); }
static void RemoveApplicationCommand(FunctionObject func, CommonObject that, CommonObject command) { var window = that.CastTo<WindowObject>().window; window.ApplicationCommands.Remove((ICommand)command); }
public static void Run(FunctionObject _, CommonObject that, BoxedValue obj) { var configObj = that.CastTo <ConfigJsObject>(); configObj.configBase.Run(new JavaScriptApp(obj.Object)); }
public static void Run(FunctionObject _, CommonObject that, BoxedValue obj) { var configObj = that.CastTo<ConfigJsObject>(); configObj.configBase.Run(new JavaScriptApp(obj.Object)); }
private static CommonObject Construct(FunctionObject ctor, CommonObject _) { CommonObject prototype = ctor.GetT<CommonObject>("prototype"); return new CommonObject(ctor.Env, prototype); }
public static void Map(FunctionObject _, CommonObject that, string str, BoxedValue func) { var configObj = that.CastTo<ConfigJsObject>(); configObj.configBase.Map(str, BuilderJsObject.MapBuilder(func.Func)); }
public ConfigJsObject(IronJS.Environment env, ConfigBase config, CommonObject prototype) : base(env, prototype) { configBase = config; }
static CommonObject ConstructHttp(FunctionObject ctor, CommonObject _, string x) { var prototype = ctor.GetT<CommonObject>("prototype"); return new HttpObject(x, ctor.Env, prototype); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { object o = null; DA.GetData(0, ref o); if (o == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Failed to get object"); return; } CommonObject myObj = null; GH_Mesh mesh = o as GH_Mesh; if (mesh != null) { myObj = mesh.Value; } GH_Brep brep = o as GH_Brep; if (brep != null) { myObj = brep.Value; } GH_Surface srf = o as GH_Surface; if (srf != null) { myObj = srf.Value; } GH_Curve crv = o as GH_Curve; if (crv != null) { myObj = crv.Value; } Point pt = o as Rhino.Geometry.Point; if (pt != null) { myObj = pt; } if (myObj == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Failed to get object"); DA.SetData(0, null); return; } if (myObj.UserDictionary == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Object has no user dictionary."); DA.SetData(0, null); return; } DA.SetData(0, myObj.UserDictionary); }
public object BaoCaoMucDo_CauHoi(DK_BaoCao_CauhoiMucDo dieuKien) { try { List <MucDoCauHoiReport> mucDoCauHoiReports = new List <MucDoCauHoiReport>(); var cauhois = _context.CauHoiKhaoSats.ToList(); var cauhoiViews = Mapper.Map <List <CauHoiKhaoSat>, List <CauHoiKhaoSatViewModel> >(cauhois); var boPhans = _context.BoPhans.ToList(); foreach (var cauHoi in cauhoiViews) { MucDoCauHoiReport mucDoCau = new MucDoCauHoiReport { CauHoiKhaoSatViewModel = cauHoi, CommonObjects = new List <CommonObject>() }; foreach (var boPhan in boPhans) { CommonObject commonObject = new CommonObject(); commonObject.Name = boPhan.TenBoPhan; commonObject.Value = 0; mucDoCau.CommonObjects.Add(commonObject); } mucDoCauHoiReports.Add(mucDoCau); } foreach (var item in mucDoCauHoiReports) { foreach (var i in item.CommonObjects) { var temp = (from b in _context.BoPhans join p in _context.PhieuDanhGias on b.Id equals p.BoPhanId join ctp in _context.ChiTietPhieuDanhGias on p.Id equals ctp.PhieuDanhGiaId where i.Name == b.TenBoPhan && ctp.MucDoHaiLongId == dieuKien.MucDoHaiLongId && ctp.CauHoiKhaoSatId == item.CauHoiKhaoSatViewModel.Id select new { b.Id, ChiTietPhieuId = ctp.Id, NgayTaoPhieu = p.NgayTao, }).ToList(); if (dieuKien.TuNgay != null && dieuKien.DenNgay != null) { temp = temp.Where(x => x.NgayTaoPhieu.Value.Date >= dieuKien.TuNgay.Value.Date && x.NgayTaoPhieu.Value.Date <= dieuKien.DenNgay.Value.Date).ToList(); } i.Value = temp.Count; } } return(mucDoCauHoiReports); } catch (DbUpdateConcurrencyException) { return(BadRequest("Lỗi không xác định!")); } }
static void Exit(FunctionObject func, CommonObject that) { var window = that.CastTo<WindowObject>().window; window.Exit(); }
IEnumerable<TreeViewItem> renderObjectProperties(CommonObject jsObject) { if (jsObject != null && !alreadyRendered.Contains(jsObject)) { if (jsObject.Prototype != null) { yield return renderProperty("[[Prototype]]", jsObject.Prototype); } if (jsObject is ValueObject) { var value = (jsObject as ValueObject).Value.Value.ClrBoxed; yield return renderProperty("[[Value]]", value); } alreadyRendered.Add(jsObject); foreach (var member in jsObject.Members) { yield return renderProperty(member.Key, member.Value); } if (jsObject is ArrayObject) { var arrayObject = jsObject as ArrayObject; for (var i = 0u; i < arrayObject.Length; ++i) { yield return renderProperty("[" + i + "]", arrayObject.Get(i).ClrBoxed); } } } }
static CommonObject ConstructHttp(FunctionObject ctor, CommonObject _, string x) { var prototype = ctor.GetT <CommonObject>("prototype"); return(new HttpObject(x, ctor.Env, prototype)); }
static CommonObject Construct(FunctionObject ctor, CommonObject _, double x) { var prototype = ctor.GetT <CommonObject>("prototype"); return(new RobotObject(ctor.Env, prototype)); }
public WindowObject(Env env, CommonObject prototype, IMainWindow window) : base(env, env.Maps.Base, prototype) { this.window = window; }
static void Trigger( FunctionObject func, CommonObject that, string eventName, BoxedValue data) { EventObject self = that.CastTo<EventObject>(); self.Trigger(eventName, data); }
static void AddCommand(FunctionObject func, CommonObject that, CommonObject command) { var window = that.CastTo<WindowObject>().window; window.Commands.Add((ICommand)command); }
/// <summary> /// Constructor that takes the list of items from the calling object /// </summary> /// <param name="propertyBag"></param> public PropertyBagHelper(CommonObject commonObject) => this.commonObject = commonObject;
public EventObject(Env env, CommonObject prototype) : base(env, env.Maps.Base, prototype) { events = new Dictionary<string, List<FunctionObject>>(); }